Example #1
0
 def test_host_fields_with_err(self):
     """Test the method host_fields with error."""
     host_field_url = 'https://{sat_host}:{port}/api/v2/hosts/{host_id}'
     with requests_mock.Mocker() as mocker:
         url = construct_url(url=host_field_url, sat_host='1.2.3.4',
                             host_id=1)
         mocker.get(url, status_code=500)
         with self.assertRaises(SatelliteException):
             host_fields(self.scan_task, 2, host_field_url, None, 1)
Example #2
0
 def test_host_fields(self):
     """Test the method host_fields."""
     host_field_url = 'https://{sat_host}:{port}/api/v2/hosts/{host_id}'
     with requests_mock.Mocker() as mocker:
         url = construct_url(url=host_field_url,
                             sat_host='1.2.3.4',
                             host_id=1)
         jsonresult = {
             'architecture_id': 1,
             'architecture_name': 'x86_64',
             'operatingsystem_name': 'RedHat 7.4',
             'uuid': None,
             'created_at': '2017-12-04 13:19:57 UTC',
             'updated_at': '2017-12-04 13:21:47 UTC',
             'organization_name': 'ACME',
             'location_name': 'Raleigh',
             'name': 'mac52540071bafe.prov.lan',
             'virtual_host': {
                 'uuid': '100',
                 'name': 'vhost1'
             },
             'virtual_guests': [{
                 'name': 'foo'
             }],
             'content_facet_attributes': {
                 'id': 11,
                 'katello_agent_installed': False
             },
             'subscription_facet_attributes': {
                 'uuid': '00c7a108-48ec-4a97-835c-aa3369777f64',
                 'last_checkin': '2018-01-04 17:36:07 UTC',
                 'registered_at': '2017-12-04 13:33:52 UTC',
                 'registered_by': 'sat-r220-07.lab.eng.rdu2.redhat.com',
                 'virtual_host': {
                     'uuid': '100',
                     'name': 'vhost1'
                 },
                 'virtual_guests': [{
                     'name': 'foo'
                 }],
             },
             'facts': {
                 'memorysize_mb': '992.45',
                 'memorysize': '992.45 MB',
                 'hostname': 'fdi',
                 'type': 'Other',
                 'architecture': 'x86_64',
                 'is_virtual': 'true',
                 'virtual': 'kvm',
                 'net::interface::ipv4_address': '192.168.99.123',
                 'net::interface::mac_address': 'fe80::5054:ff:fe24:946e',
             },
         }
         mocker.get(url, status_code=200, json=jsonresult)
         host_info = host_fields(2, jsonresult)
         expected = {
             'uuid': '00c7a108-48ec-4a97-835c-aa3369777f64',
             'hostname': 'mac52540071bafe.prov.lan',
             'registered_by': 'sat-r220-07.lab.eng.rdu2.redhat.com',
             'registration_time': '2017-12-04 13:33:52 UTC',
             'last_checkin_time': '2018-01-04 17:36:07 UTC',
             'katello_agent_installed': False,
             'os_release': 'RedHat 7.4',
             'organization': 'ACME',
             'virtual_host_uuid': '100',
             'virtual_host_name': 'vhost1',
             'virt_type': None,
             'kernel_version': None,
             'architecture': None,
             'is_virtualized': None,
             'cores': None,
             'num_sockets': None,
             'num_virtual_guests': 1,
             'virtual': 'hypervisor',
             'location': 'Raleigh',
             'ip_addresses': ['192.168.99.123'],
             'mac_addresses': ['fe80::5054:ff:fe24:946e'],
             'os_name': 'RedHat',
             'os_version': '7.4'
         }
         self.assertEqual(host_info, expected)