Exemplo n.º 1
0
from pulp_rpm.yum_plugin import util
from pulp_rpm.plugins.db import models
from pulp_rpm.plugins.distributors.export_distributor import export_utils
from pulp_rpm.plugins.distributors.export_distributor import generate_iso
from pulp_rpm.plugins.importers.yum.parse.treeinfo import KEY_PACKAGEDIR
from . import configuration
from .metadata.filelists import FilelistsXMLFileContext
from .metadata.metadata import REPO_DATA_DIR_NAME
from .metadata.other import OtherXMLFileContext
from .metadata.prestodelta import PrestodeltaXMLFileContext
from .metadata.primary import PrimaryXMLFileContext
from .metadata.repomd import RepomdXMLFileContext
from .metadata.updateinfo import UpdateinfoXMLFileContext
from .metadata.package import PackageXMLFileContext

logger = util.getLogger(__name__)


class BaseYumRepoPublisher(platform_steps.PluginStep):
    """
    Yum HTTP/HTTPS publisher class that is responsible for the actual publishing
    of a yum repository over HTTP and/or HTTPS.
    """
    def __init__(self,
                 repo,
                 publish_conduit,
                 config,
                 distributor_type,
                 association_filters=None,
                 **kwargs):
        """
Exemplo n.º 2
0
from pulp.server.exceptions import MissingResource

from pulp_rpm.common.constants import (
    SCRATCHPAD_DEFAULT_METADATA_CHECKSUM,
    CONFIG_DEFAULT_CHECKSUM,
    CONFIG_KEY_CHECKSUM_TYPE,
    REPO_AUTH_CONFIG_FILE,
    PUBLISH_HTTP_KEYWORD,
    PUBLISH_HTTPS_KEYWORD,
)
from pulp_rpm.common.ids import TYPE_ID_DISTRIBUTOR_YUM
from pulp.repoauth import protected_repo_utils, repo_cert_utils
from pulp_rpm.yum_plugin import util


_LOG = util.getLogger(__name__)

REQUIRED_CONFIG_KEYS = ("relative_url", "http", "https")

OPTIONAL_CONFIG_KEYS = (
    "gpgkey",
    "auth_ca",
    "auth_cert",
    "https_ca",
    "checksum_type",
    "http_publish_dir",
    "https_publish_dir",
    "protected",
    "skip",
    "skip_pkg_tags",
    "generate_sqlite",
Exemplo n.º 3
0
import os
from xml.etree import ElementTree

from pulp_rpm.plugins.distributors.yum.metadata.metadata import (
    MetadataFileContext, REPO_DATA_DIR_NAME)
from pulp_rpm.yum_plugin import util


_logger = util.getLogger(__name__)

UPDATE_INFO_XML_FILE_NAME = 'updateinfo.xml.gz'


class UpdateinfoXMLFileContext(MetadataFileContext):

    def __init__(self, working_dir, checksum_type=None):

        metadata_file_path = os.path.join(working_dir, REPO_DATA_DIR_NAME, UPDATE_INFO_XML_FILE_NAME)
        super(UpdateinfoXMLFileContext, self).__init__(metadata_file_path, checksum_type)

    def _write_root_tag_open(self):

        updates_element = ElementTree.Element('updates')
        bogus_element = ElementTree.SubElement(updates_element, '')

        updates_tags_string = ElementTree.tostring(updates_element, 'utf-8')
        bogus_tag_string = ElementTree.tostring(bogus_element, 'utf-8')
        opening_tag, closing_tag = updates_tags_string.split(bogus_tag_string, 1)

        self.metadata_file_handle.write(opening_tag + '\n')
Exemplo n.º 4
0
import isodate
from pulp.common import dateutils
from pulp.server.db.model.criteria import UnitAssociationCriteria
from pulp.server.exceptions import MissingResource
from pulp.server.managers.repo.distributor import RepoDistributorManager
from pulp.server.managers.repo.query import RepoQueryManager

from pulp_rpm.common import constants, ids
from pulp_rpm.plugins.db import models
from pulp_rpm.plugins.distributors.export_distributor import generate_iso
from pulp_rpm.yum_plugin import comps_util, updateinfo, metadata
from pulp_rpm.yum_plugin import util as yum_utils


_logger = yum_utils.getLogger(__name__)

ISO_NAME_REGEX = re.compile(r"^[_A-Za-z0-9-]+$")
ASSOCIATED_UNIT_DATE_KEYWORD = "created"


def is_valid_prefix(file_prefix):
    """
    Used to check if the given file prefix is valid. A valid prefix contains only letters, numbers, _,
    and -

    :param file_prefix: The string used to prefix the export file(s)
    :type  file_prefix: str

    :return: True if the given file_prefix is a valid match; False otherwise
    :rtype:  bool
