def populate_tenant_choices(self, request): tenant = keystone.tenant_get(request, request.user.project_id) tenant_list = [] if tenant: tenant_list = [(tenant.name, tenant.name)] else: tenant_list.insert(0, ("", _("No tenants available"))) return tenant_list
def _new_get_default_domain(request, get_name=True): domain = original_get_default_domain(request, get_name) if request.user.is_federated: # If user is federated, we should use the domain of the project # that the user is scoped to. project = keystone.tenant_get(request, request.user.project_id) domain.id = project.domain_id domain.name = keystone.domain_get(request, domain.id).name return domain
def get_data(self, request, group_id): group = super().get_data(request, group_id) tenant_id = getattr(group, 'project_id') try: tenant = keystone.tenant_get(request, tenant_id) group.tenant_name = getattr(tenant, "name") except Exception: msg = _('Unable to retrieve volume group project information.') exceptions.handle(request, msg) return group
def get_data(self, request, group_id): groups = cinder.group_list_with_vol_type_names(request, group_id) tenant_id = getattr(groups, 'project_id') try: tenant = keystone.tenant_get(request, tenant_id) groups.tenant_name = getattr(tenant, "name") except Exception: msg = _('Unable to retrieve volume group project information.') exceptions.handle(request, msg) return groups
def get_data(self, request, group_id): group = super(UpdateRow, self).get_data(request, group_id) tenant_id = getattr(group, 'project_id') try: tenant = keystone.tenant_get(request, tenant_id) group.tenant_name = getattr(tenant, "name") except Exception: msg = _('Unable to retrieve volume group project information.') exceptions.handle(request, msg) return group
def get_data(self, request, snapshot_id): snapshot = super().get_data(request, snapshot_id) snapshot.host_name = getattr(snapshot._volume, 'os-vol-host-attr:host') tenant_id = getattr(snapshot._volume, 'os-vol-tenant-attr:tenant_id') try: tenant = keystone.tenant_get(request, tenant_id) snapshot.tenant_name = getattr(tenant, "name") except Exception: msg = _('Unable to retrieve volume snapshot project information.') exceptions.handle(request, msg) return snapshot
def get_tenant(self, tenant_id): """Returns tenant fetched from API. Caching the result, so it doesn't contact API twice with the same query. """ tenant = self._tenants.get(tenant_id, None) if not tenant: tenant = keystone.tenant_get(self._request, tenant_id) # caching the tenant for later use self._tenants[tenant_id] = tenant return tenant
def get_tenant(self, tenant_id): """Returns tenant fetched form API. Caching the result, so it doesn't contact API twice with the same query """ tenant = self._tenants.get(tenant_id, None) if not tenant: tenant = keystone.tenant_get(self._request, tenant_id) # caching the tenant for later use self._tenants[tenant_id] = tenant return tenant
def get_data(self, request, snapshot_id): snapshot = cinder.volume_snapshot_get(request, snapshot_id) snapshot._volume = cinder.volume_get(request, snapshot.volume_id) snapshot.host_name = getattr(snapshot._volume, "os-vol-host-attr:host") tenant_id = getattr(snapshot._volume, "os-vol-tenant-attr:tenant_id") try: tenant = keystone.tenant_get(request, tenant_id) snapshot.tenant_name = getattr(tenant, "name") except Exception: msg = _("Unable to retrieve volume project information.") exceptions.handle(request, msg) return snapshot
def get_project_assigned_network(request): tenant_id = request.user.tenant_id tenant = keystone.tenant_get(request, tenant_id) network_name = getattr(settings, 'FIXED_MURANO_NETWORK', 'murano_network') tenant_network_id = getattr(tenant, network_name, None) if not tenant_network_id: LOG.warning(("murano_network property is not " "defined for project '%s'") % tenant_id) return [] try: tenant_network = neutron.network_get(request, tenant_network_id) return [((tenant_network.id, None), tenant_network.name_or_id)] except exc.NeutronClientException: return []
def get_data(self): project_id = self.kwargs['project_id'] try: project = keystone_api.tenant_get(self.request, project_id) self.page_title = _("Edit Private Price List") + ": %s" % \ project.name except Exception: exceptions.handle(self.request, _("Unable to retrieve project.")) prev_marker = self.request.GET.get( project_catalog_tables.PrivatePriceTable._meta .prev_pagination_param, None) if prev_marker is not None: sort_dir = 'asc' marker = prev_marker else: sort_dir = 'desc' marker = self.request.GET.get( project_catalog_tables.PrivatePriceTable._meta .pagination_param, None) if marker is not None: marker = marker.split('|')[0] filters = self.get_filters() self._prev = False self._more = False catalog_scope_list, self._prev, self._more = \ ticket_api.catalog_scope_list(self.request, project_id, marker=marker, sort_key='catalog_id', sort_dir=sort_dir, filters=filters, paginate=True) return catalog_scope_list