Search in sources :

Example 86 with Service

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

the class AddVm 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 "vms" service:
    VmsService vmsService = connection.systemService().vmsService();
    // Use the "add" method to create a new virtual machine:
    vmsService.add().vm(vm().name("myvm").cluster(cluster().name("mycluster")).template(template().name("Blank"))).send();
    // Close the connection to the server:
    connection.close();
}
Also used : Connection(org.ovirt.engine.sdk4.Connection) VmsService(org.ovirt.engine.sdk4.services.VmsService)

Example 87 with Service

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

the class AssignAffinityLabelToVm 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 "vms" service:
    VmsService vmsService = connection.systemService().vmsService();
    // Find the virtual machine:
    Vm vm = vmsService.list().search("name=myvm").send().vms().get(0);
    // Get the reference to the affinity labels service:
    AffinityLabelsService affinityLabelsService = connection.systemService().affinityLabelsService();
    // Find the id of the affinity label:
    String affinityLabelId = null;
    for (AffinityLabel affinityLabel : affinityLabelsService.list().send().labels()) {
        if (affinityLabel.name().equals("my_affinity_label")) {
            affinityLabelId = affinityLabel.id();
            break;
        }
    }
    // Locate the service that manages the affinity label named `my_affinity_label`:
    AffinityLabelService affinityLabelService = affinityLabelsService.labelService(affinityLabelId);
    // Get the reference to the service that manages the set of virtual machines that have the affinity label
    // named `my_affinity_label` assigned:
    AffinityLabelVmsService affinityLabelVmsService = affinityLabelService.vmsService();
    // Assign affinity label to virtual machine:
    affinityLabelVmsService.add().vm(vm().id(vm.id())).send();
    // Close the connection to the server:
    connection.close();
}
Also used : AffinityLabelsService(org.ovirt.engine.sdk4.services.AffinityLabelsService) AffinityLabel(org.ovirt.engine.sdk4.types.AffinityLabel) AffinityLabelService(org.ovirt.engine.sdk4.services.AffinityLabelService) AffinityLabelVmsService(org.ovirt.engine.sdk4.services.AffinityLabelVmsService) Vm(org.ovirt.engine.sdk4.types.Vm) Connection(org.ovirt.engine.sdk4.Connection) AffinityLabelVmsService(org.ovirt.engine.sdk4.services.AffinityLabelVmsService) VmsService(org.ovirt.engine.sdk4.services.VmsService)

Example 88 with Service

use of org.ovirt.engine.sdk4.Service 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)

Example 89 with Service

use of org.ovirt.engine.sdk4.Service in project cloudbreak by hortonworks.

the class OpenStackClient method getRegion.

public Set<String> getRegion(CloudCredential cloudCredential) {
    Access access = createAccess(cloudCredential);
    Token token = createToken(cloudCredential);
    Set<String> regions = new HashSet<>();
    if (token == null && access == null) {
        throw new CloudConnectorException("Unsupported keystone version");
    } else if (token != null) {
        for (Service service : token.getCatalog()) {
            for (Endpoint endpoint : service.getEndpoints()) {
                regions.add(endpoint.getRegion());
            }
        }
    } else {
        for (Access.Service service : access.getServiceCatalog()) {
            for (org.openstack4j.model.identity.v2.Endpoint endpoint : service.getEndpoints()) {
                regions.add(endpoint.getRegion());
            }
        }
    }
    LOGGER.info("regions from openstack: {}", regions);
    return regions;
}
Also used : Endpoint(org.openstack4j.model.identity.v3.Endpoint) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) Access(org.openstack4j.model.identity.v2.Access) Service(org.openstack4j.model.identity.v3.Service) Token(org.openstack4j.model.identity.v3.Token) HashSet(java.util.HashSet)

Example 90 with Service

use of org.ovirt.engine.sdk4.Service in project seldon-core by SeldonIO.

the class SeldonDeploymentOperatorImpl method createResources.

