Пример #1
0
    def test_structure(self):
        # Ensure all of the expected options are there
        self.command = sp.RunPublishRepositoryCommand(
            self.context,
            self.mock_renderer,
            distributor_id='yum_distributor',
            override_config_options=self.additional_publish_options)
        found_option_keywords = set([o.keyword for o in self.command.options])
        found_group_option_keywords = set(
            [o.keyword for o in self.command.option_groups[0].options])

        expected_option_keywords = set(
            [options.OPTION_REPO_ID.keyword, polling.FLAG_BACKGROUND.keyword])
        expected_group_option_keywords = set(
            [self.sample_option1.keyword, self.sample_option2.keyword])

        self.assertEqual(found_option_keywords, expected_option_keywords)
        self.assertEqual(found_group_option_keywords,
                         expected_group_option_keywords)

        # Ensure the correct method is wired up
        self.assertEqual(self.command.method, self.command.run)

        # Ensure the correct metadata
        self.assertEqual(self.command.name, 'run')
        self.assertEqual(self.command.description, sp.DESC_PUBLISH_RUN)
Пример #2
0
def initialize(context):
    structure.ensure_repo_structure(context.cli)
    upload_manager = _upload_manager(context)

    repo_section = structure.repo_section(context.cli)
    repo_section.add_command(repo_create_update.PkgRepoCreateCommand(context))
    repo_section.add_command(repo_create_update.PkgRepoUpdateCommand(context))
    repo_section.add_command(cudl.DeleteRepositoryCommand(context))
    repo_section.add_command(repo_list.RepoListCommand(context))
    repo_section.add_command(
        RepoSearchCommand(context, constants.REPO_NOTE_PKG))

    copy_section = structure.repo_copy_section(context.cli)
    copy_section.add_command(copy_commands.MsiCopyCommand(context))
    copy_section.add_command(copy_commands.MsmCopyCommand(context))
    copy_section.add_command(copy_commands.AllCopyCommand(context))

    remove_section = structure.repo_remove_section(context.cli)
    remove_section.add_command(remove.MsiRemoveCommand(context))
    remove_section.add_command(remove.MsmRemoveCommand(context))

    contents_section = structure.repo_contents_section(context.cli)
    contents_section.add_command(contents.SearchMsiCommand(context))
    contents_section.add_command(contents.SearchMsmCommand(context))

    uploads_section = structure.repo_uploads_section(context.cli)
    for cls_ in [
            package.CreateMsiCommand, package.CreateMsmCommand,
            upload.ResumeCommand, upload.CancelCommand, upload.ListCommand
    ]:
        uploads_section.add_command(cls_(context, upload_manager))

    sync_section = structure.repo_sync_section(context.cli)
    renderer = status.PackageStatusRenderer(context)
    sync_section.add_command(
        sync_publish.RunSyncRepositoryCommand(context, renderer))
    sync_section.add_command(sync_publish.SyncStatusCommand(context, renderer))

    publish_section = structure.repo_publish_section(context.cli)
    renderer = PublishStepStatusRenderer(context)
    distributor_id = ids.TYPE_ID_DISTRIBUTOR_WIN
    publish_section.add_command(
        sync_publish.RunPublishRepositoryCommand(context, renderer,
                                                 distributor_id))
    publish_section.add_command(
        sync_publish.PublishStatusCommand(context, renderer))

    sync_schedules_section = structure.repo_sync_schedules_section(context.cli)
    sync_schedules_section.add_command(
        sync_schedules.PkgCreateScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.PkgUpdateScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.PkgDeleteScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.PkgListScheduleCommand(context))

    sync_schedules_section.add_command(
        sync_schedules.PkgNextRunCommand(context))
Пример #3
0
 def setUp(self):
     super(RunPublishRepositoryCommandTests, self).setUp()
     self.mock_renderer = mock.MagicMock()
     self.command = sp.RunPublishRepositoryCommand(
         self.context, self.mock_renderer, distributor_id='yum_distributor')
     self.sample_option1 = PulpCliOption('--sample-option1',
                                         "sample_option1",
                                         required=False)
     self.sample_option2 = PulpCliOption('--sample-option2',
                                         "sample_option2",
                                         required=False)
     self.additional_publish_options = [
         self.sample_option1, self.sample_option2
     ]
