Esempio n. 1
0
    def test_70_contextualize_vm(self, test_connectivity):
        ctxt_agent = CtxtAgent(None)
        ctxt_agent.logger = self.logger
        ctxt_agent.changeVMCredentials = MagicMock()
        ctxt_agent.changeVMCredentials.return_value = True
        ctxt_agent.LaunchAnsiblePlaybook = MagicMock()
        queue = MagicMock()
        queue.get.return_value = None, 0, None
        ctxt_agent.LaunchAnsiblePlaybook.return_value = (MagicMock(), queue)
        ctxt_agent.wait_winrm_access = MagicMock()
        ctxt_agent.wait_winrm_access.return_value = True
        ctxt_agent.wait_ssh_access = MagicMock()
        ctxt_agent.wait_ssh_access.return_value = 'init'
        ctxt_agent.removeRequiretty = MagicMock()
        ctxt_agent.removeRequiretty.return_value = True

        res = ctxt_agent.contextualize_vm(self.gen_general_conf(),
                                          self.gen_vm_conf(["basic"]))
        expected_res = {
            'SSH_WAIT': True,
            'OK': True,
            'CHANGE_CREDS': True,
            'basic': True
        }
        self.assertEqual(res, expected_res)

        res = ctxt_agent.contextualize_vm(self.gen_general_conf(),
                                          self.gen_vm_conf(["main", "front"]))
        expected_res = {'OK': True, 'front': True, 'main': True}
        self.assertEqual(res, expected_res)
Esempio n. 2
0
 def test_30_removeRequiretty(self, execute_timeout):
     execute_timeout.return_value = "", "", 0
     vm = self.gen_vm_data()
     vm['ctxt_ip'] = "10.0.0.1"
     vm['ctxt_port'] = 22
     ctxt_agent = CtxtAgent(None)
     ctxt_agent.logger = self.logger
     res = ctxt_agent.removeRequiretty(vm, None)
     self.assertTrue(res)
Esempio n. 3
0
 def test_30_removeRequiretty(self, execute_timeout):
     CtxtAgent.logger = self.logger
     execute_timeout.return_value = "", "", 0
     vm = self.gen_vm_data()
     res = CtxtAgent.removeRequiretty(vm, None)
     self.assertTrue(res)