Package com.vmware.vim25

Examples of com.vmware.vim25.TaskInfoState


        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 */
 
View Full Code Here


                                   newVmName,
                                   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;
        }

View Full Code Here

        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);
View Full Code Here

 
  public ObjectContent[] getVmPropertiesOnHyperHost(String[] propertyPaths) throws Exception {
    if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - retrieveProperties() for VM properties. target MOR: " + _mor.get_value() + ", properties: " + new Gson().toJson(propertyPaths));
   
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("VirtualMachine");
    pSpec.setPathSet(propertyPaths);
   
      TraversalSpec host2VmTraversal = new TraversalSpec();
      host2VmTraversal.setType("HostSystem");
      host2VmTraversal.setPath("vm");
      host2VmTraversal.setName("host2VmTraversal");
View Full Code Here

  @Override
  public ObjectContent[] getDatastorePropertiesOnHyperHost(String[] propertyPaths) throws Exception {
    if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - retrieveProperties() on Datastore properties. target MOR: " + _mor.get_value() + ", properties: " + new Gson().toJson(propertyPaths));

    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("Datastore");
    pSpec.setPathSet(propertyPaths);
   
      TraversalSpec host2DatastoreTraversal = new TraversalSpec();
      host2DatastoreTraversal.setType("HostSystem");
      host2DatastoreTraversal.setPath("datastore");
      host2DatastoreTraversal.setName("host2DatastoreTraversal");
View Full Code Here

     *
     */
    public boolean waitForTask(ManagedObjectReference task, int runningDelayInMillSecond, int queuedDelayInMillSecond) throws RuntimeFaultFaultMsg, RemoteException,
    InterruptedException {
        boolean retVal = false;
        TaskInfoState tState = null;
        int tries = 0;
        int maxTries = 3;
        Exception getInfoException = null;

        while ((tState == null) || tState.equals(TaskInfoState.RUNNING) || tState.equals(TaskInfoState.QUEUED)) {
            tState = null;
            getInfoException = null;
            tries = 0;
            // under load getTaskInfo may return null when there really is valid task info, so we try 3 times to get it.
            while (tState == null) {
                tries++;
                if (tries > maxTries) {
                    if (getInfoException == null) {
                        throw new RuntimeException("VCenter failed to return task info after 3 tries.");
                    } else if (getInfoException instanceof RuntimeFaultFaultMsg) {
                        throw (RuntimeFaultFaultMsg) getInfoException;
                    } else if (getInfoException instanceof RemoteException) {
                        throw (RemoteException) getInfoException;
                    } else {
                        throw new RuntimeException(getInfoException);
                    }
                }

                try {
                    TaskInfo tInfo = (TaskInfo) getDynamicProperty(task, "info");
                    if (tInfo != null) {
                        tState = tInfo.getState();
                    }
                } catch (Exception e) {
                    // silently catch 3 exceptions
                    getInfoException = e;
                }
            }

            // sleep for a specified time based on task state.
            if (tState.equals(TaskInfoState.RUNNING)) {
                Thread.sleep(runningDelayInMillSecond);
            } else {
                Thread.sleep(queuedDelayInMillSecond);
            }
        }

        if (tState.equals(TaskInfoState.SUCCESS)) {
            retVal = true;
        }
        return retVal;
    }
View Full Code Here

     *
     */
    public boolean waitForTask(ManagedObjectReference task, int runningDelayInMillSecond, int queuedDelayInMillSecond) throws RuntimeFaultFaultMsg, RemoteException,
    InterruptedException {
        boolean retVal = false;
        TaskInfoState tState = null;
        int tries = 0;
        int maxTries = 3;
        Exception getInfoException = null;

        while ((tState == null) || tState.equals(TaskInfoState.RUNNING) || tState.equals(TaskInfoState.QUEUED)) {
            tState = null;
            getInfoException = null;
            tries = 0;
            // under load getTaskInfo may return null when there really is valid task info, so we try 3 times to get it.
            while (tState == null) {
                tries++;
                if (tries > maxTries) {
                    if (getInfoException == null) {
                        throw new RuntimeException("VCenter failed to return task info after 3 tries.");
                    } else if (getInfoException instanceof RuntimeFaultFaultMsg) {
                        throw (RuntimeFaultFaultMsg) getInfoException;
                    } else if (getInfoException instanceof RemoteException) {
                        throw (RemoteException) getInfoException;
                    } else {
                        throw new RuntimeException(getInfoException);
                    }
                }

                try {
                    TaskInfo tInfo = (TaskInfo) getDynamicProperty(task, "info");
                    if (tInfo != null) {
                        tState = tInfo.getState();
                    }
                } catch (Exception e) {
                    // silently catch 3 exceptions
                    getInfoException = e;
                }
            }

            // sleep for a specified time based on task state.
            if (tState.equals(TaskInfoState.RUNNING)) {
                Thread.sleep(runningDelayInMillSecond);
            } else {
                Thread.sleep(queuedDelayInMillSecond);
            }
        }

        if (tState.equals(TaskInfoState.SUCCESS)) {
            retVal = true;
        }
        return retVal;
    }
View Full Code Here

   *
   * @author Eric Forgette (forgette@netapp.com)
   */
  public String waitForTask(int runningDelayInMillSecond, int queuedDelayInMillSecond) throws RuntimeFault, RemoteException, InterruptedException 
  {        
    TaskInfoState tState = null;
    int tries = 0;
    int maxTries=3;
    Exception getInfoException = null;

    while((tState == null) || tState.equals(TaskInfoState.running) || tState.equals(TaskInfoState.queued))
    {
      tState = null;
      getInfoException = null;
      tries=0;
      // under load getTaskInfo may return null when there really is valid task info, so we try 3 times to get it.
      while (tState==null)
      {
        tries++;
        if (tries > maxTries)
        {
          if (getInfoException == null)
          {
            throw new NullPointerException();
          }
          else if (getInfoException instanceof RuntimeFault)
          {
            throw (RuntimeFault) getInfoException;
          }
          else if (getInfoException  instanceof RemoteException )
          {
            throw (RemoteException) getInfoException;
          }
          else
          {
              throw new RuntimeException(getInfoException);
          }
        }

        try
        {
          tState = getTaskInfo().getState();
        }
        catch (Exception e)
        {
          //silently catch 3 exceptions
          getInfoException=e;
        }
      }

      // sleep for a specified time based on task state.
      if (tState.equals(TaskInfoState.running))
      {
        Thread.sleep(runningDelayInMillSecond);
      }
      else
      {
        Thread.sleep(queuedDelayInMillSecond);
      }
    }
    return tState.toString();
  }
View Full Code Here

   *
   * @author Eric Forgette (forgette@netapp.com)
   */
  public String waitForTask(int runningDelayInMillSecond, int queuedDelayInMillSecond) throws RuntimeFault, RemoteException, InterruptedException 
  {        
    TaskInfoState tState = null;
    int tries = 0;
    int maxTries=3;
    Exception getInfoException = null;

    while((tState == null) || tState.equals(TaskInfoState.running) || tState.equals(TaskInfoState.queued))
    {
      tState = null;
      getInfoException = null;
      tries=0;
      // under load getTaskInfo may return null when there really is valid task info, so we try 3 times to get it.
      while (tState==null)
      {
        tries++;
        if (tries > maxTries)
        {
          if (getInfoException == null)
          {
            throw new NullPointerException();
          }
          else if (getInfoException instanceof RuntimeFault)
          {
            throw (RuntimeFault) getInfoException;
          }
          else if (getInfoException  instanceof RemoteException )
          {
            throw (RemoteException) getInfoException;
          }
          else
          {
              throw new RuntimeException(getInfoException);
          }
        }

        try
        {
          tState = getTaskInfo().getState();
        }
        catch (Exception e)
        {
          //silently catch 3 exceptions
          getInfoException=e;
        }
      }

      // sleep for a specified time based on task state.
      if (tState.equals(TaskInfoState.running))
      {
        Thread.sleep(runningDelayInMillSecond);
      }
      else
      {
        Thread.sleep(queuedDelayInMillSecond);
      }
    }
    return tState.toString();
  }
View Full Code Here

  public ManagedObjectReference getNetworkMor(String portGroupName) throws Exception {
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("Network");
    pSpec.setPathSet(new String[] {"summary.name"});
   
      TraversalSpec host2NetworkTraversal = new TraversalSpec();
      host2NetworkTraversal.setType("HostSystem");
      host2NetworkTraversal.setPath("network");
      host2NetworkTraversal.setName("host2NetworkTraversal");

      ObjectSpec oSpec = new ObjectSpec();
      oSpec.setObj(_mor);
      oSpec.setSkip(Boolean.TRUE);
      oSpec.setSelectSet(new SelectionSpec[] { host2NetworkTraversal });
View Full Code Here

TOP

Related Classes of com.vmware.vim25.TaskInfoState

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.