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


Python db.aggregate_delete函数代码示例

本文整理汇总了Python中nova.db.aggregate_delete函数的典型用法代码示例。如果您正苦于以下问题:Python aggregate_delete函数的具体用法?Python aggregate_delete怎么用?Python aggregate_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了aggregate_delete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_aggregate_host_add

    def test_aggregate_host_add(self):
        aggregate_ref = self._setup_aggregate_with_host()

        self.assertTrue(any([host == 'bar'
                             for host in aggregate_ref['hosts']]))

        db.aggregate_delete(self.context.elevated(), aggregate_ref['id'])
开发者ID:gminator,项目名称:nova,代码行数:7,代码来源:test_conductor.py

示例2: migrate_aggregates

def migrate_aggregates(ctxt, count):
    main_db_ids = _get_main_db_aggregate_ids(ctxt, count)
    if not main_db_ids:
        return 0, 0

    count_all = len(main_db_ids)
    count_hit = 0

    for aggregate_id in main_db_ids:
        try:
            aggregate = Aggregate.get_by_id(ctxt, aggregate_id)
            remove = ['metadata', 'hosts']
            values = {field: getattr(aggregate, field)
                      for field in aggregate.fields if field not in remove}
            _aggregate_create_in_db(ctxt, values, metadata=aggregate.metadata)
            for host in aggregate.hosts:
                _host_add_to_db(ctxt, aggregate_id, host)
            count_hit += 1
            db.aggregate_delete(ctxt, aggregate.id)
        except exception.AggregateNotFound:
            LOG.warning(
                _LW('Aggregate id %(id)i disappeared during migration'),
                {'id': aggregate_id})
        except (exception.AggregateNameExists) as e:
            LOG.error(str(e))

    return count_all, count_hit
开发者ID:4everming,项目名称:nova,代码行数:27,代码来源:aggregate.py

示例3: test_destroy

 def test_destroy(self):
     self.mox.StubOutWithMock(db, 'aggregate_delete')
     db.aggregate_delete(self.context, 123)
     self.mox.ReplayAll()
     agg = aggregate.Aggregate()
     agg.id = 123
     agg.destroy(self.context)
开发者ID:CrazyTeaFs,项目名称:nova,代码行数:7,代码来源:test_aggregate.py

示例4: test_aggregate_delete

 def test_aggregate_delete(self):
     """Ensure we can delete an aggregate."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt, metadata=None)
     db.aggregate_delete(ctxt, result['id'])
     expected = db.aggregate_get_all(ctxt, read_deleted='no')
     self.assertEqual(0, len(expected))
开发者ID:baz-reddwarf,项目名称:nova,代码行数:7,代码来源:test_db_api.py

示例5: test_aggregate_create_avoid_name_conflict

 def test_aggregate_create_avoid_name_conflict(self):
     """Test we can avoid conflict on deleted aggregates."""
     r1 = _create_aggregate(metadata=None)
     db.aggregate_delete(context.get_admin_context(), r1.id)
     values = {'name': r1.name, 'availability_zone': 'new_zone'}
     r2 = _create_aggregate(values=values)
     self.assertEqual(r2.name, values['name'])
     self.assertEqual(r2.availability_zone, values['availability_zone'])
开发者ID:baz-reddwarf,项目名称:nova,代码行数:8,代码来源:test_db_api.py

示例6: test_aggregate_delete

 def test_aggregate_delete(self):
     """Ensure we can delete an aggregate."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt, metadata=None)
     db.aggregate_delete(ctxt, result['id'])
     expected = db.aggregate_get_all(ctxt, read_deleted='no')
     self.assertEqual(0, len(expected))
     aggregate = db.aggregate_get(ctxt, result['id'], read_deleted='yes')
     self.assertEqual(aggregate["operational_state"], "dismissed")
开发者ID:alejuanito,项目名称:nova,代码行数:9,代码来源:test_db_api.py

示例7: test_aggregate_create_avoid_name_conflict

 def test_aggregate_create_avoid_name_conflict(self):
     """Test we can avoid conflict on deleted aggregates."""
     r1 = _create_aggregate(metadata=None)
     db.aggregate_delete(context.get_admin_context(), r1.id)
     values = {"name": r1.name, "availability_zone": "new_zone"}
     r2 = _create_aggregate(values=values)
     self.assertEqual(r2.name, values["name"])
     self.assertEqual(r2.availability_zone, values["availability_zone"])
     self.assertEqual(r2.operational_state, "created")
