def index(request, tenant_id): tenant = {} try: tenant = api.token_get_tenant(request, request.user.tenant) except api_exceptions.ApiException, e: messages.error( request, "Unable to retrienve tenant info\ from keystone: %s" % e.message, )
def launch(request, tenant_id, image_id): def flavorlist(): try: fl = api.flavor_list(request) # TODO add vcpu count to flavors sel = [(f.id, "%s (%svcpu / %sGB Disk / %sMB Ram )" % (f.name, f.vcpus, f.disk, f.ram)) for f in fl] return sorted(sel) except api_exceptions.ApiException: LOG.error("Unable to retrieve list of instance types", exc_info=True) return [(1, "m1.tiny")] def keynamelist(): try: fl = api.keypair_list(request) sel = [(f.key_name, f.key_name) for f in fl] return sel except api_exceptions.ApiException: LOG.error("Unable to retrieve list of keypairs", exc_info=True) return [] def securitygrouplist(): try: fl = api.security_group_list(request) sel = [(f.name, f.name) for f in fl] return sel except api_exceptions.ApiException: LOG.error("Unable to retrieve list of security groups", exc_info=True) return [] # TODO(mgius): Any reason why these can't be after the launchform logic? # If The form is valid, we've just wasted these two api calls image = api.image_get(request, image_id) tenant = api.token_get_tenant(request, request.user.tenant) quotas = api.tenant_quota_get(request, request.user.tenant) try: quotas.ram = int(quotas.ram) / 100 except Exception, e: messages.error(request, "Error parsing quota for %s: %s" % (image_id, e.message)) return redirect(topbar + "/instances", tenant_id)