本文整理匯總了Python中vnc_api.vnc_api.VncApi.execute_job方法的典型用法代碼示例。如果您正苦於以下問題:Python VncApi.execute_job方法的具體用法?Python VncApi.execute_job怎麽用?Python VncApi.execute_job使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vnc_api.vnc_api.VncApi
的用法示例。
在下文中一共展示了VncApi.execute_job方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: SanityBase
# 需要導入模塊: from vnc_api.vnc_api import VncApi [as 別名]
# 或者: from vnc_api.vnc_api.VncApi import execute_job [as 別名]
#.........這裏部分代碼省略.........
# Check for timeout
if retry_count > self._max_retries:
raise Exception("Timed out waiting for '%s' job to complete" %
job_name)
retry_count += 1
time.sleep(self._timeout)
def _get_job_percentage_complete(self, job_execution_id, fabric_fq_name,
job_template_fq_name):
url = "http://%s:%d/analytics/uves/job-execution/%s:%s:%s:%s" %\
(self._analytics['host'], self._analytics['port'],
fabric_fq_name[0], fabric_fq_name[1],
job_template_fq_name[0], job_template_fq_name[1])
r = requests.get(url)
if r.status_code == 200:
response = r.json()
job_uve = response.get('FabricJobExecution')
if job_uve:
percomp = "?"
for pc in job_uve['percentage_completed']:
if job_execution_id in pc[1]:
percomp = pc[0]["#text"]
break
return percomp
else:
return "??"
else:
return "???"
def discover_fabric_device(self, fab):
"""Discover all devices specified by the fabric management namespaces
"""
self._logger.info('Discover devices in fabric "%s" ...', fab.fq_name)
job_execution_info = self._api.execute_job(
job_template_fq_name=[
'default-global-system-config', 'discover_device_template'],
job_input={'fabric_uuid': fab.uuid}
)
job_execution_id = job_execution_info.get('job_execution_id')
self._logger.debug(
"Device discovery job started with execution id: %s",
job_execution_id)
self._wait_for_job_to_finish('Device discovery', job_execution_id)
fab = self._api.fabric_read(fab.fq_name)
discovered_prouter_refs = fab.get_physical_router_back_refs()
self._logger.debug(
"Disovered devices:\n%s",
pprint.pformat(discovered_prouter_refs, indent=4))
msg = "Discovered following devices in fabric '%s':" % fab.fq_name
discovered_prouters = []
for prouter_ref in discovered_prouter_refs:
prouter = self._api.physical_router_read(prouter_ref.get('to'))
discovered_prouters.append(prouter)
msg += "\n - %s (%s)" % (
prouter.name, prouter.physical_router_management_ip)
self._logger.info(msg)
return discovered_prouters
# end discover_fabric_device
def device_import(self, prouters):
"""import device inventories for the prouters specified in the
argument"""