Ask Your Question
1

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
0

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

teju gravatar image

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 = '127.0.0.1'
dummy_initiator_info =  {'ip': dummy_ip, 'host': dummy_host_name, 'initiator': dummy_initiator_iqn}

target_info = volume.manager.initialize_connection(volume.id, dummy_initiator_info)

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

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

Stats

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

Seen: 413 times

Last updated: Feb 16