lookup_service_helper.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:vsphere-automation-sdk-python 作者: vmware 项目源码 文件源码
def connect(self):
        if self.client is None:
            # Suds library doesn't support passing unverified context to disable
            # server certificate verification. Thus disable checking globally in
            # order to skip verification. This is not recommended in production
            # code. see https://www.python.org/dev/peps/pep-0476/
            if self.skip_verification:
                import ssl
                try:
                    _create_unverified_https_context = \
                        ssl._create_unverified_context
                except AttributeError:
                    # Legacy Python that doesn't verify HTTPS certificates by
                    # default
                    pass
                else:
                    # Handle target environment that doesn't support HTTPS
                    # verification
                    ssl._create_default_https_context = \
                        _create_unverified_https_context

            self.client = Client(url=self.wsdl_url, location=self.soap_url)
            assert self.client is not None
            self.client.set_options(service='LsService', port='LsPort')

        self.managedObjectReference = self.client.factory.create(
            'ns0:ManagedObjectReference')
        self.managedObjectReference._type = 'LookupServiceInstance'
        self.managedObjectReference.value = 'ServiceInstance'

        lookupServiceContent = self.client.service.RetrieveServiceContent(
            self.managedObjectReference)

        self.serviceRegistration = lookupServiceContent.serviceRegistration
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号