Exemple #1
0
 def test_unsupported_parrent(self):
     with self.assertRaises(ArgumentValueError) as excinfo:
         vmware.get_dvportgroups(MagicMock())
     self.assertEqual(
         excinfo.exception.strerror,
         'Parent has to be either a datacenter, or a '
         'distributed virtual switch')
Exemple #2
0
 def test_get_mors_with_properties(self):
     vmware.get_dvportgroups(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=['name'],
         traversal_spec=self.mock_traversal_spec)
Exemple #3
0
    def test_traversal_spec_dvs_parent(self):
        mock_traversal_spec = MagicMock(return_value='traversal_spec')
        with patch(
                'salt.utils.vmware.vmodl.query.PropertyCollector.TraversalSpec',
                mock_traversal_spec):

            vmware.get_dvportgroups(self.mock_dvs_ref)
        mock_traversal_spec.assert_called_once_with(
            path='portgroup', skip=False, type=vim.DistributedVirtualSwitch)
Exemple #4
0
    def test_traversal_spec_datacenter_parent(self):
        mock_traversal_spec = MagicMock(return_value='traversal_spec')
        with patch(
                'salt.utils.vmware.vmodl.query.PropertyCollector.TraversalSpec',
                mock_traversal_spec):

            vmware.get_dvportgroups(self.mock_dc_ref)
        mock_traversal_spec.assert_has_calls([
            call(path='childEntity', skip=False, type=vim.Folder),
            call(path='networkFolder',
                 skip=True,
                 type=vim.Datacenter,
                 selectSet=['traversal_spec'])
        ])
Exemple #5
0
 def test_get_all_pgs(self):
     ret = vmware.get_dvportgroups(self.mock_dvs_ref,
                                   get_all_portgroups=True)
     self.assertEqual(ret, [i['object'] for i in self.mock_items])
Exemple #6
0
 def test_get_no_pgs(self):
     ret = vmware.get_dvportgroups(self.mock_dvs_ref)
     self.assertEqual(ret, [])
Exemple #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.get_dvportgroups(self.mock_dc_ref)
     mock_get_managed_object_name.assert_called_once_with(self.mock_dc_ref)