當前位置: 首頁>>代碼示例>>Python>>正文


Python VncApi.physical_router_create方法代碼示例

本文整理匯總了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
開發者ID:Juniper,項目名稱:contrail-controller,代碼行數:69,代碼來源:device_info.py


注:本文中的vnc_api.vnc_api.VncApi.physical_router_create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。