I tried to authorize the softlayer endurance storage on a new system, using this command
curl -v -i -X POST -d '{"parameters": [{"id": [IP ADDRESS ID]}]}' -u "[USERNAME]:[APIKEY]" https://api.softlayer.com/rest/v3/SoftLayer_Network_Storage/[STORAGE ID]/allowAccessFromIpAddress.jso
I followed the instruction in the link, but it doesn't work. https://sldn.softlayer.com/it/blog/sjanowiak/how-use-softlayer-api-authorize-guest-vms-iscsi-storage
The console returns this error. (Obviously I put the correct values in the parameters)
{"error":"SoftLayer_Network_Storage::allowAccesstFromVirtualGuestList is not implemented.","code":"SoftLayer_Exception_NotImplemented"}
How can I use the SoftLayer API to authorize a VMs to use the iSCSI Storage?
Is there a funcion with the python service SoftLayer.ISCSIManager(client)
?
Regards
Below are some suggestions that may help you:
These requests help us to get available items can be authorized to an specific “network storage” as we can see in the Portal:
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
To get valid available virtual guests, please execute:
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Network_Storage_Iscsi/[storage_id]/ getAllowableVirtualGuests?objectMask=mask[id,fullyQualifiedDomainName] Method: GET
Available Bar metal:
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Network_Storage/[storage_id]/getAllowableHardware
Method: GET
References:
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage_Iscsi/getAllowableVirtualGuests http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage_Iscsi/getAllowableSubnets http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage_Iscsi/getAllowableHardware
It seems to not be a function to authorize network storage using ISCSI Manager. But below are some examples using python client.
Python examples:
Using: SoftLayer_Network_Storage:: allowAccessFromIpAddress
# So we can talk to the SoftLayer API:
import SoftLayer
# For nice debug output:
from pprint import pprint as pp
# Your SoftLayer API username and key.
API_USERNAME = 'set me'
API_KEY = 'set me'
# Set the server id that you wish to allow.
ipAddressId = 20636706
iscsiId = 8393467
# Set up your API client
client = SoftLayer.Client(
username=API_USERNAME,
api_key=API_KEY
)
try:
# The expected result after executing the script is: true
# To get valid Ip address, execute:
# https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Network_Storage/[Storage_id]/getAllowableSubnets?objectMask=mask[id,networkIdentifier,cidr,subnetType,ipAddresses[id,ipAddress]]
result = client['SoftLayer_Network_Storage'].allowAccessFromIpAddress({"id":ipAddressId},id=iscsiId)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to allow the access to ISCSI faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
Using: SoftLayer_Network_Storage:: allowAccessFromVirtualGuest
# So we can talk to the SoftLayer API:
import SoftLayer
# For nice debug output:
from pprint import pprint as pp
# Your SoftLayer API username and key.
API_USERNAME = 'set me'
API_KEY = 'set me'
# Set the server id that you wish to allow.
vsiId = 14388437
iscsiId = 8393467
# Set up your API client
client = SoftLayer.Client(
username=API_USERNAME,
api_key=API_KEY
)
try:
# The expected result after executing the script is: true
# To get valid Virtual Guest ids, execute:
# https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Network_Storage/[storage_id]/getAllowableVirtualGuests?objectMask=mask[id,fullyQualifiedDomainName]
result = client['SoftLayer_Network_Storage'].allowAccessFromVirtualGuest({"id":vsiId},id=iscsiId)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to allow the access to ISCSI faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
Using: SoftLayer_Virtual_Guest::allowAccessToNetworkStorage
# So we can talk to the SoftLayer API:
import SoftLayer
# For nice debug output:
from pprint import pprint as pp
# Your SoftLayer API username and key.
API_USERNAME = 'set me'
API_KEY = 'set me'
# Set the server id that you wish to allow.
serverId = 14388435
iscsiId = 8393467
# Set up your API client
client = SoftLayer.Client(
username=API_USERNAME,
api_key=API_KEY
)
try:
# The expected result after executing the script is: true
result = client['SoftLayer_Virtual_Guest'].allowAccessToNetworkStorage({"id":iscsiId},id=serverId)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to allow the access to ISCSI faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
References:
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage/allowAccessFromVirtualGuest http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage/allowAccessFromHardware http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/allowAccessToNetworkStorage
https://github.com/softlayer/softlayer-python
EDIT
I was able to reproduce the same problem using “Endurance Replica”. This is a python example to authorize a virtual Guest:
# So we can talk to the SoftLayer API:
import SoftLayer
# For nice debug output:
from pprint import pprint as pp
# Your SoftLayer API username and key.
API_USERNAME = 'set me'
API_KEY = 'set me'
# Set the server id that you wish to allow.
vsiId = 15571333
storageId = 6550721
objectType = "SoftLayer_Virtual_Guest"
# Set up your API client
client = SoftLayer.Client(
username=API_USERNAME,
api_key=API_KEY
)
try:
# To get valid Virtual Guest ids, execute:
# https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Network_Storage/[storage_id]/getAllowableVirtualGuests?objectMask=mask[id,fullyQualifiedDomainName]
result = client['SoftLayer_Network_Storage'].allowAccessFromHostList([{"id":vsiId,"objectType": objectType}],id=storageId)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to allow the access to network Storage faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
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:
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Storage/allowAccessFromHostList
Regards.