I am trying to update a password/Username of OS using Java API in Softlayer. But after executing API, Password is not modified. Here is the code i've tested. Please comment me if you find any doubts. Thanks
import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.Hardware;
import com.softlayer.api.service.hardware.Server;
import com.softlayer.api.service.software.Component;
import com.softlayer.api.service.software.Description;
import com.softlayer.api.service.virtual.Guest;
public void deviceSoftcomp_BM_reName() throws Exception {
Server.Service bmService = Server.service(client, 8045737l);
bmService.withMask().softwareComponents().passwords().username().password();
bmService.withMask().softwareComponents().softwareDescription().name();
Hardware hd = bmService.getObject();
List<Component> compList = hd.getSoftwareComponents();
for (Component comp : compList) {
Description desc = comp.getSoftwareDescription();
System.out.println(" software name : " + desc.getName());
Long softId = comp.getId();
System.out.println(" software id : " + softId);
List<com.softlayer.api.service.software.component.Password> passList = comp.getPasswords();
for (com.softlayer.api.service.software.component.Password password : passList) {
System.out.println(" Username : " + password.getUsername());
System.out.println(" Password : " + password.getPassword());
if(softId == 9824519){
System.out.println("--- Rename OS name " );
password.setUsername("newUser");
password.setPassword("xfdgasdf123");
}
}
}
}
Here is java sample code to update software in device.
Please try the following: SoftLayer_Software_Component_Password::editObject
Below is a REST example:
Also, to get passwords of server software components, please see: