本文整理汇总了Python中nova.db.aggregate_get_by_host函数的典型用法代码示例。如果您正苦于以下问题:Python aggregate_get_by_host函数的具体用法?Python aggregate_get_by_host怎么用?Python aggregate_get_by_host使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了aggregate_get_by_host函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_by_host
def test_by_host(self):
self.mox.StubOutWithMock(db, "aggregate_get_by_host")
db.aggregate_get_by_host(self.context, "fake-host", key=None).AndReturn([fake_aggregate])
self.mox.ReplayAll()
aggs = aggregate.AggregateList.get_by_host(self.context, "fake-host")
self.assertEqual(1, len(aggs))
self.compare_obj(aggs[0], fake_aggregate, subs=SUBS)
示例2: test_aggregate_get_by_host
def test_aggregate_get_by_host(self):
"""Ensure we can get aggregates by host."""
ctxt = context.get_admin_context()
values = {"name": "fake_aggregate2", "availability_zone": "fake_avail_zone"}
a1 = _create_aggregate_with_hosts(context=ctxt)
a2 = _create_aggregate_with_hosts(context=ctxt, values=values)
r1 = db.aggregate_get_by_host(ctxt, "foo.openstack.org")
self.assertEqual([a1.id, a2.id], [x.id for x in r1])
示例3: test_aggregate_get_by_host_with_key
def test_aggregate_get_by_host_with_key(self):
"""Ensure we can get aggregates by host."""
ctxt = context.get_admin_context()
values = {"name": "fake_aggregate2", "availability_zone": "fake_avail_zone"}
a1 = _create_aggregate_with_hosts(context=ctxt, metadata={"goodkey": "good"})
a2 = _create_aggregate_with_hosts(context=ctxt, values=values)
# filter result by key
r1 = db.aggregate_get_by_host(ctxt, "foo.openstack.org", key="goodkey")
self.assertEqual([a1.id], [x.id for x in r1])
示例4: test_aggregate_get_by_host_with_key
def test_aggregate_get_by_host_with_key(self):
"""Ensure we can get aggregates by host."""
ctxt = context.get_admin_context()
values = {'name': 'fake_aggregate2',
'availability_zone': 'fake_avail_zone', }
a1 = _create_aggregate_with_hosts(context=ctxt,
metadata={'goodkey': 'good'})
a2 = _create_aggregate_with_hosts(context=ctxt, values=values)
# filter result by key
r1 = db.aggregate_get_by_host(ctxt, 'foo.openstack.org', key='goodkey')
self.assertEqual([a1.id], [x.id for x in r1])
示例5: _get_host_uuid
def _get_host_uuid(self):
if self.is_slave:
aggr = db.aggregate_get_by_host(context.get_admin_context(), FLAGS.host, key=pool_states.POOL_FLAG)[0]
if not aggr:
LOG.error(_("Host is member of a pool, but DB " "says otherwise"))
raise exception.AggregateHostNotFound()
return aggr.metadetails[FLAGS.host]
else:
with self._get_session() as session:
host_ref = session.xenapi.session.get_this_host(session.handle)
return session.xenapi.host.get_uuid(host_ref)
示例6: _populate_host_uuid
def _populate_host_uuid(self):
if self.is_slave:
try:
aggr = db.aggregate_get_by_host(context.get_admin_context(),
FLAGS.host)
self.host_uuid = aggr.metadetails[FLAGS.host]
except exception.AggregateHostNotFound:
LOG.exception(_('Host is member of a pool, but DB '
'says otherwise'))
raise
else:
with self._get_session() as session:
host_ref = session.xenapi.session.get_this_host(session.handle)
self.host_uuid = session.xenapi.host.get_uuid(host_ref)
示例7: _host_find
def _host_find(context, session, src, dst):
"""Return the host from the xenapi host reference.
:param src: the compute host being put in maintenance (source of VMs)
:param dst: the hypervisor host reference (destination of VMs)
:return: the compute host that manages dst
"""
# NOTE: this would be a lot simpler if nova-compute stored
# FLAGS.host in the XenServer host's other-config map.
# TODO(armando-migliaccio): improve according the note above
aggregate = db.aggregate_get_by_host(context, src)
uuid = session.call_xenapi('host.get_record', dst)['uuid']
for compute_host, host_uuid in aggregate.metadetails.iteritems():
if host_uuid == uuid:
return compute_host
raise exception.NoValidHost(reason='Host %(host_uuid)s could not be found '
'from aggregate metadata: %(metadata)s.' %
{'host_uuid': uuid,
'metadata': aggregate.metadetails})
示例8: test_aggregate_get_by_host
def test_aggregate_get_by_host(self):
"""Ensure we can get an aggregate by host."""
ctxt = context.get_admin_context()
r1 = _create_aggregate_with_hosts(context=ctxt)
r2 = db.aggregate_get_by_host(ctxt, 'foo.openstack.org')
self.assertEqual(r1.id, r2.id)
示例9: aggregate_get_by_host
def aggregate_get_by_host(self, context, host, key=None):
return db.aggregate_get_by_host(context, host, key)
示例10: get_by_host
def get_by_host(cls, context, host, key=None):
db_aggregates = db.aggregate_get_by_host(context, host, key=key)
return base.obj_make_list(context, cls(context), objects.Aggregate, db_aggregates)
示例11: get_by_host
def get_by_host(cls, context, host):
db_aggregates = db.aggregate_get_by_host(context, host)
return base.obj_make_list(context, AggregateList(), Aggregate,
db_aggregates)
示例12: get_by_host
def get_by_host(cls, context, host, key=None):
api_db_aggregates = [cls._fill_deprecated(agg) for agg in
_get_by_host_from_db(context, host, key=key)]
db_aggregates = db.aggregate_get_by_host(context, host, key=key)
return base.obj_make_list(context, cls(context), objects.Aggregate,
db_aggregates + api_db_aggregates)
示例13: test_aggregate_get_by_host_not_found
def test_aggregate_get_by_host_not_found(self):
"""Ensure AggregateHostNotFound is raised with unknown host."""
ctxt = context.get_admin_context()
_create_aggregate_with_hosts(context=ctxt)
self.assertEqual([], db.aggregate_get_by_host(ctxt, 'unknown_host'))