def extend_nav(cls): """A decorator, that when placed on a class will turn it to a nav tree extension. Takes the original class and "compiles" it into the nav tree in form of lists/dicts that :py:mod:`ui_navigate` takes. The classes in the structure are not instantiated during the scavenge process, they serve as a sort of static container of namespaced functions. Example: .. code-block:: python @extend_nav class infra_vms(object): # This will extend the node infra_vms class node_a(object): # with node a def navigate(_): # that can be reached this way from preceeding one pass def leaf_location(ctx): # Leaf location, no other child locations pass class node_x(object): # Or an another location that can contain locations def navigate(_): pass Args: cls: Class to be decorated. """ nav.add_branch(cls.__name__, _scavenge_class(cls, ignore_navigate=True)) return cls
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')), {'infrastructure_provider_edit': lambda _: cfg_btn('Edit this Infrastructure Provider'), 'infrastructure_provider_policy_assignment': lambda _: pol_btn('Manage Policies'), 'infrastructure_provider_timelines': lambda _: mon_btn('Timelines')}]}) class Provider(Updateable, Pretty): """ Abstract model of an infrastructure provider in cfme. See VMwareProvider or RHEVMProvider. Args: name: Name of the provider. details: a details record (see VMwareDetails, RHEVMDetails inner class).
('validate_btn', page_specific_locators.creds_validate_btn) ]) manage_policies_form = Form( fields=[ ('policy_select', Tree("//div[@id='treebox']/div/table")), ]) cfg_btn = partial(tb.select, 'Configuration') pol_btn = partial(tb.select, 'Policy') nav.add_branch('clouds_providers', {'clouds_provider_new': lambda _: cfg_btn('Add a New Cloud Provider'), 'clouds_provider_discover': lambda _: cfg_btn('Discover Cloud Providers'), 'clouds_provider': [lambda ctx: sel.click(Quadicon(ctx['provider'].name, 'cloud_prov')), {'clouds_provider_edit': lambda _: cfg_btn('Edit this Cloud Provider'), 'clouds_provider_policy_assignment': lambda _: pol_btn('Manage Policies')}]}) class Provider(Updateable, Pretty): """ Abstract model of a cloud provider in cfme. See EC2Provider or OpenStackProvider. Args: name: Name of the provider. details: a details record (see EC2Details, OpenStackDetails inner class). credentials (Credential): see Credential inner class. key: The CFME key of the provider in the yaml.
details_page = Region(infoblock_type='detail') cfg_btn = partial(tb.select, 'Configuration') pol_btn = partial(tb.select, 'Policy') def nav_to_cluster_through_provider(context): sel.force_navigate('infrastructure_provider', context=context) list_acc.select('Relationships', 'Show all managed Clusters') sel.click(Quadicon(context['cluster'].name, 'cluster')) nav.add_branch( 'infrastructure_clusters', { 'infrastructure_cluster': lambda ctx: sel.click(Quadicon(ctx['cluster'].name, 'cluster')) if 'provider' not in ctx else nav_to_cluster_through_provider(ctx) }) class Cluster(Pretty): """ Model of an infrastructure cluster in cfme Args: name: Name of the cluster. provider_key: Name of the provider this cluster is attached to. Note: If given a provider_key, it will navigate through ``Infrastructure/Providers`` instead of the direct path through ``Infrastructure/Clusters``. """
("validate_btn", page_specific_locators.creds_validate_btn), ] ) manage_policies_form = Form(fields=[("policy_select", Tree("//div[@id='treebox']/div/table"))]) cfg_btn = partial(tb.select, "Configuration") pol_btn = partial(tb.select, "Policy") 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")), { "infrastructure_provider_edit": lambda _: cfg_btn("Edit this Infrastructure Provider"), "infrastructure_provider_policy_assignment": lambda _: pol_btn("Manage Policies"), }, ], }, ) class Provider(Updateable): """ Abstract model of an infrastructure provider in cfme. See VMwareProvider or RHEVMProvider. Args: name: Name of the provider. details: a details record (see VMwareDetails, RHEVMDetails inner class).
('description_text', "//input[@id='description']"), ('display_checkbox', "//input[@id='display']"), ('add_button', "//img[@title='Add']")]) def catalog_in_table(catalog): return "//div[@class='objbox']//td[.='%s']" % catalog.name def catalog_in_tree(catalog): return "//div[@id='stcat_tree_div']//td[@class='standartTreeRow']/span[.='%s']" % catalog.name def _all_catalogs_add_new(_): sel.click("//div[@id='stcat_tree_div']//td[.='All Catalogs']") tb_select('Add a New Catalog') nav.add_branch( 'services_catalogs', {'catalogs': [nav.partial(accordion.click, 'Catalogs'), {'catalog_new': _all_catalogs_add_new, 'catalog': [lambda ctx: sel.click(catalog_in_tree(ctx['catalog'])), {'catalog_edit': nav.partial(tb_select, "Edit this Item")}]}], 'catalog_items': [nav.partial(accordion.click, 'Catalog Items'), {'catalog_item_new': _all_catalogs_add_new, 'catalog_item': [lambda ctx: sel.click(catalog_in_tree(ctx['catalog_item'])), {'catalog_item_edit': nav.partial(tb_select, "Edit this Item")}]}]})
from cfme.fixtures import pytest_selenium as sel from cfme.web_ui import Quadicon, Region, toolbar as tb from functools import partial from utils.pretty import Pretty from utils.providers import get_crud from utils.wait import wait_for details_page = Region(infoblock_type='detail') cfg_btn = partial(tb.select, 'Configuration') pol_btn = partial(tb.select, 'Policy') nav.add_branch( 'infrastructure_resource_pools', { 'infrastructure_resource_pool': lambda ctx: sel.click(Quadicon(ctx['resource_pool'].name, 'resource_pool')) } ) class ResourcePool(Pretty): """ Model of an infrastructure Resource pool in cfme Args: name: Name of the Resource pool. provider_key: Name of the provider this resource pool is attached to. Note: If given a provider_key, it will navigate through ``Infrastructure/Providers`` instead of the direct path through ``Infrastructure/Resourcepool``. """
('default_secret', "//*[@id='default_password']"), ('default_verify_secret', "//*[@id='default_verify']"), ('candu_button', "//div[@id='auth_tabs']/ul/li/a[@href='#default']"), ('candu_principal', "//*[@id='default_userid']"), ('candu_secret', "//*[@id='default_password']"), ('candu_verify_secret', "//*[@id='default_verify']"), ('validate_btn', page_specific_locators.creds_validate_btn) ]) cfg_btn = partial(tb.select, 'Configuration') 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')), {'infrastructure_provider_edit': lambda _: cfg_btn('Edit this Infrastructure Provider')}]}) class Provider(Updateable): """ Abstract model of an infrastructure provider in cfme. See VMwareProvider or RHEVMProvider. Args: name: Name of the provider. details: a details record (see VMwareDetails, RHEVMDetails inner class). credentials (Credential): see Credential inner class. key: The CFME key of the provider in the yaml.
def _all_servicedialogs_add_new(context): service_dialog_tree.click_path("All Dialogs") cfg_btn("Add a new Dialog") sel.wait_for_element(label_form.label) nav.add_branch( "automate_customization", { "service_dialogs": [ nav.partial(accordion.click, "Service Dialogs"), { "service_dialog_new": _all_servicedialogs_add_new, "service_dialog": [ lambda ctx: accordion.tree("Service Dialogs", ctx["dialog"].label), {"service_dialog_edit": nav.partial(cfg_btn, "Edit this Dialog")}, ], }, ] }, ) class ServiceDialog(Updateable): def __init__( self, label=None, description=None, submit=False,
"infrastructure_requests": click_fn(infrastructure.requests)}], "control": [move_to_fn(main.control), {"control_explorer": click_fn(control.explorer), "control_simulation": click_fn(control.simulation), "control_import_export": click_fn(control.import_export), "control_log": click_fn(control.log)}], "automate": [move_to_fn(main.automate), {"automate_explorer": click_fn(automate.explorer), "automate_simulation": click_fn(automate.simulation), "automate_customization": click_fn(automate.customization), "automate_import_export": click_fn(automate.import_export), "automate_log": click_fn(automate.log), "automate_requests": click_fn(automate.requests)}], "optimize": [move_to_fn(main.optimize), {"utilization": click_fn(optimize.utilization), "planning": click_fn(optimize.planning), "bottlenecks": click_fn(optimize.bottlenecks)}], "configure": [move_to_fn(main.configure), {"my_settings": click_fn(configure.my_settings), "tasks": click_fn(configure.tasks), "configuration": click_fn(configure.configuration), "smartproxies": click_fn(configure.smartproxies), "about": click_fn(configure.about)}]} nav.add_branch('toplevel', nav_tree)
menu_elem = sel.element(Loc.toplevel_loc.format(menu_name)) sel.move_to_element(menu_elem) for submenu_elem in sel.elements("../ul/li/a", root=menu_elem): displayed_menus.append((menu_name, sel.text(submenu_elem))) # Do reverse lookups so we can compare to the list of nav destinations for this group return sorted([reverse_lookup(*displayed) for displayed in displayed_menus]) # Construct the nav tree based on sections _branches = dict() # The main tab destination is usually the first secondlevel page in that tab # Since this is redundant, it's arguable that the toplevel tabs should be # nav destination at all; they're included here "just in case". The toplevel # and secondlevel destinations exist at the same level of nav_tree because the # secondlevel destinations don't depend on the toplevel nav taking place to reach # their destination. for (toplevel_dest, toplevel), secondlevels in sections.items(): for level in secondlevels: if len(level) == 2: secondlevel_dest, secondlevel = level reset_action = None elif len(level) == 3: secondlevel_dest, secondlevel, reset_action = level else: raise Exception("Wrong length of menu navigation tuple! ({})".format(len(level))) _branches[secondlevel_dest] = nav_to_fn(toplevel, secondlevel, reset_action) _branches[toplevel_dest] = [nav_to_fn(toplevel, None), {}] nav.add_branch("toplevel", _branches)
nav.add_branch( 'infrastructure_config_management', { 'infrastructure_config_managers': [ lambda _: (accordion.tree('Providers', version.pick({version.LOWEST: 'All Red Hat Satellite Providers', version.UPSTREAM: 'All Foreman Providers'})), toolbar.set_vms_grid_view()), { 'infrastructure_config_manager_new': lambda _: cfg_btn('Add a new Provider'), 'infrastructure_config_manager': [ lambda ctx: sel.check( Quadicon( '{} Configuration Manager' .format(ctx['manager'].name), None).checkbox), { 'infrastructure_config_manager_edit': lambda _: cfg_btn('Edit Selected item'), 'infrastructure_config_manager_refresh': lambda _: cfg_btn('Refresh Relationships and Power states', invokes_alert=True), 'infrastructure_config_manager_remove': lambda _: cfg_btn('Remove selected items from the VMDB', invokes_alert=True) } ], 'infrastructure_config_manager_detail': [ lambda ctx: sel.click( Quadicon('{} Configuration Manager'.format(ctx['manager'].name), None)), { 'infrastructure_config_manager_edit_detail': lambda _: cfg_btn('Edit this Provider'), 'infrastructure_config_manager_refresh_detail': lambda _: cfg_btn('Refresh Relationships and Power states', invokes_alert=True), 'infrastructure_config_manager_remove_detail': lambda _: cfg_btn('Remove this Provider from the VMDB', invokes_alert=True), 'infrastructure_config_manager_config_profile': lambda ctx: list_table.click_cell('Description', ctx['profile'].name) } ] } ], 'infrastructure_config_systems': [ lambda _: accordion.tree('Configured Systems', version.pick({version.LOWEST: 'All Red Hat Satellite Configured Systems', version.UPSTREAM: 'All Foreman Configured Systems'})), { 'infrastructure_config_system': [ lambda ctx: (toolbar.set_vms_grid_view(), sel.click(Quadicon(ctx['system'].name, None))), { 'infrastructure_config_system_provision': lambda _: cfg_btn('Provision Configured System'), 'infrastructure_config_system_edit_tags': lambda _: cfg_btn('Edit Tags') } ] } ] } )
nav.add_branch( 'infrastructure_virtual_machines', { "infra_vm_and_templates": [ accordion_fn("VMs & Templates", "All VMs & Templates"), { "vm_templates_provider_branch": [ lambda ctx: visible_tree.click_path(ctx["provider_name"]), { "datacenter_branch": [ lambda ctx: visible_tree.click_path(ctx[ "datacenter_name"]), { "infra_vm_obj": lambda ctx: visible_tree.click_path(ctx[ "vm_name"]), } ], } ], "vm_templates_archived_branch": [ lambda ctx: visible_tree.click_path('Archived'), { "infra_archive_obj": lambda ctx: visible_tree.click_path(ctx["archive_name"] ), } ], "vm_templates_orphaned_branch": [ lambda ctx: visible_tree.click_path('Orphaned'), { "infra_orphan_obj": lambda ctx: visible_tree.click_path(ctx["orphan_name"] ), } ], } ], "infra_vms": [ lambda _: accordion.click("VMs"), { "infra_vms_filter_folder": [ lambda ctx: visible_tree.click_path(ctx["folder_name"]), { "infra_vms_filter": lambda ctx: visible_tree.click_path(ctx["filter_name"] ), } ], } ], "infra_templates": [ lambda _: accordion.click("Templates"), { "infra_templates_filter_folder": [ lambda ctx: visible_tree.click_path(ctx["folder_name"]), { "infra_templates_filter": lambda ctx: visible_tree.click_path(ctx["filter_name"] ), } ], } ], })
"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')), { 'infrastructure_provider_edit': lambda _: cfg_btn('Edit this Infrastructure Provider'), 'infrastructure_provider_policy_assignment': lambda _: pol_btn('Manage Policies'), 'infrastructure_provider_timelines': lambda _: mon_btn('Timelines') } ] }) class Provider(Updateable): """ Abstract model of an infrastructure provider in cfme. See VMwareProvider or RHEVMProvider. Args:
details_page = Region(infoblock_type='detail') cfg_btn = partial(tb.select, 'Configuration') pol_btn = partial(tb.select, 'Policy') def nav_to_cluster_through_provider(context): sel.force_navigate('infrastructure_provider', context=context) list_acc.select('Relationships', 'Show all managed Clusters') sel.click(Quadicon(context['cluster'].name, 'cluster')) nav.add_branch( 'infrastructure_clusters', { 'infrastructure_cluster': lambda ctx: sel.click(Quadicon(ctx['cluster'].name, 'cluster')) if 'provider' not in ctx else nav_to_cluster_through_provider(ctx) } ) class Cluster(Pretty): """ Model of an infrastructure cluster in cfme Args: name: Name of the cluster. provider_key: Name of the provider this cluster is attached to. Note: If given a provider_key, it will navigate through ``Infrastructure/Providers`` instead of the direct path through ``Infrastructure/Clusters``.
('validate_btn', page_specific_locators.creds_validate_btn) ]) manage_policies_form = Form( fields=[ ('policy_select', Tree("//div[@id='treebox']/div/table")), ]) cfg_btn = partial(tb.select, 'Configuration') pol_btn = partial(tb.select, 'Policy') nav.add_branch('clouds_providers', {'cloud_provider_new': lambda _: cfg_btn('Add a New Cloud Provider'), 'cloud_provider_discover': lambda _: cfg_btn('Discover Cloud Providers'), 'cloud_provider': [lambda ctx: sel.click(Quadicon(ctx['provider'].name, 'cloud_prov')), {'cloud_provider_edit': lambda _: cfg_btn('Edit this Cloud Provider'), 'cloud_provider_policy_assignment': lambda _: pol_btn('Manage Policies')}]}) class Provider(Updateable): """ Abstract model of a cloud provider in cfme. See EC2Provider or OpenStackProvider. Args: name: Name of the provider. details: a details record (see EC2Details, OpenStackDetails inner class). credentials (Credential): see Credential inner class. key: The CFME key of the provider in the yaml.
for menu_name in menu_names: menu_elem = sel.element(Loc.toplevel_loc.format(menu_name)) sel.move_to_element(menu_elem) for submenu_elem in sel.elements('../ul/li/a', root=menu_elem): displayed_menus.append((menu_name, sel.text(submenu_elem))) # Do reverse lookups so we can compare to the list of nav destinations for this group return sorted([reverse_lookup(*displayed) for displayed in displayed_menus]) # Construct the nav tree based on sections _branches = dict() # The main tab destination is usually the first secondlevel page in that tab # Since this is redundant, it's arguable that the toplevel tabs should be # nav destination at all; they're included here "just in case". The toplevel # and secondlevel destinations exist at the same level of nav_tree because the # secondlevel destinations don't depend on the toplevel nav taking place to reach # their destination. for (toplevel_dest, toplevel), secondlevels in sections.items(): for level in secondlevels: if len(level) == 2: secondlevel_dest, secondlevel = level reset_action = None elif len(level) == 3: secondlevel_dest, secondlevel, reset_action = level else: raise Exception("Wrong length of menu navigation tuple! ({})".format(len(level))) _branches[secondlevel_dest] = nav_to_fn(toplevel, secondlevel, reset_action) _branches[toplevel_dest] = [nav_to_fn(toplevel, None), {}] nav.add_branch('toplevel', _branches)
"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'), 'infrastructure_host': [lambda ctx: sel.click(Quadicon(ctx['host'].name, 'host')), {'infrastructure_host_edit': lambda _: cfg_btn('Edit this Host'), 'infrastructure_host_policy_assignment': lambda _: pol_btn('Manage Policies')}]}) class Host(Updateable): """ Model of an infrastructure host in cfme. Args: name: Name of the host. hostname: Hostname of the host. ip_address: The IP address as a string.
details_page = Region(infoblock_type='detail') cfg_btn = partial(tb.select, 'Configuration') pol_btn = partial(tb.select, 'Policy') def nav_to_datastore_through_provider(context): sel.force_navigate('infrastructure_provider', context=context) list_acc.select('Relationships', 'Show all managed Datastores') sel.click(Quadicon(context['datastore'].name, 'datastore')) nav.add_branch( 'infrastructure_datastores', { 'infrastructure_datastore': lambda ctx: sel.click(Quadicon(ctx['datastore'].name, 'datastore')) if 'provider' not in ctx else nav_to_datastore_through_provider(ctx) } ) class Datastore(Pretty): """ Model of an infrastructure datastore in cfme Args: name: Name of the datastore. provider_key: Name of the provider this datastore is attached to. Note: If given a provider_key, it will navigate through ``Infrastructure/Providers`` instead of the direct path through ``Infrastructure/Datastores``.
})) 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'), 'infrastructure_host': [ lambda ctx: sel.click(Quadicon(ctx['host'].name, 'host')), { 'infrastructure_host_edit': lambda _: cfg_btn('Edit this Host'), 'infrastructure_host_policy_assignment': lambda _: pol_btn('Manage Policies') } ] }) class Host(Updateable): """ Model of an infrastructure host in cfme. Args: name: Name of the host.
output_table = version.pick({ '5.5': Table('//div[@id="list_grid"]/table'), '5.4': SplitTable( ('//*[@id="list_grid"]//table[contains(@class, "hdr")]/tbody', 1), ('//*[@id="list_grid"]//table[contains(@class, "obj")]/tbody', 1)) }) edit_tags_form = Form(fields=[( "select_tag", ui.Select("select#tag_cat")), ("select_value", ui.Select("select#tag_add"))]) nav.add_branch('clouds_stacks', { 'clouds_stack': lambda ctx: sel.click(Quadicon(ctx['stack'].name, 'stack')) }) class Stack(Pretty): pretty_attrs = ['name'] def __init__(self, name=None): self.name = name def delete(self): sel.force_navigate('clouds_stack', context={'stack': self}) cfg_btn("Remove this Stack from the VMDB", invokes_alert=True) sel.handle_alert() flash.assert_success_message( 'The selected Orchestration Stack was deleted')
cfg_btn = partial(tb.select, "Configuration") pol_btn = partial(tb.select, 'Policy') output_table = SplitTable( ('//*[@id="list_grid"]//table[contains(@class, "hdr")]/tbody', 1), ('//*[@id="list_grid"]//table[contains(@class, "obj")]/tbody', 1) ) edit_tags_form = Form( fields=[ ("select_tag", ui.Select("select#tag_cat")), ("select_value", ui.Select("select#tag_add")) ]) nav.add_branch( 'clouds_stacks', { 'clouds_stack': lambda ctx: sel.click(Quadicon(ctx['stack'].name, 'stack')) } ) class Stack(Pretty): pretty_attrs = ['name'] def __init__(self, name=None): self.name = name def delete(self): sel.force_navigate('clouds_stack', context={'stack': self}) cfg_btn("Remove this Stack from the VMDB", invokes_alert=True) sel.handle_alert() flash.assert_success_message('The selected Orchestration Stack was deleted')
nav.add_branch( 'infrastructure_config_management', { 'infrastructure_config_managers': [ lambda _: (accordion.tree( 'Providers', version.pick({ version.LOWEST: 'All Red Hat Satellite Providers', version.UPSTREAM: 'All Foreman Providers' })), tb.select('Grid View')), { 'infrastructure_config_manager_new': lambda _: cfg_btn('Add a new Provider'), 'infrastructure_config_manager': [ lambda ctx: sel.check( Quadicon( '{} Configuration Manager'. format(ctx['manager'].name), None).checkbox), { 'infrastructure_config_manager_edit': lambda _: cfg_btn('Edit Selected item'), 'infrastructure_config_manager_refresh': lambda _: cfg_btn( 'Refresh Relationships and Power states', invokes_alert=True), 'infrastructure_config_manager_remove': lambda _: cfg_btn( 'Remove selected items from the VMDB', invokes_alert=True) } ], 'infrastructure_config_manager_detail': [ lambda ctx: sel.click( Quadicon( '{} Configuration Manager'.format(ctx['manager']. name), None)), { 'infrastructure_config_manager_edit_detail': lambda _: cfg_btn('Edit this Provider'), 'infrastructure_config_manager_refresh_detail': lambda _: cfg_btn( 'Refresh Relationships and Power states', invokes_alert=True), 'infrastructure_config_manager_remove_detail': lambda _: cfg_btn('Remove this Provider from the VMDB', invokes_alert=True), 'infrastructure_config_manager_config_profile': lambda ctx: list_table.click_cell( 'Description', ctx['profile'].name) } ] } ], 'infrastructure_config_systems': [ lambda _: accordion.tree( 'Configured Systems', version.pick({ version.LOWEST: 'All Red Hat Satellite Configured Systems', version.UPSTREAM: 'All Foreman Configured Systems' })), { 'infrastructure_config_system': [ lambda ctx: (tb.select('Grid View'), sel.click(Quadicon(ctx['system'].name, None))), { 'infrastructure_config_system_provision': lambda _: cfg_btn('Provision Configured System'), 'infrastructure_config_system_edit_tags': lambda _: cfg_btn('Edit Tags') } ] } ] })
def _all_servicedialogs_add_new(context): service_dialog_tree.click_path('All Dialogs') cfg_btn('Add a new Dialog') sel.wait_for_element(label_form.label) nav.add_branch( 'automate_customization', { 'service_dialogs': [ nav.partial(accordion.click, 'Service Dialogs'), { 'service_dialog_new': _all_servicedialogs_add_new, 'service_dialog': [ lambda ctx: accordion.tree('Service Dialogs', ctx[ 'dialog'].label), { 'service_dialog_edit': nav.partial(cfg_btn, "Edit this Dialog") } ] } ] }) class ServiceDialog(Updateable): def __init__(self, label=None, description=None, submit=False, cancel=False,
_branches = dict() for (toplevel_dest, toplevel), secondlevels in input_set.items(): for level in secondlevels: if len(level) == 2: secondlevel_dest, secondlevel = level reset_action = None elif len(level) == 3: secondlevel_dest, secondlevel, reset_action = level else: raise Exception("Wrong length of menu navigation tuple! ({})".format(len(level))) _branches[secondlevel_dest] = nav_to_fn(toplevel, secondlevel, reset_action) _branches[toplevel_dest] = [nav_to_fn(toplevel, None), {}] return _branches _branches = branch_convert(sections) nav.add_branch('toplevel', _branches) ## # Tree class DSL # TODOS: # * Maybe kwargify the functions? So we can then specify the args directly in the methods and not # pull them from the context. (probably more question on ui_navigate itself) def _scavenge_class(cls, ignore_navigate=False): """Scavenges locations and nav functions from the class. Recursively goes through so no loops. Args: ignore_navigate: Useful for the initial - root class that has no navigate function. """ if "navigate" not in cls.__dict__ and not ignore_navigate: raise ValueError(
"5.5": FormButton("Add") } cfg_btn = partial(tb.select, 'Configuration') pol_btn = partial(tb.select, 'Policy') pow_btn = partial(tb.select, 'Power') lif_btn = partial(tb.select, 'Lifecycle') nav.add_branch('infrastructure_hosts', {'infrastructure_host_new': lambda _: cfg_btn( version.pick({version.LOWEST: 'Add a New Host', '5.4': 'Add a New item'})), 'infrastructure_host_discover': lambda _: cfg_btn( 'Discover Hosts'), 'infrastructure_host': [lambda ctx: sel.click(Quadicon(ctx['host'].name, 'host')), {'infrastructure_host_edit': lambda _: cfg_btn( version.pick({version.LOWEST: 'Edit this Host', '5.4': 'Edit this item'})), 'infrastructure_host_policy_assignment': lambda _: pol_btn('Manage Policies'), 'infrastructure_provision_host': lambda _: lif_btn( version.pick({version.LOWEST: 'Provision this Host', '5.4': 'Provision this item'}))}]}) class Host(Updateable, Pretty): """ Model of an infrastructure host in cfme. Args:
catalog_item_tree.click_path('All Catalog Items') tb_select('Add a New Catalog Item') provider_type = context['provider_type'] sel.select("//select[@id='st_prov_type']", provider_type) def _all_catalogbundle_add_new(context): sel.click("//div[@id='sandt_tree_div']//td[normalize-space(.)='All Catalog Items']") tb_select('Add a New Catalog Bundle') nav.add_branch( 'services_catalogs', {'catalog_items': [nav.partial(accordion.click, 'Catalog Items'), {'catalog_item_new': _all_catalogitems_add_new, 'catalog_item': [lambda ctx: catalog_item_tree. click_path('All Catalog Items', ctx['catalog'], ctx['catalog_item'].name), {'catalog_item_edit': nav.partial(tb_select, "Edit this Item")}]}]}) class Template(Pretty): pretty_attrs = ['name'] def __init__(self, name): self.name = name class Instance(Updateable, Pretty): pretty_attrs = ['name', 'item_type', 'catalog', 'vm_name', 'instance_type', 'availability_zone']
details_page = Region(infoblock_type='detail') cfg_btn = partial(tb.select, 'Configuration') pol_btn = partial(tb.select, 'Policy') def nav_to_datastore_through_provider(context): sel.force_navigate('infrastructure_provider', context=context) list_acc.select('Relationships', 'Show all managed Datastores') sel.click(Quadicon(context['datastore'].name, 'datastore')) nav.add_branch( 'infrastructure_datastores', { 'infrastructure_datastore': lambda ctx: sel.click(Quadicon(ctx['datastore'].name, 'datastore')) if 'provider' not in ctx else nav_to_datastore_through_provider(ctx) }) class Datastore(Pretty): """ Model of an infrastructure datastore in cfme Args: name: Name of the datastore. provider_key: Name of the provider this datastore is attached to. Note: If given a provider_key, it will navigate through ``Infrastructure/Providers`` instead of the direct path through ``Infrastructure/Datastores``. """
def _all_catalogbundle_add_new(context): sel.click("//div[@id='sandt_tree_div']//td[.='All Catalog Items']") tb_select('Add a New Catalog Bundle') nav.add_branch( 'services_catalogs', { 'catalog_items': [ nav.partial(accordion.click, 'Catalog Items'), { 'catalog_item_new': _all_catalogitems_add_new, 'catalog_item': [ lambda ctx: catalog_item_tree.click_path( 'All Catalog Items', ctx['catalog'], ctx[ 'catalog_item'].name), { 'catalog_item_edit': nav.partial(tb_select, "Edit this Item") } ] } ] }) class Template(object): def __init__(self, name): self.name = name
nav.add_branch( 'infrastructure_virtual_machines', { "infra_vm_and_templates": [ accordion_fn("VMs & Templates", "All VMs & Templates"), { "vm_templates_provider_branch": [ lambda ctx: visible_tree.click_path(ctx["provider_name"]), { "datacenter_branch": [ lambda ctx: visible_tree.click_path(ctx["datacenter_name"]), { "infra_vm_obj": lambda ctx: visible_tree.click_path(ctx["vm_name"]), } ], } ], "vm_templates_archived_branch": [ lambda ctx: visible_tree.click_path('Archived'), { "infra_archive_obj": lambda ctx: visible_tree.click_path(ctx["archive_name"]), } ], "vm_templates_orphaned_branch": [ lambda ctx: visible_tree.click_path('Orphaned'), { "infra_orphan_obj": lambda ctx: visible_tree.click_path(ctx["orphan_name"]), } ], } ], "infra_vms": [ lambda _: accordion.click("VMs"), { "infra_vms_filter_folder": [ lambda ctx: visible_tree.click_path(ctx["folder_name"]), { "infra_vms_filter": lambda ctx: visible_tree.click_path(ctx["filter_name"]), } ], } ], "infra_templates": [ lambda _: accordion.click("Templates"), { "infra_templates_filter_folder": [ lambda ctx: visible_tree.click_path(ctx["folder_name"]), { "infra_templates_filter": lambda ctx: visible_tree.click_path(ctx["filter_name"]), } ], } ], } )