Exemple #1
0
 def test_get_no_uplink_pg(self):
     with patch('salt.utils.vmware.get_mors_with_properties',
                MagicMock(return_value=[])):
         with self.assertRaises(VMwareObjectRetrievalError) as excinfo:
             vmware.get_uplink_dvportgroup(self.mock_dvs_ref)
     self.assertEqual(excinfo.exception.strerror,
                      'Uplink portgroup of DVS \'fake_dvs\' wasn\'t found')
Exemple #2
0
 def test_get_mors_with_properties(self):
     vmware.get_uplink_dvportgroup(self.mock_dvs_ref)
     self.mock_get_mors.assert_called_once_with(
         self.mock_si,
         vim.DistributedVirtualPortgroup,
         container_ref=self.mock_dvs_ref,
         property_list=['tag'],
         traversal_spec=self.mock_traversal_spec)
Exemple #3
0
    def test_traversal_spec(self):
        mock_traversal_spec = MagicMock(return_value='traversal_spec')
        with patch(
                'salt.utils.vmware.vmodl.query.PropertyCollector.TraversalSpec',
                mock_traversal_spec):

            vmware.get_uplink_dvportgroup(self.mock_dvs_ref)
        mock_traversal_spec.assert_called_once_with(
            path='portgroup', skip=False, type=vim.DistributedVirtualSwitch)
Exemple #4
0
 def test_get_uplink_pg(self):
     ret = vmware.get_uplink_dvportgroup(self.mock_dvs_ref)
     self.assertEqual(ret, self.mock_items[1]['object'])
Exemple #5
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.get_uplink_dvportgroup(self.mock_dvs_ref)
     mock_get_managed_object_name.assert_called_once_with(self.mock_dvs_ref)