Source:
public static void main ( java.lang.String [ ] args ) throws java.lang.Exception { org.ovirt.engine.sdk4.Connection connection = org.ovirt.engine.sdk4.ConnectionBuilder.connection ( ) . url ( "https://engine40.example.com/ovirt-engine/api" ) . user ( "admin@internal" ) . password ( "redhat123" ) . trustStoreFile ( "truststore.jks" ) . build ( ) ; org.ovirt.engine.sdk4.services.VmsService vmsService = connection.systemService ( ) . vmsService ( ) ; org.ovirt.engine.sdk4.types.Vm vm = vmsService.list ( ) . search ( "name=myvm" ) . send ( ) . vms ( ) . get ( 0 ) ; org.ovirt.engine.sdk4.services.DiskAttachmentsService diskAttachmentsService = vmsService.vmService ( vm.id ( ) ) . diskAttachmentsService ( ) ; org.ovirt.engine.sdk4.types.DiskAttachment diskAttachment = diskAttachmentsService.add ( ) . attachment ( org.ovirt.engine.sdk4.builders.Builders.diskAttachment ( ) . disk ( org.ovirt.engine.sdk4.builders.Builders.disk ( ) . name ( "mydisk" ) . description ( "My disk" ) . format ( DiskFormat.COW ) . provisionedSize ( ( 1 * ( ( int ) ( java.lang.Math.pow ( 2 , 20 ) ) ) ) ) . storageDomains ( org.ovirt.engine.sdk4.builders.Builders.storageDomain ( ) . name ( "mydata" ) ) ) . interface_ ( DiskInterface.VIRTIO ) . bootable ( false ) ) . send ( ) . attachment ( ) ; org.ovirt.engine.sdk4.services.DisksService disksService = connection.systemService ( ) . disksService ( ) ; org.ovirt.engine.sdk4.services.DiskService diskService = disksService.diskService ( diskAttachment.disk ( ) . id ( ) ) ; for ( ; ; ) { java.lang.Thread.sleep ( ( 5 * 1000 ) ) ; org.ovirt.engine.sdk4.types.Disk disk = diskService.get ( ) . send ( ) . disk ( ) ; if ( ( disk.status ( ) ) == ( org.ovirt.engine.sdk4.types.DiskStatus.OK ) ) { break ; } } connection.close ( ) ; }

Target:
public static void main ( java.lang.String [ ] args ) throws java.lang.Exception { org.ovirt.engine.sdk4.Connection connection = org.ovirt.engine.sdk4.ConnectionBuilder.connection ( ) . url ( "https://engine40.example.com/ovirt-engine/api" ) . user ( "admin@internal" ) . password ( "redhat123" ) . trustStoreFile ( "truststore.jks" ) . build ( ) ; org.ovirt.engine.sdk4.services.VmsService vmsService = connection.systemService ( ) . vmsService ( ) ; org.ovirt.engine.sdk4.types.Vm vm = vmsService.list ( ) . search ( "name=myvm" ) . send ( ) . vms ( ) . get ( 0 ) ; org.ovirt.engine.sdk4.services.DiskAttachmentsService diskAttachmentsService = vmsService.vmService ( vm.id ( ) ) . diskAttachmentsService ( ) ; org.ovirt.engine.sdk4.types.DiskAttachment diskAttachment = diskAttachmentsService.add ( ) . attachment ( org.ovirt.engine.sdk4.builders.Builders.diskAttachment ( ) . disk ( org.ovirt.engine.sdk4.builders.Builders.disk ( ) . name ( "mydisk" ) . description ( "My disk" ) . format ( DiskFormat.COW ) . provisionedSize ( ( 10 * ( ( int ) ( java.lang.Math.pow ( 2 , 30 ) ) ) ) ) . storageDomains ( org.ovirt.engine.sdk4.builders.Builders.storageDomain ( ) . name ( "mydata" ) ) ) . interface_ ( DiskInterface.VIRTIO ) . bootable ( false ) ) . send ( ) . attachment ( ) ; org.ovirt.engine.sdk4.services.DisksService disksService = connection.systemService ( ) . disksService ( ) ; org.ovirt.engine.sdk4.services.DiskService diskService = disksService.diskService ( diskAttachment.disk ( ) . id ( ) ) ; for ( ; ; ) { java.lang.Thread.sleep ( ( 5 * 1000 ) ) ; org.ovirt.engine.sdk4.types.Disk disk = diskService.get ( ) . send ( ) . disk ( ) ; if ( ( disk.status ( ) ) == ( org.ovirt.engine.sdk4.types.DiskStatus.OK ) ) { break ; } } connection.close ( ) ; }