Package com.vmware.vim25.mo.util

Examples of com.vmware.vim25.mo.util.CommandLineParser


        VirtualMachineSnapshotTree[] snapTree =
            vm_.getSnapshot().getRootSnapshotList();

        if (snapTree == null) { return null; }
       
        VirtualMachineSnapshotTree st =
            findSnapshotInTree(snapTree, vmSnap);
        return st;
    }
View Full Code Here


     */
    private VirtualMachineSnapshotTree findSnapshotInTree
        (VirtualMachineSnapshotTree[] snapTree, VirtualMachineSnapshot vmSnap)
    {
        for (int i = 0; i < snapTree.length; i ++) {
            VirtualMachineSnapshotTree node = snapTree[i];
            if (node.getSnapshot().equals(vmSnap.getMOR())) {
                return node;
            }
            VirtualMachineSnapshotTree[] childTree =
                node.getChildSnapshotList();
            if (childTree != null) {
                VirtualMachineSnapshotTree ret =
                    findSnapshotInTree(childTree, vmSnap);
                if (ret != null) {
                    return ret;
                }
            }
View Full Code Here

     */
    private ManagedObjectReference findSnapshotInTree
        (VirtualMachineSnapshotTree[] snapTree, String snapName)
    {
        for (int i = 0; i < snapTree.length; i ++) {
            VirtualMachineSnapshotTree node = snapTree[i];
            if (snapName.equals(node.getName())) {
                return node.getSnapshot();
            } else {
                VirtualMachineSnapshotTree[] childTree =
                    node.getChildSnapshotList();
                if (childTree != null) {
                    ManagedObjectReference mor =
                        findSnapshotInTree(childTree, snapName);
                    if (mor != null) { return mor; }
                }
View Full Code Here

        ctrl.setKey(ckey_);
        ctrl.setBusNumber(busNumber_);
        if (isScsi) {
            assert ctrl instanceof VirtualSCSIController;
            VirtualSCSIController scsiCtrl = (VirtualSCSIController) ctrl;
            scsiCtrl.setSharedBus(VirtualSCSISharing.noSharing);
        }
        controllerSpec.setDevice(ctrl);

        return controllerSpec;
    }
View Full Code Here

        /* Get the HostSystem */
        HostSystem host = getAvailableHost(hostName);
        assert host != null;

        /* Check the specified datastore exists and available with the host. */
        Datastore datastore = getAvailableDatastore(datastoreName, host);
        assert datastore != null;
       
        /* create spec */
        Folder vmFolder = null;
        OvfCreateImportSpecParams importSpecParams
            = new OvfCreateImportSpecParams();
        String ovfDescriptor = "";

        vmFolder = (Folder) host.getVms()[0].getParent();

        importSpecParams.setLocale("US");
        importSpecParams.setEntityName(newVmName);
        importSpecParams.setDeploymentOption("");
        OvfNetworkMapping networkMapping = new OvfNetworkMapping();
        networkMapping.setName("Network 1");
        networkMapping.setNetwork(host.getNetworks()[0].getMOR());
        importSpecParams.setNetworkMapping(new OvfNetworkMapping[] { networkMapping });
        importSpecParams.setPropertyMapping(null);

        /* read ovf from the file. */
        ovfDescriptor = readOvfContent(ovfPath);

        /* create ovf descriptor */
        ovfDescriptor = escapeSpecialChars(ovfDescriptor);
        //logger_.info("ovfDesc: " + ovfDescriptor);

        ResourcePool rp = ((ComputeResource) host.getParent()).getResourcePool();

        logger_.fine(String.format("vmname: %s\n" +
                                   "resourcepool: %s\n" +
                                   "host:%s\n" +
                                   "datastore:%s\n",
                                   newVmName,
                                   rp.getName(),
                                   host.getName(),
                                   datastore.getName()));
       
        OvfCreateImportSpecResult ovfImportResult = null;
        HttpNfcLease httpNfcLease = null;       

        /* create import spec */
 
View Full Code Here

    private Datastore getAvailableDatastore
        (String datastoreName, HostSystem host)
        throws Exception
    {
        assert host != null;
        Datastore datastore = null;

        if (datastoreName != null) {
            List<Datastore> datastores = getAllDatastoreList(host);
            for (Datastore d: datastores) {
                if (datastoreName.equals(d.getName())) {
                    datastore = d; break;
                }
            }
        }

        if (datastoreName != null && datastore == null) {
            logger_.warning
                (String.format("Datastore %s not found.", datastoreName));
            datastoreName = null;
        }
       
        if (datastoreName == null) {
            datastore = getDefaultDatastore(host);
            logger_.info
                (String.format
                 ("Use default datastore %s.", datastore.getName()));
        }
       
        if (datastore == null) {
            throw new Exception("datastore is null.");
        }
View Full Code Here

        /* Check the specified datastore exists and available with the host. */
        Datastore datastore = getAvailableDatastore(datastoreName, host);
        assert datastore != null;
       
        /* create spec */
        Folder vmFolder = null;
        OvfCreateImportSpecParams importSpecParams
            = new OvfCreateImportSpecParams();
        String ovfDescriptor = "";

        vmFolder = (Folder) host.getVms()[0].getParent();
View Full Code Here

        throws Exception
    {
        if (conn_.isConnected() == false) { conn_.connect(); }

        /* Get the HostSystem */
        HostSystem host = getAvailableHost(hostName);
        assert host != null;

        /* Check the specified datastore exists and available with the host. */
        Datastore datastore = getAvailableDatastore(datastoreName, host);
        assert datastore != null;
       
        /* create spec */
        Folder vmFolder = null;
        OvfCreateImportSpecParams importSpecParams
            = new OvfCreateImportSpecParams();
        String ovfDescriptor = "";

        vmFolder = (Folder) host.getVms()[0].getParent();

        importSpecParams.setLocale("US");
        importSpecParams.setEntityName(newVmName);
        importSpecParams.setDeploymentOption("");
        OvfNetworkMapping networkMapping = new OvfNetworkMapping();
        networkMapping.setName("Network 1");
        networkMapping.setNetwork(host.getNetworks()[0].getMOR());
        importSpecParams.setNetworkMapping(new OvfNetworkMapping[] { networkMapping });
        importSpecParams.setPropertyMapping(null);

        /* read ovf from the file. */
        ovfDescriptor = readOvfContent(ovfPath);

        /* create ovf descriptor */
        ovfDescriptor = escapeSpecialChars(ovfDescriptor);
        //logger_.info("ovfDesc: " + ovfDescriptor);

        ResourcePool rp = ((ComputeResource) host.getParent()).getResourcePool();

        logger_.fine(String.format("vmname: %s\n" +
                                   "resourcepool: %s\n" +
                                   "host:%s\n" +
                                   "datastore:%s\n",
                                   newVmName,
                                   rp.getName(),
                                   host.getName(),
                                   datastore.getName()));
       
        OvfCreateImportSpecResult ovfImportResult = null;
        HttpNfcLease httpNfcLease = null;       

View Full Code Here

     */
    private HostSystem getAvailableHost(String hostName)
        throws Exception
    {

        HostSystem host = null;

        if (hostName != null) {
            List<HostSystem> hosts = getAllHostList();
            for (HostSystem h: hosts) {
                if (hostName.equals(h.getName())) {
                    host = h; break;
                }
            }
        }

        if (hostName != null && host == null) {
            logger_.warning
                (String.format("Host %s not found.", hostName));
            hostName = null;
        }
       
        if (hostName == null) {
            host = getDefaultHost();
            logger_.info(String.format
                         ("Use default host %s.", host.getName()));
        }

        if (host == null) {
            throw new Exception("host is null.");
        }
View Full Code Here

                                   rp.getName(),
                                   host.getName(),
                                   datastore.getName()));
       
        OvfCreateImportSpecResult ovfImportResult = null;
        HttpNfcLease httpNfcLease = null;       

        /* create import spec */
        ovfImportResult =
            conn_.getServiceInstance().getOvfManager().createImportSpec
            (ovfDescriptor, rp, datastore, importSpecParams);

        /* import execution */
        try {
            httpNfcLease =
                rp.importVApp(ovfImportResult.getImportSpec(), vmFolder, host);
        } catch (Exception e) {
            logger_.warning("importVapp failed.");
            throw e;
        }

        String morefOfNewVm = null;
       
        /* wait nfc lease */
        HttpNfcLeaseState hls;
    while (true) {
      hls = httpNfcLease.getState();
      if (hls == HttpNfcLeaseState.ready ||
                hls == HttpNfcLeaseState.error) { break; }
    }
        if (hls == HttpNfcLeaseState.ready) {

            morefOfNewVm = httpNfcLease.getInfo().getEntity().getVal();

            logger_.info
                (String.format
                 ("Moref of the created vm: %s\n", morefOfNewVm));
           
            httpNfcLease.httpNfcLeaseComplete();
            /*
              We do not upload disk files, because the specified ovf
              must not contain disk information.
            */
        } else {
View Full Code Here

TOP

Related Classes of com.vmware.vim25.mo.util.CommandLineParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.