Ask Your Question

How to list iscsi target details like iqn number using cinder client? [closed]

asked 2013-12-31 05:11:09 -0500

teju gravatar image

updated 2014-01-20 21:27:38 -0500

I have cinder on Ubuntu12.04. I've created volumes and when I run the command tgt-admin -s ,it shows all the target details corresponding to the volumes created. We can get iqn numbers by querying the db as : select provider_location from cinder.volumes; My requirement is to get similar details without querying the db. Is there a way to achieve the same using REST API or python cinder client?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by teju
close date 2015-02-16 23:24:52.356350

2 answers

Sort by ยป oldest newest most voted

answered 2015-02-16 23:23:56 -0500

teju gravatar image

updated 2016-02-11 01:04:29 -0500

I've asked this question almost an year ago. I would like to answer now since it may help others who have a similar requirement.

Here is the simple python code snippet to get target details:

NOTE: Pass Cinder Volume Object as the argument to the below function

def get_target_details(volume):

# store dummy initiator details
dummy_initiator_iqn = 'iqn.openstack-2015'
dummy_host_name = 'localhost'
dummy_ip = ''
dummy_initiator_info =  {'ip': dummy_ip, 'host': dummy_host_name, 'initiator': dummy_initiator_iqn}

target_info = volume.manager.initialize_connection(, dummy_initiator_info)

#target IQN
print target_info['data']['target_iqn']
#target IP
print target_info['data']['target_portal'].split(':')[0]
#target Port
print target_info['data']['target_portal'].split(':')[1]
#target LUN
print target_info['data']['target_lun']
edit flag offensive delete link more


what is returned when we invoke initialize_connection, depends on what underneath storage driver returns right? If the export already exists, some of the underneath drivers might return the existing export information, while others might throw an error. Will this work? which storage did you test?

raviteja gravatar imageraviteja ( 2016-02-25 03:19:29 -0500 )edit

also when i tried select provider_location from cinder.volumes; it shows all null values, even when volumes are exported. Am i missing something?

raviteja gravatar imageraviteja ( 2016-02-25 03:27:36 -0500 )edit

answered 2014-02-09 01:05:15 -0500

jgriffith gravatar image

No, Cinder does not provide that via the API or client. It's intent is to abstract that out so you don't have to know about it.

That being said it would be trivial to write your own extension to do something along the lines of what you want. Or even easier just use the tgt-admin commands like you mentioned, it's the same info that's stored in the provider_location field.

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2013-12-31 05:11:09 -0500

Seen: 1,313 times

Last updated: Feb 11 '16