def test_get_compute_node_by_uuid(self, mock_write, mock_read): mock_read.side_effect = etcd.EtcdKeyNotFound compute_node = utils.create_test_compute_node(context=self.context) mock_read.side_effect = lambda *args: FakeEtcdResult(compute_node. as_dict()) res = dbapi.get_compute_node(self.context, compute_node.uuid) self.assertEqual(compute_node.uuid, res.uuid) self.assertEqual(compute_node.hostname, res.hostname)
def test_get_compute_node_by_name(self, mock_db_inst, mock_write, mock_read): mock_db_inst.return_value = etcdapi.get_backend() mock_read.side_effect = etcd.EtcdKeyNotFound node = utils.create_test_compute_node(context=self.context) mock_read.side_effect = lambda *args: FakeEtcdResult( node.as_dict()) res = dbapi.get_compute_node(self.context, node.hostname) self.assertEqual(node.uuid, res.uuid)
def get_by_uuid(cls, context, uuid): """Find a compute node based on uuid. :param uuid: the uuid of a compute node. :param context: Security context :returns: a :class:`ComputeNode` object. """ db_compute_node = dbapi.get_compute_node(context, uuid) compute_node = ComputeNode._from_db_object( context, cls(context), db_compute_node) return compute_node
def test_get_compute_node_by_uuid(self): node = utils.create_test_compute_node(context=self.context) res = dbapi.get_compute_node( self.context, node.uuid) self.assertEqual(node.uuid, res.uuid) self.assertEqual(node.hostname, res.hostname)