Exemplo n.º 1
0
    def _test_distribute_agents_collision(self):
        agents = {
            'UU1D_master_0': {
                'id': 'UU1D_master_0',
                'mode': 'master',
                'ip': '10.0.0.3',
                'slave_id': 'UU1D_slave_0'
            },
            'UU1D_slave_0': {
                'id': 'UU1D_slave_0',
                'master_id': 'UU1D_master_0',
                'ip': '10.0.0.4',
                'mode': 'slave'
            },
            'UU1D_master_1': {
                'id': 'UU1D_master_1',
                'mode': 'master',
                'ip': '10.0.0.5',
                'slave_id': 'UU1D_slave_1'
            },
            'UU1D_slave_1': {
                'id': 'UU1D_slave_1',
                'master_id': 'UU1D_master_1',
                'ip': '10.0.0.6',
                'mode': 'slave'
            },
        }
        hosts = {
            'UU1D_master_0': '001',
            'UU1D_slave_0': '001',  # collides with master_0
            'UU1D_master_1': '003',
            'UU1D_slave_1': '004',
        }

        expected = {
            'UU1D_master_0': {
                'id': 'UU1D_master_0',
                'mode': 'master',
                'ip': '10.0.0.3',
                'node': '001',
                'slave_id': 'UU1D_slave_1'
            },
            'UU1D_slave_1': {
                'id': 'UU1D_slave_1',
                'master_id': 'UU1D_master_0',
                'ip': '10.0.0.6',
                'node': '004',
                'mode': 'slave'
            },
        }

        observed = deploy.distribute_agents(agents, lambda x: hosts[x])

        self.assertEqual(expected, observed)
Exemplo n.º 2
0
    def _test_distribute_agents_collision(self):
        agents = {
            'UU1D_primary_0': {
                'id': 'UU1D_primary_0',
                'mode': 'primary',
                'ip': '10.0.0.3',
                'minion_id': 'UU1D_minion_0'
            },
            'UU1D_minion_0': {
                'id': 'UU1D_minion_0',
                'primary_id': 'UU1D_primary_0',
                'ip': '10.0.0.4',
                'mode': 'minion'
            },
            'UU1D_primary_1': {
                'id': 'UU1D_primary_1',
                'mode': 'primary',
                'ip': '10.0.0.5',
                'minion_id': 'UU1D_minion_1'
            },
            'UU1D_minion_1': {
                'id': 'UU1D_minion_1',
                'primary_id': 'UU1D_primary_1',
                'ip': '10.0.0.6',
                'mode': 'minion'
            },
        }
        hosts = {
            'UU1D_primary_0': '001',
            'UU1D_minion_0': '001',  # collides with primary_0
            'UU1D_primary_1': '003',
            'UU1D_minion_1': '004',
        }

        expected = {
            'UU1D_primary_0': {
                'id': 'UU1D_primary_0',
                'mode': 'primary',
                'ip': '10.0.0.3',
                'node': '001',
                'minion_id': 'UU1D_minion_1'
            },
            'UU1D_minion_1': {
                'id': 'UU1D_minion_1',
                'primary_id': 'UU1D_primary_0',
                'ip': '10.0.0.6',
                'node': '004',
                'mode': 'minion'
            },
        }

        observed = deploy.distribute_agents(agents, lambda x: hosts[x])

        self.assertEqual(expected, observed)
Exemplo n.º 3
0
    def test_distribute_agents(self):
        agents = {
            'UU1D_master_0': {
                'id': 'UU1D_master_0',
                'mode': 'master',
                'ip': '10.0.0.3',
                'slave_id': 'UU1D_slave_0'
            },
            'UU1D_slave_0': {
                'id': 'UU1D_slave_0',
                'master_id': 'UU1D_master_0',
                'ip': '10.0.0.4',
                'mode': 'slave'
            },
            'UU1D_master_1': {
                'id': 'UU1D_master_1',
                'mode': 'master',
                'ip': '10.0.0.5',
                'slave_id': 'UU1D_slave_1'
            },
            'UU1D_slave_1': {
                'id': 'UU1D_slave_1',
                'master_id': 'UU1D_master_1',
                'ip': '10.0.0.6',
                'mode': 'slave'
            },
        }
        hosts = {
            'UU1D_master_0': '001',
            'UU1D_slave_0': '002',
            'UU1D_master_1': '003',
            'UU1D_slave_1': '004',
        }

        expected = copy.deepcopy(agents)
        for k, v in hosts.items():
            expected[k]['node'] = v

        observed = deploy.distribute_agents(agents, lambda x: hosts[x])

        # expected no changes
        self.assertEqual(agents, observed)