通过文件导入方式添加主机

POST/zstack/v1/hosts/kvm/from-file

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "hostInfo": "FILE CONTENT ENCODE BY BASE64"
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"hostInfo":"FILE CONTENT ENCODE BY BASE64"}}' http://localhost:8080/zstack/v1/hosts/kvm/from-file

参数列表

名字类型位置描述可选值起始版本
hostInfoStringbody(包含在params结构中)经过base64编码的主机信息 3.1.0
resourceUuid (可选)Stringbody(包含在params结构中)  3.1.0
systemTags (可选)Listbody  3.1.0
userTags (可选)Listbody  3.1.0

API返回

返回示例

{
  "results": [
    {
      "ip": "127.0.0.1",
      "success": true
    }
  ]
}
名字类型描述起始版本
successboolean 3.1.0
errorErrorCode错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error3.1.0
resultsList详情参考results3.1.0

error

名字类型描述起始版本
codeString错误码号,错误的全局唯一标识,例如SYS.1000, HOST.10013.1.0
descriptionString错误的概要描述3.1.0
detailsString错误的详细信息3.1.0
elaborationString保留字段,默认为null3.1.0
opaqueLinkedHashMap保留字段,默认为null3.1.0
causeErrorCode根错误,引发当前错误的源错误,若无原错误,该字段为null3.1.0

results

名字类型描述起始版本
ipString主机IP3.1.0
successboolean 3.1.0
errorErrorCode详情参考error3.1.0

error

名字类型描述起始版本
codeString错误码号,错误的全局唯一标识,例如SYS.1000, HOST.10013.1.0
descriptionString错误的概要描述3.1.0
detailsString错误的详细信息3.1.0
elaborationString保留字段,默认为null3.1.0
opaqueLinkedHashMap保留字段,默认为null3.1.0
causeErrorCode根错误,引发当前错误的源错误,若无原错误,该字段为null3.1.0

SDK示例

Java SDK

AddKVMHostFromConfigFileAction action = new AddKVMHostFromConfigFileAction();
action.hostInfo = "FILE CONTENT ENCODE BY BASE64";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddKVMHostFromConfigFileAction.Result res = action.call();

Python SDK

AddKVMHostFromConfigFileAction action = AddKVMHostFromConfigFileAction()
action.hostInfo = "FILE CONTENT ENCODE BY BASE64"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddKVMHostFromConfigFileAction.Result res = action.call()