我正在使用Softlayer java客户端实现添加监视器。 执行creatObject()后,它将返回Athentication错误。请查看下面的示例代码,如果您发现任何疑问,请告知我们。 我的用户ID是超级用户(IBMxxxxx),它没有设置权限。
错误:com.softlayer.api.ApiException $ Internal:无法创建SoftLayer_Network_Monitor_Version1_Query_Host类型的新对象。确保身份验证方法正确。(代码:SoftLayer_Exception,status:500)
private void AddMonitoringInfo() {
Long hardwareId = new Long(848429);
// Define Ip Address
String ipAddress = "173.192.36.250";
// Define Query Type (1 = SERVICE PING, 17 = SLOW PING)
Long queryTypeId = new Long(1);
// Define Response action id (1 = Do Nothing, 2 = Notify Users)
Long responseActionId = new Long(2);
// Define waitCycles 0 = Immediately, 1 = 5 Minutes, 2 = 10 Minutes, etc
Long waitCycles = new Long(1);
// Define SoftLayer_Network_Monitor_Version1_Query_Host service
Host.Service hostService = Host.service(client);
// Build a SoftLayer_Network_Monitor_Version1_Query_Host object that you
// wish to create
Host templateObject = new Host();
templateObject.setHardwareId(hardwareId);
templateObject.setIpAddress(ipAddress);
templateObject.setQueryTypeId(queryTypeId);
templateObject.setResponseActionId(responseActionId);
templateObject.setWaitCycles(waitCycles);
try {
Host result = hostService.createObject(templateObject);
Gson gson = new Gson();
System.out.println("Result : " + gson.toJson(result));
} catch (Exception e) {
System.out.println("Error: " + e);
}
}
答案 0 :(得分:0)
您遇到的问题与权限有关。
请检查您尝试创建显示器的用户是否已启用管理设备监控权限。