예제 #1
0
파일: test_metadata.py 프로젝트: dims/nova
    def test_get_metadata_by_address(self, mock_net_api, mock_get_context):
        mock_get_context.return_value = "CONTEXT"
        api = mock.Mock()
        fixed_ip = objects.FixedIP(instance_uuid="2bfd8d71-6b69-410c-a2f5-dbca18d02966")
        api.get_fixed_ip_by_address.return_value = fixed_ip
        mock_net_api.return_value = api

        with mock.patch.object(base, "get_metadata_by_instance_id") as gmd:
            base.get_metadata_by_address("foo")

        api.get_fixed_ip_by_address.assert_called_once_with("CONTEXT", "foo")
        gmd.assert_called_once_with(fixed_ip.instance_uuid, "foo", "CONTEXT")
예제 #2
0
    def get_metadata_by_remote_address(self, address):
        if not address:
            raise exception.FixedIpNotFoundForAddress(address=address)

        cache_key = 'metadata-%s' % address
        data = self._cache.get(cache_key)
        if data:
            return data

        try:
            data = base.get_metadata_by_address(self.conductor_api, address)
        except exception.NotFound:
            return None

        self._cache.set(cache_key, data, CACHE_EXPIRATION)

        return data
예제 #3
0
파일: handler.py 프로젝트: xww/nova-old
    def get_metadata(self, address):
        if not address:
            raise exception.FixedIpNotFoundForAddress(address=address)

        cache_key = 'metadata-%s' % address
        data = self._cache.get(cache_key)
        if data:
            return data

        try:
            data = base.get_metadata_by_address(address)
        except exception.NotFound:
            return None

        self._cache.set(cache_key, data, 15)

        return data
예제 #4
0
파일: handler.py 프로젝트: paulwhb/nova
    def get_metadata(self, address):
        if not address:
            raise exception.FixedIpNotFoundForAddress(address=address)

        cache_key = 'metadata-%s' % address
        data = self._cache.get(cache_key)
        if data:
            return data

        try:
            data = base.get_metadata_by_address(address)
        except exception.NotFound:
            return None

        self._cache.set(cache_key, data, 15)

        return data
예제 #5
0
파일: handler.py 프로젝트: mnaser/nova-1
    def get_metadata_by_remote_address(self, address):
        if not address:
            raise exception.FixedIpNotFoundForAddress(address=address)

        cache_key = 'metadata-%s' % address
        data = self._cache.get(cache_key)
        if data:
            LOG.debug("Using cached metadata for %s", address)
            return data

        try:
            data = base.get_metadata_by_address(address)
        except exception.NotFound:
            return None

        if CONF.metadata_cache_expiration > 0:
            self._cache.set(cache_key, data, CONF.metadata_cache_expiration)

        return data
예제 #6
0
파일: handler.py 프로젝트: 375670450/nova
    def get_metadata_by_remote_address(self, address):
        if not address:
            raise exception.FixedIpNotFoundForAddress(address=address)

        cache_key = 'metadata-%s' % address
        data = self._cache.get(cache_key)
        if data:
            LOG.debug("Using cached metadata for %s", address)
            return data

        try:
            data = base.get_metadata_by_address(address)
        except exception.NotFound:
            return None

        if CONF.metadata_cache_expiration > 0:
            self._cache.set(cache_key, data)

        return data