Ask Your Question
0

Retrieve host-name attribute of Cinder Volume [closed]

asked 2016-01-06 09:48:37 -0600

Pradip gravatar image

Hello,

From CLI, I can see the host-name in the cinder show command as follows:

| os-vol-host-attr:host | openstack4@SCSIBackend#pool1** |

stack@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@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                |
+---------------------------------------+--------------------------------------+

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'

However can not see the host-attr:

>>> 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

Thanks, Pradip

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Pradip
close date 2016-01-06 22:08:28.032272

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-01-06 22:08:07 -0600

Pradip gravatar image

Courtney to Duncan Thomas:

Try client.volumes..get(id).__dict__['os-vol-host-attr:host']

>>> cinder.volumes.list()
[<volume: e8be1df5-64fb-43fa-aacd-9bebba17fba5="">]
>>> volumes = cinder.volumes.list()
>>> volumes[0]
<volume: e8be1df5-64fb-43fa-aacd-9bebba17fba5="">
>>> volumes[0].__dict__['os-vol-host-attr:host']
u'openstack4@SCSIBackend#pool1'
edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2016-01-06 09:48:37 -0600

Seen: 450 times

Last updated: Jan 06 '16