Example #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)
Example #2
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)
Example #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
Example #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")
Example #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)
Example #6
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")
Example #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
Example #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)
Example #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"])
Example #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
Example #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'])
Example #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'])
Example #13
0
 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)
Example #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)
Example #15
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)
Example #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)
Example #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)
Example #18
0
 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)
Example #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)