本文整理汇总了Python中vnc_api.vnc_api.VncApi.ref_update方法的典型用法代码示例。如果您正苦于以下问题:Python VncApi.ref_update方法的具体用法?Python VncApi.ref_update怎么用?Python VncApi.ref_update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnc_api.vnc_api.VncApi
的用法示例。
在下文中一共展示了VncApi.ref_update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DeviceInfo
# 需要导入模块: from vnc_api.vnc_api import VncApi [as 别名]
# 或者: from vnc_api.vnc_api.VncApi import ref_update [as 别名]
#.........这里部分代码省略.........
break
return hostname
def device_info_processing(self, host, oid_mapped):
valid_creds = False
return_code = True
if not oid_mapped.get('family') or not oid_mapped.get('vendor'):
self.logger.info("Could not retrieve family/vendor info for "
"the host: {}, not creating PR "
"object".format(host))
self.logger.info("vendor: {}, family: {}".format(
oid_mapped.get('vendor'), oid_mapped.get('family')))
oid_mapped = {}
if oid_mapped.get('host'):
valid_creds = self._detailed_cred_check(host, oid_mapped,
self.credentials)
if not valid_creds and oid_mapped:
self.logger.info("No credentials matched for host: {}, nothing "
"to update in DB".format(host))
oid_mapped = {}
if oid_mapped:
if self.serial_num_flag:
if oid_mapped.get('serial-number') not in \
self.all_serial_num:
self.logger.info(
"Serial number {} for host {} not present "
"in fabric_namespace, nothing to update "
"in DB".format(
oid_mapped.get('serial-number'), host))
return
# use the user input hostname is there. If its none check
# for hostname derived from the device system info. If
# that is also missing then set the hostname to the serial num
user_input_hostname = None
if self.job_ctx.get('job_input').get('device_to_ztp') is not None:
user_input_hostname = \
self.get_hostname_from_job_input(oid_mapped.get(
'serial-number'))
if user_input_hostname is not None:
oid_mapped['hostname'] = user_input_hostname
elif oid_mapped.get('hostname') is None:
oid_mapped['hostname'] = oid_mapped.get('serial-number')
fq_name = [
'default-global-system-config',
oid_mapped.get('hostname')]
return_code, pr_uuid = self._pr_object_create_update(
oid_mapped, fq_name, False)
if return_code == REF_EXISTS_ERROR:
physicalrouter = self.vncapi.physical_router_read(
fq_name=fq_name)
phy_router = self.vncapi.obj_to_dict(physicalrouter)
if (phy_router.get('physical_router_management_ip')
== oid_mapped.get('host')):
self.logger.info(
"Device with same mgmt ip already exists {}".format(
phy_router.get('physical_router_management_ip')))
return_code, pr_uuid = self._pr_object_create_update(
oid_mapped, fq_name, True)
else:
fq_name = [
'default-global-system-config',
oid_mapped.get('hostname') +
'_' +
oid_mapped.get('host')]
return_code, pr_uuid = self._pr_object_create_update(
oid_mapped, fq_name, False)
if return_code == REF_EXISTS_ERROR:
self.logger.debug("Object already exists")
if return_code is True:
self.vncapi.ref_update(
"physical_router", pr_uuid, "fabric", self.fabric_uuid,
None, "ADD")
self.logger.info(
"Fabric updated with physical router info for "
"host: {}".format(host))
temp = {}
temp['device_management_ip'] = oid_mapped.get('host')
temp['device_fqname'] = fq_name
temp['device_username'] = oid_mapped.get('username')
temp['device_password'] = oid_mapped.get('password')
temp['device_family'] = oid_mapped.get('family')
temp['device_vendor'] = oid_mapped.get('vendor')
temp['device_product'] = oid_mapped.get('product')
temp['device_serial_number'] = oid_mapped.get('serial-number')
DeviceInfo.output.update({pr_uuid: temp})
def discovery_percentage_write(self):
if self.module.results.get('percentage_completed'):
exec_id = self.job_ctx.get('job_execution_id')
pb_id = self.job_ctx.get('unique_pb_id')
self._job_file_write.write_to_file(
exec_id, pb_id, JobFileWrite.JOB_PROGRESS,
str(self.module.results.get('percentage_completed'))
)