Package com.vmware.apputils.vim25

Examples of com.vmware.apputils.vim25.ServiceUtil


    return dcPair.first().getMor();
  }

  @Override
  public ManagedObjectReference getHyperHostOwnerResourcePool() throws Exception {
    ServiceUtil serviceUtil = _context.getServiceUtil();
    ManagedObjectReference morComputerResource = (ManagedObjectReference)serviceUtil.getDynamicProperty(_mor, "parent");
    return (ManagedObjectReference)serviceUtil.getDynamicProperty(morComputerResource, "resourcePool");
  }
View Full Code Here


    return (ManagedObjectReference)serviceUtil.getDynamicProperty(morComputerResource, "resourcePool");
  }

  @Override
  public ManagedObjectReference getHyperHostCluster() throws Exception {
    ServiceUtil serviceUtil = _context.getServiceUtil();
    ManagedObjectReference morParent = (ManagedObjectReference)serviceUtil.getDynamicProperty(_mor, "parent");
   
    if(morParent.getType().equalsIgnoreCase("ClusterComputeResource")) {
      return morParent;
    }
   
View Full Code Here

    assert(false);
    throw new Exception("Standalone host is not supported");
  }
 
  public ManagedObjectReference[] getHostLocalDatastore() throws Exception {
    ServiceUtil serviceUtil = _context.getServiceUtil();
    ManagedObjectReference[] datastores = (ManagedObjectReference[])serviceUtil.getDynamicProperty(
      _mor, "datastore");
    List<ManagedObjectReference> l = new ArrayList<ManagedObjectReference>();
    if(datastores != null) {
      for(ManagedObjectReference mor : datastores) {
        DatastoreSummary summary = (DatastoreSummary)serviceUtil.getDynamicProperty(mor, "summary");
        if(summary.getType().equalsIgnoreCase("VMFS") && !summary.getMultipleHostAccess())
          l.add(mor);
      }
    }
    return l.toArray(new ManagedObjectReference[1]);
View Full Code Here

    @Deprecated
    private ManagedObjectReference addHostToVCenterCluster(VmwareContext serviceContext, ManagedObjectReference morCluster,
            String host, String userName, String password) throws Exception {

        ServiceUtil serviceUtil = serviceContext.getServiceUtil();
        ManagedObjectReference morHost = serviceUtil.getDecendentMoRef(morCluster, "HostSystem", host);
        if(morHost == null) {
            HostConnectSpec hostSpec = new HostConnectSpec();
            hostSpec.setUserName(userName);
            hostSpec.setPassword(password);
            hostSpec.setHostName(host);
            hostSpec.setForce(true);    // forcely take over the host

            ManagedObjectReference morTask = serviceContext.getService().addHost_Task(morCluster, hostSpec, true, null, null);
            String taskResult = serviceUtil.waitForTask(morTask);
            if(!taskResult.equals("sucess")) {
                s_logger.error("Unable to add host " + host + " to vSphere cluster due to " + TaskMO.getTaskFailureInfo(serviceContext, morTask));
                throw new CloudRuntimeException("Unable to add host " + host + " to vSphere cluster due to " + taskResult);
            }
            serviceContext.waitForTaskProgressDone(morTask);

            // init morHost after it has been created
            morHost = serviceUtil.getDecendentMoRef(morCluster, "HostSystem", host);
            if(morHost == null) {
                throw new CloudRuntimeException("Successfully added host into vSphere but unable to find it later on?!. Please make sure you are either using IP address or full qualified domain name for host");
            }
        }
View Full Code Here

    return dcPair.first().getMor();
  }

  @Override
  public ManagedObjectReference getHyperHostOwnerResourcePool() throws Exception {
    ServiceUtil serviceUtil = _context.getServiceUtil();
    ManagedObjectReference morComputerResource = (ManagedObjectReference)serviceUtil.getDynamicProperty(_mor, "parent");
    return (ManagedObjectReference)serviceUtil.getDynamicProperty(morComputerResource, "resourcePool");
  }
View Full Code Here

    return (ManagedObjectReference)serviceUtil.getDynamicProperty(morComputerResource, "resourcePool");
  }

  @Override
  public ManagedObjectReference getHyperHostCluster() throws Exception {
    ServiceUtil serviceUtil = _context.getServiceUtil();
    ManagedObjectReference morParent = (ManagedObjectReference)serviceUtil.getDynamicProperty(_mor, "parent");
   
    if(morParent.getType().equalsIgnoreCase("ClusterComputeResource")) {
      return morParent;
    }
   
View Full Code Here

    assert(false);
    throw new Exception("Standalone host is not supported");
  }
 
  public ManagedObjectReference[] getHostLocalDatastore() throws Exception {
    ServiceUtil serviceUtil = _context.getServiceUtil();
    ManagedObjectReference[] datastores = (ManagedObjectReference[])serviceUtil.getDynamicProperty(
      _mor, "datastore");
    List<ManagedObjectReference> l = new ArrayList<ManagedObjectReference>();
    if(datastores != null) {
      for(ManagedObjectReference mor : datastores) {
        DatastoreSummary summary = (DatastoreSummary)serviceUtil.getDynamicProperty(mor, "summary");
        if(summary.getType().equalsIgnoreCase("VMFS") && !summary.getMultipleHostAccess())
          l.add(mor);
      }
    }
    return l.toArray(new ManagedObjectReference[1]);
View Full Code Here

    return dcPair.first().getMor();
  }
 
  @Override
  public ManagedObjectReference getHyperHostOwnerResourcePool() throws Exception {
    ServiceUtil serviceUtil = _context.getServiceUtil();
    return (ManagedObjectReference)serviceUtil.getDynamicProperty(getMor(), "resourcePool");
  }
