Skip to content
Permalink
Browse files

Use sysmetadata to get instance_name in API

Change-Id: If2ca9ff307f0d9b977d76f6ba8f34fb828c893cd
  • Loading branch information...
sorrison committed Apr 29, 2014
1 parent 808a725 commit 6bf1cf78b86bed99733e1119b891397dee15a65e
Showing with 14 additions and 1 deletion.
  1. +14 −1 nova/api/openstack/compute/contrib/extended_server_attributes.py
@@ -14,15 +14,26 @@

"""The Extended Server Attributes API extension."""

from oslo.config import cfg

from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import utils

CONF = cfg.CONF

authorize = extensions.soft_extension_authorizer('compute',
'extended_server_attributes')


class ExtendedServerAttributesController(wsgi.Controller):
def _get_hypervisor_instance_name(self, context, instance):
if not CONF.cells.enable:
return instance['name']
sys_metadata = utils.instance_sys_meta(instance)
return sys_metadata.get('instance_name', '')

def _extend_server(self, context, server, instance):
key = "%s:hypervisor_hostname" % Extended_server_attributes.alias
server[key] = instance['node']
@@ -31,9 +42,11 @@ def _extend_server(self, context, server, instance):
if attr == 'name':
key = "%s:instance_%s" % (Extended_server_attributes.alias,
attr)
server[key] = self._get_hypervisor_instance_name(context,
instance)
else:
key = "%s:%s" % (Extended_server_attributes.alias, attr)
server[key] = instance[attr]
server[key] = instance[attr]

@wsgi.extends
def show(self, req, resp_obj, id):

0 comments on commit 6bf1cf7

Please sign in to comment.
You can’t perform that action at this time.