Пример #4
0
def _add_publish_section(context, parent_section):
    """
    add a publish section to the repo section

    :param context:        The client context
    :type  context:        pulp.client.extensions.core.ClientContext
    :param parent_section: section of the CLI to which the repo section should be added
    :type  parent_section: pulp.client.extensions.extensions.PulpCliSection
    """
    section = parent_section.create_subsection(SECTION_PUBLISH, DESC_PUBLISH)

    renderer = status.PublishStepStatusRenderer(context)
    section.add_command(
        sync_publish.RunPublishRepositoryCommand(context, renderer,
                                                 constants.CLI_DISTRIBUTOR_ID))
    section.add_command(sync_publish.PublishStatusCommand(context, renderer))
Пример #5
0
def add_publish_section(context, repo_section):
    """
    Add the publish subsection and all of its children to the repo section.

    :param context: ClientContext containing the CLI instance being configured
    :type  context: pulp.client.extensions.core.ClientContext
    :param repo_section: The parent repo section that we wish to add the publish subsection
                         to.
    :type  repo_section: pulp.client.extensions.extensions.PulpCliSection
    """
    publish_section = repo_section.create_subsection(SECTION_PUBLISH,
                                                     DESC_PUBLISH)

    renderer = status.ISOStatusRenderer(context)

    publish_section.add_command(
        sync_publish.RunPublishRepositoryCommand(
            context, renderer, distributor_id=ids.TYPE_ID_DISTRIBUTOR_ISO))
    publish_section.add_command(
        sync_publish.PublishStatusCommand(context, renderer))
Пример #6
0
def add_export_section(context, parent_section):
    """
    add a export section to the parent section

    :type  context: pulp.client.extensions.core.ClientContext
    :param parent_section:  section of the CLI to which the export section should be added
    :type  parent_section:  pulp.client.extensions.extensions.PulpCliSection
    """
    section = parent_section.create_subsection(SECTION_EXPORT, DESC_EXPORT)
    section.add_command(
        sync_publish.RunPublishRepositoryCommand(
            context=context,
            renderer=status.PublishStepStatusRenderer(context),
            distributor_id=constants.CLI_EXPORT_DISTRIBUTOR_ID,
            description=DESC_EXPORT_RUN,
            override_config_options=[OPTION_EXPORT_FILE]))
    section.add_command(
        sync_publish.PublishStatusCommand(
            context, status.PublishStepStatusRenderer(context)))

    return section
Пример #7
0
def add_publish_section(context, parent_section):
    """
    add a publish section with subsections to the repo section

    This adds both an "http" and "glance" publish command.

    :param context: pulp context
    :type  context: pulp.client.extensions.core.ClientContext
    :param parent_section:  section of the CLI to which the repo section should be added
    :type  parent_section:  pulp.client.extensions.extensions.PulpCliSection
    :return: populated section
    :rtype: PulpCliSection
    """
    publish_section = parent_section.create_subsection(SECTION_PUBLISH,
                                                       DESC_PUBLISH)

    http_section = publish_section.create_subsection(SECTION_PUBLISH_HTTP,
                                                     DESC_PUBLISH_HTTP)
    glance_section = publish_section.create_subsection(SECTION_PUBLISH_GLANCE,
                                                       DESC_PUBLISH_GLANCE)

    renderer = status.PublishStepStatusRenderer(context)
    http_section.add_command(
        sync_publish.RunPublishRepositoryCommand(
            context, renderer, constants.CLI_WEB_DISTRIBUTOR_ID))
    http_section.add_command(
        sync_publish.PublishStatusCommand(context, renderer))

    glance_publish_command = sync_publish.\
        RunPublishRepositoryCommand(context, renderer, constants.CLI_GLANCE_DISTRIBUTOR_ID)

    glance_section.add_command(glance_publish_command)
    glance_section.add_command(
        sync_publish.PublishStatusCommand(context, renderer))

    return publish_section
