Exemplo n.º 1
0
class PolicyProfileAssignable(object):
    """This class can be inherited by anything that provider load_details method.

    It provides functionality to assign and unassign Policy Profiles
    """
    manage_policies_tree = deferred_verpick({
        version.LOWEST: CheckboxTree("//div[@id='protect_treebox']/ul"),
        "5.7": BootstrapTreeview("protectbox")
    })

    @property
    def assigned_policy_profiles(self):
        try:
            return self._assigned_policy_profiles
        except AttributeError:
            self._assigned_policy_profiles = set([])
            return self._assigned_policy_profiles

    def assign_policy_profiles(self, *policy_profile_names):
        """ Assign Policy Profiles to this object.

        Args:
            policy_profile_names: :py:class:`str` with Policy Profile names. After Control/Explorer
                coverage goes in, PolicyProfile objects will be also passable.
        """
        map(self.assigned_policy_profiles.add, policy_profile_names)
        self._assign_unassign_policy_profiles(True, *policy_profile_names)

    def unassign_policy_profiles(self, *policy_profile_names):
        """ Unssign Policy Profiles to this object.

        Args:
            policy_profile_names: :py:class:`str` with Policy Profile names. After Control/Explorer
                coverage goes in, PolicyProfile objects will be also passable.
        """
        for pp_name in policy_profile_names:
            try:
                self.assigned_policy_profiles.remove(pp_name)
            except KeyError:
                pass
        self._assign_unassign_policy_profiles(False, *policy_profile_names)

    def _assign_unassign_policy_profiles(self, assign, *policy_profile_names):
        """DRY function for managing policy profiles.

        See :py:func:`assign_policy_profiles` and :py:func:`assign_policy_profiles`

        Args:
            assign: Wheter to assign or unassign.
            policy_profile_names: :py:class:`str` with Policy Profile names.
        """
        self.load_details(refresh=True)
        pol_btn("Manage Policies")
        for policy_profile in policy_profile_names:
            if assign:
                self.manage_policies_tree.check_node(policy_profile)
            else:
                self.manage_policies_tree.uncheck_node(policy_profile)
        form_buttons.save()
        flash.assert_no_errors()
class Role(Updateable, Pretty, Navigatable):
    form = Form(fields=[
        ('name_txt', Input('name')),
        ('vm_restriction_select', AngularSelect('vm_restriction')),
        ('product_features_tree', {
            version.LOWEST: CheckboxTree("//div[@id='features_treebox']/ul"),
            '5.7': BootstrapTreeview("features_treebox")
        }),
    ])
    pretty_attrs = ['name', 'product_features']

    def __init__(self,
                 name=None,
                 vm_restriction=None,
                 product_features=None,
                 appliance=None):
        Navigatable.__init__(self, appliance=appliance)
        self.name = name
        self.vm_restriction = vm_restriction
        self.product_features = product_features or []

    def create(self):
        navigate_to(self, 'Add')
        fill(self.form, {
            'name_txt': self.name,
            'vm_restriction_select': self.vm_restriction,
            'product_features_tree': self.product_features
        },
             action=form_buttons.add)
        flash.assert_success_message('Role "{}" was saved'.format(self.name))

    def update(self, updates):
        navigate_to(self, 'Edit')
        fill(self.form, {
            'name_txt': updates.get('name'),
            'vm_restriction_select': updates.get('vm_restriction'),
            'product_features_tree': updates.get('product_features')
        },
             action=form_buttons.save)
        flash.assert_success_message('Role "{}" was saved'.format(
            updates.get('name', self.name)))

    def delete(self):
        navigate_to(self, 'Details')
        tb_select('Delete this Role', invokes_alert=True)
        sel.handle_alert()
        flash.assert_success_message('Role "{}": Delete successful'.format(
            self.name))

    def copy(self, name=None):
        if not name:
            name = self.name + "copy"
        navigate_to(self, 'Details')
        tb.select('Configuration', 'Copy this Role to a new Role')
        new_role = Role(name=name)
        fill(self.form, {'name_txt': new_role.name}, action=form_buttons.add)
        flash.assert_success_message('Role "{}" was saved'.format(
            new_role.name))
        return new_role
