def test_positive_proxy_option(self): """ Verify http_proxy option by hammer virt-who-config update" :id: becd00f7-e140-481a-9249-8a3082297a4b :expectedresults: http_proxy and no_proxy option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ name = gen_string('alpha') args = self._make_virtwho_configure() args.update({'name': name}) vhd = VirtWhoConfig.create(args)['general-information'] http_proxy = 'test.example.com:3128' no_proxy = 'test.satellite.com' VirtWhoConfig.update({ 'id': vhd['id'], 'proxy': http_proxy, 'no-proxy': no_proxy, }) result = VirtWhoConfig.info({'id': vhd['id']}) self.assertEqual(result['connection']['http-proxy'], http_proxy) self.assertEqual(result['connection']['ignore-proxy'], no_proxy) command = get_configure_command(vhd['id']) deploy_configure_by_command(command) self.assertEqual(get_configure_option('http_proxy', VIRTWHO_SYSCONFIG), http_proxy) self.assertEqual(get_configure_option('NO_PROXY', VIRTWHO_SYSCONFIG), no_proxy) VirtWhoConfig.delete({'name': name}) self.assertFalse(VirtWhoConfig.exists(search=('name', name)))
def test_positive_debug_option(self, default_org, form_data, virtwho_config): """Verify debug option by hammer virt-who-config update" :id: c98bc518-828c-49ba-a644-542db3190263 :expectedresults: debug option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ assert virtwho_config['name'] == form_data['name'] new_name = gen_string('alphanumeric') VirtWhoConfig.update({ 'id': virtwho_config['id'], 'new-name': new_name }) virt_who_instance_name = VirtWhoConfig.info( {'id': virtwho_config['id']})['general-information']['name'] assert virt_who_instance_name == new_name options = {'true': '1', 'false': '0', 'yes': '1', 'no': '0'} for key, value in sorted(options.items(), key=lambda item: item[0]): VirtWhoConfig.update({'id': virtwho_config['id'], 'debug': key}) command = get_configure_command(virtwho_config['id'], default_org.name) deploy_configure_by_command(command, form_data['hypervisor-type'], org=default_org.label) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == value VirtWhoConfig.delete({'name': new_name}) assert not VirtWhoConfig.exists(search=('name', new_name))
def test_positive_deploy_configure_by_script(self, form_data, virtwho_config): """ Verify " hammer virt-who-config fetch" :id: ef0f1e33-7084-4d0e-95f1-d3080dfbb4cc :expectedresults: Config can be created, fetch and deploy :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' script = VirtWhoConfig.fetch({'id': virtwho_config['id']}, output_format='base') hypervisor_name, guest_name = deploy_configure_by_script(script, debug=True) virt_who_instance = VirtWhoConfig.info({'id': virtwho_config['id']})[ 'general-information' ]['status'] assert virt_who_instance == 'OK' hosts = [ (hypervisor_name, f'product_id={settings.virtwho.sku_vdc_physical} and type=NORMAL'), (guest_name, f'product_id={settings.virtwho.sku_vdc_physical} and type=STACK_DERIVED'), ] for hostname, sku in hosts: host = Host.list({'search': hostname})[0] subscriptions = Subscription.list({'organization': DEFAULT_ORG, 'search': sku}) vdc_id = subscriptions[0]['id'] if 'type=STACK_DERIVED' in sku: for item in subscriptions: if hypervisor_name.lower() in item['type']: vdc_id = item['id'] break result = Host.subscription_attach({'host-id': host['id'], 'subscription-id': vdc_id}) assert 'attached to the host successfully' in '\n'.join(result) VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_hypervisor_id_option(self, form_data, virtwho_config): """Verify hypervisor_id option by hammer virt-who-config update" :id: 8e234492-33cb-4523-abb3-582626ad704c :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ values = ['uuid', 'hostname'] for value in values: VirtWhoConfig.update({ 'id': virtwho_config['id'], 'hypervisor-id': value }) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['hypervisor-id'] == value config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('hypervisor_id', config_file) == value VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_debug_option(self): """ Verify debug option by hammer virt-who-config update" :id: 27ae5606-16a8-4b4a-9596-e0fa97e81c0d :expectedresults: debug option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ name = gen_string('alpha') new_name = gen_string('alphanumeric') args = self._make_virtwho_configure() args.update({'name': name}) vhd = VirtWhoConfig.create(args)['general-information'] self.assertEqual(vhd['name'], name) VirtWhoConfig.update({'id': vhd['id'], 'new-name': new_name}) self.assertEqual( VirtWhoConfig.info({'id': vhd['id']})['general-information']['name'], new_name) options = {'true': '1', 'false': '0', 'yes': '1', 'no': '0'} for key, value in sorted(options.items(), key=lambda item: item[0]): VirtWhoConfig.update({'id': vhd['id'], 'debug': key}) command = get_configure_command(vhd['id']) deploy_configure_by_command(command) self.assertEqual( get_configure_option('VIRTWHO_DEBUG', VIRTWHO_SYSCONFIG), value) VirtWhoConfig.delete({'name': new_name}) self.assertFalse(VirtWhoConfig.exists(search=('name', name)))
def test_positive_hypervisor_id_option(self, default_org, form_data, virtwho_config): """Verify hypervisor_id option by hammer virt-who-config update" :id: 57b89c7e-538e-4ab8-98b5-af4b9f587792 :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ values = ['uuid', 'hostname'] for value in values: VirtWhoConfig.update({ 'id': virtwho_config['id'], 'hypervisor-id': value }) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['hypervisor-id'] == value config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id'], default_org.name) deploy_configure_by_command(command, form_data['hypervisor-type'], org=default_org.label) assert get_configure_option('hypervisor_id', config_file) == value VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_foreman_packages_protection(self, form_data, virtwho_config): """foreman-protector should allow virt-who to be installed :id: 635ef99b-c5a3-4ac4-a0f1-09f7036d116e :expectedresults: virt-who packages can be installed the virt-who plugin can be deployed successfully :CaseLevel: Integration :customerscenario: true :CaseImportance: Medium :BZ: 1783987 """ virtwho_package_locked() command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command, form_data['hypervisor-type']) virt_who_instance = VirtWhoConfig.info( {'id': virtwho_config['id']})['general-information']['status'] assert virt_who_instance == 'OK' VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_deploy_configure_by_id(self, form_data, virtwho_config): """ Verify " hammer virt-who-config deploy" :id: 19ffe76e-7e3d-48c7-b846-10a83afe0f3e :expectedresults: Config can be created and deployed :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' command = get_configure_command(virtwho_config['id']) hypervisor_name, guest_name = deploy_configure_by_command(command, debug=True) virt_who_instance = VirtWhoConfig.info({'id': virtwho_config['id']})[ 'general-information' ]['status'] assert virt_who_instance == 'OK' hosts = [ (hypervisor_name, f'product_id={settings.virtwho.sku_vdc_physical} and type=NORMAL'), (guest_name, f'product_id={settings.virtwho.sku_vdc_physical} and type=STACK_DERIVED'), ] for hostname, sku in hosts: host = Host.list({'search': hostname})[0] subscriptions = Subscription.list({'organization': DEFAULT_ORG, 'search': sku}) vdc_id = subscriptions[0]['id'] if 'type=STACK_DERIVED' in sku: for item in subscriptions: if hypervisor_name.lower() in item['type']: vdc_id = item['id'] break result = Host.subscription_attach({'host-id': host['id'], 'subscription-id': vdc_id}) assert 'attached to the host successfully' in '\n'.join(result) VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_proxy_option(self, form_data, virtwho_config): """Verify http_proxy option by hammer virt-who-config update" :id: 409d108e-e814-482b-93ed-09db89d21dda :expectedresults: http_proxy and no_proxy option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ http_proxy = 'test.example.com:3128' no_proxy = 'test.satellite.com' VirtWhoConfig.update({ 'id': virtwho_config['id'], 'proxy': http_proxy, 'no-proxy': no_proxy }) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['http-proxy'] == http_proxy assert result['connection']['ignore-proxy'] == no_proxy command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('http_proxy', VIRTWHO_SYSCONFIG) == http_proxy assert get_configure_option('NO_PROXY', VIRTWHO_SYSCONFIG) == no_proxy VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_hypervisor_id_option(self): """ Verify hypervisor_id option by hammer virt-who-config update" :id: eae7e767-8a71-424c-87da-475c91ac2ea1 :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ name = gen_string('alpha') args = self._make_virtwho_configure() args.update({'name': name}) vhd = VirtWhoConfig.create(args)['general-information'] values = ['uuid', 'hostname'] if self.hypervisor_type in ('esx', 'rhevm'): values.append('hwuuid') for value in values: VirtWhoConfig.update({'id': vhd['id'], 'hypervisor-id': value}) result = VirtWhoConfig.info({'id': vhd['id']}) self.assertEqual(result['connection']['hypervisor-id'], value) config_file = get_configure_file(vhd['id']) command = get_configure_command(vhd['id']) deploy_configure_by_command(command) self.assertEqual( get_configure_option('hypervisor_id', config_file), value) VirtWhoConfig.delete({'name': name}) self.assertFalse(VirtWhoConfig.exists(search=('name', name)))
def test_positive_hypervisor_id_option(self, form_data, virtwho_config): """Verify hypervisor_id option by hammer virt-who-config update" :id: 4e6bad11-2019-458b-a368-26ea95afc7f5 :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ # esx and rhevm support hwuuid option values = ['uuid', 'hostname', 'hwuuid'] for value in values: VirtWhoConfig.update({ 'id': virtwho_config['id'], 'hypervisor-id': value }) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['hypervisor-id'] == value config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('hypervisor_id', config_file) == value VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_debug_option(self, form_data, virtwho_config): """ Verify debug option by hammer virt-who-config update" :id: 27ae5606-16a8-4b4a-9596-e0fa97e81c0d :expectedresults: debug option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ assert virtwho_config['name'] == form_data['name'] new_name = gen_string('alphanumeric') VirtWhoConfig.update({'id': virtwho_config['id'], 'new-name': new_name}) virt_who_instance_name = VirtWhoConfig.info({'id': virtwho_config['id']})[ 'general-information' ]['name'] assert virt_who_instance_name == new_name options = {'true': '1', 'false': '0', 'yes': '1', 'no': '0'} for key, value in sorted(options.items(), key=lambda item: item[0]): VirtWhoConfig.update({'id': virtwho_config['id'], 'debug': key}) command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command) assert get_configure_option('VIRTWHO_DEBUG', VIRTWHO_SYSCONFIG), value VirtWhoConfig.delete({'name': new_name}) assert not VirtWhoConfig.exists(search=('name', new_name))
def test_positive_proxy_option(self, form_data, virtwho_config): """Verify http_proxy option by hammer virt-who-config update" :id: 409d108e-e814-482b-93ed-09db89d21dda :expectedresults: http_proxy and no_proxy option can be updated. :CaseLevel: Integration :CaseImportance: Medium :BZ: 1902199 """ # Check the https proxy option, update it via http proxy name https_proxy_url, https_proxy_name, https_proxy_id = create_http_proxy() no_proxy = 'test.satellite.com' VirtWhoConfig.update( {'id': virtwho_config['id'], 'http-proxy': https_proxy_name, 'no-proxy': no_proxy} ) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['http-proxy']['http-proxy-name'] == https_proxy_name assert result['connection']['ignore-proxy'] == no_proxy command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('https_proxy', VIRTWHO_SYSCONFIG) == https_proxy_url assert get_configure_option('NO_PROXY', VIRTWHO_SYSCONFIG) == no_proxy # Check the http proxy option, update it via http proxy id http_proxy_url, http_proxy_name, http_proxy_id = create_http_proxy(type='http') VirtWhoConfig.update({'id': virtwho_config['id'], 'http-proxy-id': http_proxy_id}) deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('http_proxy', VIRTWHO_SYSCONFIG) == http_proxy_url VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_post_crud_virt_who_configuration(self): """Virt-who config is intact post upgrade and verify the config can be updated and deleted. :id: postupgrade-d7ae7b2b-3291-48c8-b412-cb54e444c7a4 :steps: 1. Post upgrade, Verify virt-who exists and has same status. 2. Verify the connection of the guest on Content host. 3. Verify the virt-who config-file exists. 4. Update virt-who config with new name. 5. Delete virt-who config. :expectedresults: 1. virt-who config is intact post upgrade. 2. the config and guest connection have the same status. 3. virt-who config should update and delete successfully. """ org = entities.Organization().search(query={'search': 'name={0}'.format(self.org_name)})[0] # Post upgrade, Verify virt-who exists and has same status. vhd = entities.VirtWhoConfig(organization_id=org.id).search( query={'search': 'name={}'.format(self.name)} )[0] if not is_open('BZ:1802395'): self.assertEqual(vhd.status, 'ok') # Verify virt-who status via CLI as we cannot check it via API now vhd_cli = VirtWhoConfig.exists(search=('name', self.name)) self.assertEqual( VirtWhoConfig.info({'id': vhd_cli['id']})['general-information']['status'], 'OK' ) # Vefify the connection of the guest on Content host entity_data = get_entity_data(self.__class__.__name__) hypervisor_name = entity_data.get('hypervisor_name') guest_name = entity_data.get('guest_name') hosts = [hypervisor_name, guest_name] for hostname in hosts: result = ( entities.Host(organization=org.id) .search(query={'search': hostname})[0] .read_json() ) self.assertEqual(result['subscription_status_label'], 'Fully entitled') # Verify the virt-who config-file exists. config_file = get_configure_file(vhd.id) get_configure_option('hypervisor_id', config_file), # Update virt-who config modify_name = gen_string('alpha') vhd.name = modify_name vhd.update(['name']) # Delete virt-who config vhd.delete() self.assertFalse( entities.VirtWhoConfig(organization_id=org.id).search( query={'search': 'name={}'.format(modify_name)} ) )
def test_positive_filter_option(self, form_data, virtwho_config): """ Verify filter option by hammer virt-who-config update" :id: f46e4aa8-c325-4281-8744-f85e819e68c1 :expectedresults: filter and filter_hosts can be updated. :CaseLevel: Integration :CaseImportance: Medium """ regex = '.*redhat.com' whitelist = {'id': virtwho_config['id'], 'filtering-mode': 'whitelist', 'whitelist': regex} blacklist = {'id': virtwho_config['id'], 'filtering-mode': 'blacklist', 'blacklist': regex} if settings.virtwho.hypervisor_type == 'esx': whitelist['filter-host-parents'] = regex blacklist['exclude-host-parents'] = regex config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) # Update Whitelist and check the result VirtWhoConfig.update(whitelist) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['filtering'] == 'Whitelist' assert result['connection']['filtered-hosts'] == regex if settings.virtwho.hypervisor_type == 'esx': assert result['connection']['filter-host-parents'] == regex deploy_configure_by_command(command) assert get_configure_option('filter_hosts', config_file) == regex if settings.virtwho.hypervisor_type == 'esx': assert get_configure_option('filter_host_parents', config_file) == regex # Update Blacklist and check the result VirtWhoConfig.update(blacklist) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['filtering'] == 'Blacklist' assert result['connection']['excluded-hosts'] == regex if settings.virtwho.hypervisor_type == 'esx': assert result['connection']['exclude-host-parents'] == regex deploy_configure_by_command(command) assert get_configure_option('exclude_hosts', config_file) == regex if settings.virtwho.hypervisor_type == 'esx': assert get_configure_option('exclude_host_parents', config_file) == regex VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def get_configure_id(name): """Return the configure id by hammer. :param str name: the configure name you have created. :raises: VirtWhoError: If failed to get the configure info by hammer. """ config = VirtWhoConfig.info({'name': name}) if 'id' in config['general-information']: return config['general-information']['id'] else: raise VirtWhoError("No configure id found for {}".format(name))
def test_positive_deploy_configure_by_script(self, default_org, form_data, virtwho_config): """Verify " hammer virt-who-config fetch" :id: 6aaffaeb-aaf2-42cf-b0dc-ca41a53d42a6 :expectedresults: Config can be created, fetch and deploy :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' script = VirtWhoConfig.fetch({'id': virtwho_config['id']}, output_format='base') hypervisor_name, guest_name = deploy_configure_by_script( script, form_data['hypervisor-type'], debug=True, org=default_org.label) virt_who_instance = VirtWhoConfig.info( {'id': virtwho_config['id']})['general-information']['status'] assert virt_who_instance == 'OK' hosts = [ ( hypervisor_name, f'product_id={settings.virtwho.sku.vdc_physical} and type=NORMAL', ), ( guest_name, f'product_id={settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED', ), ] for hostname, sku in hosts: host = Host.list({'search': hostname})[0] subscriptions = Subscription.list({ 'organization': default_org.name, 'search': sku }) vdc_id = subscriptions[0]['id'] if 'type=STACK_DERIVED' in sku: for item in subscriptions: if hypervisor_name.lower() in item['type']: vdc_id = item['id'] break result = Host.subscription_attach({ 'host-id': host['id'], 'subscription-id': vdc_id }) assert result.strip( ) == 'Subscription attached to the host successfully.' VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_filter_option(self, form_data, virtwho_config): """Verify filter option by hammer virt-who-config update" :id: aaf45c5e-9504-47ce-8f25-b8073c2de036 :expectedresults: filter and filter_hosts can be updated. :CaseLevel: Integration :CaseImportance: Medium """ regex = '.*redhat.com' whitelist = {'id': virtwho_config['id'], 'filtering-mode': 'whitelist', 'whitelist': regex} blacklist = {'id': virtwho_config['id'], 'filtering-mode': 'blacklist', 'blacklist': regex} # esx support filter-host-parents and exclude-host-parents options whitelist['filter-host-parents'] = regex blacklist['exclude-host-parents'] = regex config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) # Update Whitelist and check the result VirtWhoConfig.update(whitelist) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['filtering'] == 'Whitelist' assert result['connection']['filtered-hosts'] == regex assert result['connection']['filter-host-parents'] == regex deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('filter_hosts', config_file) == regex assert get_configure_option('filter_host_parents', config_file) == regex # Update Blacklist and check the result VirtWhoConfig.update(blacklist) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['filtering'] == 'Blacklist' assert result['connection']['excluded-hosts'] == regex assert result['connection']['exclude-host-parents'] == regex deploy_configure_by_command(command, form_data['hypervisor-type']) assert get_configure_option('exclude_hosts', config_file) == regex assert get_configure_option('exclude_host_parents', config_file) == regex VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_deploy_configure_by_id(self, default_org, form_data, virtwho_config): """Verify " hammer virt-who-config deploy" :id: e66bf88a-bd4e-409a-91a8-bc5e005d95dd :expectedresults: Config can be created and deployed :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' command = get_configure_command(virtwho_config['id'], default_org.name) hypervisor_name, guest_name = deploy_configure_by_command( command, form_data['hypervisor-type'], debug=True, org=default_org.label) virt_who_instance = VirtWhoConfig.info( {'id': virtwho_config['id']})['general-information']['status'] assert virt_who_instance == 'OK' hosts = [ (hypervisor_name, f'product_id={settings.virtwho.sku.vdc_physical} and type=NORMAL' ), (guest_name, f'product_id={settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' ), ] for hostname, sku in hosts: host = Host.list({'search': hostname})[0] subscriptions = Subscription.list({ 'organization': default_org.name, 'search': sku }) vdc_id = subscriptions[0]['id'] if 'type=STACK_DERIVED' in sku: for item in subscriptions: if hypervisor_name.lower() in item['type']: vdc_id = item['id'] break result = Host.subscription_attach({ 'host-id': host['id'], 'subscription-id': vdc_id }) assert result.strip( ) == 'Subscription attached to the host successfully.' VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_deploy_configure_by_id(self): """ Verify " hammer virt-who-config deploy" :id: 19ffe76e-7e3d-48c7-b846-10a83afe0f3e :expectedresults: Config can be created and deployed :CaseLevel: Integration :CaseImportance: High """ name = gen_string('alpha') args = self._make_virtwho_configure() args.update({'name': name}) vhd = VirtWhoConfig.create(args)['general-information'] self.assertEqual(vhd['status'], 'No Report Yet') command = get_configure_command(vhd['id']) hypervisor_name, guest_name = deploy_configure_by_command(command, debug=True) self.assertEqual( VirtWhoConfig.info({'id': vhd['id']})['general-information']['status'], 'OK') hosts = [ (hypervisor_name, 'product_id={} and type=NORMAL'.format(self.vdc_physical)), (guest_name, 'product_id={} and type=STACK_DERIVED'.format(self.vdc_physical)) ] for hostname, sku in hosts: host = Host.list({'search': hostname})[0] subscriptions = Subscription.list({ 'organization': DEFAULT_ORG, 'search': sku, }) vdc_id = subscriptions[0]['id'] if 'type=STACK_DERIVED' in sku: for item in subscriptions: if hypervisor_name.lower() in item['type']: vdc_id = item['id'] break result = Host.subscription_attach({ 'host-id': host['id'], 'subscription-id': vdc_id }) self.assertTrue( 'attached to the host successfully' in '\n'.join(result)) VirtWhoConfig.delete({'name': name}) self.assertFalse(VirtWhoConfig.exists(search=('name', name)))
def test_positive_hypervisor_id_option(self, form_data, virtwho_config): """ Verify hypervisor_id option by hammer virt-who-config update" :id: eae7e767-8a71-424c-87da-475c91ac2ea1 :expectedresults: hypervisor_id option can be updated. :CaseLevel: Integration :CaseImportance: Medium """ values = ['uuid', 'hostname'] if settings.virtwho.hypervisor_type in ('esx', 'rhevm'): values.append('hwuuid') for value in values: VirtWhoConfig.update({'id': virtwho_config['id'], 'hypervisor-id': value}) result = VirtWhoConfig.info({'id': virtwho_config['id']}) assert result['connection']['hypervisor-id'] == value config_file = get_configure_file(virtwho_config['id']) command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command) assert get_configure_option('hypervisor_id', config_file) == value VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_foreman_packages_protection(self, form_data, virtwho_config): """foreman-protector should allow virt-who to be installed :id: 73dc895f-50b8-4de5-91de-ea55da935fe5 :expectedresults: virt-who packages can be installed the virt-who plugin can be deployed successfully :CaseLevel: Integration :CaseImportance: Medium :BZ: 1783987 """ virtwho_package_locked() command = get_configure_command(virtwho_config['id']) deploy_configure_by_command(command) virt_who_instance = VirtWhoConfig.info({'id': virtwho_config['id']})[ 'general-information' ]['status'] assert virt_who_instance == 'OK' VirtWhoConfig.delete({'name': virtwho_config['name']}) assert not VirtWhoConfig.exists(search=('name', form_data['name']))
def test_positive_filter_option(self): """ Verify filter option by hammer virt-who-config update" :id: f46e4aa8-c325-4281-8744-f85e819e68c1 :expectedresults: filter and filter_hosts can be updated. :CaseLevel: Integration :CaseImportance: Medium """ name = gen_string('alpha') args = self._make_virtwho_configure() args.update({'name': name}) vhd = VirtWhoConfig.create(args)['general-information'] regex = '.*redhat.com' whitelist = { 'id': vhd['id'], 'filtering-mode': 'whitelist', 'whitelist': regex, } blacklist = { 'id': vhd['id'], 'filtering-mode': 'blacklist', 'blacklist': regex, } if self.hypervisor_type == 'esx': whitelist['filter-host-parents'] = regex blacklist['exclude-host-parents'] = regex config_file = get_configure_file(vhd['id']) command = get_configure_command(vhd['id']) # Update Whitelist and check the result VirtWhoConfig.update(whitelist) result = VirtWhoConfig.info({'id': vhd['id']}) self.assertEqual(result['connection']['filtering'], 'Whitelist') self.assertEqual(result['connection']['filtered-hosts'], regex) if self.hypervisor_type == 'esx': self.assertEqual(result['connection']['filter-host-parents'], regex) deploy_configure_by_command(command) self.assertEqual(get_configure_option('filter_hosts', config_file), regex) if self.hypervisor_type == 'esx': self.assertEqual( get_configure_option('filter_host_parents', config_file), regex) # Update Blacklist and check the result VirtWhoConfig.update(blacklist) result = VirtWhoConfig.info({'id': vhd['id']}) self.assertEqual(result['connection']['filtering'], 'Blacklist') self.assertEqual(result['connection']['excluded-hosts'], regex) if self.hypervisor_type == 'esx': self.assertEqual(result['connection']['exclude-host-parents'], regex) deploy_configure_by_command(command) self.assertEqual(get_configure_option('exclude_hosts', config_file), regex) if self.hypervisor_type == 'esx': self.assertEqual( get_configure_option('exclude_host_parents', config_file), regex) VirtWhoConfig.delete({'name': name}) self.assertFalse(VirtWhoConfig.exists(search=('name', name)))