minor pep8 fixes for api and gitignore fix for new layout
This commit is contained in:
parent
fb74829042
commit
d7243d75b4
4
.gitignore
vendored
4
.gitignore
vendored
@ -5,8 +5,8 @@ django-openstack/develop-eggs/
|
||||
django-openstack/downloads/
|
||||
django-openstack/eggs/
|
||||
django-openstack/parts/
|
||||
django-openstack/src/django_nova.egg-info
|
||||
django-openstack/src/django_openstack.egg-info
|
||||
django-openstack/django_nova.egg-info
|
||||
django-openstack/django_openstack.egg-info
|
||||
django-nova-syspanel/src/django_nova_syspanel.egg-info
|
||||
openstack-dashboard/.dashboard-venv
|
||||
openstack-dashboard/local/dashboard_openstack.sqlite3
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
import logging
|
||||
@ -15,6 +14,7 @@ import openstackx.auth
|
||||
from urlparse import urlparse
|
||||
import json
|
||||
|
||||
|
||||
def url_for(request, service_name, admin=False):
|
||||
catalog = request.session['serviceCatalog']
|
||||
if admin:
|
||||
@ -23,26 +23,33 @@ def url_for(request, service_name, admin=False):
|
||||
rv = catalog[service_name][0]['internalURL']
|
||||
return rv
|
||||
|
||||
|
||||
def compute_api(request):
|
||||
compute = openstack.compute.Compute(auth_token=request.session['token'],
|
||||
compute = openstack.compute.Compute(
|
||||
auth_token=request.session['token'],
|
||||
management_url=url_for(request, 'nova'))
|
||||
# this below hack is necessary to make the jacobian compute client work
|
||||
compute.client.auth_token = request.session['token']
|
||||
compute.client.management_url = url_for(request, 'nova')
|
||||
return compute
|
||||
|
||||
|
||||
def account_api(request):
|
||||
return openstackx.extras.Account(auth_token=request.session['token'],
|
||||
return openstackx.extras.Account(
|
||||
auth_token=request.session['token'],
|
||||
management_url=url_for(request, 'keystone', True))
|
||||
|
||||
|
||||
def glance_api(request):
|
||||
o = urlparse(url_for(request, 'glance'))
|
||||
return glance.client.Client(o.hostname, o.port)
|
||||
|
||||
|
||||
def admin_api(request):
|
||||
return openstackx.admin.Admin(auth_token=request.session['token'],
|
||||
management_url=url_for(request, 'nova', True))
|
||||
|
||||
|
||||
def extras_api(request):
|
||||
return openstackx.extras.Extras(auth_token=request.session['token'],
|
||||
management_url=url_for(request, 'nova'))
|
||||
@ -136,7 +143,9 @@ def server_list(request):
|
||||
return extras_api(request).servers.list()
|
||||
|
||||
|
||||
def server_reboot(request, instance_id, hardness=openstack.compute.servers.REBOOT_HARD):
|
||||
def server_reboot(request,
|
||||
instance_id,
|
||||
hardness=openstack.compute.servers.REBOOT_HARD):
|
||||
server = server_get(request, instance_id)
|
||||
return server.reboot(hardness)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user