Exemplo n.º 1
0
 def test_register_vm_host_task_call(self):
     vmware.register_vm(self.datacenter,
                        self.vm_name,
                        self.mock_vmx_path,
                        self.mock_resourcepool_object,
                        host_object=self.mock_host_object)
     self.mock_vm_register_task.assert_called_once()
Exemplo n.º 2
0
 def test_register_vm_wait_for_task(self):
     mock_wait_for_task = MagicMock()
     with patch('salt.utils.vmware.wait_for_task', mock_wait_for_task):
         vmware.register_vm(self.datacenter, self.vm_name,
                            self.mock_vmx_path,
                            self.mock_resourcepool_object)
     mock_wait_for_task.assert_called_once_with(self.mock_task,
                                                self.vm_name,
                                                'RegisterVM Task')
Exemplo n.º 3
0
 def test_register_vm_raise_runtime_fault(self):
     exception = vmodl.RuntimeFault()
     exception.msg = 'vmodl.RuntimeFault msg'
     self.vm_folder_object.RegisterVM_Task = MagicMock(
         side_effect=exception)
     with self.assertRaises(VMwareRuntimeError) as exc:
         vmware.register_vm(self.datacenter, self.vm_name,
                            self.mock_vmx_path,
                            self.mock_resourcepool_object)
     self.assertEqual(exc.exception.strerror, 'vmodl.RuntimeFault msg')
Exemplo n.º 4
0
 def test_register_vm_raise_no_permission(self):
     exception = vim.fault.NoPermission()
     self.vm_folder_object.RegisterVM_Task = MagicMock(
         side_effect=exception)
     with self.assertRaises(VMwareApiError) as exc:
         vmware.register_vm(self.datacenter, self.vm_name,
                            self.mock_vmx_path,
                            self.mock_resourcepool_object)
     self.assertEqual(exc.exception.strerror,
                      'Not enough permissions. Required privilege: ')