use of com.trilead.ssh2.Connection in project ovirt-engine-sdk-java by oVirt.
the class ImportVm method main.
public static void main(String[] args) throws Exception {
// Create connection to the oVirt engine server:
Connection connection = connection().url("https://engine40.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
// Get storage domains service
StorageDomainsService storageDomainsService = connection.systemService().storageDomainsService();
// Get export storage domain
StorageDomain exportDomain = storageDomainsService.list().search("name=myexport").send().storageDomains().get(0);
// Get target storage domain
StorageDomain targetStorageDomain = storageDomainsService.list().search("name=mydata").send().storageDomains().get(0);
// Get cluster service
ClustersService clustersService = connection.systemService().clustersService();
// Get the cluster we import the VM to
Cluster cluster = clustersService.list().search("name=mycluster").send().clusters().get(0);
// Get VM service for export storage domain
StorageDomainVmsService vmsService = storageDomainsService.storageDomainService(exportDomain.id()).vmsService();
// Get the first exported VM, assuming we have one
Vm exportedVm = vmsService.list().send().vm().get(0);
// Import the exported VM into target storage domain, 'mydata'
vmsService.vmService(exportedVm.id()).import_().storageDomain(storageDomain().id(targetStorageDomain.id())).cluster(cluster().id(cluster.id())).vm(vm().id(exportedVm.id())).send();
// Close the connection
connection.close();
}
use of com.trilead.ssh2.Connection in project ovirt-engine-sdk-java by oVirt.
the class IscsiDiscover 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 hosts service:
HostsService hostsService = connection.systemService().hostsService();
// Find the host:
Host host = hostsService.list().search("name=myhost").send().hosts().get(0);
// Locate the service that manages the host, as that is where the action methods are defined:
HostService hostService = hostsService.hostService(host.id());
// Call the "iscsiDiscover" method of the service to start it:
HostService.IscsiDiscoverResponse response = hostService.iscsiDiscover().iscsi(iscsiDetails().address("myaddress")).send();
// Print only targets:
for (String target : response.iscsiTargets()) {
System.out.println(target);
}
// Print only address corresponding to target:
for (IscsiDetails detail : response.discoveredTargets()) {
System.out.println(detail.address() + ":" + detail.target());
}
// Close the connection to the server:
connection.close();
}
use of com.trilead.ssh2.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 com.trilead.ssh2.Connection 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 com.trilead.ssh2.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();
}
Aggregations