class InfraProvidersDiscoverView(BaseLoggedInPage): """ Discover View from Infrastructure Providers page """ title = Text('//div[@id="main-content"]//h1') vmware = Checkbox('discover_type_virtualcenter') scvmm = Checkbox('discover_type_scvmm') rhevm = Checkbox('discover_type_rhevm') osp_infra = Checkbox('discover_type_openstack_infra') from_ip1 = Input('from_first') from_ip2 = Input('from_second') from_ip3 = Input('from_third') from_ip4 = Input('from_fourth') to_ip4 = Input('to_fourth') start = Button('Start') cancel = Button('Cancel') @property def is_displayed(self): return (self.logged_in_as_current_user and self.navigation.currently_selected == ['Compute', 'Infrastructure', 'Providers'] and self.title.text == 'Infrastructure Providers Discovery')
class ProviderAddView(BaseLoggedInPage): """ represents Provider Add View """ title = Text('//div[@id="main-content"]//h1') name = Input('name') prov_type = BootstrapSelect(id='emstype') zone = Input('zone') flash = FlashMessages( './/div[@id="flash_msg_div"]/div[@id="flash_text_div" or ' 'contains(@class, "flash_text_div")]') add = Button('Add') cancel = Button('Cancel') @View.nested class endpoints(View): # NOQA # this is switchable view that gets replaced with concrete view. # it gets changed according to currently chosen provider type # look at cfme.common.provider.BaseProvider.create() method pass @property def is_displayed(self): return self.logged_in_as_current_user
class PXEServerForm(View): title = Text('//div[@id="main-content"]//h1') flash = FlashMessages( './/div[@id="flash_msg_div"]/div[@id="flash_text_div" or ' 'contains(@class, "flash_text_div")]') # common fields name = Input(id='name') depot_type = BootstrapSelect(id='log_protocol') access_url = Input(id='access_url') pxe_dir = Input(id='pxe_directory') windows_images_dir = Input(id='windows_images_directory') customization_dir = Input(id='customization_directory') filename = Input(id='pxemenu_0') uri = Input(id='uri') # both NFS and Samba # Samba only username = Input(id='log_userid') password = Input(id='log_password') confirm_password = Input(id='log_verify') validate = Button('Validate the credentials by logging into the Server') @property def is_displayed(self): return False
class web_services(WaitTab): # noqa TAB_NAME = "Web Services" change_stored_password = Text(".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="ws_userid") password = Input(name="ws_password") confirm_password = Input(name="ws_verify") validate_button = Button("Validate")
class default(Tab): # noqa change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="default_userid") password = Input(name="default_password") confirm_password = Input(name="default_verify") validate_button = Button("Validate")
class remote_login(WaitTab): # noqa TAB_NAME = "Remote Login" change_stored_password = Text(".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="remote_userid") password = Input(name="remote_password") confirm_password = Input(name="remote_verify") validate_button = Button("Validate")
class ProviderAddView(BaseLoggedInPage): """ represents Provider Add View """ title = Text('//div[@id="main-content"]//h1') name = Input('name') prov_type = BootstrapSelect(id='emstype') zone = Input('zone') add = Button('Add') cancel = Button('Cancel') @View.nested class endpoints(View): # NOQA # this is switchable view that gets replaced with concrete view. # it gets changed according to currently chosen provider type # look at cfme.common.provider.BaseProvider.create() method pass @property def is_displayed(self): return ( self.title.is_displayed and self.name.is_displayed and self.prov_type.is_displayed and self.zone.is_displayed and self.add.is_displayed and self.cancel.is_displayed )
class inputs(ParametrizedView): # noqa PARAMETERS = ('name', ) ROOT = ParametrizedLocator( '//tr[./td[2]/input[normalize-space(@value)={name|quote}]]') ALL_FIELDS = '//div[@id="inputs_div"]/table//tr/td[2]/input' @cached_property def row_id(self): attr = self.browser.get_attribute( 'id', './/td/input[contains(@id, "fields_name_")]', parent=self) return int(attr.rsplit('_', 1)[-1]) name = Input(locator=ParametrizedLocator( './/td/input[contains(@id, "fields_name_{@row_id}")]')) data_type = Select(locator=ParametrizedLocator( './/td/select[contains(@id, "fields_datatype_{@row_id}")]')) default_value = Input(locator=ParametrizedLocator( './/td/input[contains(@id, "fields_value_{@row_id}")]')) @classmethod def all(cls, browser): results = [] for e in browser.elements(cls.ALL_FIELDS): results.append((browser.get_attribute('value', e), )) return results def delete(self): xpath = './/a/i[contains(@class, "pficon-delete")]' self.browser.click(xpath, parent=self) try: del self.row_id except AttributeError: pass
class ipmi(WaitTab): # noqa TAB_NAME = "IPMI" change_stored_password = Text(".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="ipmi_userid") password = Input(name="ipmi_password") confirm_password = Input(name="ipmi_verify") validate_button = Button("Validate")
class ProviderEditView(ProviderAddView): """ represents Provider Edit View """ prov_type = Text(locator='//label[@name="emstype"]') # only in edit view vnc_start_port = Input('host_default_vnc_port_start') vnc_end_port = Input('host_default_vnc_port_end') save = Button('Save') reset = Button('Reset') cancel = Button('Cancel') @property def is_displayed(self): provider_obj = self.context['object'] expected_title = "Edit {type} Providers '{name}'".format( type=provider_obj.string_name, name=provider_obj.name) return (self.logged_in_as_current_user and self.title.text == expected_title and self.navigation.currently_selected == [ 'Compute', ('Clouds' if provider_obj.string_name == "Cloud" else provider_obj.string_name), 'Providers' ])
class PXECustomizationTemplateForm(View): title = Text('//div[@id="main-content"]//h1') name = Input(id='name') description = Input(id='description') image_type = BootstrapSelect(id='img_typ') type = BootstrapSelect(id='typ') script = ScriptBox(locator='//textarea[contains(@id, "script_data")]') is_displayed = displayed_not_implemented
class PXECustomizationTemplateForm(View): title = Text('//div[@id="main-content"]//h1') name = Input(id='name') description = Input(id='description') image_type = BootstrapSelect(id='img_typ') type = BootstrapSelect(id='typ') script = ScriptBox(locator='//textarea[contains(@id, "script_data")]') @property def is_displayed(self): raise NotImplementedError( "This view has no unique markers for is_displayed check")
class CopyViewBase(View): title = Text('#explorer_title_text') to_domain_select = BootstrapSelect('domain') to_domain_text = Text('.//div[./label[normalize-space(.)="To Domain"]]/div/p[not(.//button)]') new_name = Input(name='new_name') override_source = Checkbox(name='override_source') override_existing = Checkbox(name='override_existing') namespace = Input(name='namespace') copy_button = Button('Copy') reset_button = Button('Reset') cancel_button = Button('Cancel')
class PlaybookInputParameters(View): """Represents input parameters part of playbook method edit form. """ input_name = Input(name="provisioning_key") default_value = Input(name="provisioning_value") provisioning_type = PlaybookBootstrapSelect("provisioning_type") add_button = Button(**{"ng-click": "vm.addKeyValue()"}) variables_table = Table( ".//div[@id='inputs_div']//table", column_widgets={"Actions": ActionsCell()} ) def _values_to_remove(self, values): return list(set(self.all_vars) - set(values)) def _values_to_add(self, values): return list(set(values) - set(self.all_vars)) def fill(self, values): """ Args: values (list): [] to remove all vars or [("var", "value", "type"), ...] to fill the view """ if set(values) == set(self.all_vars): return False else: for value in self._values_to_remove(values): rows = list(self.variables_table) for row in rows: if row[0].text == value[0]: row["Actions"].widget.delete.click() break for value in self._values_to_add(values): self.input_name.fill(value[0]) self.default_value.fill(value[1]) self.provisioning_type.fill(value[2]) self.add_button.click() return True @property def all_vars(self): if self.variables_table.is_displayed: return [(row["Input Name"].text, row["Default value"].text, row["Data Type"].text) for row in self.variables_table] else: return [] def read(self): return self.all_vars
class PXECustomizationTemplateForm(View): title = Text('//div[@id="main-content"]//h1') flash = FlashMessages('.//div[@id="flash_msg_div"]/div[@id="flash_text_div" or ' 'contains(@class, "flash_text_div")]') name = Input(id='name') description = Input(id='description') image_type = BootstrapSelect(id='img_typ') type = BootstrapSelect(id='typ') script = ScriptBox(locator='//textarea[contains(@id, "script_data")]') @property def is_displayed(self): return False
class HostFormView(ComputeInfrastructureHostsView): # Info/Settings title = Text(".//div[@id='main-content']//h1") name = Input(name="name") hostname = Input(name="hostname") custom_ident = Input(name="custom_1") ipmi_address = Input(name="ipmi_address") mac_address = Input(name="mac_address") @View.nested class endpoints(View): # noqa @View.nested class default(Tab): # noqa change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="default_userid") password = Input(name="default_password") confirm_password = Input(name="default_verify") validate_button = Button("Validate") @View.nested class remote_login(Tab): # noqa TAB_NAME = "Remote Login" change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="remote_userid") password = Input(name="remote_password") confirm_password = Input(name="remote_verify") validate_button = Button("Validate") @View.nested class web_services(Tab): # noqa TAB_NAME = "Web Services" change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="ws_userid") password = Input(name="ws_password") confirm_password = Input(name="ws_verify") validate_button = Button("Validate") @View.nested class ipmi(Tab): # noqa TAB_NAME = "IPMI" change_stored_password = Text( ".//a[contains(@ng-hide, 'bChangeStoredPassword')]") username = Input(name="ipmi_userid") password = Input(name="ipmi_password") confirm_password = Input(name="ipmi_verify") validate_button = Button("Validate") cancel_button = Button("Cancel")
class ProviderEditView(ProviderAddView): """ represents Provider Edit View """ prov_type = Text(locator='//label[@name="emstype"]') # only in edit view vnc_start_port = Input('host_default_vnc_port_start') vnc_end_port = Input('host_default_vnc_port_end') save = Button('Save') reset = Button('Reset') cancel = Button('Cancel') @property def is_displayed(self): return self.logged_in_as_current_user
class ProviderEditView(ProviderAddView): prov_type = Text(locator='//label[@name="emstype"]') # only in edit view vnc_start_port = Input('host_default_vnc_port_start') vnc_end_port = Input('host_default_vnc_port_end') save = Button('Save') reset = Button('Reset') cancel = Button('Cancel') @property def is_displayed(self): return self.logged_in_as_current_user and \ self.navigation.currently_selected == ['Compute', 'Infrastructure', 'Providers'] and \ self.title.text == 'Edit Infrastructure Provider'
class PXESystemImageTypeForm(View): title = Text('//div[@id="main-content"]//h1') name = Input(id='name') type = BootstrapSelect(id='provision_type') @property def is_displayed(self): return False
class HostDiscoverView(ComputeInfrastructureHostsView): """Discover View from Compute/Infrastructure/Hosts page.""" esx = Checkbox(name="discover_type_esx") ipmi = Checkbox(name="discover_type_ipmi") from_ip1 = Input(name="from_first") from_ip2 = Input(name="from_second") from_ip3 = Input(name="from_third") from_ip4 = Input(name="from_fourth") to_ip4 = Input(name="to_fourth") start_button = Button("Start") cancel_button = Button("Cancel") @property def is_displayed(self): return self.in_compute_infrastructure_hosts and self.title.text == "Hosts / Nodes Discovery"
class MethodAddView(AutomateExplorerView): title = Text('#explorer_title_text') location = BootstrapSelect('cls_method_location', can_hide_on_select=True) inline_name = Input(name='cls_method_name') inline_display_name = Input(name='cls_method_display_name') script = ScriptBox() data = Input(name='cls_method_data') validate_button = Button('Validate') # TODO: inline input parameters playbook_name = Input(name='name') playbook_display_name = Input(name='display_name') repository = PlaybookBootstrapSelect('provisioning_repository_id') playbook = PlaybookBootstrapSelect('provisioning_playbook_id') machine_credential = PlaybookBootstrapSelect( 'provisioning_machine_credential_id') hosts = Input('provisioning_inventory') max_ttl = Input('provisioning_execution_ttl') escalate_privilege = BootstrapSwitch('provisioning_become_enabled') verbosity = PlaybookBootstrapSelect('provisioning_verbosity') playbook_input_parameters = PlaybookInputParameters() add_button = Button('Add') cancel_button = Button('Cancel') @property def is_displayed(self): return (self.in_explorer and self.datastore.is_opened and self.title.text == 'Adding a new Automate Method' and check_tree_path(self.datastore.tree.currently_selected, self.context['object'].tree_path))
class InfraProviderAddView(ProviderAddView): api_version = BootstrapSelect(id='api_version') # only for OpenStack keystone_v3_domain_id = Input('keystone_v3_domain_id') # OpenStack only @property def is_displayed(self): return (super().is_displayed and self.navigation.currently_selected == ['Compute', 'Infrastructure', 'Providers'] and self.title.text == 'Add New Infrastructure Provider')
class PXESystemImageTypeForm(View): title = Text('//div[@id="main-content"]//h1') name = Input(id='name') type = BootstrapSelect(id='provision_type') @property def is_displayed(self): raise NotImplementedError( "This view has no unique markers for is_displayed check")
class ProviderEditView(ProviderAddView): """ represents Provider Edit View """ prov_type = Text(locator='//label[@name="emstype"]') # only in edit view vnc_start_port = Input('host_default_vnc_port_start') vnc_end_port = Input('host_default_vnc_port_end') flash = FlashMessages('.//div[@id="flash_msg_div"]/div[@id="flash_text_div" or ' 'contains(@class, "flash_text_div")]') save = Button('Save') reset = Button('Reset') cancel = Button('Cancel') @property def is_displayed(self): return self.logged_in_as_current_user
class PXESystemImageTypeForm(View): title = Text('//div[@id="main-content"]//h1') flash = FlashMessages('.//div[@id="flash_msg_div"]/div[@id="flash_text_div" or ' 'contains(@class, "flash_text_div")]') name = Input(id='name') type = BootstrapSelect(id='provision_type') @property def is_displayed(self): return False
class CloudProviderAddView(ProviderAddView): """ represents Cloud Provider Add View """ # bug in cfme this field has different ids for cloud and infra add views prov_type = BootstrapSelect(id='ems_type') region = BootstrapSelect(id='provider_region') # Azure/AWS/GCE tenant_id = Input('azure_tenant_id') # only for Azure subscription = Input('subscription') # only for Azure project_id = Input('project') # only for Azure # bug in cfme this field has different ids for cloud and infra add views api_version = BootstrapSelect(id='ems_api_version') # only for OpenStack infra_provider = BootstrapSelect(id='ems_infra_provider_id') # OpenStack only tenant_mapping = Checkbox(name='tenant_mapping_enabled') # OpenStack only @property def is_displayed(self): return (super(CloudProviderAddView, self).is_displayed and self.navigation.currently_selected == ['Compute', 'Clouds', 'Providers'] and self.title.text == 'Add New Cloud Provider')
class PXEServerForm(View): title = Text('//div[@id="main-content"]//h1') # common fields name = Input(id='name') depot_type = BootstrapSelect(id='log_protocol') access_url = Input(id='access_url') pxe_dir = Input(id='pxe_directory') windows_images_dir = Input(id='windows_images_directory') customization_dir = Input(id='customization_directory') filename = Input(id='pxemenu_0') uri = Input(id='uri') # both NFS and Samba # Samba only username = Input(id='log_userid') password = Input(id='log_password') confirm_password = Input(id='log_verify') validate = Button('Validate the credentials by logging into the Server') is_displayed = displayed_not_implemented
class advanced(Tab, BeforeFillMixin): # NOQA TAB_NAME = 'Advanced' adv_http = Input('provider_options_image_inspector_options_http_proxy') adv_https = Input('provider_options_image_inspector_options_https_proxy') no_proxy = Input('provider_options_image_inspector_options_no_proxy') image_repo = Input('provider_options_image_inspector_options_repository') image_reg = Input('provider_options_image_inspector_options_registry') image_tag = Input('provider_options_image_inspector_options_image_tag') cve_loc = Input('provider_options_image_inspector_options_cve_url')
class MethodEditView(AutomateExplorerView): title = Text('#explorer_title_text') # inline inline_name = Input(name='method_name') inline_display_name = Input(name='method_display_name') script = ScriptBox() data = Input(name='method_data') validate_button = Button('Validate') inputs = View.nested(Inputs) # playbook playbook_name = Input(name='name') playbook_display_name = Input(name='display_name') repository = PlaybookBootstrapSelect('provisioning_repository_id') playbook = PlaybookBootstrapSelect('provisioning_playbook_id') machine_credential = PlaybookBootstrapSelect('provisioning_machine_credential_id') hosts = Input('provisioning_inventory') max_ttl = Input('provisioning_execution_ttl') logging_output = PlaybookBootstrapSelect('provisioning_log_output') escalate_privilege = BootstrapSwitch('provisioning_become_enabled') verbosity = PlaybookBootstrapSelect('provisioning_verbosity') playbook_input_parameters = PlaybookInputParameters() # Edit embedded method embedded_method_table = Table('//*[@id="embedded_methods_div"]/table') embedded_method = EntryPoint(locator='//*[@id="automate-inline-method-select"]//button', tree_id="treeview-entrypoint_selection") save_button = Button('Save') reset_button = Button('Reset') cancel_button = Button('Cancel') def before_fill(self, values): location = self.context['object'].location.lower() if 'display_name' in values and location in ['inline', 'playbook']: values['{}_display_name'.format(location)] = values['display_name'] del values['display_name'] elif 'name' in values and location in ['inline', 'playbook']: values['{}_name'.format(location)] = values['name'] del values['name'] @property def is_displayed(self): return ( self.in_explorer and self.datastore.is_opened and (f'Editing Automate Method "{self.context["object"].name}"' in self.title.text) and check_tree_path( self.datastore.tree.currently_selected, self.context["object"].tree_path, partial=True, ) )
class MethodAddView(AutomateExplorerView): title = Text('#explorer_title_text') name = Input(name='cls_method_name') display_name = Input(name='cls_method_display_name') location = BootstrapSelect('cls_method_location') script = ScriptBox() data = Input(name='cls_method_data') validate_button = Button('Validate') add_button = Button('Add') cancel_button = Button('Cancel') # TODO: Input parameters @property def is_displayed(self): return (self.in_explorer and self.datastore.is_opened and self.title.text == 'Adding a new Automate Method' and check_tree_path(self.datastore.tree.currently_selected, self.context['object'].tree_path))