slipstream / SlipStreamClient

SlipStream Python client
Apache License 2.0
1 stars 4 forks source link

refactor access to VM instance elements #362

Closed konstan closed 6 years ago

konstan commented 6 years ago

This was discussed in this PR https://github.com/slipstream/SlipStreamConnectors/pull/174 and https://github.com/slipstream/SlipStreamClient/pull/361.

This PR https://github.com/slipstream/SlipStreamClient/pull/361 was accepted and https://github.com/slipstream/SlipStreamConnectors/pull/174 was closed under the condition that this issue will be created and the idea below will be implemented.

The correct agreed solution (as commented in https://github.com/slipstream/SlipStreamConnectors/pull/174) is overloaded _vm_get_id (& friends). Which in turn should be pulled up as a common implementation which would satisfy all connectors

@staticmethod
def _vm_get_id(vm):
    if hasattr(vm, 'id'):
        return vm.id
    else:
        return vm['id']