检索有关已配置的SoftLayer服务器的用户元数据返回null [英] Retrieving user metadata about a provisioned SoftLayer server comes back null

查看:32
本文介绍了检索有关已配置的SoftLayer服务器的用户元数据返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图一致地检索每台计算机的用户元信息,但是我发现最多台计算机缺少此数据.我想更好地了解该用户数据在那里需要什么.我很好奇是否可以在不需要用户信息的情况下请求和配置服务器(例如,用于订购服务器的API调用,但未提供用户数据).还是我在检索此信息时是否缺少某些东西.这是我正在运行的基本红宝石程序:

I'm trying to retrieve the user meta information for each machine consistently but what I'm finding is most of my machines are missing this data. I'd like to understand better what is required for this user data to be there. I'm curious if a server can be requested and provisioned without requiring user information (e.g. an API call to order a server and no user data is given). Or whether I am missing something in how I retrieve this information. Here is the basic ruby program I'm running:

user = ###
api_key = ###

client = SoftLayer::Client.new(:username => user, :api_key => api_key, :timeout => 999999)

list_of_virtual_machines = client['Account'].result_limit(i*50,50).object_mask("mask[id, billingItem[recurringFee, associatedChildren[recurringFee], orderItem[description, order[userRecord[username], id]]], userData]").getVirtualGuests
for x in 0..list_of_virtual_machines.length - 1
  pp list_of_virtual_machines[i]['userData']
  if list_of_virtual_machines[i]['billingItem'] && list_of_virtual_machines[i]['billingItem']['orderItem'] && list_of_virtual_machines[i]['billingItem']['orderItem']['order'] && list_of_virtual_machines[i]['billingItem']['orderItem']['order']['userRecord']
    pp list_of_virtual_machines[i]['billingItem']['orderItem']['order']['userRecord']
  end
end

我的照片始终显示为空.这个问题与我不久前问过的一个类似问题有关(但该问题的焦点移到了ProvisionDate上):如何获取订单用户名和使用Ruby的所有SoftLayer计算机的ProvisioningDate?

My prints are consistently showing null. This question is related to a similar question I asked not too long ago (but the focus of that question moved towards the provisionDate): How to get order username and provisionDate for all SoftLayer machines using Ruby?

推荐答案

由于您未添加数据,因此缺少该数据.

They are missing that data because you did not added.

您现在可以创建用户数据来订购新服务器或VSI,您只需使用 createObject 方法或 placeOrder 在订购请求中发送数据即可.强>方法.参见 http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject

you can create the user data at moment to order a new server or VSI, you just have to send the data in your order request either using the createObject method or the placeOrder method. see http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject

例如

{ 
    "userData": [ 
        { 
            "value": "someValue" 
        } 
    ] 
}

或者您可以在使用这些方法配置服务器之后进行设置

or you can set it after the server has been provisioned using these methods

http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/setUserMetadata http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/setUserMetadata

基本上,如果您要使用安装后脚本,则usermetadata很有用.订购新服务器不需要usermetadata值

Basically the usermetadata are useful if you are going to use a post install script. The usermetadata value is not required to order a new server

看看本文中的示例: http://sldn.softlayer.com/blog/jarteche/getting-started-user-data-and-post-provisioning-scripts

这篇关于检索有关已配置的SoftLayer服务器的用户元数据返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