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