Exemplo n.º 5
0
import gzip
import os
import time
from xml.etree import ElementTree

from pulp_rpm.common.constants import CONFIG_DEFAULT_CHECKSUM
from pulp_rpm.plugins.distributors.yum.metadata.metadata import (
    MetadataFileContext, REPO_DATA_DIR_NAME, REPOMD_FILE_NAME)

from pulp_rpm.yum_plugin import util

_LOG = util.getLogger(__name__)

REPO_XML_NAME_SPACE = 'http://linux.duke.edu/metadata/repo'
RPM_XML_NAME_SPACE = 'http://linux.duke.edu/metadata/rpm'


class RepomdXMLFileContext(MetadataFileContext):
    def __init__(self,
                 working_dir,
                 checksum_type=CONFIG_DEFAULT_CHECKSUM,
                 gpg_sign=False,
                 sign_options=None):

        metadata_file_path = os.path.join(working_dir, REPO_DATA_DIR_NAME,
                                          REPOMD_FILE_NAME)
        super(RepomdXMLFileContext, self).__init__(metadata_file_path,
                                                   checksum_type)
        self.gpg_sign = gpg_sign
        self.sign_options = sign_options
Exemplo n.º 6
0
# -*- coding: utf-8 -*-

import os
import commands
import datetime
import tempfile
from stat import ST_SIZE

from pulp_rpm.yum_plugin.util import getLogger


log = getLogger(__name__)

# Define the size (in megabytes) of a DVD sized ISO
DVD_ISO_SIZE = 4380

MKISOFS_COMMAND_TEMPLATE = "mkisofs -r -D -graft-points -path-list %s -o %s"


def create_iso(target_dir, output_dir, prefix, image_size=DVD_ISO_SIZE, progress_callback=None):
    """
    Run the export process.

    :param target_dir:          The directory to be written to ISO images
    :type  target_dir:          str
    :param output_dir:          destination directory where the ISO images are written
    :type  output_dir:          str
    :param prefix:              prefix for the ISO file names; usually includes a repo id
    :type  prefix:              str
    :param image_size:          The maximum size of the image in bytes. Defaults to a dvd sized
    image.
Exemplo n.º 7
0
from gettext import gettext as _
import os
import re

import isodate
import mongoengine
from pulp.common import dateutils

from pulp_rpm.common import constants
from pulp_rpm.yum_plugin import util as yum_utils

_logger = yum_utils.getLogger(__name__)

ISO_NAME_REGEX = re.compile(r'^[_A-Za-z0-9-]+$')
ASSOCIATED_UNIT_DATE_KEYWORD = 'created'


def is_valid_prefix(file_prefix):
    """
    Used to check if the given file prefix is valid. A valid prefix contains only letters,
    numbers, _,
    and -

    :param file_prefix: The string used to prefix the export file(s)
    :type  file_prefix: str

    :return: True if the given file_prefix is a valid match; False otherwise
    :rtype:  bool
    """
    return ISO_NAME_REGEX.match(file_prefix) is not None