Merge "Xenapi: Handle missing aggregate metadata on startup"

This commit is contained in:
Jenkins 2015-11-24 14:06:58 +00:00 committed by Gerrit Code Review
commit 4614c4b8cb
2 changed files with 14 additions and 1 deletions

View File

@ -1501,6 +1501,19 @@ iface eth0 inet6 static
self.conn._session._get_host_uuid)
self.assertTrue(was['called'])
def test_session_handles_aggregate_metadata(self):
def fake_aggregate_get(context, host, key):
agg = copy.copy(test_aggregate.fake_aggregate)
agg['metadetails'][CONF.host] = 'this_should_be_metadata'
return [agg]
self.stubs.Set(db, 'aggregate_get_by_host',
fake_aggregate_get)
self.stubs.Set(self.conn._session, "is_slave", True)
self.assertEqual('this_should_be_metadata',
self.conn._session._get_host_uuid())
def test_per_instance_usage_running(self):
instance = self._create_instance(spawn=True)
flavor = flavors.get_flavor(3)

View File

@ -154,7 +154,7 @@ class XenAPISession(object):
LOG.error(_LE('Host is member of a pool, but DB '
'says otherwise'))
raise exception.AggregateHostNotFound()
return aggr.metadetails[CONF.host]
return aggr.metadata[CONF.host]
else:
with self._get_session() as session:
host_ref = session.xenapi.session.get_this_host(session.handle)