Exemplo n.º 3
0
class Role(Updateable, Pretty):
    form = Form(fields=[
        ('name_txt', Input('name')),
        ('vm_restriction_select', Select("//*[@id='vm_restriction']")),
        ('product_features_tree',
         CheckboxTree("//div[@id='features_treebox']/ul")),
    ])
    pretty_attrs = ['name', 'product_features']

    def __init__(self, name=None, vm_restriction=None, product_features=None):
        self.name = name
        self.vm_restriction = vm_restriction
        self.product_features = product_features or []

    def create(self):
        sel.force_navigate('cfg_accesscontrol_role_add')
        fill(self.form, {
            'name_txt': self.name,
            'vm_restriction_select': self.vm_restriction,
            'product_features_tree': self.product_features
        },
             action=form_buttons.add)
        flash.assert_success_message('Role "{}" was saved'.format(self.name))

    def update(self, updates):
        sel.force_navigate("cfg_accesscontrol_role_edit",
                           context={"role": self})
        fill(self.form, {
            'name_txt': updates.get('name'),
            'vm_restriction_select': updates.get('vm_restriction'),
            'product_features_tree': updates.get('product_features')
        },
             action=form_buttons.save)
        flash.assert_success_message('Role "{}" was saved'.format(
            updates.get('name', self.name)))

    def delete(self):
        sel.force_navigate("cfg_accesscontrol_role_ed", context={"role": self})
        tb_select('Delete this Role', invokes_alert=True)
        sel.handle_alert()
        flash.assert_success_message('Role "{}": Delete successful'.format(
            self.name))

    def copy(self, name=None):
        if not name:
            name = self.name + "copy"
        sel.force_navigate("cfg_accesscontrol_role_ed", context={"role": self})
        tb.select('Configuration', 'Copy this Role to a new Role')
        new_role = Role(name=name)
        fill(self.form, {'name_txt': new_role.name}, action=form_buttons.add)
        flash.assert_success_message('Role "{}" was saved'.format(
            new_role.name))
        return new_role
Exemplo n.º 4
0
class DefaultFilter(Updateable, Pretty):
    filter_form = Form(fields=[
        ("filter_tree", {
            version.LOWEST:
            CheckboxTree("//div[@id='all_views_treebox']/div/table"),
            "5.3":
            CheckboxTree("//div[@id='all_views_treebox']/ul")
        }),
    ])

    pretty_attrs = ['name', 'filters']

    def __init__(self, name=None, filters=None):
        self.name = name
        self.filters = filters or []

    def update(self, updates, expect_success=True):
        sel.force_navigate("my_settings_default_filters", context=self)
        fill(self.filter_form, {'filter_tree': updates.get('filters')},
             action=form_buttons.save)
        if expect_success:
            flash.assert_success_message('Default Filters saved successfully')
Exemplo n.º 5
0
class DefaultFilter(Updateable, Pretty, Navigatable):
    filter_form = Form(fields=[
        ("filter_tree", {
            version.LOWEST: CheckboxTree("//div[@id='all_views_treebox']/ul"),
            '5.7': BootstrapTreeview('df_treebox')
        }),
    ])

    pretty_attrs = ['name', 'filters']

    def __init__(self, name=None, filters=None, appliance=None):
        Navigatable.__init__(self, appliance=appliance)
        self.name = name
        self.filters = filters or []

    def update(self, updates, expect_success=True):
        navigate_to(self, 'All')
        fill(self.filter_form, {'filter_tree': updates.get('filters')},
             action=form_buttons.save)
        if expect_success:
            flash.assert_success_message('Default Filters saved successfully')
