Fixed our keystone hack.

* Changed the Nova client remote creator to use the tenant ID.
* Updated the view code a bit.
This commit is contained in:
Tim Simpson
2012-03-20 11:59:23 -05:00
parent 64b2d614b3
commit 1e505aeea9
3 changed files with 19 additions and 18 deletions

View File

@@ -39,7 +39,7 @@ def create_nova_client(context):
#TODO(cp16net) need to fix this proxy_tenant_id
client = Client(PROXY_ADMIN_USER, PROXY_ADMIN_PASS,
PROXY_ADMIN_TENANT_NAME, PROXY_AUTH_URL,
proxy_tenant_id="reddwarf",
proxy_tenant_id=context.tenant,
proxy_token=context.auth_tok,
region_name=REGION_NAME,
service_type=SERVICE_TYPE,

View File

@@ -105,6 +105,10 @@ class Instance(object):
def id(self):
return self.db_info.id
@property
def is_building(self):
return self.status == "BUILDING"
@property
def name(self):
return self.server.name
@@ -131,7 +135,7 @@ class Instance(object):
def links(self):
#TODO(tim.simpson): Review whether we should be returning the server
# links.
return self.server.links
return self._build_links(self.server.links)
@property
def addresses(self):
@@ -139,6 +143,14 @@ class Instance(object):
# addresses.
return self.server.addresses
@staticmethod
def _build_links(links):
#TODO(tim.simpson): Don't return the Nova port.
"""Build the links for the instance"""
for link in links:
link['href'] = link['href'].replace('servers', 'instances')
return links
class Instances(Instance):
@@ -156,13 +168,9 @@ class DatabaseModelBase(ModelBase):
@classmethod
def create(cls, **values):
values['id'] = utils.generate_uuid()
print values
# values['created_at'] = utils.utcnow()
instance = cls(**values).save()
if not instance.is_valid():
raise InvalidModelError(instance.errors)
# instance._notify_fields("create")
return instance
def save(self):

View File

@@ -22,25 +22,18 @@ class InstanceView(object):
self.instance = instance
def data(self):
return {"instance": {
instance_dict = {
"id": self.instance.id,
"name": self.instance.name,
"status": self.instance.status,
"created": self.instance.created,
"updated": self.instance.updated,
"flavor": self.instance.flavor,
"links": self._build_links(self.instance.links),
"addresses": self.instance.addresses,
},
"links": self.instance.links
}
@staticmethod
def _build_links(links):
#TODO(tim.simpson): Move this to the model.
"""Build the links for the instance"""
for link in links:
link['href'] = link['href'].replace('servers', 'instances')
return links
if not self.instance.is_building:
instance_dict["addresses"] = self.instance.addresses
return { "instance": instance_dict }
class InstancesView(object):