简体   繁体   English

Azure Python SDK问题-从RoleInstance中提取终结点信息

[英]Azure Python SDK Issue - Extracting endpoint information from RoleInstance

I'm trying to access RoleInstance endpoint information of the Azure RoleInstance using Azure Python SDK. 我正在尝试使用Azure Python SDK访问Azure RoleInstance的RoleInstance终结点信息。 However RoleInstance does not have any attributes to find endpoint info. 但是,RoleInstance没有任何属性可查找端点信息。

Attributes for RoleInstance are as follows: RoleInstance的属性如下:

['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'fqdn', 'instance_error_code', 'instance_fault_domain', 'instance_name', 'instance_size', 'instance_state_details', 'instance_status', 'instance_upgrade_domain', 'ip_address', 'power_state', 'role_name']

I have a sample code that looks like following: 我有一个示例代码,如下所示:

deployment = self.sms.get_deployment_by_slot(hosted_service.service_name, 'production')

for instance in deployment.role_instance_list:
    print('Instance name: ' + instance.instance_name)
    print('Instance status: ' + instance.instance_status)
    print('Instance size: ' + instance.instance_size)
    print('Instance role name: ' + instance.role_name)
    print('Instance ip address: ' + instance.ip_address)
    print('')

How can I extract endpoint information from 'instance'? 如何从“实例”中提取端点信息?

Looking at the source code for SDK here: https://github.com/WindowsAzure/azure-sdk-for-python/blob/master/azure/servicemanagement/ init .py , I see Deployment has a property called input_endpoint_list . 在此处查看SDK的源代码: https : //github.com/WindowsAzure/azure-sdk-for-python/blob/master/azure/servicemanagement/ init .py ,我看到Deployment具有一个名为input_endpoint_list的属性。

deployment = self.sms.get_deployment_by_slot(hosted_service.service_name, 'production')
for input_endpoint in deployment.input_endpoint_list:
    print ('Role Name:' + input_endpoint.role_name)
    print ('Role VIP:' + input_endpoint.vip)
    print ('Port:' + input_endpoint.port)   

Will this work? 这样行吗?

Thank you for reporting this. 感谢您举报。 We've filed and issue, and just now checked in a fix for it. 我们已提交并签发了文件,并且刚刚检查了修复程序。

Missing role instance endpoint in get_deployment_by_X get_deployment_by_X中缺少角色实例端点

Have a look at the pull request referenced in the issue, you should be able to patch your library pretty easily, or pip install from our github repository. 看看问题中引用的拉取请求,您应该可以轻松修补您的库,或者从我们的github存储库中进行pip安装。

Here's the code you would use to access the first endpoint: 以下是用于访问第一个端点的代码:

endpoint = instance.instance_endpoints[0]
print(endpoint.name)
print(endpoint.protocol)
print(endpoint.public_port)
print(endpoint.local_port)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM