use of org.ovirt.engine.sdk4.services.NetworksService 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.services.NetworksService 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();
}
Aggregations