Пример #8
0
def initialize(context):
    structure.ensure_repo_structure(context.cli)
    upload_manager = _upload_manager(context)

    repo_section = structure.repo_section(context.cli)
    repo_section.add_command(repo_create_update.RpmRepoCreateCommand(context))
    repo_section.add_command(repo_create_update.RpmRepoUpdateCommand(context))
    repo_section.add_command(cudl.DeleteRepositoryCommand(context))
    repo_section.add_command(repo_list.RpmRepoListCommand(context))
    repo_section.add_command(
        RepoSearchCommand(context, constants.REPO_NOTE_RPM))

    copy_section = structure.repo_copy_section(context.cli)
    copy_section.add_command(copy_commands.RpmCopyCommand(context))
    copy_section.add_command(copy_commands.ErrataCopyCommand(context))
    copy_section.add_command(copy_commands.DistributionCopyCommand(context))
    copy_section.add_command(copy_commands.PackageGroupCopyCommand(context))
    copy_section.add_command(copy_commands.PackageCategoryCopyCommand(context))
    copy_section.add_command(
        copy_commands.PackageEnvironmentCopyCommand(context))
    copy_section.add_command(copy_commands.AllCopyCommand(context))
    copy_section.add_command(copy_commands.SrpmCopyCommand(context))
    copy_section.add_command(copy_commands.YumRepoMetadataFileCommand(context))
    copy_section.add_command(copy_commands.DrpmCopyCommand(context))

    # Disabled as per 950690. We'll likely be able to add these back once the new
    # yum importer is finished and DRPMs are properly handled.
    # copy_section.add_command(copy_commands.DrpmCopyCommand(context))

    remove_section = structure.repo_remove_section(context.cli)
    remove_section.add_command(remove.RpmRemoveCommand(context))
    remove_section.add_command(remove.SrpmRemoveCommand(context))
    remove_section.add_command(remove.DrpmRemoveCommand(context))
    remove_section.add_command(remove.ErrataRemoveCommand(context))
    remove_section.add_command(remove.PackageGroupRemoveCommand(context))
    remove_section.add_command(remove.PackageCategoryRemoveCommand(context))
    remove_section.add_command(remove.PackageEnvironmentRemoveCommand(context))
    remove_section.add_command(remove.DistributionRemoveCommand(context))
    remove_section.add_command(remove.YumMetadataFileRemoveCommand(context))

    contents_section = structure.repo_contents_section(context.cli)
    contents_section.add_command(contents.SearchRpmsCommand(context))
    contents_section.add_command(contents.SearchDrpmsCommand(context))
    contents_section.add_command(contents.SearchSrpmsCommand(context))
    contents_section.add_command(contents.SearchPackageGroupsCommand(context))
    contents_section.add_command(
        contents.SearchPackageCategoriesCommand(context))
    contents_section.add_command(
        contents.SearchPackageEnvironmentsCommand(context))
    contents_section.add_command(contents.SearchDistributionsCommand(context))
    contents_section.add_command(contents.SearchErrataCommand(context))
    contents_section.add_command(
        contents.SearchYumMetadataFileCommand(context))

    # Add the group section, all its subsections, and commands
    group_export_section = structure.repo_group_export_section(context.cli)
    renderer = PublishStepStatusRenderer(context)
    group_export_section.add_command(
        export.RpmGroupExportCommand(context, renderer))
    group_export_section.add_command(
        export.GroupExportStatusCommand(context, renderer))

    uploads_section = structure.repo_uploads_section(context.cli)
    uploads_section.add_command(
        package.CreateRpmCommand(context, upload_manager))
    uploads_section.add_command(
        package.CreateSrpmCommand(context, upload_manager))
    uploads_section.add_command(
        errata.CreateErratumCommand(context, upload_manager))
    uploads_section.add_command(
        package_group.CreatePackageGroupCommand(context, upload_manager))
    uploads_section.add_command(
        category.CreatePackageCategoryCommand(context, upload_manager))
    uploads_section.add_command(
        comps.CreateCompsCommand(context, upload_manager))
    uploads_section.add_command(
        environment.CreatePackageEnvironmentCommand(context, upload_manager))
    uploads_section.add_command(upload.ResumeCommand(context, upload_manager))
    uploads_section.add_command(upload.CancelCommand(context, upload_manager))
    uploads_section.add_command(upload.ListCommand(context, upload_manager))

    sync_section = structure.repo_sync_section(context.cli)
    renderer = status.RpmStatusRenderer(context)
    sync_section.add_command(
        sync_publish.RunSyncRepositoryCommand(context, renderer))
    sync_section.add_command(sync_publish.SyncStatusCommand(context, renderer))

    publish_section = structure.repo_publish_section(context.cli)
    renderer = PublishStepStatusRenderer(context)
    distributor_id = ids.TYPE_ID_DISTRIBUTOR_YUM
    publish_section.add_command(
        sync_publish.RunPublishRepositoryCommand(context, renderer,
                                                 distributor_id))
    publish_section.add_command(
        sync_publish.PublishStatusCommand(context, renderer))

    repo_export_section = structure.repo_export_section(context.cli)
    renderer = PublishStepStatusRenderer(context)
    repo_export_section.add_command(export.RpmExportCommand(context, renderer))
    repo_export_section.add_command(
        sync_publish.PublishStatusCommand(context,
                                          renderer,
                                          description=DESC_EXPORT_STATUS))

    sync_schedules_section = structure.repo_sync_schedules_section(context.cli)
    sync_schedules_section.add_command(
        sync_schedules.RpmCreateScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.RpmUpdateScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.RpmDeleteScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.RpmListScheduleCommand(context))

    sync_schedules_section.add_command(
        sync_schedules.RpmNextRunCommand(context))
