예제 #1
0
class LauncherDefinition(PlainBoxConfig):
    """
    Launcher definition.

    Launchers are small executables using one of the available user interfaces
    as the interpreter. This class contains all the available options that can
    be set inside the launcher, that will affect the user interface at runtime.
    This generic launcher definition class helps to pick concrete version of
    the launcher definition.
    """
    launcher_version = config.Variable(
        section="launcher",
        help_text=_("Version of launcher to use"))

    config_filename = config.Variable(
        section="config",
        default="checkbox.conf",
        help_text=_("Name of custom configuration file"))

    def get_concrete_launcher(self):
        """Create appropriate LauncherDefinition instance.

        Depending on the value of launcher_version variable appropriate
        LauncherDefinition class is chosen and its instance returned.

        :returns: LauncherDefinition instance
        :raises KeyError: for unknown launcher_version values
        """
        return {
            '1': LauncherDefinition1,
            config.Unset: LauncherDefinitionLegacy
        }[self.launcher_version]()
예제 #2
0
class PlainBoxConfig(config.Config):
    """
    Configuration for PlainBox itself
    """

    environment = config.Section(
        help_text=_("Environment variables for scripts and jobs"))

    welcome_text = config.Variable(section="common",
                                   help_text=_(
                                       "Welcome text to display prior to test"
                                       " selection/execution"))

    default_provider = config.Variable(
        section="common",
        help_text=_("Name of the default provider to use"),
        validator_list=[config.ChoiceValidator(['all', 'stub'])],
        default="all")

    class Meta:

        # TODO: properly depend on xdg and use real code that also handles
        # XDG_CONFIG_HOME.
        filename_list = [
            '/etc/xdg/plainbox.conf',
            os.path.expanduser('~/.config/plainbox.conf')
        ]
예제 #3
0
class CheckBoxConfig(PlainBoxConfig):
    """
    Configuration for checkbox-ng
    """

    secure_id = config.Variable(
        section="sru",
        help_text="Secure ID of the system",
        validator_list=[
            config.PatternValidator(r"^[a-zA-Z0-9]{15}$|^[a-zA-Z0-9]{18}$")
        ])

    # TODO: Add a validator to check if URL looks fine
    c3_url = config.Variable(
        section="sru",
        help_text="URL of the certification website",
        default="https://certification.canonical.com/submissions/submit/")

    fallback_file = config.Variable(section="sru",
                                    help_text="Location of the fallback file")

    whitelist = config.Variable(
        section="sru",
        help_text="Optional whitelist with which to run SRU testing")

    class Meta(PlainBoxConfig.Meta):
        # TODO: properly depend on xdg and use real code that also handles
        # XDG_CONFIG_HOME.
        #
        # NOTE: filename_list is composed of checkbox and plainbox variables,
        # mixed so that:
        # - checkbox takes precedence over plainbox
        # - ~/.config takes precedence over /etc
        filename_list = list(
            itertools.chain(*zip(PlainBoxConfig.Meta.filename_list, (
                '/etc/xdg/checkbox.conf',
                os.path.expanduser('~/.config/checkbox.conf')))))
예제 #4
0
class PlainBoxConfig(config.Config):
    """
    Configuration for PlainBox itself
    """

    environment = config.Section(
        help_text=_("Environment variables for scripts and jobs"))

    extcmd = config.Variable(
        section='FEATURE-FLAGS', kind=str, default="legacy",
        validator_list=[config.ChoiceValidator(["legacy", "glibc"])],
        help_text=_("Which implementation of extcmd to use"))

    class Meta:

        # TODO: properly depend on xdg and use real code that also handles
        # XDG_CONFIG_HOME.
        filename_list = [
            '/etc/xdg/plainbox.conf',
            os.path.expanduser('~/.config/plainbox.conf')]
