0
votes

How to proceed to attach and detach a storage block endurance to a Virtuel Machine from the API.

2

2 Answers

1
votes

To authorize/allow hosts to a Network Storage (i.e. Endurance), please execute:

URL:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Network_Storage/[Storage_id]/allowAccessFromHostList

Method: POST

Json Payload:

{
  "parameters": [
    [
      {
        "id": 1234567,
        "objectType": "SoftLayer_Virtual_Guest"
      }
    ]
  ]
}

Where: 1234567 is the Virtual Server Instance

The Above request is used to authorize “Endurance” and “Performance”. If you want to authorize “Virtual Guest”,“IpAddress” or “Hardware”, valid values for “objectType” are: “SoftLayer_Virtual_Guest “,”SoftLayer_Network_Subnet_IpAddress”, ”SoftLayer_Hardware” respectively.

Reference: SoftLayer_Network_Storage::allowAccessFromHostList

Note: The “network storage” and VSI/Bar Metal/Subnet must to be located in the same location/datacenter.

These requests help us to get available hosts can be authorized to a specific “network storage” as we can see in the Portal:

To get valid available virtual guests, please execute:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Network_Storage/[storage_id]/getAllowableVirtualGuests?objectMask=mask[id,fullyQualifiedDomainName] 

Method: GET

Reference: SoftLayer_Network_Storage::getAllowableVirtualGuests

Available Bar metal:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Network_Storage/[storage_id]/getAllowableHardware
Method: GET

Reference: SoftLayer_Network_Storage::getAllowableHardware

To get valid available subnets with associated IP addresses, execute:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Network_Storage/[storage_id]/ getAllowableSubnets?objectMask=mask[id,networkIdentifier,cidr,subnetType,ipAddresses[id,ipAddress]]
Method: GET

Reference: SoftLayer_Network_Storage::getAllowableSubnets