Exemplo n.º 6
0
class Role(Updateable):
    form = Form(fields=[
        ('name_txt', "//*[@id='name']"),
        ('vm_restriction_select', Select("//*[@id='vm_restriction']")),
        ('product_features_tree',
         CheckboxTree("//div[@id='features_treebox']/ul")),
    ])

    def __init__(self, name=None, vm_restriction=None, product_features=None):
        self.name = name
        self.vm_restriction = vm_restriction
        self.product_features = product_features or []

    def create(self):
        sel.force_navigate('cfg_accesscontrol_role_add')
        fill(self.form, {
            'name_txt': self.name,
            'vm_restriction_select': self.vm_restriction,
            'product_features_tree': self.product_features
        },
             action=form_buttons.add)
        flash.assert_success_message('Role "%s" was saved' % self.name)

    def update(self, updates):
        sel.force_navigate("cfg_accesscontrol_role_edit", context=self)
        fill(self.form, {
            'name_txt': updates.get('name'),
            'vm_restriction_select': updates.get('vm_restriction'),
            'product_features_tree': updates.get('product_features')
        },
             action=form_buttons.save)
        flash.assert_success_message('Role "%s" was saved' %
                                     updates.get('name', self.name))

    def delete(self):
        sel.force_navigate("cfg_accesscontrol_role_ed", context=self)
        tb_select('Delete this Role', invokes_alert=True)
        sel.handle_alert()
        flash.assert_success_message('Role "%s": Delete successful' %
                                     self.name)
Exemplo n.º 7
0
from cfme.web_ui.tabstrip import TabStripForm
from utils import conf, version, ParamClassName
from utils.appliance import Navigatable
from utils.appliance.implementations.ui import navigate_to
from utils.browser import ensure_browser_open
from utils.log import logger
from utils.wait import wait_for, RefreshTimer
from utils.stats import tol_check
from utils.update import Updateable
from utils.varmeth import variable

from . import PolicyProfileAssignable, Taggable, SummaryMixin

cfg_btn = partial(tb.select, 'Configuration')

manage_policies_tree = CheckboxTree("//div[@id='protect_treebox']/ul")

details_page = Region(infoblock_type='detail')


def base_types():
    from pkg_resources import iter_entry_points
    return {
        ep.name: ep.resolve()
        for ep in iter_entry_points('manageiq.provider_categories')
    }


def provider_types(category):
    from pkg_resources import iter_entry_points
    return {
Exemplo n.º 8
0
            ('start_button', FormButton("Start the Host Discovery"))])

properties_form = Form(
    fields=[('type_select',
             Select("select#server_emstype")), (
                 'name_text',
                 Input("name")), ('hostname_text', Input("hostname")),
            ('ipaddress_text', Input("ipaddress"), {
                "removed_since": "5.4.0.0.15"
            }), ('api_port', Input("port")),
            ('sec_protocol',
             Select("select#security_protocol")), ('sec_realm',
                                                   Input("realm"))])

manage_policies_tree = CheckboxTree({
    version.LOWEST: "//div[@id='treebox']/div/table",
    "5.3": "//div[@id='protect_treebox']/ul"
})

cfg_btn = partial(tb.select, 'Configuration')
pol_btn = partial(tb.select, 'Policy')
mon_btn = partial(tb.select, 'Monitoring')

