i trying implement of reloados() on portal site. os reloaded same configuration. how can set current configuration parameter reloadoperatingsystem()?
can use api without "hardware.getid()" reloados baremetal? com.softlayer.api.service.hardware.server.service(client, hardware.getid()) once id included, produces syntax error.
this code i've tested. looking feed back.. thank you. mike
if(devicetype.equals("virtual server")){ (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")){ (hardware hardware : account.service(client).gethardware()){ if(hardware.getfullyqualifieddomainname().equals(devicename)){ com.softlayer.api.service.hardware.server.service(client).reloadoperatingsystem("force", config) ; } } }
oh man, afraid issue, see https://github.com/softlayer/softlayer-java/issues/21
in order reload server using same configuration need call method: http://sldn.softlayer.com/reference/services/softlayer_hardware_server/reloadcurrentoperatingsystemconfiguration
as can see required parameter set “id” otherwise not work.
this suggestion, ca change code of “com.softlayer.api.service.hardware.server” class
look method class:
public static service service(apiclient client) { return client.createservice(service.class, null); }
and bellow method add method:
public static service service(apiclient client, long id) { return client.createservice(service.class, id == null ? null : id.tostring()); }
in way way able set id in service (i not find method set id after creating service , afraid such method not exit @ all). can use code reload server
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 api client apiclient client = new restapiclient().withcredentials(user, apikey); account.service accountservice = account.service(client); try { (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 reload. " + e.getmessage()); } } }
Comments
Post a Comment