Search in sources :

Example 66 with User

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

the class AssignNetworkToCluster 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 networks service and use it to find the network:
    NetworksService networksService = connection.systemService().networksService();
    Network network = networksService.list().search("name=mynetwork and datacenter=mydatacenter").send().networks().get(0);
    // Locate the clusters service and use it to find the cluster:
    ClustersService clustersService = connection.systemService().clustersService();
    Cluster cluster = clustersService.list().search("name=mycluster").send().clusters().get(0);
    // Locate the service that manages the networks of the cluster:
    ClusterService clusterService = clustersService.clusterService(cluster.id());
    ClusterNetworksService assignedNetworksService = clusterService.networksService();
    // Use the "add" method to assign network to cluster:
    assignedNetworksService.add().network(network().id(network.id()).required(true)).send();
    // Close the connection to the server:
    connection.close();
}
Also used : ClusterService(org.ovirt.engine.sdk4.services.ClusterService) ClusterNetworksService(org.ovirt.engine.sdk4.services.ClusterNetworksService) Network(org.ovirt.engine.sdk4.types.Network) Connection(org.ovirt.engine.sdk4.Connection) ClustersService(org.ovirt.engine.sdk4.services.ClustersService) NetworksService(org.ovirt.engine.sdk4.services.NetworksService) ClusterNetworksService(org.ovirt.engine.sdk4.services.ClusterNetworksService) Cluster(org.ovirt.engine.sdk4.types.Cluster)

Aggregations

Connection (org.ovirt.engine.sdk4.Connection)63 VmsService (org.ovirt.engine.sdk4.services.VmsService)30 Vm (org.ovirt.engine.sdk4.types.Vm)30 VmService (org.ovirt.engine.sdk4.services.VmService)18 SystemService (org.ovirt.engine.sdk4.services.SystemService)13 StorageDomainsService (org.ovirt.engine.sdk4.services.StorageDomainsService)12 StorageDomain (org.ovirt.engine.sdk4.types.StorageDomain)12 HostsService (org.ovirt.engine.sdk4.services.HostsService)6 StorageDomainService (org.ovirt.engine.sdk4.services.StorageDomainService)6 Host (org.ovirt.engine.sdk4.types.Host)6 DataCentersService (org.ovirt.engine.sdk4.services.DataCentersService)5 HostService (org.ovirt.engine.sdk4.services.HostService)5 Disk (org.ovirt.engine.sdk4.types.Disk)5 ClustersService (org.ovirt.engine.sdk4.services.ClustersService)4 Cluster (org.ovirt.engine.sdk4.types.Cluster)4 ArrayList (java.util.ArrayList)3 AffinityLabelsService (org.ovirt.engine.sdk4.services.AffinityLabelsService)3 AssignedTagsService (org.ovirt.engine.sdk4.services.AssignedTagsService)3 DataCenterService (org.ovirt.engine.sdk4.services.DataCenterService)3 DiskAttachmentsService (org.ovirt.engine.sdk4.services.DiskAttachmentsService)3