简体   繁体   中英

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. However RoleInstance does not have any attributes to find endpoint info.

Attributes for RoleInstance are as follows:

['__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 .

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

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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