如何将用户元数据添加到 IBM Cloud 虚拟设备订单?
How to add user metadata to IBM Cloud virtual device order?
我通过发布 JSON 使用 NodeJS (JavaScript) 在 IBM Cloud(前 SoftLayer)上成功订购了新设备,如下所示。现在我正在尝试修改我的订单并将用户元数据添加到每个订购的设备,但找不到轻松添加它的方法。
这是我的工作订单(在一个 API 电话中请求 3 个 Ubuntu 盒子):
var ibm_order = {
imageTemplateGlobalIdentifier: 'a1237539-c54d-46dd-bece-c17c2329c607',
imageTemplateId: '',
location: 138124,
packageId: 46,
presetId: '',
quantity: 3,
sourceVirtualGuestId: '',
useHourlyPricing: true,
complexType: 'SoftLayer_Container_Product_Order_Virtual_Guest',
prices:
[{id: 1641}, // description: 2 x 2.0 GHz Cores
{id: 1647}, // description: 8 GB
{id: 13899}, // description: 25 GB (LOCAL)
{id: 905}, // description: Reboot / Remote Console
{id: 274}, // description: 1 Gbps Public & Private Network Uplinks
{id: 1800}, // description: 0 GB Bandwidth
{id: 21}, // description: 1 IP Address
{id: 55}, // description: Host Ping
{id: 57}, // description: Email and Ticket
{id: 58}, // description: Automated Notification
{id: 420}, // description: Unlimited SSL VPN Users & 1 PPTP VPN User per account
{id: 418}], // description: Nessus Vulnerability Assessment & Reporting
sshKeys: [{sshKeyIds: [4512]}],
virtualGuests: [
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1a'},
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1b'},
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1c'}
]
}
并且此代码使用 softlayer-node npm:
发布上述订单
var SoftLayer = require('softlayer-node');
var softlayer_client = new SoftLayer();
// actual SL API call
softlayer_client
.auth(softlayer_username, softlayer_api_key)
.path('Product_Order', 'placeOrder')
.parameters(ibm_order)
.post()
.then(function(result:any) {
console.log('success! result: ' + JSON.stringify(result, null, 4) );
}, function(error:any) {
console.log('error: details: ' + JSON.stringify(error, null, 4) );
});
问题:如何将用户元数据添加到每个请求的设备?
用户元数据是一个字符串数组,大概应该是 virtualGuests 数组元素的一部分(每个 "virtual guest" 都有自己的 user_metadata 数组),但是当我试图指定 "UserMetadata" 我出现错误:
error: details: {
"message": {
"error": "The property 'UserMetadata' is not valid for 'SoftLayer_Virtual_Guest'.",
"code": "SoftLayer_Exception_Public"
},
"statusCode": 500
}
我找到了这些 SoftLayer API 参考页:
1) 参考 » 数据类型 » SoftLayer_Container_Product_Order_Virtual_Guest
2) 参考 » 服务 » SoftLayer_Virtual_Guest
但这些并不是 100% 相关(他们建议使用 setUserMetadata 方法,但我只有一个低水平 "pre-baked" JSON!)
或者可能有其他更优雅的方式从 NodeJS 从 IBM Cloud(前 SoftLayer)订购新设备?
您是对的,但错误是由于您发送的 属性 "UserMetaData",这不是 virtualGuests, the specific property you are looking for is called "userData" instead, it is inside the datatype Virtual_Guest 的有效 属性。
尝试以下操作:
var ibm_order = {
imageTemplateGlobalIdentifier: 'a1237539-c54d-46dd-bece-c17c2329c607',
imageTemplateId: '',
location: 138124,
packageId: 46,
presetId: '',
quantity: 3,
sourceVirtualGuestId: '',
useHourlyPricing: true,
complexType: 'SoftLayer_Container_Product_Order_Virtual_Guest',
prices:
[{id: 1641}, // description: 2 x 2.0 GHz Cores
{id: 1647}, // description: 8 GB
{id: 13899}, // description: 25 GB (LOCAL)
{id: 905}, // description: Reboot / Remote Console
{id: 274}, // description: 1 Gbps Public & Private Network Uplinks
{id: 1800}, // description: 0 GB Bandwidth
{id: 21}, // description: 1 IP Address
{id: 55}, // description: Host Ping
{id: 57}, // description: Email and Ticket
{id: 58}, // description: Automated Notification
{id: 420}, // description: Unlimited SSL VPN Users & 1 PPTP VPN User per account
{id: 418}], // description: Nessus Vulnerability Assessment & Reporting
sshKeys: [{sshKeyIds: [4512]}],
virtualGuests: [
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1a', userData: [{value: 'someValue1'}]},
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1b', userData: [{value: 'someValue2'}]},
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1c', userData: [{value: 'someValue3'}]}
]
}
有关更多信息,您可以在下面看到:
http://sldn.softlayer.com/blog/jarteche/getting-started-user-data-and-post-provisioning-scripts
我通过发布 JSON 使用 NodeJS (JavaScript) 在 IBM Cloud(前 SoftLayer)上成功订购了新设备,如下所示。现在我正在尝试修改我的订单并将用户元数据添加到每个订购的设备,但找不到轻松添加它的方法。
这是我的工作订单(在一个 API 电话中请求 3 个 Ubuntu 盒子):
var ibm_order = {
imageTemplateGlobalIdentifier: 'a1237539-c54d-46dd-bece-c17c2329c607',
imageTemplateId: '',
location: 138124,
packageId: 46,
presetId: '',
quantity: 3,
sourceVirtualGuestId: '',
useHourlyPricing: true,
complexType: 'SoftLayer_Container_Product_Order_Virtual_Guest',
prices:
[{id: 1641}, // description: 2 x 2.0 GHz Cores
{id: 1647}, // description: 8 GB
{id: 13899}, // description: 25 GB (LOCAL)
{id: 905}, // description: Reboot / Remote Console
{id: 274}, // description: 1 Gbps Public & Private Network Uplinks
{id: 1800}, // description: 0 GB Bandwidth
{id: 21}, // description: 1 IP Address
{id: 55}, // description: Host Ping
{id: 57}, // description: Email and Ticket
{id: 58}, // description: Automated Notification
{id: 420}, // description: Unlimited SSL VPN Users & 1 PPTP VPN User per account
{id: 418}], // description: Nessus Vulnerability Assessment & Reporting
sshKeys: [{sshKeyIds: [4512]}],
virtualGuests: [
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1a'},
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1b'},
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1c'}
]
}
并且此代码使用 softlayer-node npm:
发布上述订单 var SoftLayer = require('softlayer-node');
var softlayer_client = new SoftLayer();
// actual SL API call
softlayer_client
.auth(softlayer_username, softlayer_api_key)
.path('Product_Order', 'placeOrder')
.parameters(ibm_order)
.post()
.then(function(result:any) {
console.log('success! result: ' + JSON.stringify(result, null, 4) );
}, function(error:any) {
console.log('error: details: ' + JSON.stringify(error, null, 4) );
});
问题:如何将用户元数据添加到每个请求的设备? 用户元数据是一个字符串数组,大概应该是 virtualGuests 数组元素的一部分(每个 "virtual guest" 都有自己的 user_metadata 数组),但是当我试图指定 "UserMetadata" 我出现错误:
error: details: {
"message": {
"error": "The property 'UserMetadata' is not valid for 'SoftLayer_Virtual_Guest'.",
"code": "SoftLayer_Exception_Public"
},
"statusCode": 500
}
我找到了这些 SoftLayer API 参考页:
1) 参考 » 数据类型 » SoftLayer_Container_Product_Order_Virtual_Guest
2) 参考 » 服务 » SoftLayer_Virtual_Guest
但这些并不是 100% 相关(他们建议使用 setUserMetadata 方法,但我只有一个低水平 "pre-baked" JSON!)
或者可能有其他更优雅的方式从 NodeJS 从 IBM Cloud(前 SoftLayer)订购新设备?
您是对的,但错误是由于您发送的 属性 "UserMetaData",这不是 virtualGuests, the specific property you are looking for is called "userData" instead, it is inside the datatype Virtual_Guest 的有效 属性。
尝试以下操作:
var ibm_order = {
imageTemplateGlobalIdentifier: 'a1237539-c54d-46dd-bece-c17c2329c607',
imageTemplateId: '',
location: 138124,
packageId: 46,
presetId: '',
quantity: 3,
sourceVirtualGuestId: '',
useHourlyPricing: true,
complexType: 'SoftLayer_Container_Product_Order_Virtual_Guest',
prices:
[{id: 1641}, // description: 2 x 2.0 GHz Cores
{id: 1647}, // description: 8 GB
{id: 13899}, // description: 25 GB (LOCAL)
{id: 905}, // description: Reboot / Remote Console
{id: 274}, // description: 1 Gbps Public & Private Network Uplinks
{id: 1800}, // description: 0 GB Bandwidth
{id: 21}, // description: 1 IP Address
{id: 55}, // description: Host Ping
{id: 57}, // description: Email and Ticket
{id: 58}, // description: Automated Notification
{id: 420}, // description: Unlimited SSL VPN Users & 1 PPTP VPN User per account
{id: 418}], // description: Nessus Vulnerability Assessment & Reporting
sshKeys: [{sshKeyIds: [4512]}],
virtualGuests: [
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1a', userData: [{value: 'someValue1'}]},
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1b', userData: [{value: 'someValue2'}]},
{domain: 'mydomain.com', hostname: 'rw-ff-dal05-1c', userData: [{value: 'someValue3'}]}
]
}
有关更多信息,您可以在下面看到:
http://sldn.softlayer.com/blog/jarteche/getting-started-user-data-and-post-provisioning-scripts