'Need disk sizes and GPU type on a Bare Metal device using curl
Iam using the curl command and I am trying to determine the number of disks and their sizes on a bare metal device. I thought I could use these in an objectMask, but nothing is returned.
blockDeviceTemplateGroup.name,blockDeviceTemplateGroup.id,blockDeviceTemplateGroup.blockDevices,blockDevices.diskImage
I am also trying the g=find if a Bare Metal device has a GPU and the type of GPU. Can I get that using objectMask?
Thanks
Solution 1:[1]
If you want to get the disks of a specific bare metal device, you can use https://sldn.softlayer.com/reference/services/SoftLayer_Hardware/getComponents/ to get all components and a filter to get only the disks. The url should be
https://api.softlayer.com/rest/v3.1/SoftLayer_Hardware/123456/getComponents?objectFilter={"components":{"hardwareComponentModel":{"hardwareGenericComponentModel":{"hardwareComponentType":{"keyName":{"operation":"HARD_DRIVE"}}}}}}
Where 123456 is the id of the bare metal device, but in curl, it's necessary to escape the special characters, so you must send the object filter encoded and finally the structure you can send is
curl -u USER:API_KEY https://api.softlayer.com/rest/v3.1/SoftLayer_Hardware/123456/getComponents.json?objectFilter=%7B%22components%22%3A%7B%22hardwareComponentModel%22%3A%7B%22hardwareGenericComponentModel%22%3A%7B%22hardwareComponentType%22%3A%7B%22keyName%22%3A%7B%22operation%22%3A%22HARD_DRIVE%22%7D%7D%7D%7D%7D%7D
Where USER and API_KEY are your username and the apikey you generated
To get the bare metal devices with GPU you can use https://sldn.softlayer.com/reference/services/SoftLayer_Account/getHardware/ to get all bare metal devices and a filter get only the devices with GPU components. The url should be
https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getHardware?objectFilter={"hardware":{"components":{"hardwareComponentModel":{"hardwareGenericComponentModel":{"hardwareComponentType":{"keyName":{"operation":"GPU"}}}}}}}
But like in curl, it's necessary to escape the special characters, so you must send the object filter encoded and finally the structure you can send is
curl -u USER:API_KEY https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getHardware?objectFilter=%7B%22hardware%22%3A%7B%22components%22%3A%7B%22hardwareComponentModel%22%3A%7B%22hardwareGenericComponentModel%22%3A%7B%22hardwareComponentType%22%3A%7B%22keyName%22%3A%7B%22operation%22%3A%22GPU%22%7D%7D%7D%7D%7D%7D%7D
Where USER and API_KEY are your username and the apikey you generated
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Brian SantivaƱez |
