softlayer / softlayer-python

A set of Python libraries that assist in calling the SoftLayer API.
http://softlayer.github.io/softlayer-python/
MIT License
154 stars 192 forks source link

`slcli vs reload` should support generic OS versions #1826

Open allmightyspiff opened 1 year ago

allmightyspiff commented 1 year ago

The portal page lists base OSes, so there should be a way to do this.

TODO

  1. Add a way to list the ID/KeyName/imageId or whatever the OS reload needs to provision a base OS
  2. update slcli vs reload to mention how to get the key for base OSes, and if needed a way to specify the user wants to reload into a base os.

image

Might need to set https://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Hardware_Server_Configuration/#itemPrices when doing this type of reload. I don't want users to have to input the priceId though, just the catalog keyName ideally.

allmightyspiff commented 1 year ago
$ slcli -vvv vs reload 133875286 --image OS_CENTOS_8_X_MINIMAL_64_BIT
This action cannot be undone! Type "133875286" or press Enter to abort: 133875286
Calling: SoftLayer_Virtual_Guest::reloadOperatingSystem(id=133875286, mask='', filter='None', args=('FORCE', {'imageTemplateId': 'OS_CENTOS_8_X_MINIMAL_64_BIT'}), limit=None, offset=None))
Starting new HTTPS connection (1): api.softlayer.com:443
https://api.softlayer.com:443 "POST /rest/v3.1/SoftLayer_Virtual_Guest/133875286/reloadOperatingSystem.json HTTP/1.1" 200 3
Returned Data:
"1"

┌──────────────────┬──────────────────────────────────────────────────────────────────┐
│       name       │                              value                               │
├──────────────────┼──────────────────────────────────────────────────────────────────┤
│  execution_time  │                            4.169691s                             │
│    api_calls     │ ┌────────────────────────────────────────────────────────────┐   │
│                  │ │ API Calls                                                  │   │
│                  │ ├────────────────────────────────────────────────────────────┤   │
│                  │ │ SoftLayer_Virtual_Guest::reloadOperatingSystem (0.948168s) │   │
│                  │ └────────────────────────────────────────────────────────────┘   │
│     version      │                     softlayer-python/v6.1.3                      │
│  python_version  │ 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] │
│ library_location │     C:\Users\allmi\Source\py311\Lib\site-packages\SoftLayer      │
└──────────────────┴──────────────────────────────────────────────────────────────────┘

┌────────┬────────────────────────────────────────────────┐
│        │ SoftLayer_Virtual_Guest::reloadOperatingSystem │
├────────┼────────────────────────────────────────────────┤
│ id     │ 133875286                                      │
│ mask   │                                                │
│ filter │ None                                           │
│ limit  │ None                                           │
│ offset │ None                                           │
└────────┴────────────────────────────────────────────────┘

curl -u $SL_USER:$SL_APIKEY -X POST -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress" -d '{"parameters": ["FORCE", {"imageTemplateId":
"OS_CENTOS_8_X_MINIMAL_64_BIT"}]}' 'https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/133875286/reloadOperatingSystem.json'

That kicks off an OS reload, but the server stays as Debian.

Looks like using the price id for the OS works, just need a way to print the priceIds for each OS, maybe in create-options? Or another new command maybe....

allmi@SPF-WIN10 MINGW64 ~/Source/softlayer-python (issues1768)
$ curl -u $SL_USER:$SL_APIKEY -X POST  -d '{"parameters": ["FORCE", {"itemPrices": [{"id":242518}]}]}' 'https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/133875286/reloadOperatingSystem.json'
{"error":"CentOS 8.x - Minimal Install (64 bit) is not available as of 01\/01\/2022 (Item #(14190).","code":"SoftLayer_Exception_Order_Item_Unavailable"}(py311)
allmi@SPF-WIN10 MINGW64 ~/Source/softlayer-python (issues1768)
$ curl -u $SL_USER:$SL_APIKEY -X POST  -d '{"parameters": ["FORCE", {"itemPrices": [{"id":45466}]}]}' 'https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/133875286/reloadOperatingSystem.json'
"1"(py311
ramkishor-ch commented 9 months ago

Hi @allmightyspiff,

I think issue was already was fixed in this: https://github.com/softlayer/softlayer-python/issues/1837

Can you please check it.

Thanks, Ramkishor Chaladi.