コード例 #1
0
ファイル: test_compute_node.py プロジェクト: haris00/nova
 def test_get_by_service_id(self):
     self.mox.StubOutWithMock(db, 'compute_nodes_get_by_service_id')
     db.compute_nodes_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,
                      subs=self.subs(),
                      comparators=self.comparators())
コード例 #2
0
 def test_get_by_service_id(self):
     self.mox.StubOutWithMock(db, 'compute_nodes_get_by_service_id')
     db.compute_nodes_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,
                      subs=self.subs(),
                      comparators=self.comparators())
コード例 #3
0
ファイル: test_service.py プロジェクト: tohosys/nova
 def test_compute_node(self):
     self.mox.StubOutWithMock(db, 'compute_nodes_get_by_service_id')
     db.compute_nodes_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,
                      subs=self.subs(),
                      allow_missing=OPTIONAL,
                      comparators=self.comparators())
     # Make sure it doesn't re-fetch this
     service_obj.compute_node
コード例 #4
0
ファイル: test_service.py プロジェクト: dtroyer/nova
 def test_compute_node(self):
     self.mox.StubOutWithMock(db, 'compute_nodes_get_by_service_id')
     db.compute_nodes_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,
                      subs=self.subs(),
                      allow_missing=OPTIONAL,
                      comparators=self.comparators())
     # Make sure it doesn't re-fetch this
     service_obj.compute_node
コード例 #5
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.
         try:
             service = objects.Service.get_by_compute_host(context, host)
             db_computes = db.compute_nodes_get_by_service_id(
                 context, service.id)
         except exception.ServiceNotFound:
             # We need to provide the same exception upstream
             raise exception.ComputeHostNotFound(host=host)
         db_compute = None
         for compute in db_computes:
             if compute['hypervisor_hostname'] == nodename:
                 db_compute = compute
                 # We can avoid an extra call to Service object in
                 # _from_db_object
                 db_compute['host'] = service.host
                 break
         if not db_compute:
             raise exception.ComputeHostNotFound(host=host)
     return cls._from_db_object(context, cls(), db_compute)
コード例 #6
0
ファイル: compute_node.py プロジェクト: wenlongwljs/nova
 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.
         try:
             service = objects.Service.get_by_compute_host(context, host)
             db_computes = db.compute_nodes_get_by_service_id(context, service.id)
         except exception.ServiceNotFound:
             # We need to provide the same exception upstream
             raise exception.ComputeHostNotFound(host=host)
         db_compute = None
         for compute in db_computes:
             if compute["hypervisor_hostname"] == nodename:
                 db_compute = compute
                 # We can avoid an extra call to Service object in
                 # _from_db_object
                 db_compute["host"] = service.host
                 break
         if not db_compute:
             raise exception.ComputeHostNotFound(host=host)
     return cls._from_db_object(context, cls(), db_compute)
コード例 #7
0
ファイル: compute_node.py プロジェクト: wenlongwljs/nova
 def _get_by_service(cls, context, service_id, use_slave=False):
     try:
         db_computes = db.compute_nodes_get_by_service_id(context, service_id)
     except exception.ServiceNotFound:
         # NOTE(sbauza): Previous behaviour was returning an empty list
         # if the service was created with no computes, we need to keep it.
         db_computes = []
     return base.obj_make_list(context, cls(context), objects.ComputeNode, db_computes)
コード例 #8
0
 def _get_by_service(cls, context, service_id, use_slave=False):
     try:
         db_computes = db.compute_nodes_get_by_service_id(
             context, service_id)
     except exception.ServiceNotFound:
         # NOTE(sbauza): Previous behaviour was returning an empty list
         # if the service was created with no computes, we need to keep it.
         db_computes = []
     return base.obj_make_list(context, cls(context), objects.ComputeNode,
                               db_computes)
コード例 #9
0
ファイル: compute_node.py プロジェクト: wenlongwljs/nova
 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.
         try:
             service = objects.Service.get_by_compute_host(context, host, use_slave)
             db_computes = db.compute_nodes_get_by_service_id(context, service.id)
         except exception.ServiceNotFound:
             # We need to provide the same exception upstream
             raise exception.ComputeHostNotFound(host=host)
         # We can avoid an extra call to Service object in _from_db_object
         for db_compute in db_computes:
             db_compute["host"] = service.host
     return base.obj_make_list(context, cls(context), objects.ComputeNode, db_computes)
コード例 #10
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.
         try:
             service = objects.Service.get_by_compute_host(
                 context, host, use_slave)
             db_computes = db.compute_nodes_get_by_service_id(
                 context, service.id)
         except exception.ServiceNotFound:
             # We need to provide the same exception upstream
             raise exception.ComputeHostNotFound(host=host)
         # We can avoid an extra call to Service object in _from_db_object
         for db_compute in db_computes:
             db_compute['host'] = service.host
     return base.obj_make_list(context, cls(context), objects.ComputeNode,
                               db_computes)
コード例 #11
0
ファイル: compute_node.py プロジェクト: cotyb/nova
 def get_by_service_id(cls, context, service_id):
     db_computes = db.compute_nodes_get_by_service_id(context, service_id)
     # NOTE(sbauza): Old version was returning an item, we need to keep this
     # behaviour for backwards compatibility
     db_compute = db_computes[0]
     return cls._from_db_object(context, cls(), db_compute)
コード例 #12
0
 def get_by_service_id(cls, context, service_id):
     db_computes = db.compute_nodes_get_by_service_id(context, service_id)
     # NOTE(sbauza): Old version was returning an item, we need to keep this
     # behaviour for backwards compatibility
     db_compute = db_computes[0]
     return cls._from_db_object(context, cls(), db_compute)