@Override
public DeploymentResources createResources(SeldonDeployment mlDep) throws SeldonDeploymentException {
    OwnerReference ownerRef = getOwnerReference(mlDep);
    List<Deployment> deployments = new ArrayList<>();
    // for each predictor Create/replace deployment
    String serviceLabel = mlDep.getSpec().getName();
    for (PredictorSpec p : mlDep.getSpec().getPredictorsList()) {
        String depName = getKubernetesDeploymentName(mlDep.getSpec().getName(), p.getName());
        PodTemplateSpec.Builder podSpecBuilder = PodTemplateSpec.newBuilder(p.getComponentSpec());
        podSpecBuilder.getSpecBuilder().addContainers(createEngineContainer(mlDep, p)).setTerminationGracePeriodSeconds(20);
        podSpecBuilder.getMetadataBuilder().putAnnotations("prometheus.io/path", "/prometheus").putAnnotations("prometheus.io/port", "" + clusterManagerProperites.getEngineContainerPort()).putAnnotations("prometheus.io/scrape", "true");
        Deployment deployment = V1beta1Extensions.Deployment.newBuilder().setMetadata(ObjectMeta.newBuilder().setName(depName).putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel).putLabels(Constants.LABEL_SELDON_ID, mlDep.getSpec().getName()).putLabels("app", depName).putLabels("version", // FIXME
        "v1").putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_TYPE_KEY, SeldonDeploymentOperatorImpl.LABEL_SELDON_TYPE_VAL).addOwnerReferences(ownerRef)).setSpec(DeploymentSpec.newBuilder().setTemplate(podSpecBuilder.build()).setStrategy(DeploymentStrategy.newBuilder().setRollingUpdate(RollingUpdateDeployment.newBuilder().setMaxUnavailable(IntOrString.newBuilder().setType(1).setStrVal("10%")))).setReplicas(p.getReplicas())).build();
        deployments.add(deployment);
    }
    final String serviceName = mlDep.getSpec().getName();
    Service s = Service.newBuilder().setMetadata(ObjectMeta.newBuilder().setName(serviceName).putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel).putLabels("seldon-deployment-id", mlDep.getSpec().getName()).addOwnerReferences(ownerRef).putAnnotations("getambassador.io/config", getAmbassadorAnnotation(mlDep, serviceName))).setSpec(ServiceSpec.newBuilder().addPorts(ServicePort.newBuilder().setProtocol("TCP").setPort(clusterManagerProperites.getEngineContainerPort()).setTargetPort(IntOrString.newBuilder().setIntVal(clusterManagerProperites.getEngineContainerPort())).setName("http")).addPorts(ServicePort.newBuilder().setProtocol("TCP").setPort(clusterManagerProperites.getEngineGrpcContainerPort()).setTargetPort(IntOrString.newBuilder().setIntVal(clusterManagerProperites.getEngineGrpcContainerPort())).setName("grpc")).setType("ClusterIP").putSelector(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel)).build();
    // Create service for deployment
    return new DeploymentResources(deployments, s);
}
Also used : V1OwnerReference(io.kubernetes.client.models.V1OwnerReference) OwnerReference(io.kubernetes.client.proto.Meta.OwnerReference) PodTemplateSpec(io.kubernetes.client.proto.V1.PodTemplateSpec) ArrayList(java.util.ArrayList) SeldonDeployment(io.seldon.protos.DeploymentProtos.SeldonDeployment) Deployment(io.kubernetes.client.proto.V1beta1Extensions.Deployment) RollingUpdateDeployment(io.kubernetes.client.proto.V1beta1Extensions.RollingUpdateDeployment) Service(io.kubernetes.client.proto.V1.Service) IntOrString(io.kubernetes.client.proto.IntStr.IntOrString) PredictorSpec(io.seldon.protos.DeploymentProtos.PredictorSpec)

Aggregations

Connection (org.ovirt.engine.sdk4.Connection)55 Vm (org.ovirt.engine.sdk4.types.Vm)26 VmsService (org.ovirt.engine.sdk4.services.VmsService)25 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 CoreException (org.eclipse.core.runtime.CoreException)18 VmService (org.ovirt.engine.sdk4.services.VmService)15 ArrayList (java.util.ArrayList)12 StorageDomain (org.ovirt.engine.sdk4.types.StorageDomain)12 StorageDomainsService (org.ovirt.engine.sdk4.services.StorageDomainsService)11 SystemService (org.ovirt.engine.sdk4.services.SystemService)10 ServerPort (org.eclipse.wst.server.core.ServerPort)9 StorageDomainService (org.ovirt.engine.sdk4.services.StorageDomainService)7 HostService (org.ovirt.engine.sdk4.services.HostService)6 HostsService (org.ovirt.engine.sdk4.services.HostsService)6 Disk (org.ovirt.engine.sdk4.types.Disk)6 Test (org.junit.Test)5 DataCenterService (org.ovirt.engine.sdk4.services.DataCenterService)5 DataCentersService (org.ovirt.engine.sdk4.services.DataCentersService)5 Cluster (org.ovirt.engine.sdk4.types.Cluster)5