예제 #1
0
    def get(self, blueprint_id, **kwargs):
        """
        Download blueprint's archive
        """
        blueprint = get_storage_manager().get(models.Blueprint, blueprint_id)

        for arc_type in SUPPORTED_ARCHIVE_TYPES:
            # attempting to find the archive file on the file system
            local_path = os.path.join(
                config.instance.file_server_root,
                FILE_SERVER_UPLOADED_BLUEPRINTS_FOLDER,
                blueprint.tenant.name,
                blueprint.id,
                '{0}.{1}'.format(blueprint.id, arc_type))

            if os.path.isfile(local_path):
                archive_type = arc_type
                break
        else:
            raise RuntimeError("Could not find blueprint's archive; "
                               "Blueprint ID: {0}".format(blueprint.id))

        blueprint_path = '{0}/{1}/{2}/{3}/{3}.{4}'.format(
            FILE_SERVER_RESOURCES_FOLDER,
            FILE_SERVER_UPLOADED_BLUEPRINTS_FOLDER,
            blueprint.tenant.name,
            blueprint.id,
            archive_type)

        return make_streaming_response(
            blueprint.id,
            blueprint_path,
            os.path.getsize(local_path),
            archive_type
        )
예제 #2
0
    def get(self, plugin_id, **kwargs):
        """
        Download plugin archive
        """
        # Verify plugin exists.
        plugin = get_storage_manager().get(models.Plugin, plugin_id)
        # While installing a plugin we add an `installing` prefix to the
        # archive_name, since the archive is saved without this prefix we
        # remove it before searching for the archive in the file system.
        archive_name = (plugin.archive_name[11:] if
                        plugin.archive_name.startswith(INSTALLING_PREFIX)
                        else plugin.archive_name)
        # attempting to find the archive file on the file system
        local_path = utils.get_plugin_archive_path(plugin_id, archive_name)
        if not os.path.isfile(local_path):
            raise RuntimeError("Could not find plugins archive; "
                               "Plugin ID: {0}".format(plugin_id))

        plugin_path = '{0}/{1}/{2}/{3}'.format(
            FILE_SERVER_RESOURCES_FOLDER,
            FILE_SERVER_PLUGINS_FOLDER,
            plugin_id,
            archive_name)

        return rest_utils.make_streaming_response(
            plugin_id,
            plugin_path,
            os.path.getsize(local_path),
            'tar.gz'
        )
예제 #3
0
    def get(self, plugin_id, **kwargs):
        """
        Download plugin archive
        """
        # Verify plugin exists.
        plugin = get_storage_manager().get(models.Plugin, plugin_id)

        archive_name = plugin.archive_name
        # attempting to find the archive file on the file system
        local_path = utils.get_plugin_archive_path(plugin_id, archive_name)
        if not os.path.isfile(local_path):
            raise RuntimeError("Could not find plugins archive; "
                               "Plugin ID: {0}".format(plugin_id))

        plugin_path = '{0}/{1}/{2}/{3}'.format(
            FILE_SERVER_RESOURCES_FOLDER,
            FILE_SERVER_PLUGINS_FOLDER,
            plugin_id,
            archive_name)

        return rest_utils.make_streaming_response(
            plugin_id,
            plugin_path,
            os.path.getsize(local_path),
            'tar.gz'
        )
예제 #4
0
    def get(self, blueprint_id, **kwargs):
        """
        Download blueprint's archive
        """
        blueprint = get_storage_manager().get(models.Blueprint, blueprint_id)

        for arc_type in SUPPORTED_ARCHIVE_TYPES:
            # attempting to find the archive file on the file system
            local_path = os.path.join(
                config.instance.file_server_root,
                FILE_SERVER_UPLOADED_BLUEPRINTS_FOLDER,
                blueprint.tenant.name,
                blueprint.id,
                '{0}.{1}'.format(blueprint.id, arc_type))

            if os.path.isfile(local_path):
                archive_type = arc_type
                break
        else:
            raise RuntimeError("Could not find blueprint's archive; "
                               "Blueprint ID: {0}".format(blueprint.id))

        blueprint_path = '{0}/{1}/{2}/{3}/{3}.{4}'.format(
            FILE_SERVER_RESOURCES_FOLDER,
            FILE_SERVER_UPLOADED_BLUEPRINTS_FOLDER,
            blueprint.tenant.name,
            blueprint.id,
            archive_type)

        return make_streaming_response(
            blueprint.id,
            blueprint_path,
            os.path.getsize(local_path),
            archive_type
        )
예제 #5
0
    def get(self, plugin_id, **kwargs):
        """
        Download plugin archive
        """
        # Verify plugin exists.
        plugin = get_storage_manager().get(models.Plugin, plugin_id)

        archive_name = plugin.archive_name
        # attempting to find the archive file on the file system
        local_path = utils.get_plugin_archive_path(plugin_id, archive_name)
        if not os.path.isfile(local_path):
            raise RuntimeError("Could not find plugins archive; "
                               "Plugin ID: {0}".format(plugin_id))

        plugin_path = '{0}/{1}/{2}/{3}'.format(
            FILE_SERVER_RESOURCES_FOLDER,
            FILE_SERVER_PLUGINS_FOLDER,
            plugin_id,
            archive_name)

        return rest_utils.make_streaming_response(
            plugin_id,
            plugin_path,
            os.path.getsize(local_path),
            'tar.gz'
        )
예제 #6
0
    def get(self, snapshot_id):
        snap = get_storage_manager().get(models.Snapshot, snapshot_id)
        if snap.status == SnapshotState.FAILED:
            raise manager_exceptions.SnapshotActionError(
                'Failed snapshot cannot be downloaded')

        snapshot_path = os.path.join(_get_snapshot_path(snapshot_id),
                                     '{0}.zip'.format(snapshot_id))

        snapshot_uri = '{0}/{1}/{2}/{2}.zip'.format(
            FILE_SERVER_RESOURCES_FOLDER, FILE_SERVER_SNAPSHOTS_FOLDER,
            snapshot_id)

        return rest_utils.make_streaming_response(
            snapshot_id, snapshot_uri, os.path.getsize(snapshot_path), 'zip')
예제 #7
0
    def get(self, plugin_id, **kwargs):
        """
        Download plugin archive
        """
        # Verify plugin exists.
        plugin = get_storage_manager().get(models.Plugin, plugin_id)
        plugin_path = '{0}/{1}/{2}/{3}'.format(
            FILE_SERVER_RESOURCES_FOLDER,
            FILE_SERVER_PLUGINS_FOLDER,
            plugin_id,
            plugin.archive_name)

        return rest_utils.make_streaming_response(
            plugin_id,
            plugin_path,
            'tar.gz'
        )
예제 #8
0
    def get(self, snapshot_id):
        snap = get_storage_manager().get(models.Snapshot, snapshot_id)
        if snap.status == SnapshotState.FAILED:
            raise manager_exceptions.SnapshotActionError(
                'Failed snapshot cannot be downloaded'
            )

        snapshot_path = os.path.join(
            _get_snapshot_path(snapshot_id),
            '{0}.zip'.format(snapshot_id)
        )

        snapshot_uri = '{0}/{1}/{2}/{2}.zip'.format(
            FILE_SERVER_RESOURCES_FOLDER,
            FILE_SERVER_SNAPSHOTS_FOLDER,
            snapshot_id
        )

        return rest_utils.make_streaming_response(
            snapshot_id,
            snapshot_uri,
            os.path.getsize(snapshot_path),
            'zip'
        )