[openstack-dev] [cinder][python-client-api] Retrieve host-name attribute of Cinder Volume
Duncan Thomas
duncan.thomas at gmail.com
Wed Jan 6 19:23:53 UTC 2016
Try client.volumes..get(id).__dict__['
*os-vol-host-attr:host'] *
*Ugly, but it seems to work*
On 6 January 2016 at 18:20, Pradip Mukhopadhyay <pradip.interra at gmail.com>
wrote:
> Thanks, Yuriy.
>
> My question was: how can I retrieve the "host at backend#pool" from the
> pythonclient API of volume listing? Once I have that, I should use this
> method to extract the pool-name.
>
> But how can I access this info? CLI is showing this as in the following
> field:
>
> stack at openstack4:~/devstack$ cinder show
> e8be1df5-64fb-43fa-aacd-9bebba17fba5
>
> +---------------------------------------+--------------------------------------+
> | Property |
> Value |
>
> +---------------------------------------+--------------------------------------+
> | attachments |
> [] |
> | availability_zone |
> nova |
> | bootable |
> false |
> | consistencygroup_id |
> None |
> | created_at |
> 2016-01-06T14:21:32.000000 |
> | description |
> None |
> | encrypted |
> False |
> | id |
> e8be1df5-64fb-43fa-aacd-9bebba17fba5 |
> | metadata |
> {} |
> | migration_status |
> None |
> | multiattach |
> False |
> | name |
> None |
> | *os-vol-host-attr:host | openstack4 at SCSIBackend#pool1*
> |
> | os-vol-mig-status-attr:migstat |
> None |
> | os-vol-mig-status-attr:name_id |
> None |
> | os-vol-tenant-attr:tenant_id |
> 4713f79411844a29b3f53d5fd7502784 |
> | os-volume-replication:driver_data |
> None |
> | os-volume-replication:extended_status |
> None |
> | replication_status |
> disabled |
> | size |
> 1 |
> | snapshot_id |
> None |
> | source_volid |
> None |
> | status |
> available |
> | updated_at |
> 2016-01-06T14:21:34.000000 |
> | user_id |
> 89b4af10bc1a473caff22384c844bc6f |
> | volume_type |
> iscsi_1 |
>
> +---------------------------------------+--------------------------------------+
>
>
>
> Now in python client API, I am not able to get that field :(
>
>
>
> >>> volumes = cinder.volumes.list()
>
> >>> volumes
>
> [<Volume: e8be1df5-64fb-43fa-aacd-9bebba17fba5>]
>
> >>> type(volumes[0])
> <class 'cinderclient.v2.volumes.Volume'>
>
> >>> volumes[0].id
>
> u'e8be1df5-64fb-43fa-aacd-9bebba17fba5'
>
> >>> volumes[0].host
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File
> "/usr/local/lib/python2.7/dist-packages/cinderclient/openstack/common/apiclient/base.py",
> line 464, in __getattr__
> raise AttributeError(k)
> AttributeError: host
> >>> volumes[0].os-vol-host-attr
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File
> "/usr/local/lib/python2.7/dist-packages/cinderclient/openstack/common/apiclient/base.py",
> line 464, in __getattr__
> raise AttributeError(k)
> AttributeError: os
>
>
>
>
> Essentially what is the way to get the attribute from the API?
>
>
>
>
> Thanks,
>
> Pradip
>
>
>
> On Wed, Jan 6, 2016 at 9:28 PM, Yuriy Nesenenko <ynesenenko at mirantis.com>
> wrote:
>
>> Sorry, of course this
>> https://github.com/openstack/cinder/blob/master/cinder/volume/utils.py#L575
>>
>> On Wed, Jan 6, 2016 at 5:57 PM, Yuriy Nesenenko <ynesenenko at mirantis.com>
>> wrote:
>>
>>> You can use this function
>>> https://github.com/openstack/cinder/blob/master/cinder/volume/utils.py#L5
>>>
>>> On Wed, Jan 6, 2016 at 5:44 PM, Pradip Mukhopadhyay <
>>> pradip.interra at gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>>
>>>> From CLI, I can see the host-name in the cinder show command as follows:
>>>>
>>>> | os-vol-host-attr:host | openstack4 at mySCSIBackend#pool1
>>>> |
>>>>
>>>> How this info can be accessed from the cinder python client?
>>>>
>>>> I can access other information (id, size, name etc.) as follows:
>>>>
>>>> >>> volumes = cinder.volumes.list()
>>>>
>>>> >>> volumes
>>>>
>>>> [<Volume: e8be1df5-64fb-43fa-aacd-9bebba17fba5>]
>>>>
>>>> >>> volumes[0].id
>>>>
>>>> u'e8be1df5-64fb-43fa-aacd-9bebba17fba5'
>>>>
>>>> >>> volumes[0].volume_type
>>>>
>>>> u'iscsi_1'
>>>>
>>>>
>>>>
>>>> Thanks,
>>>> Pradip
>>>>
>>>>
>>>>
>>>>
>>>> __________________________________________________________________________
>>>> OpenStack Development Mailing List (not for usage questions)
>>>> Unsubscribe:
>>>> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
>>>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>>>
>>>>
>>>
>>
>> __________________________________________________________________________
>> OpenStack Development Mailing List (not for usage questions)
>> Unsubscribe:
>> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>>
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
--
--
Duncan Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20160106/6a3c60b8/attachment.html>
More information about the OpenStack-dev
mailing list