def get_data(self): marker = self.request.GET.get( inst_tables.InstancesTable._meta.pagination_param, None) search_opts = self.get_filters({'marker': marker, 'paginate': True}) # Gather our instances try: instances, self._more = api.server_list(self.request, search_opts=search_opts) instances = filter(self._status_filter, instances) except Exception: self._more = False instances = [] exceptions.handle(self.request, _("Unable to retrieve instances.")) if instances: try: flavors = api.resource_list(self.request, consts.NOVA_FLAVOR) except Exception: flavors = [] exceptions.handle(self.request, ignore=True) try: images = api.resource_list(self.request, consts.GLANCE_IMAGE) except Exception: images = [] exceptions.handle(self.request, ignore=True) full_flavors = SortedDict([(str(flavor.id), flavor) for flavor in flavors]) image_map = SortedDict([(str(image.id), image) for image in images]) # Loop through instances to get flavor info. for instance in instances: if hasattr(instance, 'image'): # Instance from image returns dict if isinstance(instance.image, dict): if instance.image.get('id') in image_map: instance.image = image_map[instance.image['id']] try: flavor_id = instance.flavor['id'] if flavor_id in full_flavors: instance.full_flavor = full_flavors[flavor_id] else: instance.full_flavor = api.resource_get( self.request, consts.NOVA_FLAVOR, flavor_id) except Exception: msg = ('Unable to retrieve flavor "%s" for instance "%s".' % (flavor_id, instance.id)) LOG.info(msg) return instances
def get_data(self): marker = self.request.GET.get( inst_tables.InstancesTable._meta.pagination_param, None) search_opts = self.get_filters({'marker': marker, 'paginate': True}) # Gather our instances try: instances, self._more = api.server_list(self.request, search_opts=search_opts) instances = filter(self._status_filter, instances) except Exception: self._more = False instances = [] exceptions.handle(self.request, _("Unable to retrieve instances.")) if instances: try: flavors = api.resource_list(self.request, consts.NOVA_FLAVOR) except Exception: flavors = [] exceptions.handle(self.request, ignore=True) try: images = api.resource_list(self.request, consts.GLANCE_IMAGE) except Exception: images = [] exceptions.handle(self.request, ignore=True) full_flavors = SortedDict([(str(flavor.id), flavor) for flavor in flavors]) image_map = SortedDict([(str(image.id), image) for image in images]) # Loop through instances to get flavor info. for instance in instances: if hasattr(instance, 'image'): # Instance from image returns dict if isinstance(instance.image, dict): if instance.image.get('id') in image_map: instance.image = image_map[instance.image['id']] try: flavor_id = instance.flavor['id'] if flavor_id in full_flavors: instance.full_flavor = full_flavors[flavor_id] else: instance.full_flavor = api.resource_get( self.request, consts.NOVA_FLAVOR, flavor_id) except Exception: msg = ( 'Unable to retrieve flavor "%s" for instance "%s".' % (flavor_id, instance.id)) LOG.info(msg) return instances
def get_data(self): fips = [] try: fips = api.resource_list(self.request, consts.NEUTRON_FLOATINGIP) except Exception: exceptions.handle(self.request, _("Unable to retrieve floating IP addresses.")) return fips
def get_data(self): cgroups = [] try: cgroups = api.resource_list(self.request, consts.CINDER_CONSISGROUP) except Exception: exceptions.handle(self.request, _("Unable to retrieve " "volume consistency groups.")) return cgroups
def get_data(self): cgroups = [] try: cgroups = api.resource_list(self.request, consts.CINDER_CONSISGROUP) except Exception: exceptions.handle( self.request, _("Unable to retrieve " "volume consistency groups.")) return cgroups
def get_data(self): pools = [] try: request = self.request pools = api.resource_list(request, consts.NEUTRON_POOL)[0].pools pools = [os_api.lbaas.Pool(p) for p in pools] fips = None for pool in pools: if hasattr(pool, "vip") and pool.vip: if not fips: fips = api.resource_list(self.request, consts.NEUTRON_FLOATINGIP) vip_fip = [fip for fip in fips if fip.port_id == pool.vip.port_id] if vip_fip: pool.vip.fip = vip_fip[0] pools = filter(self._status_filter, pools) except Exception: exceptions.handle(self.request, _('Unable to retrieve pools list.')) return pools
def get_floating_ips_data(self): try: res = [] fips = api.resource_list(self.request, consts.NEUTRON_FLOATINGIP) for fip in fips: res.append(models.OverviewResource({ 'res_id': fip.id, 'res_type': consts.NEUTRON_FLOATINGIP, 'name': fip.floating_ip_address })) return res except Exception: exceptions.handle(self.request, _('Unable to retrieve floating IP addresses.')) return []
def get_pools_data(self): try: res = [] pools = api.resource_list(self.request, consts.NEUTRON_POOL) for pool in pools: res.append(models.OverviewResource({ 'res_id': pool.id, 'res_type': consts.NEUTRON_POOL, 'name': pool.name })) return res except Exception: exceptions.handle(self.request, _('Unable to retrieve pools list.')) return []
def get_floating_ips_data(self): try: res = [] fips = api.resource_list(self.request, consts.NEUTRON_FLOATINGIP) for fip in fips: res.append( models.OverviewResource({ 'res_id': fip.id, 'res_type': consts.NEUTRON_FLOATINGIP, 'name': fip.floating_ip_address })) return res except Exception: exceptions.handle(self.request, _('Unable to retrieve floating IP addresses.')) return []
def get_pools_data(self): try: res = [] pools = api.resource_list(self.request, consts.NEUTRON_POOL) for pool in pools: res.append( models.OverviewResource({ 'res_id': pool.id, 'res_type': consts.NEUTRON_POOL, 'name': pool.name })) return res except Exception: exceptions.handle(self.request, _('Unable to retrieve pools list.')) return []
def get_volumes_data(self): try: res = [] volumes = api.resource_list(self.request, consts.CINDER_VOLUME) for vol in filter(self._volume_status_filter, volumes): res.append(models.OverviewResource({ 'res_id': vol.id, 'res_type': consts.CINDER_VOLUME, 'name': vol.display_name or vol.id, 'availability_zone': vol.availability_zone })) return res except Exception: exceptions.handle(self.request, _("Unable to retrieve volumes list.")) return []
def get_instances_data(self): try: res = [] instances = api.resource_list(self.request, consts.NOVA_SERVER) for i in filter(self._instance_status_filter, instances): res.append(models.OverviewResource({ 'res_id': i.id, 'res_type': consts.NOVA_SERVER, 'name': i.name, 'availability_zone': getattr(i, 'OS-EXT-AZ:availability_zone', '') })) return res except Exception: exceptions.handle(self.request, _("Unable to retrieve instances list.")) return []
def get_volumes_data(self): try: res = [] volumes = api.resource_list(self.request, consts.CINDER_VOLUME) for vol in filter(self._volume_status_filter, volumes): res.append( models.OverviewResource({ 'res_id': vol.id, 'res_type': consts.CINDER_VOLUME, 'name': vol.display_name or vol.id, 'availability_zone': vol.availability_zone })) return res except Exception: exceptions.handle(self.request, _("Unable to retrieve volumes list.")) return []
def get_instances_data(self): try: res = [] instances = api.resource_list(self.request, consts.NOVA_SERVER) for i in filter(self._instance_status_filter, instances): res.append( models.OverviewResource({ 'res_id': i.id, 'res_type': consts.NOVA_SERVER, 'name': i.name, 'availability_zone': getattr(i, 'OS-EXT-AZ:availability_zone', '') })) return res except Exception: exceptions.handle(self.request, _("Unable to retrieve instances list.")) return []
def get(self, request, resource_type): search_opts, kwargs = rest_utils.parse_filters_kwargs(request) res = api.resource_list(request, resource_type, search_opts=search_opts) return {'items': [r.__dict__.get('_info') for r in res]}
def _render_keypair(self, context): properties = context['data'] keypairs = api.resource_list(self.request, consts.NOVA_KEYPAIR) properties['keypairs'] = keypairs return loader.render_to_string(self.container, context)
def _render_volumetype(self, context): vts = api.resource_list(self.request, consts.CINDER_VOL_TYPE) context['data']['volumetypes'] = vts return loader.render_to_string(self.container, context)