哦,伙计,恐怕这是个问题,请参阅https://github.com/softlayer/softlayer-java/issues/21
为了使用相同的配置重新加载服务器,您需要调用此方法:
http ://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/reloadCurrentOperatingSystemConfiguration
如您所见,这是设置“id”的必需参数,否则它将不起作用。
这是我的建议,你可以更改“com.softlayer.api.service.hardware.Server”类的代码
在类中寻找这个方法:
public static Service service(ApiClient client) {
return client.createService(Service.class, null);
}
并在该方法下方添加此方法:
public static Service service(ApiClient client, Long id) {
return client.createService(Service.class, id == null ? null : id.toString());
}
这样,您就可以在服务中设置 ID(创建服务后我找不到任何设置 ID 的方法,恐怕这种方法根本不会退出)。您可以使用此代码重新加载服务器
import com.google.gson.Gson;
import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.Account;
import com.softlayer.api.service.Hardware;
import com.softlayer.api.service.Hardware.Service;
import com.softlayer.api.service.container.hardware.server.Configuration;
import com.softlayer.api.service.hardware.Server;
//import com.softlayer.api.service.hardware.Server.Service;
public class ReloadBareMetal {
public static void main(String[] args) {
String user = "set me";
String apikey = "set me";
String deviceName = "example.example.com";
// Declare the API client
ApiClient client = new RestApiClient().withCredentials(user, apikey);
Account.Service accountService = Account.service(client);
try {
for (Hardware hardware : Account.service(client).getHardware()){
if(hardware.getFullyQualifiedDomainName().equals(deviceName)){
System.out.println("yepes");
Configuration conf = new Configuration();
//Hardware.Service hardwareService = Hardware.service(client,hardware.getId());
Server.Service hardwareService = Server.service(client, hardware.getId());
//hardwareService.
hardwareService.reloadCurrentOperatingSystemConfiguration("FORCE");
}
}
} catch (Exception e) {
System.out
.println("Unable to reload. " + e.getMessage());
}
}
}