Search in sources :

Example 16 with Cluster

use of org.ovirt.engine.sdk4.types.Cluster 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)13 Cluster (org.ovirt.engine.sdk4.types.Cluster)7 VmsService (org.ovirt.engine.sdk4.services.VmsService)6 Vm (org.ovirt.engine.sdk4.types.Vm)5 ClusterService (org.ovirt.engine.sdk4.services.ClusterService)4 ClustersService (org.ovirt.engine.sdk4.services.ClustersService)4 StorageDomainsService (org.ovirt.engine.sdk4.services.StorageDomainsService)4 StorageDomain (org.ovirt.engine.sdk4.types.StorageDomain)4 Test (org.junit.Test)3 SystemService (org.ovirt.engine.sdk4.services.SystemService)3 StorageDomainService (org.ovirt.engine.sdk4.services.StorageDomainService)2 StorageDomainVmsService (org.ovirt.engine.sdk4.services.StorageDomainVmsService)2 VmService (org.ovirt.engine.sdk4.services.VmService)2 Template (org.ovirt.engine.sdk4.types.Template)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 XmlReader (org.ovirt.api.metamodel.runtime.xml.XmlReader)1 ClusterNetworksService (org.ovirt.engine.sdk4.services.ClusterNetworksService)1 HostService (org.ovirt.engine.sdk4.services.HostService)1 HostsService (org.ovirt.engine.sdk4.services.HostsService)1