Example #1
0
 def test_wait_for_tasks(self):
     vmware.create_dvs(self.mock_dc_ref,
                       'fake_dvs',
                       dvs_create_spec=self.mock_dvs_create_spec)
     self.mock_wait_for_task.assert_called_once_with(
         self.mock_task, 'fake_dvs',
         '<class \'unit.utils.vmware.test_dvs.FakeTaskClass\'>')
Example #2
0
 def test_create_dvs_task_raises_runtime_fault(self):
     exc = vmodl.RuntimeFault()
     exc.msg = 'RuntimeFault msg'
     self.mock_netw_folder.CreateDVS_Task = MagicMock(side_effect=exc)
     with self.assertRaises(VMwareRuntimeError) as excinfo:
         vmware.create_dvs(self.mock_dc_ref,
                           'fake_dvs',
                           dvs_create_spec=self.mock_dvs_create_spec)
     self.assertEqual(excinfo.exception.strerror, 'RuntimeFault msg')
Example #3
0
 def test_create_dvs_task_raises_no_permission(self):
     exc = vim.fault.NoPermission()
     exc.privilegeId = 'Fake privilege'
     self.mock_netw_folder.CreateDVS_Task = MagicMock(side_effect=exc)
     with self.assertRaises(VMwareApiError) as excinfo:
         vmware.create_dvs(self.mock_dc_ref,
                           'fake_dvs',
                           dvs_create_spec=self.mock_dvs_create_spec)
     self.assertEqual(
         excinfo.exception.strerror,
         'Not enough permissions. Required privilege: '
         'Fake privilege')
Example #4
0
 def test_no_dvs_create_spec(self):
     mock_spec = MagicMock(configSpec=None)
     mock_config_spec = MagicMock()
     mock_dvs_create_spec = MagicMock(return_value=mock_spec)
     mock_vmware_dvs_config_spec = \
             MagicMock(return_value=mock_config_spec)
     with patch('salt.utils.vmware.vim.DVSCreateSpec',
                mock_dvs_create_spec):
         with patch('salt.utils.vmware.vim.VMwareDVSConfigSpec',
                    mock_vmware_dvs_config_spec):
             vmware.create_dvs(self.mock_dc_ref, 'fake_dvs')
     mock_dvs_create_spec.assert_called_once_with()
     mock_vmware_dvs_config_spec.assert_called_once_with()
     self.assertEqual(mock_spec.configSpec, mock_config_spec)
     self.assertEqual(mock_config_spec.name, 'fake_dvs')
     self.mock_netw_folder.CreateDVS_Task.assert_called_once_with(mock_spec)
Example #5
0
 def test_create_dvs_task_passed_in_spec(self):
     vmware.create_dvs(self.mock_dc_ref,
                       'fake_dvs',
                       dvs_create_spec=self.mock_dvs_create_spec)
     self.mock_netw_folder.CreateDVS_Task.assert_called_once_with(
         self.mock_dvs_create_spec)
Example #6
0
 def test_get_network_folder(self):
     mock_get_network_folder = MagicMock()
     with patch('salt.utils.vmware.get_network_folder',
                mock_get_network_folder):
         vmware.create_dvs(self.mock_dc_ref, 'fake_dvs')
     mock_get_network_folder.assert_called_once_with(self.mock_dc_ref)
Example #7
0
 def test_get_managed_object_name_call(self):
     mock_get_managed_object_name = MagicMock()
     with patch('salt.utils.vmware.get_managed_object_name',
                mock_get_managed_object_name):
         vmware.create_dvs(self.mock_dc_ref, 'fake_dvs')
     mock_get_managed_object_name.assert_called_once_with(self.mock_dc_ref)