Пример #1
0
    def _update_local_cache_from_swift(self, swift_container, object_name):
        """
        Updates the local cache of microcontrollers and dependencies

        :param container: container name
        :param object_name: Name of the microcontroller or dependency
        """
        cache_target_path = os.path.join(self.conf["cache_dir"],
                                         self.scope, 'vertigo',
                                         swift_container)
        cache_target_obj = os.path.join(cache_target_path, object_name)

        if not os.path.exists(cache_target_path):
            os.makedirs(cache_target_path, 0o777)

        resp = make_swift_request("GET", self.account, swift_container, object_name)

        with open(cache_target_obj, 'w') as fn:
            fn.write(resp.body)

        set_object_metadata(cache_target_obj, resp.headers)
Пример #2
0
    def _update_cache(self, swift_container, object_name):
        """
        Updates the local cache of microcontrollers and dependencies

        :param container: container name
        :param object_name: Name of the microcontroller or dependency
        """
        cache_target_path = os.path.join(self.conf["cache_dir"],
                                         self.scope, 'vertigo',
                                         swift_container)
        cache_target_obj = os.path.join(cache_target_path, object_name)

        if not os.path.exists(cache_target_path):
            os.makedirs(cache_target_path, 0o777)

        resp = make_swift_request(
            "GET", self.account, swift_container, object_name)

        with open(cache_target_obj, 'w') as fn:
            fn.write(resp.body)

        set_object_metadata(cache_target_obj, resp.headers)
Пример #3
0
    def _verify_access_to_storlet(self, storlet):
        """
        Verify access to the storlet object
        :params storlet: storlet name
        :return: is accessible
        :raises HTTPUnauthorized: If it fails to verify access
        """
        spath = '/'.join(['', self.api_version, self.account,
                          self.storlet_container, storlet])
        self.logger.debug('Verify access to %s' % spath)

        resp = make_swift_request("HEAD", self.account,
                                  self.storlet_container,
                                  storlet)

        if not resp.is_success:
            return False

        self.storlet_name = storlet
        self.storlet_metadata = self._parse_storlet_params(resp.headers)
        for key in ['Content-Length', 'X-Timestamp']:
            self.storlet_metadata[key] = resp.headers[key]

        return True
Пример #4
0
    def _verify_access_to_storlet(self, storlet):
        """
        Verify access to the storlet object
        :params storlet: storlet name
        :return: is accessible
        :raises HTTPUnauthorized: If it fails to verify access
        """
        spath = '/'.join([
            '', self.api_version, self.account, self.storlet_container, storlet
        ])
        self.logger.debug('Verify access to %s' % spath)

        resp = make_swift_request("HEAD", self.account, self.storlet_container,
                                  storlet)

        if not resp.is_success:
            return False

        self.storlet_name = storlet
        self.storlet_metadata = self._parse_storlet_params(resp.headers)
        for key in ['Content-Length', 'X-Timestamp']:
            self.storlet_metadata[key] = resp.headers[key]

        return True