当前位置: 首页>>代码示例>>Python>>正文


Python db.aggregate_get_by_host函数代码示例

本文整理汇总了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)
开发者ID:wenlongwljs,项目名称:nova,代码行数:7,代码来源:test_aggregate.py

示例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])
开发者ID:NewpTone,项目名称:stacklab-nova,代码行数:8,代码来源:test_db_api.py

示例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])
开发者ID:NewpTone,项目名称:stacklab-nova,代码行数:9,代码来源:test_db_api.py

示例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])
开发者ID:bhuvan,项目名称:nova,代码行数:11,代码来源:test_db_api.py

示例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)
开发者ID:nitishb,项目名称:nova,代码行数:11,代码来源:driver.py

示例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)
开发者ID:sagar-r-nikam,项目名称:nova,代码行数:14,代码来源:xenapi_conn.py

示例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})
开发者ID:chemikadze,项目名称:nova,代码行数:20,代码来源:host.py

示例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)
开发者ID:matiu2,项目名称:nova,代码行数:6,代码来源:test_db_api.py

示例9: aggregate_get_by_host

 def aggregate_get_by_host(self, context, host, key=None):
     return db.aggregate_get_by_host(context, host, key)
开发者ID:gajen,项目名称:nova,代码行数:2,代码来源:fake.py

示例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)
开发者ID:gilmeir,项目名称:nova,代码行数:3,代码来源:aggregate.py

示例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)
开发者ID:dnguyenutsa,项目名称:nova,代码行数:4,代码来源:aggregate.py

示例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)
开发者ID:4everming,项目名称:nova,代码行数:6,代码来源:aggregate.py

示例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'))
开发者ID:bhuvan,项目名称:nova,代码行数:5,代码来源:test_db_api.py


注:本文中的nova.db.aggregate_get_by_host函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。