def setup_tenant(): if flask.request.endpoint not in BARE_ENDPOINTS: visible_ids = [x.id for x in utils.get_visible_tenants()] if flask.g.tenant_id not in visible_ids: flask.abort(404) principal.Permission(('role', 'member', flask.g.tenant_id)).test() flask.g.tenant = clients.admin_clients().keystone.tenants.get( flask.g.tenant_id)
def index(): """List projects. List only enabled, sort by name. """ tenants = utils.get_visible_tenants() ordered = sorted(tenants, key=lambda x: x.name) pagina = pagination.Pagination(ordered) delete_form = forms.DeleteForm() return { 'objects': pagina.slice(ordered), 'pagination': pagina, 'delete_form': delete_form, 'title': bp.name.replace('global_', '').replace('_', ' ').capitalize(), 'subtitle': 'List of projects' }
def dashboard(): """Present brief info and useful links. Global admins see numbers summary and links to administrative section. Members of projects see links to their respective projects. """ context = {} if principal.Permission(('role', 'admin')).can(): projects = utils.get_visible_tenants() project_ids = [x.id for x in projects] users = clients.admin_clients().keystone.users.list() servers = filter( lambda x: x.tenant_id in project_ids, clients.admin_clients().nova.servers.list( search_opts={'all_tenants': 1})) context.update( dict(title='Altai private cloud', subtitle='%s users in %s projects use %s VMs' % (len(users), len(projects), len(servers)))) return context
def dashboard(): """Present brief info and useful links. Global admins see numbers summary and links to administrative section. Members of projects see links to their respective projects. """ context = {} if principal.Permission(("role", "admin")).can(): projects = utils.get_visible_tenants() project_ids = [x.id for x in projects] users = clients.admin_clients().keystone.users.list() servers = filter( lambda x: x.tenant_id in project_ids, clients.admin_clients().nova.servers.list(search_opts={"all_tenants": 1}), ) context.update( dict( title="Altai private cloud", subtitle="%s users in %s projects use %s VMs" % (len(users), len(projects), len(servers)), ) ) return context