Search code examples
centos7ibm-cloud-infrastructurelvmiscsidevice-mapper

Softlayer: determine scsi disk Softlayer-ID using the dev mapper device id


In a setup of a multiple iscsi disks attached to a Linux host (LVM pools setup), I want to be able to take a snapshot of a specific disk, using Softlayer API. How can I know the id or the LUN name of the iscsi device from the Linux device name.

For example - get "SLXXXXXXXXX-XX" from "/dev/mapper/YYYYYYYYYYYYYYp1".

I tried resolving the Iscsi target Ip, but it's possible that different disks have same target ip, so I have to figure out a different solution


Solution

  • Using these REST requests you can retrieve the ISCSI id, and LUN id of the device and its parent for those BMS and Virtual Guests that have any.

    https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests.json?objectMask=mask[allowedNetworkStorage[lunId,parentVolume[lunId]]]&objectFilter={"virtualGuests":{"allowedNetworkStorage":{"nasType":{"operation":"ISCSI"}}}}
    

    Method: GET

    https://[username]:[apiKey]@api.softlayer.com/rest/v3/SoftLayer_Account/getHardware.json?objectMask=mask[allowedNetworkStorage[lunId,parentVolume[lunId]]]&objectFilter={"hardware":{"allowedNetworkStorage":{"nasType":{"operation":"ISCSI"}}}}
    

    Method: GET

    This link might help you for further implementation: http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Storage_Iscsi http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage_Iscsi