예제 #1
0
 def test_start_new_vm(self):
     """
     Tests starting a new VM.
     """
     ret = {}
     ret["stderr"] = "vmctl: started vm 4 successfully, tty /dev/ttyp4"
     ret["retcode"] = 0
     mock_cmd = MagicMock(return_value=ret)
     mock_status = MagicMock(return_value={})
     expected = {"changes": True, "console": "/dev/ttyp4"}
     with patch.dict(vmctl.__salt__, {"cmd.run_all": mock_cmd}):
         with patch("salt.modules.vmctl.status", mock_status):
             res = vmctl.start("web1",
                               bootpath="/bsd.rd",
                               nics=2,
                               disk="/disk.img")
             mock_cmd.assert_called_once_with(
                 [
                     "vmctl",
                     "start",
                     "web1",
                     "-i 2",
                     "-b",
                     "/bsd.rd",
                     "-d",
                     "/disk.img",
                 ],
                 output_loglevel="trace",
                 python_shell=False,
             )
             self.assertDictEqual(expected, res)
예제 #2
0
 def test_start_existing_vm(self):
     '''
     Tests starting a VM that is already defined.
     '''
     ret = {}
     ret['stderr'] = 'vmctl: started vm 4 successfully, tty /dev/ttyp4'
     ret['retcode'] = 0
     mock_cmd = MagicMock(return_value=ret)
     expected = {'changes': True, 'console': '/dev/ttyp4'}
     with patch.dict(vmctl.__salt__, {'cmd.run_all': mock_cmd}):
         self.assertDictEqual(expected, vmctl.start('4'))
예제 #3
0
 def test_start_existing_vm(self):
     """
     Tests starting a VM that is already defined.
     """
     ret = {}
     ret["stderr"] = "vmctl: started vm 4 successfully, tty /dev/ttyp4"
     ret["retcode"] = 0
     mock_cmd = MagicMock(return_value=ret)
     expected = {"changes": True, "console": "/dev/ttyp4"}
     with patch.dict(vmctl.__salt__, {"cmd.run_all": mock_cmd}):
         self.assertDictEqual(expected, vmctl.start("4"))
예제 #4
0
 def test_start_new_vm(self):
     '''
     Tests starting a new VM.
     '''
     ret = {}
     ret['stderr'] = 'vmctl: started vm 4 successfully, tty /dev/ttyp4'
     ret['retcode'] = 0
     mock_cmd = MagicMock(return_value=ret)
     mock_status = MagicMock(return_value={})
     expected = {'changes': True, 'console': '/dev/ttyp4'}
     with patch.dict(vmctl.__salt__, {'cmd.run_all': mock_cmd}):
         with patch('salt.modules.vmctl.status', mock_status):
             res = vmctl.start('web1',
                               bootpath='/bsd.rd',
                               nics=2,
                               disk='/disk.img')
             mock_cmd.assert_called_once_with([
                 'vmctl', 'start', 'web1', '-i 2', '-b', '/bsd.rd', '-d',
                 '/disk.img'
             ],
                                              output_loglevel='trace',
                                              python_shell=False)
             self.assertDictEqual(expected, res)