本文整理汇总了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"""