Try the following python script:
"""
Retrieve block volume information.
This script makes a single call to the getIscsiNetworkStorage() method in the
SoftLayer_Account API service and uses a object mask and filters to get more
information about the block volume.
Important manual pages
http://sldn.softlayer.com/reference/services/SoftLayer_Account
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getIscsiNetworkStorage
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Storage
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer
from pprint import pprint as pp
"""
Client configuration
Your SoftLayer API username and key.
"""
USERNAME = 'SET-ME'
API_KEY = 'SET-ME'
# Declare the API client
client = SoftLayer.create_client_from_env(username=USERNAME,
api_key=API_KEY)
accountService = client['SoftLayer_Account']
# Declaring the object mask to get information about the block storage volumes.
objectMask = "mask[id,activeTransactions.transactionGroup,nasType,password,username," \
"hardware[id,fullyQualifiedDomainName],iops,provisionedIops,isReadyForSnapshot,osType," \
"serviceResourceBackendIpAddress,capacityGb,snapshotCapacityGb,createDate,parentVolume.replicationStatus," \
"parentVolume.volumeStatus,permissionsGroups.allowedHosts,replicatingLuns,storageType,storageTierLevel," \
"serviceResource[id,type.type,networkDevice[id,datacenter]],notes,volumeStatus,hasEncryptionAtRest," \
"originalVolumeSize,allowedVirtualGuests[fullyQualifiedDomainName,allowedHost[id,name,resourceTableId," \
"resourceTableName, credential[id,username,password],sourceSubnet]]]"
#Use the following mask to retrieve only the identifier for a iScsi block volume.
# objectMaskIscsi= "mask[id]"
# Declaring a filter, in this example the search is by iscsi name just as portal:
filter_block_username = {"iscsiNetworkStorage": {"username": {"operation": "SL01SEL111111-2"}}}
# Uncomment one of the below, and replace required values to use one of the filters in order to search
# filter_block_iqn = {"iscsiNetworkStorage":{"allowedVirtualGuests":{"allowedHost":{"name":
# {"operation":"iqn.2005-05.com.softlayer:sl01su111111-v1234567"}}}}}
try:
# Retrieve the block volumes for the account.
storageResult = accountService.getIscsiNetworkStorage(mask=objectMask, filter=filter_block_username)
pp(storageResult)
except SoftLayer.SoftLayerAPIError as e:
print("Unable to retrieve the storage volumes %s %s. " % (e.faultCode, e.faultString))
exit(1)
For more information please see below:
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getIscsiNetworkStorage
http://developer.softlayer.com/article/object-filters