Search code examples
ibm-cloud-infrastructure

How to get credentials of volume storage on softlayer


I have tried below methods, to get credentials of iscsi storage on softlayer( i have endurance block storage on softlayer) but unable to retrieve password.

SoftLayer_Network_Storage_Iscsi::getCredentials
eg. res = client['SoftLayer_Network_Storage_Iscsi'].getCredentials(id=***)
SoftLayer_Network_Storage_Iscsi::getObjectsByCredential
SoftLayer_Network_Storage_Iscsi::getObject
SoftLayer_Network_Storage_Iscsi::getAllowedVirtualGuests

I want to retrieve username, password and iqn for authorized host to specific volume. Are there any api's to retrieve this information or any other way to retrieve this information


Solution

  • You could use an object mask to retrieve this kind of information:

    mask[allowedHardware[allowedHost[credential]],allowedVirtualGuests[allowedHost[credential]]]

    This would be the usage on a REST request:

    https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Network_Storage_Iscsi/$iscsiId/getObject.json?objectMask=mask[allowedHardware[allowedHost[credential]],allowedVirtualGuests[allowedHost[credential]]]
    

    And here a sample using Python client:

    """
    Get credentials for a authorized hosts of a SoftLayer_Network_Storage_Iscsi 
    
    Important manual pages
    http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage_Iscsi
    
    License: http://sldn.softlayer.com/article/License
    Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
    """
    
    import SoftLayer
    import json
    
    USERNAME = 'set me'
    API_KEY = 'set me'
    
    iscsiStorageId = 1234567
    
    client = SoftLayer.create_client_from_env(username=USERNAME, api_key=API_KEY)
    networkStorageIscsiService = client['SoftLayer_Network_Storage_Iscsi']
    
    objectMask = 'mask[allowedHardware[allowedHost[credential]],allowedVirtualGuests[allowedHost[credential]]]'
    
    try:
        iscsiStorage = networkStorageIscsiService.getObject(mask=objectMask, id=iscsiStorageId)
        print(json.dumps(iscsiStorage, sort_keys=True, indent=2, separators=(',', ': ')))
    except SoftLayer.SoftLayerAPIError as e:
        print("Unable to retrieve the Network Storage Iscsi. faultCode=%s, faultString=%s" 
            % (e.faultCode, e.faultString))
    

    The next link might provide you further information:

    https://sldn.softlayer.com/article/object-masks