Explorar o código

Allow creating imsages from running instances

Test stats after this CL
========================
Ran 58 tests in 1482.346s

FAILED (SKIP=1, errors=25, failures=8)
Ehsan Chiniforooshan %!s(int64=8) %!d(string=hai) anos
pai
achega
0b1f95b975
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      cloudbridge/cloud/providers/gce/resources.py

+ 4 - 2
cloudbridge/cloud/providers/gce/resources.py

@@ -957,10 +957,12 @@ class GCEInstance(BaseInstance):
                              .gce_compute
                              .gce_compute
                              .images()
                              .images()
                              .insert(project=self._provider.project_name,
                              .insert(project=self._provider.project_name,
-                                     body=image_body)
+                                     body=image_body,
+                                     forceCreate=True)
                              .execute())
                              .execute())
                 self._provider.wait_for_operation(operation)
                 self._provider.wait_for_operation(operation)
-                return
+                img = self._provider.get_resource('images', name)
+                return GCEMachineImage(self._provider, img) if img else None
         cb.log.error('Failed to create image: no boot disk found.')
         cb.log.error('Failed to create image: no boot disk found.')
 
 
     def _get_existing_target_instance(self):
     def _get_existing_target_instance(self):