Ist es möglich, mit der Services API take or apply Softlayer OS image templates?SoftLayer OS Vorlagenverwendung mit Softlayer Service API
Ich beabsichtige, die Python-Bibliotheken zu verwenden, um diese beiden Operationen auszuführen.
Ist es möglich, mit der Services API take or apply Softlayer OS image templates?SoftLayer OS Vorlagenverwendung mit Softlayer Service API
Ich beabsichtige, die Python-Bibliotheken zu verwenden, um diese beiden Operationen auszuführen.
Sie dieses Skript verwenden kann eine Betriebssystem-Image-Vorlage zu nehmen:
"""
Create image template.
The script creates a standard image template, it makes
a call to the SoftLayer_Virtual_Guest::createArchiveTransaction method
sending the IDs of the disks in the request.
For more information please see below.
Important manual pages:
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createArchiveTransaction
https://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Block_Device
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer
# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'
# The virtual guest ID you want to create a template
virtualGuestId = 13925819
# The name of the image template
groupName = 'my image name'
# An optional note for the image template
note = 'an optional note'
"""
Build a skeleton SoftLayer_Virtual_Guest_Block_Device object
containing the disks you want to the image.
In this case we are going take an image template of 2 disks
from the virtual machine.
Make sure the SoftLayer_Virtual_Guest_Block_Device is not SWAP.
"""
blockDevices = [
{
"id": 18116783,
"complexType": "SoftLayer_Virtual_Guest_Block_Device"
},
{
"id": 18116845,
"complexType": "SoftLayer_Virtual_Guest_Block_Device"
}
]
# Declare a new API service object
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
try:
# Creating the transaction for the image template
response = client['SoftLayer_Virtual_Guest'].createArchiveTransaction(groupName, blockDevices, note, id=virtualGuestId)
print(response)
except SoftLayer.SoftLayerAPIError as e:
"""
# If there was an error returned from the SoftLayer API then bomb out with the
# error message.
"""
print("Unable to create the image template. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))
Sie dieses Skript verwenden kann einen virtuellen Gäste mit einer OS-Bildvorlage zu erstellen:
"""
Create Virtual Guest using an OS Template.
Important manual pages:
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer
from pprint import pprint as pp
USERNAME = 'set me'
API_KEY = 'set me'
templateId = 1348881
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
order = {
'complexType': 'SoftLayer_Container_Product_Order_Virtual_Guest',
'quantity': 1,
'virtualGuests': [
{'hostname': 'test-template', 'domain': 'example.com'}
],
'location': 168642, # San Jose 1
'packageId': 46, # CCI Package
'prices': [
{'id': 1640}, # 1 x 2.0 GHz Core
{'id': 1644}, # 1 GB RAM
{'id': 905}, # Reboot/Remote Console
{'id': 272}, # 10 Mbps Public & Private Networks
{'id':50231}, # 1000 GB Bandwidth
{'id': 21}, # 1 IP Address
{'id': 2202}, # 25 GB (SAN)
{'id': 1685}, # CentOS 5.x - Minimal Install (64 bit)
{'id': 55}, # Host Ping Monitoring
{'id': 57}, # Email and Ticket Notifications
{'id': 58}, # Automated Notification Response
{'id': 420}, # Unlimited SSL VPN Users & 1 PPTP VPN User per account
{'id': 418}, # Nessus Vulnerability Assessment & Reporting
],
'imageTemplateId': templateId
}
try:
# Use verifyOrder to make sure your order is correct.
# Use placeOrder to make an order directly.
result = client['SoftLayer_Product_Order'].verifyOrder(order)
pp(result)
except SoftLayer.SoftLayerAPIError as e:
"""
# If there was an error returned from the SoftLayer API then bomb out with the
# error message.
"""
print("Unable to verify order. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))
UPDATE
Um zu überprüfen, dass ein virtueller Server das Betriebssystem neu laden kann proce ss:
"""
Verify that a virtual server can go through the operating system reload process.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/verifyReloadOperatingSystem
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Hardware_Server_Configuration
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer
# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'
# The virtual guest ID you want to reload.
virtualGuestId = 15535983
# The image id used in the reloading process.
imageTemplateId = 1349311
"""
Build a skeleton SoftLayer_Container_Hardware_Server_Configuration object
containing image id you want to use.
"""
hardwareServerConfig = [
{
"imageTemplateId": imageTemplateId
}
]
# Declare a new API service object
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
try:
response = client['SoftLayer_Virtual_Guest'].verifyReloadOperatingSystem(hardwareServerConfig, id=virtualGuestId)
print(response)
except SoftLayer.SoftLayerAPIError as e:
"""
# If there was an error returned from the SoftLayer API then bomb out with the
# error message.
"""
print("Unable to verify reload OS. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))
Zum Nachladen Betriebssystemkonfiguration:
"""
Reloads current operating system configuration.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/reloadOperatingSystem
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Hardware_Server_Configuration
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer
# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'
# The virtual guest ID you want to reload.
virtualGuestId = 15535983
# The image id used in the reloading process.
imageTemplateId = 1349311
"""
Build a skeleton SoftLayer_Container_Hardware_Server_Configuration object
containing image id you want to use.
"""
hardwareServerConfig = [
{
"imageTemplateId": imageTemplateId
}
]
# To proceed with the reload without confirmation, simply pass in 'FORCE' as the token parameter
token = 'FORCE'
# Declare a new API service object
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
try:
response = client['SoftLayer_Virtual_Guest'].reloadOperatingSystem(token, hardwareServerConfig, id=virtualGuestId)
print(response)
except SoftLayer.SoftLayerAPIError as e:
"""
# If there was an error returned from the SoftLayer API then bomb out with the
# error message.
"""
print("Unable to reload OS. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))
Diese Methode könnte man auch helfen: SoftLayer_Virtual_Guest :: reloadCurrentOperatingSystemConfiguration
Weiterführende Links: http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/verifyReloadOperatingSystem
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/reloadOperatingSystem
Anstatt einen neuen virtuellen Gast (vm) zu bestellen, ist es möglich, ein Bild auf einem vorhandenen virtuellen Gast neu zu laden? – Recurrsion
Ich aktualisierte meine Antwort, hoffe, es hilft. –