use of org.openmuc.j60870.Connection in project ovirt-engine-sdk-java by oVirt.
the class AddNfsDataStorageDomain 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("mydata").description("My data").type(StorageDomainType.DATA).host(host().name("myhost")).storage(hostStorage().type(StorageType.NFS).address("server0.example.com").path("/nfs/ovirt/40/mydata"))).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();
}
use of org.openmuc.j60870.Connection in project ovirt-engine-sdk-java by oVirt.
the class AddSystemPermission 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 root of the tree of services:
SystemService systemService = connection.systemService();
// Get the reference to the service that manages system permissions:
SystemPermissionsService permissionsService = systemService.permissionsService();
// Add the "SupeUser" permission to the user with id "123":
permissionsService.add().permission(permission().role(role().name("SuperUser")).user(user().id("123"))).send();
// Close the connection to the server:
connection.close();
}
use of org.openmuc.j60870.Connection in project ovirt-engine-sdk-java by oVirt.
the class ListAffinityLabels 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 affinity labels service:
AffinityLabelsService affinityLabelsService = connection.systemService().affinityLabelsService();
// Use the "list" method of the affinity labels service
// to list all the affinity labels of the system:
List<AffinityLabel> affinityLabels = affinityLabelsService.list().send().labels();
// which has assigned that affinity label:
for (AffinityLabel affinityLabel : affinityLabels) {
System.out.printf("%s:\n", affinityLabel.name());
for (Vm vm_link : connection.followLink(affinityLabel.vms())) {
System.out.printf(" - %s\n", connection.followLink(vm_link).name());
}
}
// Close the connection to the server:
connection.close();
}
use of org.openmuc.j60870.Connection in project ovirt-engine-sdk-java by oVirt.
the class ListTags method main.
public static void main(String[] args) throws Exception {
Connection connection = connection().url("https://engine40.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
// Find the service that manages tags:
TagsService tagsService = connection.systemService().tagsService();
// Retrieve the tags:
List<Tag> tags = tagsService.list().send().tags();
// For each tag print its name and description:
for (Tag tag : tags) {
System.out.printf("%s: %s\n", tag.name(), tag.description());
}
// Close the connection to the server:
connection.close();
}
use of org.openmuc.j60870.Connection in project ovirt-engine-sdk-java by oVirt.
the class AddVmSnapshot 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();
// Locate the virtual machines service and use it to find the virtual machine:
VmsService vmsService = connection.systemService().vmsService();
Vm vm = vmsService.list().search("name=myvm").send().vms().get(0);
// Locate the service that manages the snapshots of the virtual machine:
SnapshotsService snapshotsService = vmsService.vmService(vm.id()).snapshotsService();
// Add the snapshot:
snapshotsService.add().snapshot(snapshot().description("My snapshot")).send();
// Close the connection to the server:
connection.close();
}
Aggregations