示例#1
0
 def test_continue_retrieval(self, get_token):
     token = mock.Mock()
     get_token.return_value = token
     vim = mock.Mock()
     retrieve_result = mock.Mock()
     vim_util.continue_retrieval(vim, retrieve_result)
     get_token.assert_called_once_with(retrieve_result)
     vim.ContinueRetrievePropertiesEx.assert_called_once_with(
         vim.service_content.propertyCollector, token=token)
示例#2
0
 def test_continue_retrieval(self, get_token):
     token = mock.Mock()
     get_token.return_value = token
     vim = mock.Mock()
     retrieve_result = mock.Mock()
     vim_util.continue_retrieval(vim, retrieve_result)
     get_token.assert_called_once_with(retrieve_result)
     vim.ContinueRetrievePropertiesEx.assert_called_once_with(
         vim.service_content.propertyCollector, token=token)
示例#3
0
 def get_mob_by_mobid(self, vim_type, mob_id):
     results = self.get_all_objects_of_type(vim_type)
     while results:
         for _mob in results.objects:
             if _mob.obj.value == mob_id:
                 vim_util.cancel_retrieval(self.session.vim, results)
                 return _mob
         results = vim_util.continue_retrieval(self.session.vim, results)
示例#4
0
 def get_mob_by_name(self, vim_type, obj_name):
     results = self.get_all_objects_of_type(vim_type)
     while results:
         for _mob in results.objects:
             for prop in _mob.propSet:
                 if prop.name == 'name' and obj_name == prop.val:
                     vim_util.cancel_retrieval(self.session.vim, results)
                     return _mob
         results = vim_util.continue_retrieval(self.session.vim, results)
示例#5
0
 def _get_dvs_moref_by_name(self, session, dvs_name):
     """Get the moref of the configured DVS."""
     results = session.invoke_api(vim_util, 'get_objects', session.vim,
                                  'DistributedVirtualSwitch', 100)
     while results:
         for dvs in results.objects:
             for prop in dvs.propSet:
                 if dvs_name == prop.val:
                     vim_util.cancel_retrieval(session.vim, results)
                     return dvs.obj
         results = vim_util.continue_retrieval(session.vim, results)
     raise nsx_exc.DvsNotFound(dvs=dvs_name)
示例#6
0
 def _get_dvs_moref(self, session, dvs_name):
     """Get the moref of the configured DVS."""
     results = session.invoke_api(vim_util,
                                  'get_objects',
                                  session.vim,
                                  'DistributedVirtualSwitch',
                                  100)
     while results:
         for dvs in results.objects:
             for prop in dvs.propSet:
                 if dvs_name == prop.val:
                     vim_util.cancel_retrieval(session.vim, results)
                     return dvs.obj
         results = vim_util.continue_retrieval(session.vim, results)
     raise nsx_exc.DvsNotFound(dvs=dvs_name)
示例#7
0
 def _get_portgroup(self, net_id):
     """Get the port group moref of the net_id."""
     results = self._session.invoke_api(vim_util,
                                        'get_objects',
                                        self._session.vim,
                                        'DistributedVirtualPortgroup',
                                        100)
     while results:
         for pg in results.objects:
             for prop in pg.propSet:
                 if net_id == prop.val:
                     vim_util.cancel_retrieval(self._session.vim, results)
                     return pg.obj
         results = vim_util.continue_retrieval(self._session.vim, results)
     raise exceptions.NetworkNotFound(net_id=net_id)
示例#8
0
 def get_dvs_moref_by_name(self, dvs_name, session=None):
     """Get the moref of DVS."""
     if not session:
         session = self.get_vc_session()
     results = session.invoke_api(vim_util,
                                  'get_objects',
                                  session.vim,
                                  'DistributedVirtualSwitch',
                                  100)
     while results:
         for dvs in results.objects:
             for prop in dvs.propSet:
                 if dvs_name == prop.val:
                     vim_util.cancel_retrieval(session.vim, results)
                     return dvs.obj
         results = vim_util.continue_retrieval(session.vim, results)
     raise nsx_exc.DvsNotFound(dvs=dvs_name)