예제 #5
0
class LauncherDefinitionLegacy(LauncherDefinition):
    """
    Launcher definition class for 'unversioned' launchers.

    This definition is used for launchers that do not specify
    'launcher_version' in their [launcher] section.
    """

    api_flags = config.Variable(
        section='launcher',
        kind=list,
        default=[],
        help_text=_('List of feature-flags the application requires'))

    api_version = config.Variable(
        section='launcher',
        default='0.99',
        help_text=_('Version of API the launcher uses'))

    title = config.Variable(
        section="welcome",
        help_text=_("Application Title"))

    text = config.Variable(
        section="welcome",
        help_text=_("Welcome Message"))

    dont_suppress_output = config.Variable(
        section="ui", kind=bool, default=False,
        help_text=_("Don't suppress the output of certain job plugin types."))

    whitelist_filter = config.Variable(
        section="suite",
        # TODO: valid regexp text validator
        help_text=_("Pattern that whitelists need to match to be displayed"))

    whitelist_selection = config.Variable(
        section="suite",
        # TODO: valid regexp text validator
        help_text=_("Pattern that whitelists need to match to be selected"))

    skip_whitelist_selection = config.Variable(
        section="suite",
        kind=bool,
        default=False,
        help_text=_("If enabled then suite selection screen is not displayed"))

    skip_test_selection = config.Variable(
        section="suite",
        kind=bool,
        default=False,
        help_text=_("If enabled then test selection screen is not displayed"))

    input_type = config.Variable(
        section="submission",
        # TODO: probably a choice validator
        help_text=_("Type of the input field?"))

    ok_btn_text = config.Variable(
        section="submission",
        help_text=_("Label on the 'send' button"))

    submit_to_hexr = config.Variable(
        section="submission",
        kind=bool,
        # TODO: default?
        help_text=_("If enabled then test results will be also sent to HEXR"))

    submit_to = config.Variable(
        section="transport",
        validator_list=[config.ChoiceValidator(get_all_transports().keys())],
        help_text=_("Where to submit the test results to"))

    # TODO: Add a validator to ensure it looks like a valid URL
    submit_url = config.Variable(
        section="transport",
        help_text=_("HTTP endpoint to submit data to, using the"
                    " transport specified with submit_to."))

    secure_id = config.Variable(
        section="submission",
        validator_list=[config.PatternValidator(SECURE_ID_PATTERN)],
        help_text=_("Secure ID to identify the system this"
                    " submission belongs to."))

    exporter = config.Section(
        help_text=_("Section with only exported unit ids as keys (no values)"))
예제 #6
0
class LauncherDefinition1(LauncherDefinition):
    """
    Definition for launchers version 1.

    As specced in https://goo.gl/qJYtPX
    """

    def __init__(self):
        super().__init__()

    launcher_version = config.Variable(
        section="launcher",
        default='1',
        help_text=_("Version of launcher to use"))

    app_id = config.Variable(
        section='launcher',
        default='checkbox-cli',
        help_text=_('Identifier of the application'))

    app_version = config.Variable(
        section='launcher',
        help_text=_('Version of the application'))

    api_flags = config.Variable(
        section='launcher',
        kind=list,
        default=[],
        validator_list=[config.SubsetValidator(get_all_sa_flags())],
        help_text=_('List of feature-flags the application requires'))

    api_version = config.Variable(
        section='launcher',
        default='0.99',
        validator_list=[config.ChoiceValidator(
            get_known_sa_api_versions())],
        help_text=_('Version of API the launcher uses'))

    stock_reports = config.Variable(
        section='launcher',
        kind=list,
        validator_list=[config.SubsetValidator({
            'text', 'certification', 'certification-staging',
            'submission_files'})],
        default=['text', 'certification', 'submission_files'],
        help_text=_('List of stock reports to use'))

    providers = config.Variable(
        section='providers',
        name='use',
        kind=list,
        default=['*'],
        help_text=_('Which providers to load; glob patterns can be used'))

    test_plan_filters = config.Variable(
        section='test plan',
        name='filter',
        default=['*'],
        kind=list,
        help_text=_('Constrain interactive choice to test plans matching this'
                    'glob'))

    test_plan_default_selection = config.Variable(
        section='test plan',
        name='unit',
        help_text=_('Select this test plan by default.'))

    test_plan_forced = config.Variable(
        section='test plan',
        name='forced',
        kind=bool,
        default=False,
        help_text=_("Don't allow the user to change test plan."))

    test_selection_forced = config.Variable(
        section='test selection',
        name='forced',
        kind=bool,
        default=False,
        help_text=_("Don't allow the user to alter test selection."))

    ui_type = config.Variable(
        section='ui',
        name='type',
        default='interactive',
        validator_list=[config.ChoiceValidator(
            ['interactive', 'silent', 'converged', 'converged-silent'])],
        help_text=_('Type of stock user interface to use.'))

    output = config.Variable(
        section='ui',
        default='show',
        validator_list=[config.ChoiceValidator(
            ['show', 'hide', 'hide-resource-and-attachment'])],
        help_text=_('Silence or restrict command output'))

    dont_suppress_output = config.Variable(
        section="ui", kind=bool, default=False,
        help_text=_("Don't suppress the output of certain job plugin types."))

    restart_strategy = config.Variable(
        section='restart',
        name='strategy',
        help_text=_('Use alternative restart strategy'))

    restart = config.Section(
        help_text=_('Restart strategy parameters'))

    reports = config.ParametricSection(
        name='report',
        help_text=_('Report declaration'))

    exporters = config.ParametricSection(
        name='exporter',
        help_text=_('Exporter declaration'))

    transports = config.ParametricSection(
        name='transport',
        help_text=_('Transport declaration'))

    environment = config.Section(
        help_text=_('Environment variables to use'))
