How to reload system with flex image using softlayer REST API specifies how to do a reload using REST. How do I do it from the "slcli" command?
Using "slcli server reload --help" doesn't show any option to specify the imageTemplateId. It only enables sshKeys and install scripts.
Using the "slcli call-api..." I don't understand if it's possible to pass parameters. It really doesn't look like it.
The slcli is not able to do that, I recomend you to use python scrips to call the API.
see this example about reloads: https://gist.github.com/softlayer/2789898
and here an example to reload from an image template, you just need to make sure that the imagetemplate id is the correct for your flex image:
"""
Reload servers from a list of IPs
This script looks for a server with a determinate IP address and reload it from an image template.
Important manual pages:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware_Server
http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/findByIpAddress
http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/reloadOperatingSystem
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer
import json
ipsToReload = ['184.172.45.215', '1.1.1.1']
# Call the Softlayer_Account::getPrivateBlockDeviceTemplateGroups method.
# to get the images templates in the account.
imageTemplateId = 51236
USERNAME = 'set me'
API_KEY = 'set me'
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
hardwareService = client['SoftLayer_Hardware_Server']
failedServers = []
for ipToReload in ipsToReload:
failedServer = {}
failedServer['ip'] = ipToReload
try:
server = hardwareService.findByIpAddress(ipToReload)
if server == '':
failedServer['error'] = "Ip does not exist."
failedServers.append(failedServer)
continue
except SoftLayer.SoftLayerAPIError as e:
failedServer['error'] = e
failedServers.append(failedServer)
continue
if 'activeTransaction' in server:
failedServer['error'] = "There is an active transaction."
failedServers.append(failedServer)
continue
config = {
'imageTemplateId': imageTemplateId
}
try:
reload = hardwareService.reloadOperatingSystem('FORCE', config, id=server['id'])
except SoftLayer.SoftLayerAPIError as e:
failedServer['error'] = e
failedServers.append(failedServer)
continue
print("The reload failed for these IPs:")
print(json.dumps(failedServers, sort_keys=True, indent=2, separators=(',', ': ')))
Regards