如何使用REST API可靠地跟踪新配置的BareMetal服务器的状态 [英] How can I reliably track the status of a newly provisioned BareMetal server using the REST API

查看:63
本文介绍了如何使用REST API可靠地跟踪新配置的BareMetal服务器的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在去年开放的SL支持凭单中,我一直在寻求有关SoftLayer问题的帮助,该问题是当我的团队通过一些自定义脚本订购Baremetal服务器时,有时,与新BM服务器相关联的服务器ID在预配过程中会更改,到那时,我的工具无法跟踪它,并且失败了.在这张票证中:

In SL support ticket opened last year, I was looking for assistance in working around a SoftLayer issue where when my team orders Baremetal servers through some custom scripting, sometimes, the server id associated with the new BM server changes during the provisioning process, and at that point, my tooling loses track of it, and fails. In this ticket:

https://control.softlayer.com/support/tickets/21903245

有人告诉我,我应该使用全局标识符而不是服务器ID.我终于可以进行测试了,但是我看到了一个问题.似乎我第一次提交请求时就无法使用全局标识符查询新服务器的硬件状态,就像使用服务器ID一样.

I was told that I should use the global identifier instead of the server id. I finally got around to testing that, but I am seeing an issue. It would seem that I can't query the hardware status of the new server using the global identifier when I have first submitted the request, like I can with the server id.

[chrisr@ratsy tools]$ curl -k -u chrisr1:<PW> "https://api.softlayer.com/rest/v3/SoftLayer_Hardware/320526/getHardwareStatus.json"
{"id":3,"status":"DEPLOY"}

[chrisr@ratsy tools]$ curl -k -u chrisr1:<PW> "https://api.softlayer.com/rest/v3/SoftLayer_Hardware/75302613-e55a-481a-829f-967799a41968/getHardwareStatus.json"
null

但是,以后确实可以使用.我对准备就绪的服务器运行相同的查询.

However, it does work later. I ran the same query for a server that was all ready provisioned.

[chrisr@ratsy tools]$ curl -sS -k -u chrisr1:<PW> "https://api.softlayer.com/rest/v3/SoftLayer_Hardware/1ab37f37-9373-4e10-9de4-7319fffcb4f8/getHardwareStatus.json" | json_pp
{
"status" : "ACTIVE",
"id" : 5
}

我需要一个可以查询的标识符:

I need an identifier that I can query on that is:

a)立即可用,并且

b)不会改变

谢谢.

推荐答案

在提供完成之前,会将全局标识符分配给硬件,因此,请求将返回"null"值.但是,如果服务器已重新分配,则标识符不会更改.

The Global Identifier is assigned to the hardware until the provision is complete, for this reason the request returns "null" value. But it is the identifier that would not change if the server has been re-assigned.

显然,不存在任何可用于根据您的需求跟踪Bare Metal Server的标识符.

Apparently there not exists any identifier that you can use to track Bare Metal Servers according your requirements.

但是,我建议您通过分配给服务器的主机名来跟踪服务器的配置.

However, I can recommend to track your server provisioning through hostname that you assigned to the server.

  1. 获取服务器信息

  1. Getting server's information

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Account/getHardware?objectFilter={"hardware":{"hostname":{"operation":"serverHostname"}}}

Method: Get

替换:将 serverHostname 替换为您所使用的服务器的主机名 在您的订单中定义.

Replace: serverHostname with the server's hostname that you defined in your order.

响应将提供有关服务器标识符的信息, 然后您可以使用它从服务器检查状态.

The response will provide information about server's identifier, then you can check the status from server with it.

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Hardware/123123/getHardwareStatus

Method: Get

注意:您需要确保主机名相同的裸机服务器不超过一个.

Note: You need to make sure that you don't have more than one bare metal server's with the same hostname.

这篇关于如何使用REST API可靠地跟踪新配置的BareMetal服务器的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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