Exemplo n.º 1
0
 def test_get_by_service_id(self):
     self.mox.StubOutWithMock(db, 'compute_node_get_by_service_id')
     db.compute_node_get_by_service_id(self.context, 456).AndReturn(
         fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode.get_by_service_id(self.context, 456)
     self.compare_obj(compute, fake_compute_node)
Exemplo n.º 2
0
 def test_get_by_service_id(self):
     self.mox.StubOutWithMock(db, 'compute_node_get_by_service_id')
     db.compute_node_get_by_service_id(self.context,
                                       456).AndReturn(fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode.get_by_service_id(self.context, 456)
     self.compare_obj(compute, fake_compute_node)
Exemplo n.º 3
0
 def test_get_by_service_id(self):
     self.mox.StubOutWithMock(db, 'compute_node_get_by_service_id')
     db.compute_node_get_by_service_id(self.context, 456).AndReturn(
         fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode.get_by_service_id(self.context, 456)
     self.compare_obj(compute, fake_compute_node,
                      comparators={'stats': self.json_comparator,
                                   'host_ip': self.str_comparator})
Exemplo n.º 4
0
 def test_get_by_service_id(self):
     self.mox.StubOutWithMock(db, 'compute_node_get_by_service_id')
     db.compute_node_get_by_service_id(self.context, 456).AndReturn(
         fake_compute_node)
     self.mox.ReplayAll()
     compute = compute_node.ComputeNode.get_by_service_id(self.context, 456)
     self.compare_obj(compute, fake_compute_node,
                      comparators={'stats': self.json_comparator,
                                   'host_ip': self.str_comparator})
Exemplo n.º 5
0
 def test_compute_node(self):
     self.mox.StubOutWithMock(db, 'compute_node_get_by_service_id')
     db.compute_node_get_by_service_id(self.context, 123).AndReturn(
         test_compute_node.fake_compute_node)
     self.mox.ReplayAll()
     service_obj = service.Service()
     service_obj._context = self.context
     service_obj.id = 123
     compare(service_obj.compute_node, test_compute_node.fake_compute_node)
     # Make sure it doesn't re-fetch this
     service_obj.compute_node
Exemplo n.º 6
0
 def test_compute_node(self):
     self.mox.StubOutWithMock(db, 'compute_node_get_by_service_id')
     db.compute_node_get_by_service_id(self.context, 123).AndReturn(
         test_compute_node.fake_compute_node)
     self.mox.ReplayAll()
     service_obj = service.Service()
     service_obj._context = self.context
     service_obj.id = 123
     compare(service_obj.compute_node, test_compute_node.fake_compute_node)
     # Make sure it doesn't re-fetch this
     service_obj.compute_node
Exemplo n.º 7
0
 def test_compute_node(self):
     self.mox.StubOutWithMock(db, 'compute_node_get_by_service_id')
     db.compute_node_get_by_service_id(self.context, 123).AndReturn(
         test_compute_node.fake_compute_node)
     self.mox.ReplayAll()
     service_obj = service.Service()
     service_obj._context = self.context
     service_obj.id = 123
     self.compare_obj(service_obj.compute_node,
                      test_compute_node.fake_compute_node,
                      allow_missing=OPTIONAL,
                      comparators={'stats': self.json_comparator})
     # Make sure it doesn't re-fetch this
     service_obj.compute_node
Exemplo n.º 8
0
 def get_by_host_and_nodename(cls, context, host, nodename):
     try:
         db_compute = db.compute_node_get_by_host_and_nodename(
             context, host, nodename)
     except exception.ComputeHostNotFound:
         # FIXME(sbauza): Some old computes can still have no host record
         # We need to provide compatibility by using the old service_id
         # record.
         # We assume the compatibility as an extra penalty of one more DB
         # call but that's necessary until all nodes are upgraded.
         service = objects.Service.get_by_compute_host(context, host)
         # NOTE(sbauza): Here, the old model is buggy because there can only
         # be one compute node per service_id
         db_compute = db.compute_node_get_by_service_id(context, service.id)
         # We can avoid an extra call to Service object in _from_db_object
         db_compute['host'] = service.host
     return cls._from_db_object(context, cls(), db_compute)
Exemplo n.º 9
0
 def get_all_by_host(cls, context, host, use_slave=False):
     try:
         db_computes = db.compute_node_get_all_by_host(context, host,
                                                       use_slave)
     except exception.ComputeHostNotFound:
         # FIXME(sbauza): Some old computes can still have no host record
         # We need to provide compatibility by using the old service_id
         # record.
         # We assume the compatibility as an extra penalty of one more DB
         # call but that's necessary until all nodes are upgraded.
         service = objects.Service.get_by_compute_host(context, host,
                                                       use_slave)
         db_compute = db.compute_node_get_by_service_id(context,
                                                        service.id)
         # We can avoid an extra call to Service object in _from_db_object
         db_compute['host'] = service.host
         # NOTE(sbauza): Yeah, the old model sucks, because there can only
         # be one node per host...
         db_computes = [db_compute]
     return base.obj_make_list(context, cls(context), objects.ComputeNode,
                               db_computes)
Exemplo n.º 10
0
 def get_by_service_id(cls, context, service_id):
     db_compute = db.compute_node_get_by_service_id(context, service_id)
     return cls._from_db_object(context, cls(), db_compute)
Exemplo n.º 11
0
 def get_by_service_id(cls, context, service_id):
     db_compute = db.compute_node_get_by_service_id(context, service_id)
     return cls._from_db_object(context, cls(), db_compute)