All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ovirt.engine.sdk.Example Maven / Gradle / Ivy

There is a newer version: 3.6.10.0
Show newest version
//
// Copyright (c) 2012 Red Hat, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//           http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package org.ovirt.engine.sdk;

import org.ovirt.engine.sdk.decorators.VMDisk;
import org.ovirt.engine.sdk.entities.Disk;

import java.io.IOException;
import java.util.List;
import java.util.UUID;

import org.apache.http.client.ClientProtocolException;
import org.ovirt.engine.sdk.decorators.Cluster;
import org.ovirt.engine.sdk.decorators.DataCenter;
import org.ovirt.engine.sdk.decorators.VMDisk;
import org.ovirt.engine.sdk.decorators.VMStatistic;
import org.ovirt.engine.sdk.entities.Action;
import org.ovirt.engine.sdk.entities.ApiSummary;
import org.ovirt.engine.sdk.entities.ProductInfo;
import org.ovirt.engine.sdk.entities.Response;
import org.ovirt.engine.sdk.entities.VM;
import org.ovirt.engine.sdk.exceptions.ServerException;
import org.ovirt.engine.sdk.exceptions.UnsecuredConnectionAttemptError;
import org.ovirt.engine.sdk.utils.SerializationHelper;

public class Example {
    /**
     * @param args
     */
    // private static final String URL = "http://localhost:8080/api";
    // private static final String URL = "https://aqua-rhel.qa.lab.tlv.redhat.com:443/api";
    // private static final String URL = "https://fire32-vdc.qa.lab.tlv.redhat.com:443/api";
    private static final String URL = "https://white-vdc.eng.lab.tlv.redhat.com:8443/api";

    @SuppressWarnings("unused")
    public static void main(String[] args) throws ClientProtocolException, ServerException,
            UnsecuredConnectionAttemptError, IOException {

        // Api api = new Api(URL, "admin@internal", "350491");
        Api api =
                new Api(URL,
                        "admin@internal",
                        "123456",
                        // "/home/mpastern/crt/fire32-vdc.qa.lab.tlv.redhat.com.truststore");
                        "/home/mpastern/crt/white-vdc.eng.lab.tlv.redhat.com.truststore");

        VM collObj = SerializationHelper.unmarshall(VM.class, "aaaaaa");

        List disks = api.getDisks().list();

        DataCenter dc = api.getDataCenters().get("Default");
        Response res = dc.delete(null, "aaa");

        // Api api = new Api(URL, "JSESSIONID=twZF+xmOSw5hAEOkdw0aunaY.undefined; Path=/api");

        // Api api = new Api(URL, "[email protected]", "123456");
        // Api api = new Api(URL, "[email protected]", "123456", true);

        // DataCenter datacenter = new DataCenter();
        // datacenter.setStorageType("aaa");
        // api.getDataCenters().add(datacenter);
        //
        // // api.getStorageDomains().add(new StorageDomain());
        //
        // // #0
        // ApiSummary sum = api.getSummary();
        // ProductInfo pi = api.getProductInfo();
        //
        // // #1
        // List vms = api.getVMs().list();
        //
        // List vms2 = api.getVMs().list("name=test", null, null);
        // //
        // List clusters = api.getClusters().list();
        //
        // // #2
        // VM vm = api.getVMs().get("nfs_desktop");
        //
        // List vmDisks = vm.getDisks().list(1);
        // List vmDisks2 = vm.getDisks().list();
        //
        // VMDisk disk = vm.getDisks().get(UUID.fromString("076f9734-0500-45df-b1a7-4ff77778fce4"));
        //
        // Disk aaa = disk;
        //
        //
        // Action act = disk.deactivate(new Action());
        //
        // // #3
        // vm.setDescription("java_sdk_test");
        // VM newVM = vm.update();
        //
        // // #4
        // Action res = vm.start(new Action() {
        // {
        // setVm(new org.ovirt.engine.sdk.entities.VM());
        // }
        // });
        //
        // // #5
        // List vmstatistics = vm.getStatistics().list();
        //
        // // #6
        // VMStatistic vmstatistic = vm.getStatistics().get(UUID.fromString("5a89a1d2-32be-33f7-a0d1-f8b5bc974ff6"));
        //
        // // #7
        // vm.delete();
        //
        // // #8
        // api.shutdown();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy