take or apply Softlayer OS image templates 서비스 API로 가능합니까?Softlayer 서비스 API로 SoftLayer OS 템플릿 사용
저는이 두 가지 작업을 모두 수행하기 위해 파이썬 라이브러리를 사용하려고합니다.
당신은 OS 이미지 템플릿을 적용하려면 스크립트를 사용할 수 있습니다take or apply Softlayer OS image templates 서비스 API로 가능합니까?Softlayer 서비스 API로 SoftLayer OS 템플릿 사용
저는이 두 가지 작업을 모두 수행하기 위해 파이썬 라이브러리를 사용하려고합니다.
당신은 OS 이미지 템플릿을 적용하려면 스크립트를 사용할 수 있습니다: OS 이미지 템플릿을 사용하여 가상 게스트를 만들려면이 스크립트를 사용할 수
"""
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))
을 :
"""
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를
가상 서버가 운영 체제를 다시로드 할 수 있는지 확인하려면 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))
는 :
"""
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))
이 방법은뿐만 아니라 당신을 도울 수 있습니다 : 더 읽기 SoftLayer_Virtual_Guest :: reloadCurrentOperatingSystemConfiguration
링크 : http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/verifyReloadOperatingSystem
을http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/reloadOperatingSystem
새로운 가상 게스트 (VM)을 주문하는 대신 기존 가상 게스트에서 이미지를 다시로드 할 수 있습니까? – Recurrsion
내 답변이 업데이트되었습니다. 도움이되기를 바랍니다. –