예제 #7
0
class LauncherDefinition1(LauncherDefinition):
    """
    Definition for launchers version 1.

    As specced in https://goo.gl/qJYtPX
    """
    def __init__(self):
        super().__init__()

    launcher_version = config.Variable(
        section="launcher",
        default='1',
        help_text=_("Version of launcher to use"))

    app_id = config.Variable(section='launcher',
                             default='checkbox-cli',
                             help_text=_('Identifier of the application'))

    app_version = config.Variable(section='launcher',
                                  help_text=_('Version of the application'))

    api_flags = config.Variable(
        section='launcher',
        kind=list,
        default=[SA_RESTARTABLE],
        validator_list=[config.SubsetValidator(get_all_sa_flags())],
        help_text=_('List of feature-flags the application requires'))

    api_version = config.Variable(
        section='launcher',
        default='0.99',
        validator_list=[config.ChoiceValidator(get_known_sa_api_versions())],
        help_text=_('Version of API the launcher uses'))

    stock_reports = config.Variable(
        section='launcher',
        kind=list,
        validator_list=[
            config.SubsetValidator({
                'text', 'certification', 'certification-staging',
                'submission_files', 'none'
            }),
            config.OneOrTheOtherValidator({'none'}, {
                'text', 'certification', 'certification-staging',
                'submission_files'
            }),
        ],
        default=['text', 'certification', 'submission_files'],
        help_text=_('List of stock reports to use'))

    local_submission = config.Variable(
        section='launcher',
        kind=bool,
        default=True,
        help_text=_("Send/generate submission report locally when using "
                    "checkbox remote"))

    session_title = config.Variable(
        section='launcher',
        default='session title',
        help_text=_("A title to be applied to the sessions created using "
                    "this launcher that can be used in report generation"))

    session_desc = config.Variable(
        section='launcher',
        default='',
        help_text=_("A string that can be applied to sessions created using "
                    "this launcher. Useful for storing some contextual "
                    "infomation about the session"))

    test_plan_filters = config.Variable(
        section='test plan',
        name='filter',
        default=['*'],
        kind=list,
        help_text=_('Constrain interactive choice to test plans matching this'
                    'glob'))

    test_plan_default_selection = config.Variable(
        section='test plan',
        name='unit',
        help_text=_('Select this test plan by default.'))

    test_plan_forced = config.Variable(
        section='test plan',
        name='forced',
        kind=bool,
        default=False,
        help_text=_("Don't allow the user to change test plan."))

    test_selection_forced = config.Variable(
        section='test selection',
        name='forced',
        kind=bool,
        default=False,
        help_text=_("Don't allow the user to alter test selection."))

    test_exclude = config.Variable(
        section='test selection',
        name='exclude',
        default=[],
        kind=list,
        help_text=_("Exclude test matching the patterns from running"))

    ui_type = config.Variable(
        section='ui',
        name='type',
        default='interactive',
        validator_list=[config.ChoiceValidator(['interactive', 'silent'])],
        help_text=_('Type of stock user interface to use.'))

    output = config.Variable(section='ui',
                             default='show',
                             validator_list=[
                                 config.ChoiceValidator([
                                     'show', 'hide',
                                     'hide-resource-and-attachment',
                                     'hide-automated'
                                 ])
                             ],
                             help_text=_('Silence or restrict command output'))

    dont_suppress_output = config.Variable(
        section="ui",
        kind=bool,
        default=False,
        help_text=_("Don't suppress the output of certain job plugin types."))

    verbosity = config.Variable(section="ui",
                                validator_list=[
                                    config.ChoiceValidator(
                                        ['normal', 'verbose', 'debug'])
                                ],
                                help_text=_('Verbosity level'),
                                default='normal')

    auto_retry = config.Variable(
        section='ui',
        kind=bool,
        default=False,
        help_text=_("Automatically retry failed jobs at the end"
                    " of the session."))

    max_attempts = config.Variable(
        section='ui',
        kind=int,
        default=3,
        help_text=_(
            "Number of attempts to run a job when in auto-retry mode."))

    delay_before_retry = config.Variable(
        section='ui',
        kind=int,
        default=1,
        help_text=_("Delay (in seconds) before retrying failed jobs in"
                    " auto-retry mode."))

    normal_user = config.Variable(
        section='daemon',
        kind=str,
        default='',
        help_text=_("Username to use for jobs that don't specify user"))

    restart_strategy = config.Variable(
        section='restart',
        name='strategy',
        help_text=_('Use alternative restart strategy'))

    restart = config.Section(help_text=_('Restart strategy parameters'))

    reports = config.ParametricSection(name='report',
                                       help_text=_('Report declaration'))

    exporters = config.ParametricSection(name='exporter',
                                         help_text=_('Exporter declaration'))

    transports = config.ParametricSection(name='transport',
                                          help_text=_('Transport declaration'))

    environment = config.Section(help_text=_('Environment variables to use'))

    daemon = config.Section(name='daemon',
                            help_text=_('Daemon-specific configuration'))

    manifest = config.Section(help_text=_('Manifest entries to use'))
