Search in sources :

Example 36 with User

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

the class AddAffinityLabel 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 "add" method to create a affinity label:
    affinityLabelsService.add().label(affinityLabel().name("myaffinitylabel")).send();
    // Close the connection to the server:
    connection.close();
}
Also used : AffinityLabelsService(org.ovirt.engine.sdk4.services.AffinityLabelsService) Connection(org.ovirt.engine.sdk4.Connection)

Example 37 with User

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

the class AddBond method main.

public static void main(String[] args) throws Exception {
    // Create the connection to the server:
    Connection connection = connection().url("https://engine42.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").insecure(true).build();
    // Find the service that manages the collection of hosts:
    HostsService hostsService = connection.systemService().hostsService();
    // Find the host:
    Host host = hostsService.list().search("name=myhost").send().hosts().get(0);
    // Find the service that manages the host:
    HostService hostService = hostsService.hostService(host.id());
    // Configure the host adding a bond with two slaves, and attaching it to a network with an static IP address:
    hostService.setupNetworks().modifiedBonds(hostNic().name("bond0").bonding(bonding().options(option().name("mode").value("1"), option().name("miimon").value("100")).slaves(hostNic().name("eth0"), hostNic().name("eth1")))).modifiedNetworkAttachments(networkAttachment().network(network().name("mynetwork")).ipAddressAssignments(ipAddressAssignment().assignmentMethod(BootProtocol.STATIC).ip(ip().address("192.168.122.100").netmask("255.255.255.0")))).send();
    // After modifying the network configuration it is very important to make it persistent:
    hostService.commitNetConfig().send();
    // Close the connection to the server:
    connection.close();
}
Also used : HostService(org.ovirt.engine.sdk4.services.HostService) Connection(org.ovirt.engine.sdk4.Connection) HostsService(org.ovirt.engine.sdk4.services.HostsService) Host(org.ovirt.engine.sdk4.types.Host)

Example 38 with User

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

the class AddCluster 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 clusters service:
    ClustersService clustersService = connection.systemService().clustersService();
    // Use the "add" method to create a new data center:
    clustersService.add().cluster(cluster().name("mycluster").description("My cluster").cpu(cpu().architecture(Architecture.X86_64).type("Intel Conroe Family")).dataCenter(dataCenter().name("mydc"))).send();
    // Close the connection to the server:
    connection.close();
}
Also used : Connection(org.ovirt.engine.sdk4.Connection) ClustersService(org.ovirt.engine.sdk4.services.ClustersService)

Example 39 with User

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

the class AddDataCenter 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 data centers service:
    DataCentersService dcsService = connection.systemService().dataCentersService();
    // Use the "add" method to create a new data center:
    dcsService.add().dataCenter(dataCenter().name("mydc").description("My data center").local(false)).send();
    // Close the connection to the server:
    connection.close();
}
Also used : DataCentersService(org.ovirt.engine.sdk4.services.DataCentersService) Connection(org.ovirt.engine.sdk4.Connection)

Example 40 with User

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

the class AddGroup 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 groups service:
    GroupsService groupsService = connection.systemService().groupsService();
    // Use the "add" method to add group from a directory service. Please note that domain name is name of the
    // authorization provider:
    groupsService.add().group(group().name("Developers").domain(domain().name("internal-authz"))).send();
    // Close the connection to the server:
    connection.close();
}
Also used : GroupsService(org.ovirt.engine.sdk4.services.GroupsService) Connection(org.ovirt.engine.sdk4.Connection)

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