开发者ID:hiteshwadekar,项目名称:nova,代码行数:9,代码来源:test_db_api.py

示例8: test_aggregate_delete

 def test_aggregate_delete(self):
     """Ensure we can delete an aggregate."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt, metadata=None)
     db.aggregate_delete(ctxt, result["id"])
     expected = db.aggregate_get_all(ctxt)
     self.assertEqual(0, len(expected))
     aggregate = db.aggregate_get(ctxt.elevated(read_deleted="yes"), result["id"])
     self.assertEqual(aggregate.deleted, True)
开发者ID:NewpTone,项目名称:stacklab-nova,代码行数:9,代码来源:test_db_api.py

示例9: test_aggregate_host_delete

    def test_aggregate_host_delete(self):
        aggregate_ref = self._setup_aggregate_with_host()

        self.conductor.aggregate_host_delete(self.context, aggregate_ref, "bar")

        aggregate_ref = db.aggregate_get(self.context.elevated(), aggregate_ref["id"])

        self.assertFalse(any([host == "bar" for host in aggregate_ref["hosts"]]))

        db.aggregate_delete(self.context.elevated(), aggregate_ref["id"])
开发者ID:jdurgin,项目名称:nova,代码行数:10,代码来源:test_conductor.py

示例10: test_aggregate_create_delete_create_with_metadata

 def test_aggregate_create_delete_create_with_metadata(self):
     """Ensure aggregate metadata is deleted bug 1052479."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt)
     expected_metadata = db.aggregate_metadata_get(ctxt, result['id'])
     self.assertDictMatch(expected_metadata, _get_fake_aggr_metadata())
     db.aggregate_delete(ctxt, result['id'])
     result = _create_aggregate(metadata=None)
     expected_metadata = db.aggregate_metadata_get(ctxt, result['id'])
     self.assertEqual(expected_metadata, {})
开发者ID:hadib,项目名称:nova,代码行数:10,代码来源:test_db_api.py

示例11: test_aggregate_get_all_non_deleted

 def test_aggregate_get_all_non_deleted(self):
     """Ensure we get only non-deleted aggregates."""
     ctxt = context.get_admin_context()
     add_counter = 5
     remove_counter = 2
     aggregates = []
     for c in xrange(1, add_counter):
         values = {"name": "fake_aggregate_%d" % c, "availability_zone": "fake_avail_zone"}
         aggregates.append(_create_aggregate(context=ctxt, values=values, metadata=None))
     for c in xrange(1, remove_counter):
         db.aggregate_delete(ctxt, aggregates[c - 1].id)
     results = db.aggregate_get_all(ctxt)
     self.assertEqual(len(results), add_counter - remove_counter)
开发者ID:hiteshwadekar,项目名称:nova,代码行数:13,代码来源:test_db_api.py

示例12: test_aggregate_host_delete

    def test_aggregate_host_delete(self):
        aggregate_ref = self._setup_aggregate_with_host()

        self.conductor.aggregate_host_delete(self.context, aggregate_ref,
                'bar')

        aggregate_ref = db.aggregate_get(self.context.elevated(),
                aggregate_ref['id'])

        self.assertFalse(any([host == 'bar'
                              for host in aggregate_ref['hosts']]))

        db.aggregate_delete(self.context.elevated(), aggregate_ref['id'])
开发者ID:gminator,项目名称:nova,代码行数:13,代码来源:test_conductor.py

示例13: tearDown

 def tearDown(self):
     db.aggregate_delete(self.context, self.agg['id'])
     super(AvailabilityZoneTestCases, self).tearDown()
开发者ID:Juniper,项目名称:nova,代码行数:3,代码来源:test_availability_zones.py

示例14: test_aggregate_get

 def test_aggregate_get(self):
     aggregate_ref = self._setup_aggregate_with_host()
     aggregate = self.conductor.aggregate_get(self.context, aggregate_ref["id"])
     self.assertEqual(jsonutils.to_primitive(aggregate_ref), aggregate)
     db.aggregate_delete(self.context.elevated(), aggregate_ref["id"])
开发者ID:jdurgin,项目名称:nova,代码行数:5,代码来源:test_conductor.py

示例15: test_aggregate_host_add

    def test_aggregate_host_add(self):
        aggregate_ref = self._setup_aggregate_with_host()

        self.assertTrue(any([host == "bar" for host in aggregate_ref["hosts"]]))

        db.aggregate_delete(self.context.elevated(), aggregate_ref["id"])
开发者ID:jdurgin,项目名称:nova,代码行数:6,代码来源:test_conductor.py


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