Examples of VcService


Examples of com.vmware.aurora.vc.vcservice.VcService

      return list;
   }

   public static Folder getRootFolder() throws Exception {
      AuAssert.check(VcContext.isInSession());
      VcService svc = VcContext.getService();
      ManagedObjectReference rootFolderRef =
         svc.getServiceInstanceContent().getRootFolder();
      return svc.getManagedObject(rootFolderRef);
   }
View Full Code Here

Examples of com.vmware.aurora.vc.vcservice.VcService

    */
   public static <T extends ManagedObject> List<T>
   getChildEntity(Folder folder, Class<T> clazz)
   {
      AuAssert.check(VcContext.isInSession());
      VcService svc = VcContext.getService();
      ManagedObjectReference[] childEntities = folder.getChildEntity();
      List<T> entities = new ArrayList<T>();
      for (ManagedObjectReference child : childEntities) {
         if (isOfType(child, clazz)) {
            entities.add(svc.<T>getManagedObject(child));
         }
      }
      return entities;
   }
View Full Code Here

Examples of com.vmware.aurora.vc.vcservice.VcService

   private static <T extends ManagedObject> void
   getDescendants(Folder folder, Class<T> clazz,
                  List<ManagedObjectReference> descendants)
   {
      AuAssert.check(VcContext.isInSession());
      VcService svc = VcContext.getService();
      ManagedObjectReference[] childEntities = folder.getChildEntity();
      for (ManagedObjectReference child : childEntities) {
         if (isOfType(child, clazz)) {
            descendants.add(child);
         } else if(isOfType(child, Folder.class)) {
            Folder childFolder = svc.<Folder>getManagedObject(child);
            getDescendants(childFolder, clazz, descendants);
         }
      }
   }
View Full Code Here

Examples of com.vmware.aurora.vc.vcservice.VcService

    * @return
    */
   protected static <T extends ManagedObject> ManagedObjectReference
   getAncestorMoRef(ManagedObjectReference parent, Class<T> clazz) {
      AuAssert.check(VcContext.isInSession());
      VcService svc = VcContext.getService();
      if (isOfType(parent, clazz)) {
         return parent;
      } else {
         ManagedObject obj = svc.getManagedObject(parent);
         if (obj instanceof Folder) {
            Folder folder = (Folder)obj;
            return getAncestorMoRef(folder.getParent(), clazz);
         }
      }
View Full Code Here

Examples of com.vmware.aurora.vc.vcservice.VcService

    * We don't want the handlers to disappear on re-establishing VC connection.
    *
    * @throws Exception
    */
   public void reset() throws Exception {
      VcService vcService = VcContext.getService();
      AuAssert.check(vcService != null && vcService.isConnected());
      AuAssert.check(Thread.currentThread() == this); // Other threads can't do this.

      logger.info("VcEventListener reset");
      currentVersion = null;

      eventManagerMoRef = vcService.getServiceInstanceContent().getEventManager();
      eventManager = MoUtil.getManagedObject(eventManagerMoRef);

      taskManagerMoRef = vcService.getServiceInstanceContent().getTaskManager();

      /* Listen to all events under targetMoRef. */
      eventFilterSpec = createEventFilterSpec();
      eventHistoryCollectorMoRef = eventManager.createCollector(eventFilterSpec);
      eventHistoryCollector = MoUtil.getManagedObject(eventHistoryCollectorMoRef);

      /*
       * Set up property collector to watch for changes of either:
       * - EventColletor.latestPage property
       * - Task.info.state property in recent tasks
       */
      eventPFS = createEventPFS();
      eventFilterMoRef = vcService.getPropertyCollector().createFilter(
            eventPFS, false);

      taskPFS = createTaskPFS();
      taskFilterMoRef = vcService.getPropertyCollector().createFilter(
            taskPFS, false);

      /*
       * Reset retry delay only if the last generation did any real work in order
       * to avoid login()/logout() in a tight loop when VC is persistently down.
View Full Code Here

Examples of com.vmware.aurora.vc.vcservice.VcService

          * VC session went bad. Logout to force automatic relogin that will
          * trigger the establishment of the new VC session. On stop, logout
          * happens along with other cleanup.
          */
         if (!stopRequested) {
            VcService vcService = VcContext.getService();
            if (vcService == null) {
               /*
                * Tomcat likes to clean out ThreadLocal on shutdown. We might land here
                * if something went wrong with the thread executing WebServiceContextListener
                * callbacks before it had a chance to cleanly shut down VcEventListener.
                * Terminate the thread - Bug 733665.
                */
               onOuterLoopTerminate(VcEventListenerState.STOPPED_UNCLEAN, null);
               break;
            } else {
               vcService.logout();
            }
         }
      }
   }
