Search in sources :

Example 16 with StorageDomain

use of org.ovirt.engine.sdk4.types.StorageDomain in project ovirt-engine-sdk-java by oVirt.

the class AddNfsIsoStorageDomain method main.

public static void main(String[] args) throws Exception {
    // Create the connection to the server:
    Connection connection = connection().url("https://engine40.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
    // Get the reference to the storage domains service:
    StorageDomainsService sdsService = connection.systemService().storageDomainsService();
    // Create a new NFS storage domain:
    StorageDomain sd = sdsService.add().storageDomain(storageDomain().name("myiso").description("My ISO").type(StorageDomainType.ISO).host(host().name("myhost")).storage(hostStorage().type(StorageType.NFS).address("server0.example.com").path("/nfs/ovirt/40/myiso"))).send().storageDomain();
    // Wait till the storage domain is unattached:
    StorageDomainService sdService = sdsService.storageDomainService(sd.id());
    for (; ; ) {
        Thread.sleep(5 * 1000);
        sd = sdService.get().send().storageDomain();
        if (sd.status() == StorageDomainStatus.UNATTACHED) {
            break;
        }
    }
    // Close the connection to the server:
    connection.close();
}
Also used : StorageDomainsService(org.ovirt.engine.sdk4.services.StorageDomainsService) StorageDomainService(org.ovirt.engine.sdk4.services.StorageDomainService) StorageDomain(org.ovirt.engine.sdk4.types.StorageDomain) Connection(org.ovirt.engine.sdk4.Connection)

Aggregations

Connection (org.ovirt.engine.sdk4.Connection)15 StorageDomain (org.ovirt.engine.sdk4.types.StorageDomain)13 StorageDomainsService (org.ovirt.engine.sdk4.services.StorageDomainsService)12 StorageDomainService (org.ovirt.engine.sdk4.services.StorageDomainService)7 SystemService (org.ovirt.engine.sdk4.services.SystemService)7 Vm (org.ovirt.engine.sdk4.types.Vm)6 VmsService (org.ovirt.engine.sdk4.services.VmsService)5 Disk (org.ovirt.engine.sdk4.types.Disk)4 DataCenterService (org.ovirt.engine.sdk4.services.DataCenterService)3 DataCentersService (org.ovirt.engine.sdk4.services.DataCentersService)3 VmService (org.ovirt.engine.sdk4.services.VmService)3 DataCenter (org.ovirt.engine.sdk4.types.DataCenter)3 AttachedStorageDomainService (org.ovirt.engine.sdk4.services.AttachedStorageDomainService)2 AttachedStorageDomainsService (org.ovirt.engine.sdk4.services.AttachedStorageDomainsService)2 DiskService (org.ovirt.engine.sdk4.services.DiskService)2 DisksService (org.ovirt.engine.sdk4.services.DisksService)2 ImagesService (org.ovirt.engine.sdk4.services.ImagesService)2 StorageDomainVmsService (org.ovirt.engine.sdk4.services.StorageDomainVmsService)2 DiskAttachment (org.ovirt.engine.sdk4.types.DiskAttachment)2 Image (org.ovirt.engine.sdk4.types.Image)2