def test_reg_and_retieve_multi(self, m_get_ip, m_gethost): m_get_ip.return_value = '1.2.3.4' m_gethost.return_value = 'test-hostname' # register local host group. start.register_group_and_hostvars(self.client) # dummy external host registration. remote = {'ansible_eth0': {'ipv4': {'address': '4.4.4.4'}}, 'ansible_eth1': {'ipv4': {'address': '4.4.4.4'}}, 'ansible_hostname': 'the-other-host', 'api_interface': 'eth2', 'role': 'testr', 'id': '55'} party.Party(self.client, '/kolla/deploy_id/groups/testr', json.dumps(remote)).join() # make sure this function gets both hosts information. groups, hostvars = start.get_groups_and_hostvars(self.client) self.assertEqual(sorted(['1.2.3.4', '4.4.4.4']), sorted(groups['testr'])) exp_local = {'ansible_eth1': {'ipv4': {'address': '1.2.3.4'}}, 'ansible_eth2': {'ipv4': {'address': '1.2.3.4'}}, 'ansible_hostname': 'test-hostname', 'api_interface': 'eth2', 'role': 'testr', 'id': '1'} self.assertEqual(exp_local, hostvars['1.2.3.4']) self.assertEqual(remote, hostvars['4.4.4.4'])
def test_reg_and_retieve_single(self, m_get_ip, m_gethost): m_get_ip.return_value = '1.2.3.4' m_gethost.return_value = 'test-hostname' start.register_group_and_hostvars(self.client) groups, hostvars = start.get_groups_and_hostvars(self.client) self.assertEqual({'testg': ['1.2.3.4']}, groups) exp = {'ansible_eth0': {'ipv4': {'address': '1.2.3.4'}}, 'ansible_eth1': {'ipv4': {'address': '1.2.3.4'}}, 'ansible_hostname': 'test-hostname', 'role': 'testr', 'id': '1'} self.assertEqual(exp, hostvars['1.2.3.4'])