예제 #1
0
 def test_aggregate_get(self):
     """Ensure we can get aggregate with all its relations."""
     ctxt = context.get_admin_context()
     result = _create_aggregate_with_hosts(context=ctxt)
     expected = db.aggregate_get(ctxt, result.id)
     self.assertEqual(_get_fake_aggr_hosts(), expected.hosts)
     self.assertEqual(_get_fake_aggr_metadata(), expected.metadetails)
예제 #2
0
파일: test_db_api.py 프로젝트: matiu2/nova
 def test_aggregate_get(self):
     """Ensure we can get aggregate with all its relations."""
     ctxt = context.get_admin_context()
     result = _create_aggregate_with_hosts(context=ctxt)
     expected = db.aggregate_get(ctxt, result.id)
     self.assertEqual(_get_fake_aggr_hosts(), expected.hosts)
     self.assertEqual(_get_fake_aggr_metadata(), expected.metadetails)
예제 #3
0
    def _setup_aggregate_with_host(self):
        aggregate_ref = db.aggregate_create(self.context.elevated(), {"name": "foo", "availability_zone": "foo"})

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

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

        return aggregate_ref
예제 #4
0
 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")
예제 #5
0
 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)
예제 #6
0
파일: test_db_api.py 프로젝트: altai/nova
 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")
예제 #7
0
    def _setup_aggregate_with_host(self):
        aggregate_ref = db.aggregate_create(self.context.elevated(),
                {'name': 'foo', 'availability_zone': 'foo'})

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

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

        return aggregate_ref
예제 #8
0
 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)
예제 #9
0
    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"])
예제 #10
0
    def _setup_aggregate_with_host(self):
        aggregate_ref = db.aggregate_create(self.context.elevated(),
                {'name': 'foo'}, metadata={'availability_zone': 'foo'})

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

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

        return aggregate_ref
예제 #11
0
    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'])
예제 #12
0
    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'])
예제 #13
0
파일: aggregate.py 프로젝트: allinhtml/nova
 def get_by_id(cls, context, aggregate_id):
     db_aggregate = db.aggregate_get(context, aggregate_id)
     return cls._from_db_object(context, cls(), db_aggregate)
예제 #14
0
 def test_get_by_id(self):
     self.mox.StubOutWithMock(db, 'aggregate_get')
     db.aggregate_get(self.context, 123).AndReturn(fake_aggregate)
     self.mox.ReplayAll()
     agg = aggregate.Aggregate.get_by_id(self.context, 123)
     self.compare_obj(agg, fake_aggregate, subs=SUBS)
예제 #15
0
파일: aggregate.py 프로젝트: 4everming/nova
 def get_by_id(cls, context, aggregate_id):
     try:
         db_aggregate = _aggregate_get_from_db(context, aggregate_id)
     except exception.AggregateNotFound:
         db_aggregate = db.aggregate_get(context, aggregate_id)
     return cls._from_db_object(context, cls(), db_aggregate)
예제 #16
0
 def test_get_by_id(self):
     self.mox.StubOutWithMock(db, 'aggregate_get')
     db.aggregate_get(self.context, 123).AndReturn(fake_aggregate)
     self.mox.ReplayAll()
     agg = aggregate.Aggregate.get_by_id(self.context, 123)
     self.compare_obj(agg, fake_aggregate, subs=SUBS)
예제 #17
0
 def get_by_id(cls, context, aggregate_id):
     try:
         db_aggregate = _aggregate_get_from_db(context, aggregate_id)
     except exception.AggregateNotFound:
         db_aggregate = db.aggregate_get(context, aggregate_id)
     return cls._from_db_object(context, cls(), db_aggregate)
예제 #18
0
파일: aggregate.py 프로젝트: gilmeir/nova
 def get_by_id(cls, context, aggregate_id):
     db_aggregate = db.aggregate_get(context, aggregate_id)
     return cls._from_db_object(context, cls(), db_aggregate)
예제 #19
0
 def test_get_by_id(self):
     self.mox.StubOutWithMock(db, "aggregate_get")
     db.aggregate_get(self.context, 123).AndReturn(fake_aggregate)
     self.mox.ReplayAll()
     agg = aggregate.Aggregate.get_by_id(self.context, 123)
     compare(agg, fake_aggregate)