use of org.ovirt.engine.sdk4.Connection 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();
}
use of org.ovirt.engine.sdk4.Connection in project ovirt-engine-sdk-java by oVirt.
the class AddLunDiskToVm method main.
public static void main(String[] args) throws Exception {
// Create the connection to the server:
Connection connection = connection().url("https://engine/ovirt-engine/api").user("admin@internal").password("123456").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 disk attachments of the virtual machine:
DiskAttachmentsService diskAttachmentsService = vmsService.vmService(vm.id()).diskAttachmentsService();
// Use the "add" method of the disk attachments service to add the LUN disk.
diskAttachmentsService.add().attachment(diskAttachment().disk(disk().name("myiscsidisk").lunStorage(hostStorage().type(StorageType.ISCSI).logicalUnits(logicalUnit().address("192.168.200.3").port(3260).target("iqn.2014-07.org.ovirt:storage").id("36001405e793bf9c57a840f58c9a8a220").username("username").password("password")))).interface_(DiskInterface.VIRTIO).bootable(false).active(true)).send().attachment();
// Close the connection to the server:
connection.close();
}
use of org.ovirt.engine.sdk4.Connection in project ovirt-engine-sdk-java by oVirt.
the class AddMacPool 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 service that manages the MAC address pools:
MacPoolsService poolsService = connection.systemService().macPoolsService();
// Add a new MAC address pool:
MacPool pool = poolsService.add().pool(macPool().name("mymacpool").ranges(range().from("02:00:00:00:00:00").to("02:00:00:01:00:00"))).send().pool();
// Find the service that manages clusters, as we need it in order to find the cluster where we wnt to set the
// MAC address pool:
ClustersService clustersService = connection.systemService().clustersService();
// Find the cluster:
Cluster cluster = clustersService.list().search("name=mycluster").send().clusters().get(0);
// Find the service that manages the cluster, as we need it in order to do the update:
ClusterService clusterService = clustersService.clusterService(cluster.id());
// Update the service so that it uses the new MAC pool:
clusterService.update().cluster(cluster().macPool(macPool().id(pool.id()))).send();
// Close the connection to the server:
connection.close();
}
use of org.ovirt.engine.sdk4.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.ovirt.engine.sdk4.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();
}
Aggregations