Package com.vmware.vim25

Examples of com.vmware.vim25.ManagedObjectReference


    public static Pair<ManagedObjectReference, String> prepareNetwork(String physicalNetwork, String namePrefix,
            HostMO hostMo, String vlanId, String secondaryvlanId, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs,
            VirtualSwitchType vSwitchType, int numPorts, String gateway, boolean configureVServiceInNexus, BroadcastDomainType broadcastDomainType,
            Map<String, String> vsmCredentials) throws Exception {
        ManagedObjectReference morNetwork = null;
        VmwareContext context = hostMo.getContext();
        ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter();
        DatacenterMO dataCenterMo = new DatacenterMO(context, dcMor);
        DistributedVirtualSwitchMO dvSwitchMo = null;
        ManagedObjectReference morEthernetPortProfile = null;
        String ethPortProfileName = null;
        ManagedObjectReference morDvSwitch = null;
        String dvSwitchName = null;
        boolean bWaitPortGroupReady = false;
        boolean createGCTag = false;
        String vcApiVersion;
        String minVcApiVersionSupportingAutoExpand;
View Full Code Here


            DVPortgroupConfigInfo dvPortgroupInfo = dataCenterMo.getDvPortGroupSpec(networkName);
            if (!isSpecMatch(dvPortgroupInfo, vid, shapingPolicy)) {
                s_logger.info("Updating Distributed Virtual Port group " + networkName);
                dvPortGroupSpec.setDefaultPortConfig(dvsPortSetting);
                dvPortGroupSpec.setConfigVersion(dvPortgroupInfo.getConfigVersion());
                ManagedObjectReference morDvPortGroup = dataCenterMo.getDvPortGroupMor(networkName);
                try {
                    dvSwitchMo.updateDvPortGroup(morDvPortGroup, dvPortGroupSpec);
                } catch (Exception e) {
                    String msg = "Failed to update distributed virtual port group " + networkName + " on dvSwitch " + physicalNetwork;
                    throw new Exception(msg);
View Full Code Here

        }       
    }
   
     public static ManagedObjectReference waitForDvPortGroupReady(
            DatacenterMO dataCenterMo, String dvPortGroupName, long timeOutMs) throws Exception {
        ManagedObjectReference morDvPortGroup = null;

        // if DvPortGroup is just created, we may fail to retrieve it, we
        // need to retry
        long startTick = System.currentTimeMillis();
        while (System.currentTimeMillis() - startTick <= timeOutMs) {
View Full Code Here

                    bWaitPortGroupReady = true;
                }
            }
        }
       
        ManagedObjectReference morNetwork;
        if(bWaitPortGroupReady)
            morNetwork = waitForNetworkReady(hostMo, networkName, timeOutMs);
        else
            morNetwork = hostMo.getNetworkMor(networkName);
        if (morNetwork == null) {
            String msg = "Failed to create guest network " + networkName;
            s_logger.error(msg);
            throw new Exception(msg);
        }

        if(createGCTag) {
            NetworkMO networkMo = new NetworkMO(hostMo.getContext(), morNetwork);
            networkMo.setCustomFieldValue(CustomFieldConstants.CLOUD_GC, "true");
        }

        if(syncPeerHosts) {
            ManagedObjectReference morParent = hostMo.getParentMor();
            if(morParent != null && morParent.getType().equals("ClusterComputeResource")) {
                // to be conservative, lock cluster
                GlobalLock lock = GlobalLock.getInternLock("ClusterLock." + morParent.getValue());
                try {
                    if(lock.lock(DEFAULT_LOCK_TIMEOUT_SECONDS)) {
                        try {
                            List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)hostMo.getContext().getVimClient().getDynamicProperty(morParent, "host");
                            if(hosts != null) {
View Full Code Here

    }

    public static ManagedObjectReference waitForNetworkReady(HostMO hostMo,
            String networkName, long timeOutMs) throws Exception {

        ManagedObjectReference morNetwork = null;

        // if portGroup is just created, getNetwork may fail to retrieve it, we
        // need to retry
        long startTick = System.currentTimeMillis();
        while (System.currentTimeMillis() - startTick <= timeOutMs) {
View Full Code Here

    public static VirtualMachineMO createWorkerVM(VmwareHypervisorHost hyperHost,
      DatastoreMO dsMo, String vmName) throws Exception {
     
      // Allow worker VM to float within cluster so that we will have better chance to
      // create it successfully
      ManagedObjectReference morCluster = hyperHost.getHyperHostCluster();
      if(morCluster != null)
        hyperHost = new ClusterMO(hyperHost.getContext(), morCluster);
     
        VirtualMachineMO workingVM = null;
        VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec();
View Full Code Here

            s_logger.info("host name in url is already in IP address, url: " + url);
            return url;
        }

        try {
            ManagedObjectReference morHost = dcMo.findHost(host);
            if(morHost != null) {
                HostMO hostMo = new HostMO(dcMo.getContext(), morHost);
                String managementPortGroupName;
                if(hostMo.getHostType() == VmwareHostType.ESXi)
                    managementPortGroupName = (String)dcMo.getContext().getStockObject("manageportgroup");
View Full Code Here

            s_logger.error(msg);
            throw new Exception(msg);
        }

        DatacenterMO dcMo = new DatacenterMO(context, host.getHyperHostDatacenter());
        ManagedObjectReference morLease = context.getService().importVApp(morRp,
                ovfImportResult.getImportSpec(), dcMo.getVmFolder(), morHost);
        if(morLease == null) {
            String msg = "importVApp() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
                    + vmName + ", diskOption: " + diskOption;
            s_logger.error(msg);
View Full Code Here

      if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - createVM_Task(). target MOR: " + _mor.getValue() + ", VirtualMachineConfigSpec: " + new Gson().toJson(vmSpec));

    assert(vmSpec != null);
    DatacenterMO dcMo = new DatacenterMO(_context, getHyperHostDatacenter());
        ManagedObjectReference morPool = getHyperHostOwnerResourcePool();

      ManagedObjectReference morTask = _context.getService().createVMTask(
        dcMo.getVmFolder(), vmSpec, morPool, null);
    boolean result = _context.getVimClient().waitForTask(morTask);

    if(result) {
      _context.waitForTaskProgressDone(morTask);
View Full Code Here

  public void importVmFromOVF(String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption) throws Exception {
      if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.getValue() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName
        + ", datastore: " + dsMo.getMor().getValue() + ", diskOption: " + diskOption);

    ManagedObjectReference morRp = getHyperHostOwnerResourcePool();
    assert(morRp != null);

    if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - importVmFromOVF(). resource pool: " + morRp.getValue());

    HypervisorHostHelper.importVmFromOVF(this, ovfFilePath, vmName, dsMo, diskOption, morRp, null);

      if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - importVmFromOVF() done");
View Full Code Here

TOP

Related Classes of com.vmware.vim25.ManagedObjectReference

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.