def is_displayed(self): expected_title = VersionPicker({ LOWEST: 'Editing Class "{}"', '5.10': 'Editing Automate Class "{}"' }).pick(self.browser.product_version) return (self.in_explorer and self.title.text == expected_title.format( self.context['object'].name))
def is_displayed(self): form_title_text = VersionPicker({ Version.lowest(): 'Migration Plan Wizard', '5.10': 'Create Migration Plan' }) return self.title.text == form_title_text.pick()
def is_displayed(self): form_title_text = VersionPicker({ Version.lowest(): 'Infrastructure Mapping Wizard', '5.10': 'Create Infrastructure Mapping' }) return (self.form.title.text == form_title_text.pick())
def is_displayed(self): expected_title = VersionPicker( { LOWEST: 'Editing Class "{}"', '5.10': 'Editing Automate Class "{}"' } ).pick(self.browser.product_version) return ( self.in_explorer and self.title.text == expected_title.format(self.context['object'].name))
class grid_tile_icons(View): # noqa infra_provider_quad = BootstrapSwitch(VersionPicker({Version.lowest(): 'quadicons_ems', '5.10': 'quadicons_infra_manager'})) cloud_provider_quad = BootstrapSwitch(VersionPicker( {Version.lowest(): 'quadicons_ems_cloud', '5.10': 'quadicons_cloud_manager'})) containers_provider_quad = BootstrapSwitch('quadicons_container_manager') host_quad = BootstrapSwitch('quadicons_host') datastore_quad = BootstrapSwitch('quadicons_storage') vm_quad = BootstrapSwitch('quadicons_vm') template_quad = BootstrapSwitch('quadicons_miq_template') long_text = BootstrapSelect('quad_truncate')
class TemplateForm(ServicesCatalogView): title = Text('#explorer_title_text') template_type = VersionPicker({ "5.11": ReactSelect("type"), LOWEST: BootstrapSelect("type") }) name = Input(name='name') description = Input(name="description") draft = Checkbox(name='draft') content = VersionPicker({ "5.11": ReactCodeMirror(), LOWEST: ScriptBox(locator="//pre[@class=' CodeMirror-line ']/span") })
class VolumeAddForm(View): storage_manager = BootstrapSelect(name='storage_manager_id') tenant = BootstrapSelect(name='cloud_tenant_id') # is for openstack block storage only volume_name = TextInput(name='name') volume_type = BootstrapSelect(name=VersionPicker({Version.lowest(): 'aws_volume_type', '5.10': 'volume_type'})) volume_size = TextInput(name='size') # az is for ec2 block storage only az = BootstrapSelect( name=VersionPicker( {Version.lowest(): 'aws_availability_zone_id', '5.11': 'availability_zone_id'})) iops = TextInput(name='aws_iops') # is for ec2 block storage only encryption = BootstrapSwitch(name="aws_encryption") # is for ec2 block storage only add = Button('Add') cancel = Button('Cancel')
class AddInfrastructureMappingView(InfrastructureMappingForm): form_title_text = VersionPicker( { Version.lowest(): "Infrastructure Mapping Wizard", "5.10": "Create Infrastructure Mapping", } )
def create(self, name, catalog_items=None, catalog=None, description=None, display_in=None, dialog=None, provisioning_entry_point=None, reconfigure_entry_point=None, retirement_entry_point=None, domain="ManageIQ (Locked)"): # TODO Move this logic into the view, the main obstacle is filling 'catalog_items' view = navigate_to(self, 'Add') # In 5.10 catalog name is appended with 'My Company' cat_name = VersionPicker({ LOWEST: getattr(catalog, 'name', None), '5.10': 'My Company/{}'.format(getattr(catalog, 'name', None)) }).pick(self.appliance.version) view.basic_info.fill({ 'name': name, 'description': description, 'display': display_in, 'select_catalog': cat_name, 'select_dialog': dialog, 'provisioning_entry_point': provisioning_entry_point, 'reconfigure_entry_point': reconfigure_entry_point, 'retirement_entry_point': retirement_entry_point, }) for cat_item in catalog_items: view.resources.fill({'select_resource': cat_item}) view.add_button.click() view.flash.assert_success_message(f'Catalog Bundle "{name}" was added') view = self.create_view(AllCatalogItemView, wait='10s') view.flash.assert_no_error() return self.instantiate(name, catalog_items=catalog_items, catalog=catalog, description=description, display_in=display_in, dialog=dialog, domain=domain)
def reconfigure_primary_replication_node(self, pwd): # Configure primary replication node with SSHExpect(self.appliance) as interaction: interaction.send('ap') interaction.answer('Press any key to continue.', '', timeout=AP_WELCOME_SCREEN_TIMEOUT) interaction.answer( 'Choose the advanced setting: ', VersionPicker({ LOWEST: '6', '5.10': 8, '5.11.2.1': 6 })) # 6/8 for Configure Database Replication interaction.answer('Choose the database replication operation: ', '1') answer_cluster_related_questions(interaction, node_uid='1', db_name='', db_username='', db_password=pwd) interaction.answer( r'Enter the primary database hostname or IP address: \|.*\| ', self.appliance.hostname) # Warning: File /etc/repmgr.conf exists. Replication is already configured interaction.answer( re.escape('Continue with configuration? (Y/N): '), 'y') interaction.answer( re.escape( 'Apply this Replication Server Configuration? (Y/N): '), 'y') interaction.answer('Press any key to continue.', '')
def infra_mapping_default_data(source_provider, provider): """ Default data for infrastructure mapping form. It is used in other methods to recursive update the data according to parameters in tests. Args: source_provider: Vmware provider provider: Target rhev/OSP provider """ plan_type = VersionPicker({Version.lowest(): None, "5.10": "rhv" if provider.one_of(RHEVMProvider) else "osp"}).pick() infra_mapping_data = { "name": fauxfactory.gen_alphanumeric(15, start="infra_map_"), "description": f"migration with vmware to {plan_type}", "plan_type": plan_type, "clusters": [component_generator("clusters", source_provider, provider)], "datastores": [component_generator( "datastores", source_provider, provider, get_data(source_provider, "datastores", "nfs").type, get_data(provider, "datastores", "nfs").type)], "networks": [ component_generator("vlans", source_provider, provider, get_data(source_provider, "vlans", "VM Network"), get_data(provider, "vlans", "ovirtmgmt")) ], } return infra_mapping_data
def is_displayed(self): return (self.in_tower_explorer and self.title.text == VersionPicker( { Version.lowest(): 'All Ansible Tower Job Templates', '5.10': 'All Ansible Tower Templates' }).pick(self.browser.product_version) and self.sidebar.job_templates.is_opened)
def is_displayed(self): expected_title = VersionPicker({ LOWEST: 'Adding a new Class', '5.10': 'Adding a new Automate Class' }).pick(self.browser.product_version) return (self.in_explorer and self.datastore.is_opened and self.title.text == expected_title)
def test_rhsm_registration_check_repo_names( temp_appliance_preconfig_funcscope, soft_assert, appliance): """ Checks default rpm repos on a fresh appliance Polarion: assignee: jhenner caseimportance: high initialEstimate: 1/4h """ ver = temp_appliance_preconfig_funcscope.version.series() repos = cfme_data.redhat_updates.repos # TODO We need the context manager here as RedHatUpdates doesn't yet support Collections. with temp_appliance_preconfig_funcscope: repo_names = VersionPicker({ Version.lowest(): repos.pre_592, Version('5.9.3'): repos.post_592, Version('5.10.0'): repos.post_510 }).pick(temp_appliance_preconfig_funcscope.version) view = navigate_to(RedHatUpdates, 'Edit') soft_assert( view.repo_name.read() == 'cf-me-{}-for-rhel-7-rpms {}'.format(ver, repo_names)) """checks current repo names""" view.repo_default_name.click() """resets repos with default button and checks they are also correct""" soft_assert( view.repo_name.read() == 'cf-me-{}-for-rhel-7-rpms {}'.format(ver, repo_names))
def backup(self, database_path="/tmp/evm_db.backup"): """Backup VMDB database using appliance console""" if BZ(1741481).blocks: self.appliance.ssh_client.run_command(""" grep 'local replication all peer map=usermap' \ /var/lib/pgsql/data/pg_hba.conf || echo 'local replication all peer map=usermap' \ >> /var/lib/pgsql/data/pg_hba.conf""") self.appliance.db_service.reload() self.logger.info('Backing up database using appliance console') with SSHExpect(self.appliance) as interaction: interaction.send('ap') interaction.answer(re.escape('Press any key to continue.'), '', timeout=40) interaction.answer(re.escape('Choose the advanced setting: '), VersionPicker({ LOWEST: 4, '5.11.2.1': 2 })) interaction.answer( re.escape('Choose the backup output file destination: |1| '), '1') interaction.answer( re.escape('Enter the location to save the backup file to: ' '|/tmp/evm_db.backup| '), database_path) interaction.answer(re.escape('Press any key to continue.'), '', timeout=240)
def _fill_provider_attributes(self, provider_attributes): """Fills provider data. Helper method for ``self.create_rest`` """ if getattr(self, "region", None): if isinstance(self.region, dict): provider_attributes["provider_region"] = VersionPicker( self.region).pick(self.appliance.version) else: provider_attributes["provider_region"] = self.region if getattr(self, "project", None): provider_attributes["project"] = self.project if self.type_name in ('openstack_infra', 'openstack'): if getattr(self, 'api_version', None): version = 'v3' if 'v3' in self.api_version else 'v2' provider_attributes['api_version'] = version if version == 'v3' and getattr(self, 'keystone_v3_domain_id', None): provider_attributes['uid_ems'] = self.keystone_v3_domain_id if self.type_name == "azure": provider_attributes["uid_ems"] = self.tenant_id provider_attributes["provider_region"] = self.region.lower( ).replace(" ", "") if getattr(self, "subscription_id", None): provider_attributes["subscription"] = self.subscription_id
def test_bad_password(context, request, appliance): """ Tests logging in with a bad password. Polarion: assignee: apagac casecomponent: WebUI initialEstimate: 1/8h tags: rbac """ username = conf.credentials['default']['username'] password = "******" cred = Credential(principal=username, secret=password) user = appliance.collections.users.instantiate(credential=cred, name='Administrator') error_message = VersionPicker({ LOWEST: "Incorrect username or password", '5.10': "Login failed: Unauthorized" }).pick(appliance.version) with appliance.context.use(context): with pytest.raises(Exception, match=error_message): appliance.server.login(user) if appliance.version >= '5.9': view = appliance.browser.create_view(LoginPage) assert view.password.read() == '' and view.username.read() == ''
def test_appliance_console_backup_restore_db_local( request, two_appliances_one_with_providers): """ Test single appliance backup and restore, configures appliance with providers, backs up database, restores it to fresh appliance and checks for matching providers. Polarion: assignee: jhenner casecomponent: Configuration caseimportance: critical initialEstimate: 1/2h """ appl1, appl2 = two_appliances_one_with_providers appl1_provider_names = set(appl1.managed_provider_names) backup_file_name = f'/tmp/backup.{fauxfactory.gen_alphanumeric()}.dump' appl1.db.backup(backup_file_name) # Transfer v2_key and db backup from first appliance to second appliance fetch_v2key(appl1, appl2) fetch_db_local(appl1, appl2, backup_file_name) # Restore DB on the second appliance appl2.evmserverd.stop() appl2.db.drop() appl2.db.create() with SSHExpect(appl2) as interaction: interaction.send('ap') interaction.answer('Press any key to continue.', '', timeout=40) interaction.answer('Choose the advanced setting: ', VersionPicker({ LOWEST: '6', '5.11.2.1': 4 })) interaction.answer( re.escape('Choose the restore database file source: |1| '), '') interaction.answer( re.escape( 'Enter the location of the local restore file: |/tmp/evm_db.backup| ' ), backup_file_name) interaction.answer( re.escape( 'Should this file be deleted after completing the restore? (Y/N): ' ), 'n') interaction.answer( re.escape( 'Are you sure you would like to restore the database? (Y/N): ' ), 'y') interaction.answer('Press any key to continue.', '', timeout=80) appl2.evmserverd.start() appl2.wait_for_web_ui() appl2.wait_for_api_available() # Assert providers on the second appliance assert set(appl2.managed_provider_names) == appl1_provider_names, ( 'Restored DB is missing some providers') # Verify that existing provider can detect new VMs on the second appliance virtual_crud = provider_app_crud(VMwareProvider, appl2) vm = provision_vm(request, virtual_crud) assert vm.mgmt.is_running, "vm not running"
class form(View): # noqa user_name = VersionPicker({ "5.11": ReactSelect('user_name'), LOWEST: BootstrapSelect('user_name') }) group_name = VersionPicker({ "5.11": ReactSelect('group_name'), LOWEST: BootstrapSelect('group_name') }) entities = View.nested(BaseNonInteractiveEntitiesView) save_button = VersionPicker({ "5.11": Button('Submit'), LOWEST: Button('Save') }) reset_button = Button('Reset') cancel_button = Button('Cancel')
def is_displayed(self): location = VersionPicker({ Version.lowest(): 'Cloud Providers', '5.11': self.context['object'].name }).pick() return (self.breadcrumb.locations[-2] == location and self.entities.title.text == self.breadcrumb.active_location)
def test_rhsm_registration_check_repo_names(temp_appliance_preconfig_funcscope, soft_assert, appliance): """ Checks default rpm repos on a fresh appliance Polarion: assignee: jhenner caseimportance: high casecomponent: Configuration initialEstimate: 1/4h """ ver = temp_appliance_preconfig_funcscope.version.series() repos = cfme_data.redhat_updates.repos repo_names = VersionPicker({ '5.10': repos.post_510, '5.11': repos.post_511 }).pick(ver) if not repo_names: pytest.skip(f'This test is not ready for CFME series {ver}') # TODO We need the context manager here as RedHatUpdates doesn't yet support Collections. with temp_appliance_preconfig_funcscope: view = navigate_to(RedHatUpdates, 'Edit') soft_assert(view.repo_name.read() == repo_names) """checks current repo names""" view.repo_default_name.click() """resets repos with default button and checks they are also correct""" soft_assert(view.repo_name.read() == repo_names)
class ActionFormCommon(ControlExplorerView): description = Input("description") action_type = BootstrapSelect("miq_action_type") snapshot_name = Input("snapshot_name") analysis_profile = BootstrapSelect("analysis_profile") alerts_to_evaluate = MultiBoxSelect() snapshot_age = BootstrapSelect("snapshot_age") parent_type = BootstrapSelect("parent_type") cpu_number = BootstrapSelect("cpu_value") memory_amount = Input("memory_value") email_sender = Input("from") email_recipient = Input("to") vcenter_attr_name = Input("attribute") vcenter_attr_value = Input("value") tag = VersionPicker({ Version.lowest(): ManageIQTree("action_tags_treebox"), "5.11": SectionedBootstrapSelect("tag") }) remove_tag = CheckboxSelect("action_options_div") run_ansible_playbook = View.nested(RunAnsiblePlaybookFromView) automation_message = Input("object_message") automation_request = Input("object_request") attribute_value_pair = AttributeValueForm('attribute_', 'value_') cancel_button = Button("Cancel")
def catalog_name(self): # In 5.10 catalog name is appended with 'My Company' cat_name = VersionPicker({ LOWEST: getattr(self.catalog, 'name', None), '5.10': 'My Company/{}'.format(getattr(self.catalog, 'name', None)) }).pick(self.appliance.version) return cat_name
class filters(Accordion): # noqa ACCORDION_NAME = VersionPicker({ Version.lowest(): 'Filters', '5.11': 'Global Filters' }) navigation = BootstrapNav('.//div/ul') tree = ManageIQTree()
def check_one_approval_mail_received(): return len( smtp_test.get_emails(subject_like=VersionPicker({ LOWEST: "%%Your Virtual Machine configuration was Approved%%", "5.10": "%%Your Virtual Machine Request was Approved%%" }).pick())) == 1
class form(View): # noqa server = VersionPicker({ "5.11": ReactSelect('serverId'), LOWEST: BootstrapSelect('server_id') }) save_button = Button('Save') reset_button = Button('Reset') cancel_button = Button('Cancel')
class BalancerDetailsToolBar(BalancerToolBar): """ Represents details toolbar of balancer summary """ download = VersionPicker({ Version.lowest(): Button(title='Download summary in PDF format'), "5.10": Button(title='Print or export summary') })
class form(View): # noqa tags = VersionPicker({ Version.lowest(): Table("//div[@id='assignments_div']//table"), "5.11": ParametrizedView.nested(AssignedTags) }) tag_category = VersionPicker({ Version.lowest(): BootstrapSelect(id='tag_cat'), "5.11": ReactSelect(locator='.//div[@id="tag_cat"]') }) tag_name = VersionPicker({ Version.lowest(): BootstrapSelect(id='tag_add'), "5.11": ReactSelect(locator='.//div[@id="cat_tags_div"]') }) entities = View.nested(BaseNonInteractiveEntitiesView) save = Button('Save') reset = Button('Reset') cancel = Button('Cancel')
class PhysicalInfrastructureControlPolicy(BasePolicy): TYPE = "Control" TREE_NODE = VersionPicker({ LOWEST: "Physical Infrastructure", "5.11": "Physical Server" }) PRETTY = "Physical Server"
class FloatingIpDetailsToolBar(View): """ Represents toolbar of summary of port """ policy = Dropdown(text='Policy') download = VersionPicker({ Version.lowest(): Button(title='Download summary in PDF format'), "5.10": Button(title='Print or export summary') })
class NetworkProviderDetailsToolBar(NetworkProviderToolBar): """ Represents provider details toolbar """ monitoring = Dropdown(text='Monitoring') download = VersionPicker({ Version.lowest(): Button(title='Download summary in PDF format'), "5.10": Button(title='Print or export summary') })