use of org.ovirt.engine.sdk4.Service 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.ovirt.engine.sdk4.Service in project ovirt-engine-sdk-java by oVirt.
the class ListGlanceImages 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 root of the services tree:
SystemService systemService = connection.systemService();
// Find the Glance storage domain that is available for default in any oVirt installation:
StorageDomainsService sdsService = systemService.storageDomainsService();
StorageDomain sd = sdsService.list().search("name=ovirt-image-repository").send().storageDomains().get(0);
// Find the service that manages the Glance storage domain:
StorageDomainService sdService = sdsService.storageDomainService(sd.id());
// Find the service that manages the images available in that storage domain:
ImagesService imagesService = sdService.imagesService();
// List the images available in the storage domain:
List<Image> images = imagesService.list().send().images();
for (Image image : images) {
System.out.println(image.name());
}
// Close the connection to the server:
connection.close();
}
use of org.ovirt.engine.sdk4.Service 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.ovirt.engine.sdk4.Service in project ovirt-engine-sdk-java by oVirt.
the class ListVmDisks 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 "vms" service:
VmsService vmsService = connection.systemService().vmsService();
// Find the virtual machine:
Vm vm = vmsService.list().search("name=myvm").send().vms().get(0);
// Locate the service that manages the virtual machine:
VmService vmService = vmsService.vmService(vm.id());
// Locate the service that manages the disk attachments of the virtual machine:
DiskAttachmentsService diskAttachmentsService = vmService.diskAttachmentsService();
// Retrieve the list of disks attachments, and print the disk details. Note that each attachment contains a link
// to the corresponding disk, but not the actual disk data. In order to retrieve the actual disk data we use the
// `follow_link` method.
List<DiskAttachment> diskAttachments = diskAttachmentsService.list().send().attachments();
for (DiskAttachment diskAttachment : diskAttachments) {
Disk disk = connection.followLink(diskAttachment.disk());
System.out.printf("name: %s\n", disk.name());
System.out.printf("id: %s\n", disk.id());
System.out.printf("status: %s\n", disk.status());
System.out.printf("provisioned_size: %s\n", disk.provisionedSize());
}
// Close the connection to the server:
connection.close();
}
use of org.ovirt.engine.sdk4.Service in project ovirt-engine-sdk-java by oVirt.
the class AddLogicalNetwork 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 "networks" service:
NetworksService networksService = connection.systemService().networksService();
// Use the "add" method to create new VM logical network in data center called "mydatacenter", with VLAN tag
// 100 and MTU 1500.
networksService.add().network(network().name("mynetwork").description("My logical network").dataCenter(dataCenter().name("mydatacenter")).vlan(vlan().id(100)).usages(Arrays.asList(NetworkUsage.DISPLAY)).mtu(1500)).send();
// Close the connection to the server:
connection.close();
}
Aggregations