minor pep8 fixes for api and gitignore fix for new layout

This commit is contained in:
Tres Henry 2011-06-23 13:52:41 -07:00
parent fb74829042
commit d7243d75b4
2 changed files with 18 additions and 9 deletions

4
.gitignore vendored
View File

@ -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

View File

@ -1,6 +1,5 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
from django.conf import settings
import logging
@ -15,34 +14,42 @@ import openstackx.auth
from urlparse import urlparse
import json
def url_for(request, service_name, admin=False):
catalog = request.session['serviceCatalog']
if admin:
rv = catalog[service_name][0]['adminURL']
rv = catalog[service_name][0]['adminURL']
else:
rv = catalog[service_name][0]['internalURL']
return rv
def compute_api(request):
compute = openstack.compute.Compute(auth_token=request.session['token'],
management_url=url_for(request, 'nova'))
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'],
management_url=url_for(request, 'keystone', True))
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)