Пример #9
0
def initialize(context):
    """
    :type context: pulp.client.extensions.core.ClientContext
    """
    structure.ensure_repo_structure(context.cli)
    structure.ensure_consumer_structure(context.cli)

    renderer = status.PuppetStatusRenderer(context)

    consumer_section = structure.consumer_section(context.cli)
    consumer_section.add_command(bind.BindCommand(context))
    consumer_section.add_command(bind.UnbindCommand(context))

    consumer_install_section = structure.consumer_install_section(context.cli)
    consumer_install_section.add_command(content.InstallCommand(context))

    consumer_update_section = structure.consumer_update_section(context.cli)
    consumer_update_section.add_command(content.UpdateCommand(context))

    consumer_uninstall_section = structure.consumer_uninstall_section(
        context.cli)
    consumer_uninstall_section.add_command(content.UninstallCommand(context))

    publish_section = structure.repo_publish_section(context.cli)
    publish_section.add_command(
        sync_publish.RunPublishRepositoryCommand(
            context, renderer, constants.DISTRIBUTOR_TYPE_ID))
    publish_section.add_command(
        sync_publish.PublishStatusCommand(context, renderer))

    publish_schedules_section = structure.repo_publish_schedules_section(
        context.cli)
    publish_schedules_section.add_command(
        publish_schedules.PuppetCreateScheduleCommand(context))
    publish_schedules_section.add_command(
        publish_schedules.PuppetUpdateScheduleCommand(context))
    publish_schedules_section.add_command(
        publish_schedules.PuppetDeleteScheduleCommand(context))
    publish_schedules_section.add_command(
        publish_schedules.PuppetListScheduleCommand(context))
    publish_schedules_section.add_command(
        publish_schedules.PuppetNextRunCommand(context))

    repo_section = structure.repo_section(context.cli)
    repo_section.add_command(CreatePuppetRepositoryCommand(context))
    repo_section.add_command(UpdatePuppetRepositoryCommand(context))
    repo_section.add_command(cudl.DeleteRepositoryCommand(context))
    repo_section.add_command(ListPuppetRepositoriesCommand(context))
    repo_section.add_command(
        RepoSearchCommand(context, constants.REPO_NOTE_PUPPET))
    repo_section.add_command(remove.RemoveCommand(context))

    repo_section.add_command(modules.ModulesCommand(context))
    repo_section.add_command(copy_modules.PuppetModuleCopyCommand(context))

    sync_section = structure.repo_sync_section(context.cli)
    sync_section.add_command(
        sync_publish.RunSyncRepositoryCommand(context, renderer))
    sync_section.add_command(sync_publish.SyncStatusCommand(context, renderer))

    sync_schedules_section = structure.repo_sync_schedules_section(context.cli)
    sync_schedules_section.add_command(
        sync_schedules.PuppetCreateScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.PuppetUpdateScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.PuppetDeleteScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.PuppetListScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.PuppetNextRunCommand(context))

    upload_manager = _upload_manager(context)
    uploads_section = structure.repo_uploads_section(context.cli)
    uploads_section.add_command(
        puppet_upload.UploadModuleCommand(context, upload_manager))
    uploads_section.add_command(upload.ListCommand(context, upload_manager))
    uploads_section.add_command(upload.CancelCommand(context, upload_manager))
    uploads_section.add_command(upload.ResumeCommand(context, upload_manager))
Пример #10
0
 def setUp(self):
     super(RunPublishRepositoryCommandTests, self).setUp()
     self.mock_renderer = mock.MagicMock()
     self.command = sp.RunPublishRepositoryCommand(
         self.context, self.mock_renderer, distributor_id='yum_distributor')