예제 #1
0
    def mapping(self):
        """Determine mapping Menu item => menu item id.

        Needed because the boxes with shortcuts are accessible only via ids.
        Need to close boxes because boxes displayed are not in the Select.
        """
        # Save opened boxes
        closed_boxes = []
        for box_id in self.opened_boxes_ids:
            closed_boxes.append((self.get_text_of(box_id), box_id))
            self.close_box(box_id)
        # Check the select
        result = {}
        for option in self.select.options:
            try:
                result[sel.text(option)] = int(
                    sel.get_attribute(option, "value"))
            except (ValueError, TypeError):
                pass
        # Restore box layout
        for name, id in closed_boxes:
            sel.select(self.select, sel.ByValue(str(id)))
            self.set_text_of(id, name)

        return result
예제 #2
0
 def _form_mapping(self, create=None, **kwargs):
     return {
         'name_text': kwargs.get('name'),
         'type_select': create and 'Google Compute Engine',
         'google_region_select': sel.ByValue(kwargs.get('region')),
         'google_project_text': kwargs.get('project')
     }
예제 #3
0
    def add(self, menu, alias=None):
        """Add a new shortcut.

        Args:
            menu: What menu item to select.
            alias: Optional alias for this menu item.
        """
        if menu not in self.mapping:
            raise NameError("Unknown menu location {}!".format(menu))
        sel.select(self.select, sel.ByValue(str(self.mapping[menu])))
        if alias is not None:
            self.set_text_of(self.mapping[menu], alias)
예제 #4
0
    def __init__(self,
                 name,
                 description,
                 active=True,
                 action=None,
                 filter_type=None,
                 filter_value=None,
                 run_type="Once",
                 run_every=None,
                 time_zone=None,
                 start_date=None,
                 start_hour=None,
                 start_min=None,
                 appliance=None):
        Navigatable.__init__(self, appliance=appliance)
        self.details = dict(
            name=name,
            description=description,
            active=active,
            action=action,
            filter_type=filter_type,
            filter_value=filter_value,
            time_zone=sel.ByValue(time_zone),
            start_date=start_date,
            start_hour=start_hour,
            start_min=start_min,
        )

        if run_type == "Once":
            self.details["timer_type"] = "Once"
        else:
            field = version.pick({
                version.LOWEST: self.tab[run_type],
                '5.5': 'timer_value'
            })
            self.details["timer_type"] = run_type
            self.details[field] = run_every
예제 #5
0
def update_registration(service,
                        url,
                        username,
                        password,
                        password_verify=None,
                        repo_name=None,
                        organization=None,
                        use_proxy=False,
                        proxy_url=None,
                        proxy_username=None,
                        proxy_password=None,
                        proxy_password_verify=None,
                        validate=True,
                        cancel=False,
                        set_default_rhsm_address=False,
                        set_default_repository=False):
    """ Fill in the registration form, validate and save/cancel

    Args:
        service: Service type (registration method).
        url: Service server URL address.
        username: Username to use for registration.
        password: Password to use for registration.
        password_verify: 2nd entry of password for verification.
                         Same as 'password' if None.
        repo_or_channel: Repository/channel to enable.
        organization: Organization (sat5/sat6 only).
        use_proxy: `True` if proxy should be used, `False` otherwise
                   (default `False`).
        proxy_url: Address of the proxy server.
        proxy_username: Username for the proxy server.
        proxy_password: Password for the proxy server.
        proxy_password_verify: 2nd entry of proxy server password for verification.
                               Same as 'proxy_password' if None.
        validate: Click the Validate button and check the
                  flash message for errors if `True` (default `True`)
        cancel: Click the Cancel button if `True` or the Save button
                if `False` (default `False`)
        set_default_rhsm_address: Click the Default button connected to
                                  the RHSM (only) address if `True`
        set_default_repository: Click the Default button connected to
                                the repo/channel if `True`

    Warning:
        'password_verify' and 'proxy_password_verify' are available in 5.4+ only.

    Note:
        With satellite 6, it is necessary to validate credentials to obtain
        available organizations from the server.
        With satellite 5, 'validate' parameter is ignored because there is
        no validation button available.
    """
    assert service in service_types, "Unknown service type '{}'".format(
        service)
    service_value = service_types[service]

    # In 5.4+, we have verification inputs as well
    if version.current_version() >= '5.4':
        password_verify = password_verify or password
        proxy_password_verify = proxy_password_verify or proxy_password
    # Otherwise, verification inputs are ignored df even if specified
    else:
        password_verify = None
        proxy_password_verify = None

    # Sat6 organization can be selected only after successful validation
    # while Sat5 organization is selected normally
    if service == 'sat6':
        organization_sat5 = None
        organization_sat6 = organization
    else:
        organization_sat5 = organization
        organization_sat6 = None

    sel.force_navigate("cfg_settings_region_red_hat_updates")
    sel.click(update_buttons.edit_registration)
    details = dict(service=sel.ByValue(service_value),
                   url=url,
                   username=username,
                   password=password,
                   password_verify=password_verify,
                   repo_name=repo_name,
                   organization_sat5=organization_sat5,
                   use_proxy=use_proxy,
                   proxy_url=proxy_url,
                   proxy_username=proxy_username,
                   proxy_password=proxy_password,
                   proxy_password_verify=proxy_password_verify)

    fill(registration_form, details)

    if set_default_rhsm_address:
        sel.click(registration_buttons.url_default)

    if set_default_repository:
        sel.click(registration_buttons.repo_default)

    if validate and service != 'sat5':
        sel.click(form_buttons.validate_short)
        flash.assert_no_errors()
        flash.dismiss()

    if organization_sat6:
        sel.select(registration_form.locators['organization_sat6'],
                   organization_sat6)

    if cancel:
        form_buttons.cancel()
    else:
        form_buttons.save()
        flash.assert_message_match("Customer Information successfully saved")
        flash.dismiss()
예제 #6
0
def update_registration(service,
                        url,
                        username,
                        password,
                        repo_name=None,
                        organization=None,
                        use_proxy=False,
                        proxy_url=None,
                        proxy_username=None,
                        proxy_password=None,
                        validate=False,
                        cancel=False,
                        set_default_rhsm_address=False,
                        set_default_repository=False):
    """ Fill in the registration form, validate and save/cancel

    Args:
        service: Service type (registration method).
        url: Service server URL address.
        username: Username to use for registration.
        password: Password to use for registration.
        repo_or_channel: Repository/channel to enable.
        organization: Organization (sat5/sat6 only).
        use_proxy: `True` if proxy should be used, `False` otherwise
                   (default `False`).
        proxy_url: Address of the proxy server.
        proxy_username: Username for the proxy server.
        proxy_password: Password for the proxy server.
        validate: Click the Validate button and check the
                  flash message for errors if `True` (default `False`)
        cancel: Click the Cancel button if `True` or the Save button
                if `False` (default `False`)
        set_default_rhsm_address: Click the Default button connected to
                                  the RHSM (only) address if `True`
        set_default_repository: Click the Default button connected to
                                the repo/channel if `True`
    """
    assert service in service_types, "Unknown service type '{}'".format(
        service)
    service_value = service_types[service]

    sel.force_navigate("cfg_settings_region_red_hat_updates")
    sel.click(update_buttons.edit_registration)
    details = dict(service=sel.ByValue(service_value),
                   url=url,
                   username=username,
                   password=password,
                   repo_name=repo_name,
                   organization=organization,
                   use_proxy=use_proxy,
                   proxy_url=proxy_url,
                   proxy_username=proxy_username,
                   proxy_password=proxy_password)

    fill(registration_form, details)

    if set_default_rhsm_address:
        sel.click(registration_buttons.url_default)

    if set_default_repository:
        sel.click(registration_buttons.repo_default)

    if validate:
        sel.click(registration_buttons.validate)
        flash.assert_no_errors()
        flash.dismiss()

    if cancel:
        form_buttons.cancel()
    else:
        form_buttons.save()
        flash.assert_message_match("Customer Information successfully saved")
        flash.dismiss()
예제 #7
0
def _fill_rateform(rf, value):
    """value should be like (5, HOURLY)"""
    fill(rf.rate_loc, value[0])
    fill(rf.unit_select_loc, sel.ByValue(value[1]))
예제 #8
0
 def _form_mapping(self, create=None, **kwargs):
     return {'name_text': kwargs.get('name'),
             'type_select': create and 'Amazon EC2',
             'amazon_region_select': sel.ByValue(kwargs.get('region'))}
예제 #9
0
    def __init__(self,
                 name,
                 description,
                 active=True,
                 protocol=None,
                 depot_name=None,
                 uri=None,
                 username=None,
                 password=None,
                 password_verify=None,
                 run_type="Once",
                 run_every=None,
                 time_zone=None,
                 start_date=None,
                 start_hour=None,
                 start_min=None):

        assert protocol in {'Samba', 'Network File System'},\
            "Unknown protocol type '{}'".format(protocol)

        if protocol == 'Samba':
            self.details = dict(
                name=name,
                description=description,
                active=active,
                action='Database Backup',
                log_protocol=sel.ByValue(protocol),
                depot_name=depot_name,
                uri=uri,
                log_userid=username,
                log_password=password,
                log_verify=password_verify,
                time_zone=sel.ByValue(time_zone),
                start_date=start_date,
                start_hour=start_hour,
                start_min=start_min,
            )
        else:
            self.details = dict(
                name=name,
                description=description,
                active=active,
                action='Database Backup',
                log_protocol=sel.ByValue(protocol),
                depot_name=depot_name,
                uri=uri,
                time_zone=sel.ByValue(time_zone),
                start_date=start_date,
                start_hour=start_hour,
                start_min=start_min,
            )

        if run_type == "Once":
            self.details["timer_type"] = "Once"
        else:
            field = version.pick({
                version.LOWEST: self.tab[run_type],
                '5.5': 'timer_value'
            })
            self.details["timer_type"] = run_type
            self.details[field] = run_every