View Full Code Here

Examples of com.vmware.aurora.vc.vcservice.VcService

   /*
    * Get VC File URL.
    */
   private static String getVcFileUrl(VcDatastore datastore, String dsFilePath)
   throws Exception {
      VcService vcs = VcContext.getService();
      String rootFolderUrl = vcs.getServiceUrl().replaceFirst("sdk", "folder");
      AuAssert.check(rootFolderUrl.endsWith("folder"));
      //construct upload file destination URL
      String relativePath = URLEncoder.encode(String.format("%s?dcPath=%s&dsName=%s", dsFilePath,
            datastore.getDatacenter().getURLName(), datastore.getURLName()), "UTF-8");
      return String.format("%s/%s", rootFolderUrl, relativePath);
View Full Code Here

Examples of com.vmware.aurora.vc.vcservice.VcService

      final String vcContentType = "application/octet-stream";
      // Retry 3 times using host URL
      // XXX VC folder uploading is not completely implemented.
      Boolean reqsUseVc[] = new Boolean[]{false, false, false};
      long lenDone = listener.getLenDone();
      VcService vcs = VcContext.getService();
      for (Boolean useVc: reqsUseVc) {
         try {
            if (useVc) {
               /*
                * If we fail to upload to host directly, try to use
                * "VC folder put API", which is orders of magnitude slower.
                */
               String sessionString = "vmware_soap_session=" + vcs.getClientSessionId();
               uploadFileWork(vcUrl, false, file, vcContentType,
                              sessionString, listener);
            } else {
               uploadFileWork(hostUrl, true, file, hostContentType, null, listener);
            }
View Full Code Here

Examples of com.vmware.aurora.vc.vcservice.VcService

   importVm(String name, VcResourcePool rp, VcDatastore ds,
            VcNetwork network, String ovfPath)
   throws Exception {
      ManagedObjectReference vmRef;
      AuAssert.check(VcContext.isInTaskSession());
      VcService vcs = VcContext.getService();

      CreateImportSpecParams importParams = new CreateImportSpecParamsImpl();
      importParams.setDeploymentOption("");
      importParams.setLocale("");
      importParams.setEntityName(name);
      NetworkMapping[] nets = {
            new NetworkMappingImpl("Network 1", network.getMoRef()),
            new NetworkMappingImpl("Network 2", network.getMoRef())
      };
      importParams.setNetworkMapping(nets);
      importParams.setIpAllocationPolicy(IpAllocationPolicy.transientPolicy.toString());
      importParams.setDiskProvisioning("thin");

      // create import spec from ovf
      CreateImportSpecResult specResult = vcs.getOvfManager().createImportSpec(
            loadOvfContents(ovfPath), rp.getMoRef(), ds.getMoRef(), importParams);
      AuAssert.check(specResult.getError() == null && specResult.getWarning() == null);
      VmImportSpec importSpec = (VmImportSpec)specResult.getImportSpec();
      // start importing the vApp and get the lease to upload vmdks
      HttpNfcLease nfcLease = rp.importVApp(importSpec);
View Full Code Here

Examples of com.vmware.aurora.vc.vcservice.VcService

   }

   public static void uploadFile(String localPath, VcDatastore datastore, String datastorePath)
         throws Exception {
      AuAssert.check(VcContext.isInTaskSession());
      VcService vcs = VcContext.getService();

      final String url = VcFileManager.getVcFileUrl(datastore, datastorePath);
      final String vcContentType = "application/octet-stream";
      final String sessionString = "vmware_soap_session=" + vcs.getClientSessionId();
      final File file = new File(localPath);
      final ProgressListener progress = new ProgressListener(null, 0);

      uploadFileWork(url, false, file, vcContentType, sessionString, progress);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.