예제 #8
0
class CheckBoxConfig(PlainBoxConfig):
    """
    Configuration for checkbox-ng
    """

    secure_id = config.Variable(
        section="sru",
        help_text=_("Secure ID of the system"),
        validator_list=[config.PatternValidator(SECURE_ID_PATTERN)])

    submit_to_c3 = config.Variable(
        section="submission",
        help_text=_("Whether to send the submission data to c3"))

    submit_to_hexr = config.Variable(
        section="submission",
        help_text=_("Whether to also send the submission data to HEXR"),
        kind=bool)

    # TODO: Add a validator to check if email looks fine
    email_address = config.Variable(
        section="sru",
        help_text=_("Email address to log into the Launchpad HWDB"))

    # TODO: Add a validator to check if URL looks fine
    c3_url = config.Variable(
        section="sru",
        help_text=_("URL of the certification website"),
        default="https://certification.canonical.com/submissions/submit/")

    # TODO: Add a validator to check if URL looks fine
    lp_url = config.Variable(
        section="sru",
        help_text=_("URL of the launchpad hardware database"),
        default="https://launchpad.net/+hwdb/+submit")

    fallback_file = config.Variable(
        section="sru",
        help_text=_("Location of the fallback file"))

    whitelist = config.Variable(
        section="sru",
        help_text=_("Optional whitelist with which to run SRU testing"))

    test_plan = config.Variable(
        section="sru",
        help_text=_("Optional test plan with which to run SRU testing"))

    staging = config.Variable(
        section="sru",
        kind=bool,
        default=False,
        help_text=_("Send the data to non-production test server"))

    class Meta(PlainBoxConfig.Meta):
        # TODO: properly depend on xdg and use real code that also handles
        # XDG_CONFIG_HOME.
        #
        # NOTE: filename_list is composed of checkbox and plainbox variables,
        # mixed so that:
        # - checkbox takes precedence over plainbox
        # - ~/.config takes precedence over /etc
        filename_list = list(
            itertools.chain(
                *zip(
                    PlainBoxConfig.Meta.filename_list, (
                        '/etc/xdg/checkbox.conf',
                        os.path.expanduser('~/.config/checkbox.conf')))))
예제 #9
0
class LauncherDefinition(config.Config):
    """
    Launcher definition.

    Launchers are small executables using one of the available user interfaces
    as the interpreter. This class contains all the available options that can
    be set inside the launcher, that will affect the user interface at runtime.
    """

    title = config.Variable(section="welcome",
                            help_text=_("Application Title"))

    text = config.Variable(section="welcome", help_text=_("Welcome Message"))

    whitelist_filter = config.Variable(
        section="suite",
        # TODO: valid regexp text validator
        help_text=_("Pattern that whitelists need to match to be displayed"))

    whitelist_selection = config.Variable(
        section="suite",
        # TODO: valid regexp text validator
        help_text=_("Pattern that whitelists need to match to be selected"))

    skip_whitelist_selection = config.Variable(
        section="suite",
        kind=bool,
        default=False,
        help_text=_("If enabled then suite selection screen is not displayed"))

    skip_test_selection = config.Variable(
        section="suite",
        kind=bool,
        default=False,
        help_text=_("If enabled then test selection screen is not displayed"))

    input_type = config.Variable(
        section="submission",
        # TODO: probably a choice validator
        help_text=_("Type of the input field?"))

    ok_btn_text = config.Variable(section="submission",
                                  help_text=_("Label on the 'send' button"))

    submit_to_hexr = config.Variable(
        section="submission",
        kind=bool,
        # TODO: default?
        help_text=_("If enabled then test results will be also sent to HEXR"))

    submit_to = config.Variable(
        section="transport",
        validator_list=[config.ChoiceValidator(get_all_transports().keys())],
        help_text=_("Where to submit the test results to"))

    # TODO: Add a validator to ensure it looks like a valid URL
    submit_url = config.Variable(
        section="transport",
        help_text=_("HTTP endpoint to submit data to, using the"
                    " transport specified with submit_to."))

    secure_id = config.Variable(
        section="submission",
        validator_list=[config.PatternValidator(SECURE_ID_PATTERN)],
        help_text=_("Secure ID to identify the system this"
                    " submission belongs to."))

    config_filename = config.Variable(
        section="config", help_text=_("Name of custom configuration file"))

    dont_suppress_output = config.Variable(
        section="ui",
        kind=bool,
        default=False,
        help_text=_("Don't suppress the output of certain job plugin types."))

    exporter = config.Section(
        help_text=_("Section with only exported unit ids as keys (no values)"))