Example #1
0
 def test_get_zun_service(self, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     zun_service = utils.create_test_zun_service()
     mock_read.side_effect = lambda *args: FakeEtcdResult(zun_service.
                                                          as_dict())
     res = dbapi.get_zun_service(self.context, zun_service.host,
                                 zun_service.binary)
     self.assertEqual(zun_service.host, res.host)
     self.assertEqual(zun_service.binary, res.binary)
Example #2
0
    def get_by_host_and_binary(cls, context, host, binary):
        """Find a zun_service based on its hostname and binary.

        :param host: The host on which the binary is running.
        :param binary: The name of the binary.
        :param context: Security context.
        :returns: a :class:`ZunService` object.
        """
        db_zun_service = dbapi.get_zun_service(context, host, binary)
        if db_zun_service is None:
            return None
        zun_service = ZunService._from_db_object(cls(context), db_zun_service)
        return zun_service
Example #3
0
    def get_by_host_and_binary(cls, context, host, binary):
        """Find a zun_service based on its hostname and binary.

        :param host: The host on which the binary is running.
        :param binary: The name of the binary.
        :param context: Security context.
        :returns: a :class:`ZunService` object.
        """
        db_zun_service = dbapi.get_zun_service(
            context, host, binary)
        if db_zun_service is None:
            return None
        zun_service = ZunService._from_db_object(
            cls(context), db_zun_service)
        return zun_service
 def test_get_zun_service_not_found(self, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     zun_service = utils.create_test_zun_service()
     res = dbapi.get_zun_service(self.context, 'wrong_host_name',
                                 zun_service.binary)
     self.assertIsNone(res)