Revision history [back]

click to hide/show revision 1
initial version

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

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
print target_info['data']['target_portal'].split(':')[1]
#target LUN
print target_info['data']['target_lun']