本文整理汇总了Python中vnc_api.vnc_api.VncApi.physical_router_create方法的典型用法代码示例。如果您正苦于以下问题:Python VncApi.physical_router_create方法的具体用法?Python VncApi.physical_router_create怎么用?Python VncApi.physical_router_create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnc_api.vnc_api.VncApi
的用法示例。
在下文中一共展示了VncApi.physical_router_create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DeviceInfo
# 需要导入模块: from vnc_api.vnc_api import VncApi [as 别名]
# 或者: from vnc_api.vnc_api.VncApi import physical_router_create [as 别名]
#.........这里部分代码省略.........
physical_router_device_family=oid_mapped.get('family'),
physical_router_vnc_managed=True,
physical_router_hostname=fq_name[-1],
display_name=fq_name[-1],
physical_router_serial_number=serial_num,
physical_router_managed_state='active',
physical_router_user_credentials={
'username': oid_mapped.get('username'),
'password': oid_mapped.get('password')
}
)
if update:
pr_unicode_obj = self.vncapi.physical_router_update(
physicalrouter)
if pr_unicode_obj:
pr_obj_dict = ast.literal_eval(pr_unicode_obj)
pr_uuid = pr_obj_dict['physical-router']['uuid']
msg = "Discovered %s:\n Host name: %s\n Vendor: %s\n" \
" Model: %s" % (
oid_mapped.get('host'),
fq_name[1],
oid_mapped.get('vendor'),
oid_mapped.get('product')
)
self.logger.info("Discovered {} : {}".format(
oid_mapped.get('host'), pr_uuid
))
else:
# underlay_managed flag should only be set at physical-router
# creation time
physicalrouter.set_physical_router_underlay_managed(
self.job_ctx.get('job_input').get('manage_underlay', True)
)
pr_uuid = self.vncapi.physical_router_create(physicalrouter)
msg = "Discovered device details: {} : {} : {}".format(
oid_mapped.get('host'), fq_name[1], oid_mapped.get(
'product'))
self.logger.info("Device created with uuid- {} : {}".format(
oid_mapped.get(
'host'), pr_uuid))
self.module.send_prouter_object_log(fq_name, "DISCOVERED",
os_version, serial_num)
except(RefsExistError, Exception) as ex:
if isinstance(ex, RefsExistError):
return REF_EXISTS_ERROR, None
self.logger.error("VNC create failed with error: {}".format(str(
ex)))
return False, None
self.module.send_job_object_log(
msg,
JOB_IN_PROGRESS,
None,
job_success_percent=self.per_greenlet_percentage)
self.discovery_percentage_write()
return True, pr_uuid
def get_hostname_from_job_input(self, serial_num):
hostname = None
devices_to_ztp = self.job_ctx.get('job_input').get('device_to_ztp')
for device_info in devices_to_ztp:
if device_info.get('serial_number') == serial_num:
hostname = device_info.get('hostname')
break
return hostname