Exemple #1
0
    def list_instance_uuids(self, node=None, template_uuids=None, force=False):
        compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone
        all_instances = gceutils.list_instances(compute, project, zone)
        self._uuid_to_gce_instance.clear()
        for instance in all_instances:
            if instance['status'] in [
                    "PROVISIONING", "STAGING", "STOPPING", "SUSPENDING",
                    "TERMINATED"
            ]:
                continue
            openstack_id = gceutils.get_instances_metadata_key(
                compute, project, zone, instance, 'openstack_id')
            if openstack_id is None:
                openstack_id = self._get_uuid_from_gce_id(instance['name'])

            self._uuid_to_gce_instance[openstack_id] = instance
        return self._uuid_to_gce_instance.keys()
Exemple #2
0
 def list_instances(self):
     """
     Return the names of all the instances known to the virtualization
     layer, as a list.
     """
     compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone
     all_instances = gceutils.list_instances(compute, project, zone)
     self._uuid_to_gce_instance.clear()
     instance_names = []
     for instance in all_instances:
         if instance['status'] in [
                 "PROVISIONING", "STAGING", "STOPPING", "SUSPENDING",
                 "TERMINATED"
         ]:
             continue
         openstack_id = gceutils.get_instances_metadata_key(
             compute, project, zone, instance, 'openstack_id')
         if openstack_id is None:
             openstack_id = self._get_uuid_from_gce_id(instance['name'])
         self._uuid_to_gce_instance[openstack_id] = instance
         instance_names.append(instance['name'])
     return instance_names