如何使用 rest api 使用标准模板软层创建虚拟服务器?
How to create virtual server using standard template softlayer using rest api?
我创建了一个镜像模板,想用这个模板创建一个虚拟服务器。我可以在 WEB GUI 上执行此操作。对于休息 api,我看到 operatingSystemReferenceCode 用于创建虚拟服务器。我认为 operatingSystemReferenceCode 与图像模板不同。
我想知道在使用映像模板创建虚拟服务器时使用了哪个api,您能举个例子真是太好了。谢谢!
嗯,简单的方法是使用 createObject 方法,在该方法中,您可以传递要使用的图像以获取更多信息,请参阅:
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject
你只需要在请求中配置这个属性:
这里有一个 RESTful 例子:
POST https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/createObject
有效负载:
{
"parameters":[
{
"hostname": "host1",
"domain": "example.com",
"startCpus": 1,
"maxMemory": 1024,
"hourlyBillingFlag": true,
"localDiskFlag": true,
"datacenter": {
"name": "dal05"
}
"blockDeviceTemplateGroup": {
"globalIdentifier": "07beadaa-1e11-476e-a188-3f7795feb9fb"
}
}
]
}
您可能想知道如何获取要使用的模板的全局标识符,有两种类型的图像模板:私有和 public。
可以使用此方法获取私有模板(您创建的模板):
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getBlockDeviceTemplateGroups
另一方面,可以使用此方法获取 public 模板:
希望对你有帮助
此致
我创建了一个镜像模板,想用这个模板创建一个虚拟服务器。我可以在 WEB GUI 上执行此操作。对于休息 api,我看到 operatingSystemReferenceCode 用于创建虚拟服务器。我认为 operatingSystemReferenceCode 与图像模板不同。
我想知道在使用映像模板创建虚拟服务器时使用了哪个api,您能举个例子真是太好了。谢谢!
嗯,简单的方法是使用 createObject 方法,在该方法中,您可以传递要使用的图像以获取更多信息,请参阅:
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject
你只需要在请求中配置这个属性:
这里有一个 RESTful 例子:
POST https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/createObject 有效负载:
{
"parameters":[
{
"hostname": "host1",
"domain": "example.com",
"startCpus": 1,
"maxMemory": 1024,
"hourlyBillingFlag": true,
"localDiskFlag": true,
"datacenter": {
"name": "dal05"
}
"blockDeviceTemplateGroup": {
"globalIdentifier": "07beadaa-1e11-476e-a188-3f7795feb9fb"
}
}
]
}
您可能想知道如何获取要使用的模板的全局标识符,有两种类型的图像模板:私有和 public。
可以使用此方法获取私有模板(您创建的模板):
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getBlockDeviceTemplateGroups
另一方面,可以使用此方法获取 public 模板:
希望对你有帮助
此致