Просмотр исходного кода

Fixed typo and handle empty set of instances

Marcus Christie 8 лет назад
Родитель
Сommit
8300990524
1 измененных файлов с 5 добавлено и 3 удалено
  1. 5 3
      cloudbridge/cloud/providers/gce/services.py

+ 5 - 3
cloudbridge/cloud/providers/gce/services.py

@@ -377,7 +377,7 @@ class GCEImageService(BaseImageService):
             for project in GCEImageService._PUBLIC_IMAGE_PROJECTS:
             for project in GCEImageService._PUBLIC_IMAGE_PROJECTS:
                 for image in helpers.iter_all(
                 for image in helpers.iter_all(
                         self.provider.gce_compute.images(), project=project):
                         self.provider.gce_compute.images(), project=project):
-                    self._public_iamges.append(
+                    self._public_images.append(
                         GCEMachineImage(self.provider, image))
                         GCEMachineImage(self.provider, image))
         except googleapiclient.errors.HttpError as http_error:
         except googleapiclient.errors.HttpError as http_error:
                 cb.log.warning("googleapiclient.errors.HttpError: {0}".format(
                 cb.log.warning("googleapiclient.errors.HttpError: {0}".format(
@@ -548,8 +548,10 @@ class GCEInstanceService(BaseInstanceService):
                               maxResults=max_result,
                               maxResults=max_result,
                               pageToken=marker)
                               pageToken=marker)
                         .execute())
                         .execute())
-        instances = [GCEInstance(self.provider, inst)
-                     for inst in response['items']]
+        instances = []
+        if 'items' in response:
+            instances = [GCEInstance(self.provider, inst)
+                         for inst in response['items']]
         if len(instances) > max_result:
         if len(instances) > max_result:
             cb.log.warning('Expected at most %d results; got %d',
             cb.log.warning('Expected at most %d results; got %d',
                            max_result, len(instances))
                            max_result, len(instances))