Using Ovirt Java SDK for VM automation .. I have to use payload mechanism as I am trying
to using same user_data for all VM customization (Centos, Ubuntu and Windows)
As push user_data content of size 8931 (String length) is it throwing 400
final_message: "The system is finally up, after $UPTIME seconds"] Size: [8931]
org.ovirt.engine.sdk4.Error: HTTP response code is "400". HTTP response message
is "Bad Request".
at org.ovirt.engine.sdk4.internal.services.ServiceImpl.throwError(ServiceImpl.java:113)
at org.ovirt.engine.sdk4.internal.services.ServiceImpl.checkFault(ServiceImpl.java:40)
at
org.ovirt.engine.sdk4.internal.services.VmServiceImpl$UpdateRequestImpl.send(VmServiceImpl.java:1543)
at
org.ovirt.engine.sdk4.internal.services.VmServiceImpl$UpdateRequestImpl.send(VmServiceImpl.java:1464)
Sample code --------------
List<org.ovirt.engine.sdk4.types.File> files = new
ArrayList<org.ovirt.engine.sdk4.types.File>();
String metadata = cloudinit.cloudInitMetaFile(map, vmname, vm.id());
String userdata = cloudinit.cloudInitUserData( map, vmname, pkglist);
logger.info("Cloud-Init Script - user data [{}] Size: [{}]", userdata,
userdata.length());
files.add(file().name("openstack/latest/meta_data.json").content(metadata).build());
files.add(file().name("openstack/latest/user_data").content(userdata).build());
if (networkdatafile != null && !networkdatafile.isEmpty()) {
files.add(file().name("openstack/latest/network_data.json").content(networkdatafile).build());
contentnetworkdatafile = cloudinit.cloudNetworkConfigMetaData(map, "eth0"
);
files.add(file().name("openstack/content/network-config").content(contentnetworkdatafile).build());
files.add(file().name("openstack/content/network-config").content(contentnetworkdatafile).build());
}
vmService.update().vm(vm().payloads(payload().type(VmDeviceType.CDROM).files(files))).send();