nav.add_branch(
    'infrastructure_providers', {
        'infrastructure_provider_new':
        lambda _: cfg_btn('Add a New Infrastructure Provider'),
        'infrastructure_provider_discover':
        lambda _: cfg_btn('Discover Infrastructure Providers'),
        'infrastructure_provider': [
            lambda ctx: sel.click(Quadicon(ctx[
                'provider'].name, 'infra_prov')), {
class Genealogy(object):
    """Class, representing genealogy of an infra object with possibility of data retrieval
    and comparison.

    Args:
        o: The :py:class:`Vm` or :py:class:`Template` object.
    """
    genealogy_tree = deferred_verpick({
        version.LOWEST:
        CheckboxTree("//div[@id='genealogy_treebox']/ul"),
        5.7:
        BootstrapTreeview('genealogy_treebox')
    })

    section_comparison_tree = CheckboxTree(
        "//div[@id='all_sections_treebox']/div/table")
    apply_button = form_buttons.FormButton("Apply sections")

    mode_mapping = {
        "exists": "Exists Mode",
        "details": "Details Mode",
    }

    attr_mapping = {
        "all": "All Attributes",
        "different": "Attributes with different values",
        "same": "Attributes with same values",
    }

    def __init__(self, o):
        self.o = o

    def navigate(self):
        self.o.load_details()
        sel.click(InfoBlock.element("Relationships", "Genealogy"))

    def compare(self, *objects, **kwargs):
        """Compares two or more objects in the genealogy.

        Args:
            *objects: :py:class:`Vm` or :py:class:`Template` or :py:class:`str` with name.

        Keywords:
            sections: Which sections to compare.
            attributes: `all`, `different` or `same`. Default: `all`.
            mode: `exists` or `details`. Default: `exists`."""
        sections = kwargs.get("sections")
        attributes = kwargs.get("attributes", "all").lower()
        mode = kwargs.get("mode", "exists").lower()
        assert len(objects) >= 2, "You must specify at least two objects"
        objects = map(lambda o: o.name
                      if isinstance(o, (Vm, Template)) else o, objects)
        self.navigate()
        for obj in objects:
            if not isinstance(obj, list):
                path = self.genealogy_tree.find_path_to(obj)
            self.genealogy_tree.check_node(*path)
        toolbar.select("Compare selected VMs")
        # COMPARE PAGE
        flash.assert_no_errors()
        if sections is not None:
            map(lambda path: self.section_comparison_tree.check_node(*path),
                sections)
            sel.click(self.apply_button)
            flash.assert_no_errors()
        # Set requested attributes sets
        toolbar.select(self.attr_mapping[attributes])
        # Set the requested mode
        toolbar.select(self.mode_mapping[mode])

    @property
    def tree(self):
        """Returns contents of the tree with genealogy"""
        self.navigate()
        return self.genealogy_tree.read_contents()

    @property
    def ancestors(self):
        """Returns list of ancestors of the represented object."""
        self.navigate()
        path = self.genealogy_tree.find_path_to(
            re.compile(r"^.*?\(Selected\)$"))
        if not path:
            raise ValueError("Something wrong happened, path not found!")
        processed_path = []
        for step in path[:-1]:
            # We will remove the (parent) and (Selected) suffixes
            processed_path.append(
                re.sub(r"\s*(?:\(Current\)|\(Parent\))$", "", step))
        return processed_path
Exemplo n.º 10
0
    fields=[('default_button',
             "//div[@id='auth_tabs']/ul/li/a[@href='#default']"
             ), ('default_principal', "//*[@id='default_userid']"
                 ), ('default_secret', "//*[@id='default_password']"
                     ), ('default_verify_secret', "//*[@id='default_verify']"),
            ('ipmi_button', "//div[@id='auth_tabs']/ul/li/a[@href='#ipmi']"
             ), ('ipmi_principal', "//*[@id='ipmi_userid']"
                 ), ('ipmi_secret', "//*[@id='ipmi_password']"
                     ), ('ipmi_verify_secret', "//*[@id='ipmi_verify']"),
            ('validate_btn',
             FormButton('Validate the credentials by logging into the Server',
                        dimmed_alt="Validate"))])

manage_policies_tree = CheckboxTree(
    version.pick({
        "default": "//div[@id='treebox']/div/table",
        "5.3": "//div[@id='protect_treebox']/ul"
    }))

host_add_btn = FormButton('Add this Host')

cfg_btn = partial(tb.select, 'Configuration')
pol_btn = partial(tb.select, 'Policy')
pow_btn = partial(tb.select, 'Power')

nav.add_branch(
    'infrastructure_hosts', {
        'infrastructure_host_new':
        lambda _: cfg_btn('Add a New Host'),
        'infrastructure_host_discover':
        lambda _: cfg_btn('Discover Hosts'),