SL ReloadOS API询价
SL ReloadOS API inquiry
我正在尝试在门户网站上实施 reloadOS()。
OS 将重新加载相同的配置。
如何将当前配置设置为 reloadOperatingSystem() 的参数?
我可以在没有 "hardware.getID()" 的情况下使用这个 API 来为 BareMetal 重新加载OS 吗?
com.softlayer.api.service.hardware.Server.service(客户端, hardware.getId())
一旦包含 ID,就会产生语法错误。
这是我测试过的代码。
寻找您的反馈……谢谢。
麦克
if(deviceType.equals("Virtual Server")){
for (Guest guest : Account.service(client).getVirtualGuests()){
if(guest.getFullyQualifiedDomainName().equals(deviceName))
Guest.service(client, guest.getId()).reloadOperatingSystem("FORCE", config);
}
}else if(deviceType.equals("Bare Metal Server")){
for (Hardware hardware : Account.service(client).getHardware()){
if(hardware.getFullyQualifiedDomainName().equals(deviceName)){
com.softlayer.api.service.hardware.Server.service(client).reloadOperatingSystem("FORCE", config) ;
}
}
}
哦,伙计,恐怕这是个问题,请参阅 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”的代码 class
在class中查找此方法:
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());
}
}
}
我正在尝试在门户网站上实施 reloadOS()。 OS 将重新加载相同的配置。 如何将当前配置设置为 reloadOperatingSystem() 的参数?
我可以在没有 "hardware.getID()" 的情况下使用这个 API 来为 BareMetal 重新加载OS 吗? com.softlayer.api.service.hardware.Server.service(客户端, hardware.getId()) 一旦包含 ID,就会产生语法错误。
这是我测试过的代码。 寻找您的反馈……谢谢。 麦克
if(deviceType.equals("Virtual Server")){
for (Guest guest : Account.service(client).getVirtualGuests()){
if(guest.getFullyQualifiedDomainName().equals(deviceName))
Guest.service(client, guest.getId()).reloadOperatingSystem("FORCE", config);
}
}else if(deviceType.equals("Bare Metal Server")){
for (Hardware hardware : Account.service(client).getHardware()){
if(hardware.getFullyQualifiedDomainName().equals(deviceName)){
com.softlayer.api.service.hardware.Server.service(client).reloadOperatingSystem("FORCE", config) ;
}
}
}
哦,伙计,恐怕这是个问题,请参阅 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”的代码 class
在class中查找此方法:
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());
}
}
}