View Full Code Here

  }
 
  public void registerTemplate(ManagedObjectReference morHost, String datastoreName,
    String templateName, String templateFileName) throws Exception {
   
    ServiceUtil serviceUtil = _context.getServiceUtil();
   
    ManagedObjectReference morFolder = (ManagedObjectReference)serviceUtil.getDynamicProperty(
      _mor, "vmFolder");
    assert(morFolder != null);
   
    ManagedObjectReference morTask = _context.getService().registerVM_Task(
         morFolder,
         String.format("[%s] %s/%s", datastoreName, templateName, templateFileName),
         templateName, true,
         null, morHost);
   
    String result = serviceUtil.waitForTask(morTask);
    if (!result.equalsIgnoreCase("Sucess")) {
      throw new Exception("Unable to register template due to " + TaskMO.getTaskFailureInfo(_context, morTask));
    } else {
      _context.waitForTaskProgressDone(morTask);
    }
View Full Code Here

    @Deprecated
    private ManagedObjectReference addHostToVCenterCluster(VmwareContext serviceContext, ManagedObjectReference morCluster,
            String host, String userName, String password) throws Exception {

        ServiceUtil serviceUtil = serviceContext.getServiceUtil();
        ManagedObjectReference morHost = serviceUtil.getDecendentMoRef(morCluster, "HostSystem", host);
        if(morHost == null) {
            HostConnectSpec hostSpec = new HostConnectSpec();
            hostSpec.setUserName(userName);
            hostSpec.setPassword(password);
            hostSpec.setHostName(host);
            hostSpec.setForce(true);    // forcely take over the host

            ManagedObjectReference morTask = serviceContext.getService().addHost_Task(morCluster, hostSpec, true, null, null);
            String taskResult = serviceUtil.waitForTask(morTask);
            if(!taskResult.equals("sucess")) {
                s_logger.error("Unable to add host " + host + " to vSphere cluster due to " + TaskMO.getTaskFailureInfo(serviceContext, morTask));
                throw new CloudRuntimeException("Unable to add host " + host + " to vSphere cluster due to " + taskResult);
            }
            serviceContext.waitForTaskProgressDone(morTask);

            // init morHost after it has been created
            morHost = serviceUtil.getDecendentMoRef(morCluster, "HostSystem", host);
            if(morHost == null) {
                throw new CloudRuntimeException("Successfully added host into vSphere but unable to find it later on?!. Please make sure you are either using IP address or full qualified domain name for host");
            }
        }
View Full Code Here

TOP

Related Classes of com.vmware.apputils.vim25.ServiceUtil

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.