def test_rssfeedwidget_crud(appliance): w = appliance.collections.dashboard_report_widgets.create( appliance.collections.dashboard_report_widgets.RSS, fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), active=True, type="Internal", feed="Administrative Events", rows="8", visibility="<To All Users>" ) view = w.create_view(AllDashboardWidgetsView) view.flash.assert_message('Widget "{}" was saved'.format(w.title)) # Basic update with update(w): w.active = False # Different feed type with update(w): w.type = "External" w.external = "SlashDot" # and custom address with update(w): w.type = "External" w.external = "http://rss.example.com/" w.delete()
def test_automate_method_inputs_crud(klass): """ Polarion: assignee: dmisharo casecomponent: Automate initialEstimate: 1/8h """ method = klass.methods.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), location='inline', script='blah', inputs={ 'foo': {'data_type': 'string'}, 'bar': {'data_type': 'integer', 'default_value': '42'}} ) assert method.exists view = navigate_to(method, 'Details') assert view.inputs.is_displayed assert view.inputs.read() == { 'foo': {'Data Type': 'string', 'Default Value': ''}, 'bar': {'Data Type': 'integer', 'Default Value': '42'}, } with update(method): method.inputs = {'different': {'default_value': 'value'}} view = navigate_to(method, 'Details') assert view.inputs.is_displayed assert view.inputs.read() == { 'different': {'Data Type': 'string', 'Default Value': 'value'}, } with update(method): method.inputs = {} view = navigate_to(method, 'Details') assert not view.inputs.is_displayed method.delete()
def test_method_crud(klass): """ Polarion: assignee: dmisharo casecomponent: Automate caseimportance: critical initialEstimate: 1/16h """ method = klass.methods.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), location='inline', script='$evm.log(:info, ":P")', ) assert method.exists origname = method.name with update(method): method.name = fauxfactory.gen_alphanumeric(8) method.script = "bar" assert method.exists with update(method): method.name = origname assert method.exists method.delete() assert not method.exists
def test_provisioning_dialog_crud(appliance): """ Polarion: assignee: jhenner casecomponent: Provisioning initialEstimate: 1/10h caseimportance: medium """ # CREATE collection = appliance.collections.provisioning_dialogs dialog = collection.create( name='test-{}'.format(fauxfactory.gen_alphanumeric(length=5)), description='test-{}'.format(fauxfactory.gen_alphanumeric(length=5)), diag_type=collection.VM_PROVISION) assert dialog.exists # UPDATE with update(dialog): dialog.name = fauxfactory.gen_alphanumeric() dialog.description = fauxfactory.gen_alphanumeric() assert dialog.exists with update(dialog): dialog.diag_type = collection.VM_MIGRATE assert dialog.exists # Update with cancel dialog.update(updates={'description': 'not saved'}, cancel=True) view = navigate_to(dialog, 'Details') assert view.entities # DELETE dialog.delete(cancel=True) assert dialog.exists dialog.delete() assert not dialog.exists
def test_action_run_ansible_playbook_unavailable_address(request, ansible_catalog_item, full_template_vm_modscope, ansible_action, policy_for_testing, ansible_credential, service_request, service): """Tests a policy with ansible playbook action against unavailable address. Polarion: assignee: dmisharo initialEstimate: 1/6h """ vm = full_template_vm_modscope with update(ansible_catalog_item): ansible_catalog_item.provisioning = {"machine_credential": ansible_credential.name} with update(ansible_action): ansible_action.run_ansible_playbook = { "inventory": { "specific_hosts": True, "hosts": "unavailable_address" } } added_tag = vm.add_tag() request.addfinalizer(lambda: vm.remove_tag(added_tag)) wait_for(service_request.exists, num_sec=600) service_request.wait_for_request() view = navigate_to(service, "Details") assert view.provisioning.details.get_text_of("Hosts") == "unavailable_address" assert view.provisioning.results.get_text_of("Status") == "failed"
def test_method_crud(klass): """ Polarion: assignee: ghubale casecomponent: Automate caseimportance: critical initialEstimate: 1/16h tags: automate """ # TODO([email protected]): Update this test case for other types of automate methods like # builtin, expression, uri, playbook, Ansible Tower Job Template and Ansible Tower Workflow # Template method = klass.methods.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), location='inline', script='$evm.log(:info, ":P")', ) view = method.create_view(ClassDetailsView) if not BZ(1704439).blocks: view.flash.assert_message('Automate Method "{}" was added'.format(method.name)) assert method.exists origname = method.name with update(method): method.name = fauxfactory.gen_alphanumeric(8) method.script = "bar" assert method.exists with update(method): method.name = origname assert method.exists method.delete() assert not method.exists
def test_method_crud(klass): """ Polarion: assignee: ghubale casecomponent: Automate caseimportance: critical initialEstimate: 1/16h tags: automate """ method = klass.methods.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), location='inline', script='$evm.log(:info, ":P")', ) view = method.create_view(ClassDetailsView) view.flash.assert_message('Automate Method "{}" was added'.format(method.name)) assert method.exists origname = method.name with update(method): method.name = fauxfactory.gen_alphanumeric(8) method.script = "bar" assert method.exists with update(method): method.name = origname assert method.exists method.delete() assert not method.exists
def test_provisioning_dialog_crud(appliance): # CREATE collection = appliance.collections.provisioning_dialogs dialog = collection.create( name='test-{}'.format(fauxfactory.gen_alphanumeric(length=5)), description='test-{}'.format(fauxfactory.gen_alphanumeric(length=5)), diag_type=collection.VM_PROVISION) assert dialog.exists # UPDATE with update(dialog): dialog.name = fauxfactory.gen_alphanumeric() dialog.description = fauxfactory.gen_alphanumeric() assert dialog.exists with update(dialog): dialog.diag_type = collection.HOST_PROVISION assert dialog.exists # Update with cancel dialog.update(updates={'description': 'not saved'}, cancel=True) view = navigate_to(dialog, 'Details') assert view.entities # DELETE dialog.delete(cancel=True) assert dialog.exists dialog.delete() assert not dialog.exists
def test_superadmin_tenant_crud(request, appliance): """Test suppose to verify CRUD operations for CFME tenants Prerequisities: * This test is not depending on any other test and can be executed against fresh appliance. Steps: * Create tenant * Update description of tenant * Update name of tenant * Delete tenant """ tenant_collection = appliance.collections.tenants tenant = tenant_collection.create( name='tenant1{}'.format(fauxfactory.gen_alphanumeric()), description='tenant1 description', parent=tenant_collection.get_root_tenant() ) @request.addfinalizer def _delete_tenant(): if tenant.exists: tenant.delete() with update(tenant): tenant.description = "{}edited".format(tenant.description) with update(tenant): tenant.name = "{}edited".format(tenant.name) tenant.delete()
def test_storage_volume_crud(appliance, provider): """ Test storage volume crud prerequisites: * Storage provider Steps: * Crate new volume * Delete volume """ # create volume volume_collection = appliance.collections.volumes manager_name = '{} Cinder Manager'.format(provider.name) volume = volume_collection.create(name=fauxfactory.gen_alpha(), storage_manager=manager_name, tenant=provider.data['provisioning']['cloud_tenant'], size=STORAGE_SIZE, provider=provider) assert volume.exists # update volume old_name = volume.name new_name = fauxfactory.gen_alpha() with update(volume): volume.name = new_name with update(volume): volume.name = old_name # delete volume volume.delete(wait=True) assert not volume.exists
def test_action_run_ansible_playbook(request, ansible_catalog_item, ansible_action, policy_for_testing, vmware_vm, ansible_credential, service_request, service, host_type, inventory): """Tests a policy with ansible playbook action against localhost, manual address, target machine and unavailable address. """ if host_type == "manual_address": inventory["inventory"]["hosts"] = vmware_vm.ip_address if host_type in ["manual_address", "target_machine"]: with update(ansible_catalog_item): ansible_catalog_item.provisioning = {"machine_credential": ansible_credential.name} with update(ansible_action): ansible_action.run_ansible_playbook = inventory vmware_vm.add_tag("Service Level", "Gold") request.addfinalizer(lambda: vmware_vm.remove_tag("Service Level", "Gold")) wait_for(service_request.exists, num_sec=600) service_request.wait_for_request() view = navigate_to(service, "Details") if host_type == "localhost": assert view.provisioning.details.get_text_of("Hosts") == "localhost" assert view.provisioning.results.get_text_of("Status") == "successful" elif host_type == "manual_address": assert view.provisioning.details.get_text_of("Hosts") == vmware_vm.ip_address assert view.provisioning.results.get_text_of("Status") == "successful" elif host_type == "target_machine": assert view.provisioning.details.get_text_of("Hosts") == vmware_vm.ip_address assert view.provisioning.results.get_text_of("Status") == "successful" elif host_type == "unavailable_address": assert view.provisioning.details.get_text_of("Hosts") == "unavailable_address" assert view.provisioning.results.get_text_of("Status") == "failed"
def test_action_cancel_clone(appliance, request, provider, vm_name, vm_big, policy_for_testing, compliance_policy): """This test checks if 'Cancel vCenter task' action works. For this test we need big template otherwise CFME won't have enough time to cancel the task https://bugzilla.redhat.com/show_bug.cgi?id=1383372#c9 """ with update(policy_for_testing): policy_for_testing.scope = ( "fill_field(VM and Instance : Name, INCLUDES, {})".format(vm_big.name)) with update(compliance_policy): compliance_policy.scope = ( "fill_field(VM and Instance : Name, INCLUDES, {})".format(vm_big.name)) policy_for_testing.assign_events("VM Clone Start") policy_for_testing.assign_actions_to_event( "VM Clone Start", ["Cancel vCenter Task"]) clone_vm_name = "{}-clone".format(vm_big.name) @request.addfinalizer def finalize(): policy_for_testing.assign_events() with update(policy_for_testing): policy_for_testing.scope = ( "fill_field(VM and Instance : Name, INCLUDES, {})".format(vm_name)) with update(compliance_policy): compliance_policy.scope = ( "fill_field(VM and Instance : Name, INCLUDES, {})".format(vm_name)) cleanup_vm(clone_vm_name, provider) vm_big.crud.clone_vm(fauxfactory.gen_email(), "first", "last", clone_vm_name, "VMware") request_description = clone_vm_name clone_request = appliance.collections.requests.instantiate(description=request_description, partial_check=True) clone_request.wait_for_request(method='ui') assert clone_request.status == "Error"
def test_physical_infra_provider_crud(provider, has_no_providers): """Tests provider add with good credentials Metadata: test_flag: crud Polarion: assignee: rhcf3_machine casecomponent: Infra initialEstimate: 1/4h """ provider.create() # Fails on upstream, all provider types - BZ1087476 provider.validate_stats(ui=True) old_name = provider.name with update(provider): provider.name = str(uuid.uuid4()) # random uuid with update(provider): provider.name = old_name # old name provider.delete(cancel=False) provider.wait_for_delete()
def finalize(): policy_for_testing.assign_events() with update(policy_for_testing): policy_for_testing.scope = ( "fill_field(VM and Instance : Name, INCLUDES, {})".format(vm_name)) with update(compliance_policy): compliance_policy.scope = ( "fill_field(VM and Instance : Name, INCLUDES, {})".format(vm_name)) cleanup_vm(clone_vm_name, provider)
def admin_email(appliance): """Required for user quota tagging services to work, as it's mandatory for it's functioning.""" user = appliance.collections.users admin = user.instantiate(name='Administrator') with update(admin): admin.email = fauxfactory.gen_email() yield with update(admin): admin.email = ''
def finalize(): policy_for_testing.assign_events() with update(policy_for_testing): policy_for_testing.scope = ( "fill_field(VM and Instance : Name, INCLUDES, {})".format(vm_name)) with update(compliance_policy): compliance_policy.scope = ( "fill_field(VM and Instance : Name, INCLUDES, {})".format(vm_name)) collection = provider.appliance.provider_based_collection(provider) collection.instantiate(clone_vm_name, provider).cleanup_on_provider()
def test_instance_display_name_unset_from_ui(request, klass): instance = klass.instances.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric()) with update(instance): instance.display_name = fauxfactory.gen_alphanumeric() assert instance.exists with update(instance): instance.display_name = "" assert instance.exists
def test_domain_lock_unlock(request, appliance): domain = appliance.collections.domains.create( name=fauxfactory.gen_alpha(), description=fauxfactory.gen_alpha(), enabled=True) request.addfinalizer(domain.delete) ns1 = domain.namespaces.create(name='ns1') ns2 = ns1.namespaces.create(name='ns2') cls = ns2.classes.create(name='class1') cls.schema.add_field(name='myfield', type='Relationship') inst = cls.instances.create(name='inst') meth = cls.methods.create(name='meth', script='$evm') # Lock the domain domain.lock() # Check that nothing is editable # namespaces details = navigate_to(ns1, 'Details') assert not details.configuration.is_displayed details = navigate_to(ns2, 'Details') if appliance.version < '5.9': assert not details.configuration.is_displayed else: assert details.configuration.is_displayed assert details.configuration.items == ['Copy selected Classes'] # class details = navigate_to(cls, 'Details') assert details.configuration.items == ['Copy selected Instances'] assert not details.configuration.item_enabled('Copy selected Instances') details.schema.select() assert not details.configuration.is_displayed # instance details = navigate_to(inst, 'Details') assert details.configuration.items == ['Copy this Instance'] # method details = navigate_to(meth, 'Details') assert details.configuration.items == ['Copy this Method'] # Unlock it domain.unlock() # Check that it is editable with update(ns1): ns1.name = 'UpdatedNs1' assert ns1.exists with update(ns2): ns2.name = 'UpdatedNs2' assert ns2.exists with update(cls): cls.name = 'UpdatedClass' assert cls.exists cls.schema.add_field(name='myfield2', type='Relationship') with update(inst): inst.name = 'UpdatedInstance' assert inst.exists with update(meth): meth.name = 'UpdatedMethod' assert meth.exists
def test_vm_analysis_profile_crud(appliance, soft_assert, analysis_profile_collection): """CRUD for VM analysis profiles. Polarion: assignee: anikifor caseimportance: medium initialEstimate: 1/2h testtype: integration """ vm_profile = analysis_profile_collection.create( name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), profile_type=analysis_profile_collection.VM_TYPE, files=files_list, categories=categories_list, registry=registry_list, events=events_check() ) view = appliance.browser.create_view( navigator.get_class(analysis_profile_collection, 'All').VIEW) vm_flash = vm_profile.name if appliance.version < '5.10' else vm_profile.description view.flash.assert_message('Analysis Profile "{}" was saved'.format(vm_flash)) assert vm_profile.exists files_updates = events_check(updates=True) with update(vm_profile): vm_profile.files = files_updates view = appliance.browser.create_view(navigator.get_class(vm_profile, 'Details').VIEW) view.flash.assert_success_message('Analysis Profile "{}" was saved'.format(vm_flash)) soft_assert(vm_profile.files == files_updates, 'Files update failed on profile: {}, {}'.format(vm_profile.name, vm_profile.files)) with update(vm_profile): vm_profile.categories = ['System'] soft_assert(vm_profile.categories == ['System'], 'Categories update failed on profile: {}'.format(vm_profile.name)) copied_profile = vm_profile.copy(new_name='copied-{}'.format(vm_profile.name)) view = appliance.browser.create_view( navigator.get_class(analysis_profile_collection, 'All').VIEW) # yep, not copy specific vm_copied_flash = ( copied_profile.name if appliance.version < '5.10' else copied_profile.description ) view.flash.assert_message('Analysis Profile "{}" was saved'.format(vm_copied_flash)) assert copied_profile.exists copied_profile.delete() assert not copied_profile.exists vm_profile.delete() view.flash.assert_success_message('Analysis Profile "{}": Delete successful'.format(vm_flash)) assert not vm_profile.exists
def test_action_cancel_clone( appliance, request, provider, vm_big, policy_for_testing, compliance_policy ): """This test checks if 'Cancel vCenter task' action works. For this test we need big template otherwise CFME won't have enough time to cancel the task https://bugzilla.redhat.com/show_bug.cgi?id=1383372#c9 Metadata: test_flag: policy, actions Bugzilla: 1383372 1685201 Polarion: assignee: jdupuy initialEstimate: 1/4h casecomponent: Control """ with update(policy_for_testing): policy_for_testing.scope = "fill_field(VM and Instance : Name, INCLUDES, {})".format( vm_big.name ) with update(compliance_policy): compliance_policy.scope = "fill_field(VM and Instance : Name, INCLUDES, {})".format( vm_big.name ) policy_for_testing.assign_events("VM Clone Start") policy_for_testing.assign_actions_to_event("VM Clone Start", ["Cancel vCenter Task"]) clone_vm_name = "{}-clone".format(vm_big.name) @request.addfinalizer def finalize(): policy_for_testing.unassign_events("VM Clone Start") collection = provider.appliance.provider_based_collection(provider) collection.instantiate(clone_vm_name, provider).cleanup_on_provider() # reset the policy scope to the original vm with update(policy_for_testing): policy_for_testing.scope = "fill_field(VM and Instance : Name, INCLUDES, {})".format( vm.name ) with update(compliance_policy): compliance_policy.scope = "fill_field(VM and Instance : Name, INCLUDES, {})".format( vm.name ) vm_big.clone_vm(fauxfactory.gen_email(), "first", "last", clone_vm_name, "VMware") request_description = clone_vm_name clone_request = appliance.collections.requests.instantiate( description=request_description, partial_check=True ) clone_request.wait_for_request(method="ui") assert clone_request.status == "Error"
def test_class_display_name_unset_from_ui(request, namespace): a_class = namespace.classes.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric() ) with update(a_class): a_class.display_name = fauxfactory.gen_alphanumeric() assert a_class.exists with update(a_class): a_class.display_name = "" assert a_class.exists
def test_domain_lock_unlock(domain, appliance): """ Polarion: assignee: ghubale casecomponent: Automate initialEstimate: 1/16h caseimportance: medium tags: automate """ assert domain.exists ns1 = domain.namespaces.create(name='ns1') ns2 = ns1.namespaces.create(name='ns2') cls = ns2.classes.create(name='class1') cls.schema.add_field(name='myfield', type='Relationship') inst = cls.instances.create(name='inst') meth = cls.methods.create(name='meth', script='$evm') # Lock the domain domain.lock() details = navigate_to(ns1, 'Details') assert not details.configuration.is_displayed details = navigate_to(ns2, 'Details') assert not details.configuration.is_displayed # class details = navigate_to(cls, 'Details') assert not details.configuration.is_enabled details.schema.select() assert not details.configuration.is_displayed # instance details = navigate_to(inst, 'Details') assert not details.configuration.is_enabled # method details = navigate_to(meth, 'Details') assert not details.configuration.is_enabled # Unlock it domain.unlock() # Check that it is editable with update(ns1): ns1.name = 'UpdatedNs1' assert ns1.exists with update(ns2): ns2.name = 'UpdatedNs2' assert ns2.exists with update(cls): cls.name = 'UpdatedClass' assert cls.exists cls.schema.add_field(name='myfield2', type='Relationship') with update(inst): inst.name = 'UpdatedInstance' assert inst.exists with update(meth): meth.name = 'UpdatedMethod' assert meth.exists
def test_instance_crud(klass): instance = klass.instances.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric() ) orig = instance.description with update(instance): instance.description = 'edited' with update(instance): instance.description = orig instance.delete() assert not instance.exists
def test_class_crud(namespace): a_class = namespace.classes.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric() ) orig = a_class.description with update(a_class): a_class.description = 'edited' with update(a_class): a_class.description = orig a_class.delete() assert not a_class.exists
def finalize(): policy_for_testing.unassign_events("VM Clone Start") collection = provider.appliance.provider_based_collection(provider) collection.instantiate(clone_vm_name, provider).cleanup_on_provider() # reset the policy scope to the original vm with update(policy_for_testing): policy_for_testing.scope = "fill_field(VM and Instance : Name, INCLUDES, {})".format( vm.name ) with update(compliance_policy): compliance_policy.scope = "fill_field(VM and Instance : Name, INCLUDES, {})".format( vm.name )
def test_dashboard_crud(appliance): d = appliance.collections.report_dashboards.create( fauxfactory.gen_alphanumeric(), "EvmGroup-administrator", title=fauxfactory.gen_alphanumeric(), locked=False, widgets=["Top CPU Consumers (weekly)", "Vendor and Guest OS Chart"] ) with update(d): d.locked = True with update(d): d.locked = False with update(d): d.widgets = "Top Storage Consumers" d.delete()
def test_alert_vm_turned_on_more_than_twice_in_past_15_minutes(request, provider, full_template_vm, smtp_test, alert_collection, setup_for_alerts): """ Tests alerts for vm turned on more than twice in 15 minutes Metadata: test_flag: alerts, provision """ vm = full_template_vm alert = alert_collection.instantiate("VM Power On > 2 in last 15 min") with update(alert): alert.active = True alert.emails = fauxfactory.gen_email() setup_for_alerts(request, [alert], "VM Power On", vm.name, provider) if not provider.mgmt.is_vm_stopped(vm.name): provider.mgmt.stop_vm(vm.name) provider.refresh_provider_relationships() vm.wait_for_vm_state_change(vm.STATE_OFF) for i in range(5): vm.power_control_from_cfme(option=vm.POWER_ON, cancel=False) wait_for(lambda: provider.mgmt.is_vm_running(vm.name), num_sec=300, message="Check if vm is running") vm.wait_for_vm_state_change(vm.STATE_ON) vm.power_control_from_cfme(option=vm.POWER_OFF, cancel=False) wait_for(lambda: provider.mgmt.is_vm_stopped(vm.name), num_sec=300, message="Check if vm is stopped") vm.wait_for_vm_state_change(vm.STATE_OFF) wait_for_alert(smtp_test, alert, delay=16 * 60)
def test_service_ansible_playbook_crud(appliance, ansible_repository): """ Polarion: assignee: sbulage casecomponent: Ansible caseimportance: critical initialEstimate: 1/6h tags: ansible_embed """ cat_item = appliance.collections.catalog_items.create( appliance.collections.catalog_items.ANSIBLE_PLAYBOOK, fauxfactory.gen_alphanumeric(), fauxfactory.gen_alphanumeric(), provisioning={ "repository": ansible_repository.name, "playbook": "dump_all_variables.yml", "machine_credential": "CFME Default Credential", "create_new": True, "provisioning_dialog_name": fauxfactory.gen_alphanumeric() } ) assert cat_item.exists with update(cat_item): new_name = "edited_{}".format(fauxfactory.gen_alphanumeric()) cat_item.name = new_name cat_item.provisioning = { "playbook": "copy_file_example.yml" } view = navigate_to(cat_item, "Details") assert new_name in view.entities.title.text assert view.entities.provisioning.info.get_text_of("Playbook") == "copy_file_example.yml" cat_item.delete() assert not cat_item.exists
def test_service_ansible_execution_ttl(request, service_catalog, ansible_catalog_item, service, service_request): """Test if long running processes allowed to finish. There is a code that guarantees to have 100 retries with a minimum of 1 minute per retry. So we need to run ansible playbook service more than 100 minutes and set max ttl greater than ansible playbook running time. Polarion: assignee: sbulage casecomponent: Ansible caseimportance: medium initialEstimate: 2h tags: ansible_embed Bugzilla: 1519275 1515841 """ with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "playbook": "long_running_playbook.yml", "max_ttl": 200 } def _revert(): with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "playbook": "dump_all_variables.yml", "max_ttl": "" } request.addfinalizer(_revert) service_catalog.order() service_request.wait_for_request(method="ui", num_sec=200 * 60, delay=120) view = navigate_to(service, "Details") assert view.provisioning.results.get_text_of("Status") == "successful"
def test_embed_tower_exec_play_against_amazon(request, provider, setup_provider, ansible_catalog_item, service, ansible_amazon_credential, service_catalog): """ Polarion: assignee: sbulage casecomponent: Ansible caseimportance: medium initialEstimate: 1/4h tags: ansible_embed """ with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "playbook": "list_ec2_instances.yml", "cloud_type": "Amazon", "cloud_credential": ansible_amazon_credential.name } @request.addfinalizer def _revert(): with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "playbook": "dump_all_variables.yml", "cloud_type": "<Choose>" } service_request = service_catalog.order() service_request.wait_for_request(method="ui", num_sec=300, delay=20) view = navigate_to(service, "Details") assert view.provisioning.results.get_text_of("Status") == "successful"
def test_button_crud(appliance, dialog, request, buttongroup, obj_type): """Test Creating a Button Prerequisities: * An Button Group Steps: * Create a Button with random button text and button hover text, and random request * Assert that the button exists * Assert that the entered values correspond with what is displayed on the details page * Change the hover text, ensure the text is changed on details page * Delete the button * Assert that the button no longer exists. Bugzillas: * 1143019, 1205235 """ button_gp = buttongroup(obj_type) button = button_gp.buttons.create(text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), dialog=dialog, system="Request", request="InspectMe") request.addfinalizer(button.delete_if_exists) assert button.exists view = navigate_to(button, 'Details') assert view.text.text == button.text assert view.hover.text == button.hover edited_hover = "edited {}".format(fauxfactory.gen_alphanumeric()) with update(button): button.hover = edited_hover assert button.exists view = navigate_to(button, 'Details') assert view.hover.text == edited_hover button.delete(cancel=True) assert button.exists button.delete() assert not button.exists
def test_embedded_ansible_credential_crud(credentials_collection, wait_for_ansible, credential_type, credentials, appliance): """ Polarion: assignee: dmisharo casecomponent: Ansible initialEstimate: 1/6h """ credential = credentials_collection.create( "{}_credential_{}".format(credential_type, fauxfactory.gen_alpha()), credential_type, **credentials) updated_value = "edited_{}".format(fauxfactory.gen_alpha()) with update(credential): if credential.credential_type == "Google Compute Engine": credential.service_account = updated_value elif credential.credential_type == "Amazon": credential.access_key = updated_value # credential.username = updated_value else: credential.username = updated_value # credential.access_key = updated_value view = navigate_to(credential, "Details") def wait_for_changes(field_name): cr_opts = view.entities.summary("Credential Options") wait_for(lambda: cr_opts.get_text_of(field_name) == updated_value, fail_func=view.browser.selenium.refresh, delay=10, timeout=60) if credential.credential_type == "Amazon": wait_for_changes("Access Key") elif credential.credential_type == "Google Compute Engine": wait_for_changes("Service Account Email Address") else: wait_for_changes("Username") credential.delete()
def test_check_files(request, compliance_vm, analysis_profile, condition_collection, policy_collection, policy_profile_collection): """This test checks presence and contents of a certain file. Due to caching, an existing file is checked. """ check_file_name = "/etc/hosts" check_file_contents = "127.0.0.1" condition = condition_collection.create( VMCondition, "Compliance testing condition {}".format( fauxfactory.gen_alphanumeric(8)), expression=("fill_find(VM and Instance.Files : Name, " "=, {}, Check Any, Contents, INCLUDES, {})".format( check_file_name, check_file_contents))) request.addfinalizer(lambda: diaper(condition.delete)) policy = policy_collection.create( VMCompliancePolicy, "Compliance {}".format(fauxfactory.gen_alphanumeric(8))) request.addfinalizer(lambda: diaper(policy.delete)) policy.assign_conditions(condition) profile = policy_profile_collection.create("Compliance PP {}".format( fauxfactory.gen_alphanumeric(8)), policies=[policy]) request.addfinalizer(lambda: diaper(profile.delete)) compliance_vm.assign_policy_profiles(profile.description) request.addfinalizer( lambda: compliance_vm.unassign_policy_profiles(profile.description)) with update(analysis_profile): analysis_profile.files = [{ "Name": check_file_name, "Collect Contents?": True }] do_scan(compliance_vm, ("Configuration", "Files")) compliance_vm.check_compliance() assert compliance_vm.compliant
def test_zone_crud(soft_assert): """ Polarion: assignee: anikifor caseimportance: low initialEstimate: 1/15h """ zc = current_appliance.collections.zones # CREATE zone = zc.create(name=fauxfactory.gen_alphanumeric(5), description=fauxfactory.gen_alphanumeric(8)) soft_assert(zone.exists, "The zone {} does not exist!".format(zone.description)) # UPDATE old_desc = zone.description with update(zone): zone.description = fauxfactory.gen_alphanumeric(8) soft_assert(zone.exists and (old_desc != zone.description), "The zone {} was not updated!".format(zone.description)) # DELETE zone.delete() soft_assert(not zone.exists, "The zone {} exists!".format(zone.description))
def test_add_ipmi_refresh(appliance, setup_provider): """ Tests IPMI IP address is not blank after running refresh relationships on the host. Bugzilla: 1669011 Polarion: assignee: anikifor initialEstimate: 1/20h caseimportance: medium casecomponent: Infra """ host = appliance.collections.hosts.all()[0] # dummy credentials and ipmi address are sufficient for this test case cred = host.Credential(principal="111", secret="222", ipmi=True) ipmi_address = "10.10.10.10" with update(host): host.ipmi_credentials = cred host.ipmi_address = ipmi_address host.refresh() view = navigate_to(host, "Edit") assert view.ipmi_address.read() == ipmi_address
def test_service_ansible_playbook_order_credentials(ansible_catalog_item, ansible_credential, service_catalog, appliance): """Test if credentials avaialable in the dropdown in ordering ansible playbook service screen. """ with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "machine_credential": ansible_credential.name } view = navigate_to(service_catalog, "Order") wait_for(lambda: view.machine_credential.is_displayed, timeout=5) if appliance.version < "5.9": options = [o.text for o in view.machine_credential.all_options] assert [ "<Default>", "CFME Default Credential", ansible_credential.name ] == options else: options = view.machine_credential.all_options assert [ ansible_credential.name, "CFME Default Credential", "<Default>" ] == options
def test_automate_ansible_playbook_method_type_crud(appliance, ansible_repository, klass): """CRUD test for ansible playbook method. Bugzilla: 1729999 1740769 Polarion: assignee: ghubale casecomponent: Automate initialEstimate: 1/12h """ method = klass.methods.create( name=fauxfactory.gen_alphanumeric(start="meth_"), location="playbook", repository=ansible_repository.name, playbook="copy_file_example.yml", machine_credential="CFME Default Credential", playbook_input_parameters=[("key", "value", "string")]) with update(method): method.name = fauxfactory.gen_alphanumeric() method.delete()
def test_service_ansible_playbook_order_credentials(ansible_catalog_item, ansible_credential, service_catalog, appliance): """Test if credentials avaialable in the dropdown in ordering ansible playbook service screen. Polarion: assignee: sbulage casecomponent: Ansible caseimportance: medium initialEstimate: 1/6h tags: ansible_embed """ with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "machine_credential": ansible_credential.name } view = navigate_to(service_catalog, "Order") options = [ o.text for o in (view.fields('credential')).visible_widget.all_options ] assert ansible_credential.name in set(options)
def test_service_ansible_playbook_crud(appliance, ansible_repository): cat_item = appliance.collections.catalog_items.create( appliance.collections.catalog_items.ANSIBLE_PLAYBOOK, fauxfactory.gen_alphanumeric(), fauxfactory.gen_alphanumeric(), provisioning={ "repository": ansible_repository.name, "playbook": "dump_all_variables.yml", "machine_credential": "CFME Default Credential", "create_new": True, "provisioning_dialog_name": fauxfactory.gen_alphanumeric() }) assert cat_item.exists with update(cat_item): new_name = "edited_{}".format(fauxfactory.gen_alphanumeric()) cat_item.name = new_name cat_item.provisioning = {"playbook": "copy_file_example.yml"} view = navigate_to(cat_item, "Details") assert new_name in view.entities.title.text assert view.entities.provisioning.info.get_text_of( "Playbook") == "copy_file_example.yml" cat_item.delete() assert not cat_item.exists
def test_chartwidget_crud(appliance): """ Polarion: assignee: jhenner casecomponent: report initialEstimate: 1/12h """ w = appliance.collections.dashboard_report_widgets.create( appliance.collections.dashboard_report_widgets.CHART, fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), active=True, filter="Configuration Management/Virtual Machines/Vendor and Guest OS", timer={ "run": "Hourly", "hours": "Hour" }, visibility="<To All Users>") view = w.create_view(AllDashboardWidgetsView) view.flash.assert_message('Widget "{}" was saved'.format(w.title)) with update(w): w.active = False w.delete()
def test_service_ansible_playbook_order_credentials(ansible_catalog_item, ansible_credential, service_catalog, appliance): """Test if credentials avaialable in the dropdown in ordering ansible playbook service screen. """ with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "machine_credential": ansible_credential.name } view = navigate_to(service_catalog, "Order") view.wait_displayed() if appliance.version < "5.9": options = [ o.text for o in (view.fields('credential')).visible_widget.all_options ] else: options = (view.fields('credential')).visible_widget.all_options assert set( ["<Default>", "CFME Default Credential", ansible_credential.name]) == set(options)
def test_user_change_password(appliance, request): group_name = 'EvmGroup-user' group = group_collection(appliance).instantiate(description=group_name) user = new_user(appliance, [group]) request.addfinalizer(user.delete) request.addfinalizer(appliance.server.login_admin) with user: appliance.server.logout() navigate_to(appliance.server, 'LoggedIn') assert appliance.server.current_full_name() == user.name appliance.server.login_admin() with update(user): user.credential = Credential( principal=user.credential.principal, secret="another_very_secret", verify_secret="another_very_secret", ) with user: appliance.server.logout() navigate_to(appliance.server, 'LoggedIn') assert appliance.server.current_full_name() == user.name
def test_embedded_ansible_custom_button_specific_hosts(full_template_vm_modscope, custom_vm_button, ansible_credential, appliance, ansible_service_request, ansible_service): """ Polarion: assignee: sbulage casecomponent: Ansible initialEstimate: 1/4h """ with update(custom_vm_button): custom_vm_button.inventory = "Specific Hosts" custom_vm_button.hosts = full_template_vm_modscope.ip_address view = navigate_to(full_template_vm_modscope, "Details") view.toolbar.custom_button(custom_vm_button.group.text).item_select(custom_vm_button.text) order_dialog_view = appliance.browser.create_view(OrderServiceCatalogView) order_dialog_view.submit_button.wait_displayed() order_dialog_view.fields("credential").fill(ansible_credential.name) order_dialog_view.submit_button.click() wait_for(ansible_service_request.exists, num_sec=600) ansible_service_request.wait_for_request() view = navigate_to(ansible_service, "Details") hosts = view.provisioning.details.get_text_of("Hosts") assert hosts == full_template_vm_modscope.ip_address assert view.provisioning.results.get_text_of("Status") == "successful"
def test_time_profile_description_required_error_validation( appliance, soft_assert): """ This test case performs the error validation of description field. Polarion: assignee: pvala casecomponent: Settings caseimportance: medium initialEstimate: 1/8h tags: settings """ collection = appliance.collections.time_profiles time_profile = collection.instantiate(description='UTC', scope='Current User', days=True, hours=True) with update(time_profile): time_profile.description = '' view = appliance.browser.create_view(TimeProfileEditView) soft_assert(view.form.description.help_block == 'Required') soft_assert(view.form.save.disabled) view.form.cancel.click()
def test_ansible_service_cloud_credentials(appliance, request, local_ansible_catalog_item, ansible_service_catalog, credential, provider_credentials, ansible_service_funcscope, ansible_service_request_funcscope): """ When the service is viewed in my services it should also show that the Cloud Credentials were attached to the service. Bugzilla: 1444092 1515561 Polarion: assignee: sbulage casecomponent: Ansible initialEstimate: 1/4h tags: ansible_embed """ # TODO: Include all providers once all playbooks are in place. old_playbook_value = local_ansible_catalog_item.provisioning playbook = credential[2] with update(local_ansible_catalog_item): local_ansible_catalog_item.provisioning = { "playbook": playbook, "cloud_type": provider_credentials.credential_type, "cloud_credential": provider_credentials.name, } @request.addfinalizer def _revert(): with update(local_ansible_catalog_item): local_ansible_catalog_item.provisioning["playbook"] = old_playbook_value["playbook"] service_request = ansible_service_catalog.order() service_request.wait_for_request(num_sec=300, delay=20) view = navigate_to(ansible_service_funcscope, "Details") assert view.provisioning.credentials.get_text_of("Cloud") == provider_credentials.name
def test_schedule_crud(appliance, current_server_time): """ Polarion: assignee: jhenner casecomponent: Reporting initialEstimate: 1/16h caseimportance: high """ current_time, _ = current_server_time start_date = current_time + relativedelta.relativedelta(days=2) schedule = appliance.collections.system_schedules.create( name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), start_date=start_date) view = appliance.browser.create_view(BaseLoggedInPage) view.flash.assert_message('Schedule "{}" was saved'.format(schedule.name)) # test for bz 1569127 start_date_updated = start_date - relativedelta.relativedelta(days=1) updates = { 'name': fauxfactory.gen_alphanumeric(), 'description': fauxfactory.gen_alphanumeric(), } schedule.update(updates, cancel=True) view.flash.assert_message( 'Edit of Schedule "{}" was cancelled by the user'.format( schedule.name)) schedule.update(updates, reset=True) view.flash.assert_message('All changes have been reset') with update(schedule): schedule.name = fauxfactory.gen_alphanumeric() schedule.start_date = start_date_updated view.flash.assert_message('Schedule "{}" was saved'.format(schedule.name)) schedule.delete(cancel=True) schedule.delete() view.flash.assert_message('Schedule "{}": Delete successful'.format( schedule.description))
def ansible_linked_vm_action(appliance, local_ansible_catalog_item, new_vm): with update(local_ansible_catalog_item): local_ansible_catalog_item.provisioning = { "playbook": "add_single_vm_to_service.yml" } action_values = { "run_ansible_playbook": { "playbook_catalog_item": local_ansible_catalog_item.name, "inventory": { "specific_hosts": True, "hosts": new_vm.ip_address }, } } action = appliance.collections.actions.create( fauxfactory.gen_alphanumeric(15, start="action_"), action_type="Run Ansible Playbook", action_values=action_values, ) yield action action.delete_if_exists()
def test_service_ansible_playbook_crud(appliance, ansible_repository): """ Polarion: assignee: sbulage casecomponent: Ansible caseimportance: critical initialEstimate: 1/6h tags: ansible_embed """ cat_item = appliance.collections.catalog_items.create( appliance.collections.catalog_items.ANSIBLE_PLAYBOOK, fauxfactory.gen_alphanumeric(15, "cat_item"), fauxfactory.gen_alphanumeric(15, "item_disc_"), provisioning={ "repository": ansible_repository.name, "playbook": "dump_all_variables.yml", "machine_credential": "CFME Default Credential", "create_new": True, "provisioning_dialog_name": fauxfactory.gen_alphanumeric(12, start="dialog_"), }) assert cat_item.exists with update(cat_item): new_name = fauxfactory.gen_alphanumeric(15, start="edited_") cat_item.name = new_name cat_item.provisioning = {"playbook": "copy_file_example.yml"} view = navigate_to(cat_item, "Details") assert new_name in view.entities.title.text assert view.entities.provisioning.info.get_text_of( "Playbook") == "copy_file_example.yml" cat_item.delete() assert not cat_item.exists
def test_host_analysis_profile_crud(appliance, soft_assert, analysis_profile_collection): """CRUD for Host analysis profiles.""" host_profile = analysis_profile_collection.create( name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), profile_type=analysis_profile_collection.HOST_TYPE, files=files_list, events=events_check() ) view = appliance.browser.create_view( navigator.get_class(analysis_profile_collection, 'All').VIEW) host_flash = host_profile.name if appliance.version < '5.10' else host_profile.description view.flash.assert_message('Analysis Profile "{}" was saved'.format(host_flash)) assert host_profile.exists files_updates = events_check(updates=True) with update(host_profile): host_profile.files = files_updates soft_assert(host_profile.files == files_updates, 'Files update failed on profile: {}, {}' .format(host_profile.name, host_profile.files)) copied_profile = host_profile.copy(new_name='copied-{}'.format(host_profile.name)) view = appliance.browser.create_view( navigator.get_class(analysis_profile_collection, 'All').VIEW) host_copied_flash = ( copied_profile.name if appliance.version < '5.10' else copied_profile.description ) view.flash.assert_message('Analysis Profile "{}" was saved'.format(host_copied_flash)) assert copied_profile.exists copied_profile.delete() assert not copied_profile.exists host_profile.delete() view.flash.assert_success_message('Analysis Profile "{}": Delete successful'.format(host_flash)) assert not host_profile.exists
def test_embedded_ansible_custom_button_localhost(full_template_vm_modscope, custom_vm_button, appliance, service_request, service, ansible_catalog_item): """ Polarion: assignee: mmojzis initialEstimate: None """ with update(custom_vm_button): custom_vm_button.inventory = "Localhost" view = navigate_to(full_template_vm_modscope, "Details") view.toolbar.custom_button(custom_vm_button.group.text).item_select( custom_vm_button.text) order_dialog_view = appliance.browser.create_view(OrderServiceCatalogView) order_dialog_view.submit_button.wait_displayed() order_dialog_view.fields("credential").fill("CFME Default Credential") order_dialog_view.submit_button.click() wait_for(service_request.exists, num_sec=600) service_request.wait_for_request() view = navigate_to(service, "Details") hosts = view.provisioning.details.get_text_of("Hosts") assert hosts == "localhost" assert view.provisioning.results.get_text_of("Status") == "successful"
def test_action_run_ansible_playbook_target_machine( request, ansible_catalog_item, ansible_action, policy_for_testing, full_template_vm_modscope, ansible_credential, service_request, service): """Tests a policy with ansible playbook action against target machine. Polarion: assignee: dmisharo initialEstimate: 1/6h """ vm = full_template_vm_modscope with update(ansible_action): ansible_action.run_ansible_playbook = { "inventory": { "target_machine": True } } added_tag = vm.add_tag() request.addfinalizer(lambda: vm.remove_tag(added_tag)) wait_for(service_request.exists, num_sec=600) service_request.wait_for_request() view = navigate_to(service, "Details") assert view.provisioning.details.get_text_of("Hosts") == vm.ip_address assert view.provisioning.results.get_text_of("Status") == "successful"
def test_action_run_ansible_playbook_localhost( request, ansible_catalog_item, ansible_action, policy_for_testing, create_vm_modscope, ansible_credential, ansible_service_request, ansible_service): """Tests a policy with ansible playbook action against localhost. Polarion: assignee: gtalreja initialEstimate: 1/6h casecomponent: Ansible """ with update(ansible_action): ansible_action.run_ansible_playbook = { "inventory": { "localhost": True } } added_tag = create_vm_modscope.add_tag() request.addfinalizer(lambda: create_vm_modscope.remove_tag(added_tag)) wait_for(ansible_service_request.exists, num_sec=600) ansible_service_request.wait_for_request() view = navigate_to(ansible_service, "Details") assert view.provisioning.details.get_text_of("Hosts") == "localhost" assert view.provisioning.results.get_text_of("Status") == "successful"
def test_ansible_service_order_vault_credentials(appliance, request, ansible_catalog_item, ansible_service_catalog, ansible_service_request, ansible_service): """ Add vault password and test in the playbook that encrypted yml can be decrypted. Polarion: assignee: gtalreja casecomponent: Ansible initialEstimate: 1/2h tags: ansible_embed """ creds = conf.credentials['vault_creds']['password'] creds_dict = {"vault_password": creds} vault_creds = appliance.collections.ansible_credentials.create( f"Vault_Credentials_{fauxfactory.gen_alpha()}", "Vault", **creds_dict) with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "playbook": "dump_secret_variable_from_vault.yml", "vault_credential": vault_creds.name, } @request.addfinalizer def _revert(): vault_creds.delete_if_exists() ansible_service_catalog.order() ansible_service_request.wait_for_request() view = navigate_to(ansible_service, "Details") assert view.provisioning.credentials.get_text_of( "Vault") == vault_creds.name assert view.provisioning.results.get_text_of("Status") == "Finished"
def test_embed_tower_exec_play_against_amazon(request, provider, setup_provider, ansible_catalog_item, service, ansible_amazon_credential, service_catalog): with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "playbook": "list_ec2_instances.yml", "cloud_type": "Amazon", "cloud_credential": ansible_amazon_credential.name } @request.addfinalizer def _revert(): with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "playbook": "dump_all_variables.yml", "cloud_type": "<Choose>" } service_request = service_catalog.order() service_request.wait_for_request(method="ui", num_sec=300, delay=20) view = navigate_to(service, "Details") assert view.provisioning.results.get_text_of("Status") == "successful"
def test_group_crud_with_tag(a_provider, category, tag, group_collection): """Test for verifying group create with tag defined Steps: * Login as Admin user * Navigate to add group page * Fill all fields * Set tag * Save group """ group = group_collection.create( description='grp{}'.format(fauxfactory.gen_alphanumeric()), role='EvmRole-approver', tag=[category.display_name, tag.display_name], host_cluster=[a_provider.data['name']], vm_template=[a_provider.data['name'], a_provider.data['datacenters'][0], 'Discovered virtual machine'] ) with update(group): group.tag = [tag.category.display_name, tag.display_name] group.host_cluster = [a_provider.data['name']] group.vm_template = [a_provider.data['name'], a_provider.data['datacenters'][0], 'Discovered virtual machine'] group.delete()
def test_host_good_creds(appliance, request, setup_provider, provider): """ Tests host credentialing with good credentials Metadata: test_flag: inventory """ test_host = random.choice(provider.data["hosts"]) host_data = get_host_data_by_name(provider.key, test_host.name) host_collection = appliance.collections.hosts host_obj = host_collection.instantiate(name=test_host.name, provider=provider) # Remove creds after test @request.addfinalizer def _host_remove_creds(): with update(host_obj): host_obj.credentials = host.Host.Credential(principal="", secret="", verify_secret="") with update(host_obj, validate_credentials=True): host_obj.credentials = host.get_credentials_from_config( host_data['credentials'])
def test_service_ansible_execution_ttl(request, service_catalog, ansible_catalog_item, service, service_request): """Test if long running processes allowed to finish. There is a code that guarantees to have 100 retries with a minimum of 1 minute per retry. So we need to run ansible playbook service more than 100 minutes and set max ttl greater than ansible playbook running time. """ with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "playbook": "long_running_playbook.yml", "max_ttl": 200 } def _revert(): with update(ansible_catalog_item): ansible_catalog_item.provisioning = { "playbook": "dump_all_variables.yml", "max_ttl": "" } request.addfinalizer(_revert) service_catalog.order() service_request.wait_for_request(method="ui", num_sec=200 * 60, delay=120) view = navigate_to(service, "Details") assert view.provisioning.results.get_text_of("Status") == "successful"
def test_widgets_on_dashboard(appliance, request, dashboard, default_widgets, custom_widgets, soft_assert): """ Polarion: assignee: jhenner casecomponent: Reporting caseimportance: medium initialEstimate: 1/12h """ with update(dashboard): dashboard.widgets = map(lambda w: w.title, custom_widgets) def _finalize(): with update(dashboard): dashboard.widgets = default_widgets request.addfinalizer(_finalize) view = navigate_to(appliance.server, "Dashboard") view.reset_widgets() dashboard_view = view.dashboards("Default Dashboard") soft_assert(len(dashboard_view.widgets.read()) == len(custom_widgets), "Count of the widgets differ") for custom_w in custom_widgets: soft_assert(dashboard_view.widgets(custom_w.title).is_displayed, "Widget {} not found on dashboard".format(custom_w.title))
def test_alert_profile_crud(request, appliance, alert_profile_class): """ Polarion: assignee: jdupuy casecomponent: Control caseimportance: critical initialEstimate: 1/12h Bugzilla: 1723815 """ alert = appliance.collections.alerts.create( fauxfactory.gen_alphanumeric(), based_on=alert_profile_class.TYPE, timeline_event=True, driving_event="Hourly Timer") request.addfinalizer(alert.delete) alert_profile = appliance.collections.alert_profiles.create( alert_profile_class, fauxfactory.gen_alphanumeric(), alerts=[alert.description]) with update(alert_profile): alert_profile.notes = "Modified!" alert_profile.delete()
def configure_vddk(request, appliance, provider, vm): vddk_version = request.param vddk_url = conf.cfme_data.get("basic_info", {}).get("vddk_url", {}).get(vddk_version, None) if vddk_url is None: pytest.skip('Could not locate vddk url in cfme_data') else: appliance.install_vddk(vddk_url=vddk_url) view = navigate_to(vm, 'Details') host_name = view.entities.summary("Relationships").get_text_of("Host") host, = [host for host in provider.hosts.all() if host.name == host_name] host_data, = [ data for data in provider.data['hosts'] if data['name'] == host.name ] # TODO: Remove Host UI validation BZ:1718209 # host.update_credentials_rest(credentials=host_data['credentials']) host_collection = appliance.collections.hosts host_obj = host_collection.instantiate(name=host.name, provider=provider) with update(host_obj, validate_credentials=True): host_obj.credentials = { 'default': host_ui.Host.Credential.from_config( host_data['credentials']['default']) } @request.addfinalizer def _finalize(): appliance.uninstall_vddk() with update(host_obj): host_obj.credentials = { 'default': host_ui.Host.Credential(principal="", secret="", verify_secret="") }