Package com.vmware.aurora.vc

Examples of com.vmware.aurora.vc.VcVirtualMachine


         for (NodeEntity node : nodes) {
            String moId = node.getMoId();
            if (moId == null) {
               continue;
            }
            VcVirtualMachine vm = VcCache.getIgnoreMissing(moId);
            if (vm == null) {
               continue;
            }
            logger.info("Process VM " + vm.getName()
                  + " for received host event " + type + " of " + hostName);
            if (logger.isDebugEnabled()) {
               logger.debug("host availability: "
                     + !vm.getHost().isUnavailbleForManagement());
               logger.debug("host connection: " + vm.getHost().isConnected());
               logger.debug("host maintenance: "
                     + vm.getHost().isInMaintenanceMode());
               logger.debug("vm connection: " + vm.isConnected());
            }
            String clusterName = CommonUtil.getClusterName(vm.getName());
            try {
               vm.updateRuntime();
               lockMgr.refreshNodeByVmName(clusterName, moId, vm.getName(),
                     true);
               if ((!vm.isConnected())
                     || vm.getHost().isUnavailbleForManagement()) {
                  logConnectionChangeEvent(vm.getName());
               }
            } catch (ManagedObjectNotFound me) {
               continue;
            }
         }
View Full Code Here


      String moId = MoUtil.morefToString(moRef);
      String externalStr = external ? " external" : "";
      logger.debug("processed" + externalStr + " vm event: " + e);
      if (external) {
         if (processExternalEvent(type, e, moId)) {
            VcVirtualMachine vm = VcCache.getIgnoreMissing(e.getVm().getVm());
            String newId = moId;
            if (vm != null) {
               newId = switchMobId(moId, vm);
            }
            processEvent(type, e, newId, true);
View Full Code Here

               lockMgr.refreshNodeByMobId(clusterName, moId, null, true);
            }
            break;
         }
         case VmDisconnected: {
            VcVirtualMachine vm = VcCache.getIgnoreMissing(moId);
            if (vm == null) {
               NodeEntity node = clusterEntityMgr.getNodeByMobId(moId);
               if (node != null) {
                  String clusterName =
                        CommonUtil.getClusterName(node.getVmName());
                  logger.debug("vm " + moId + " is already removed");
                  lockMgr.removeVmReference(clusterName, moId);
               }
               break;
            }
            if (clusterEntityMgr.getNodeByVmName(vm.getName()) != null) {
               vm.updateRuntime();
               if ((!vm.isConnected())
                     || vm.getHost().isUnavailbleForManagement()) {
                  String clusterName = CommonUtil.getClusterName(vm.getName());
                  lockMgr.setNodeConnectionState(clusterName, vm.getName());
                  logConnectionChangeEvent(vm.getName());
               }
            }
            break;
         }
         case VmPoweredOn: {
            logger.debug("vm is powered on");
            // ignore this event if waitForPowerState failed
            if (waitForPowerState(moId, PowerState.poweredOn)) {
               refreshNodeWithAction(moId, true, Constants.NODE_ACTION_WAITING_IP,
                     "Powered On");
               if (external) {
                  NodePowerOnRequest request =
                        new NodePowerOnRequest(lockMgr, moId, clusterManager,
                              softwareManagerCollector);
                  CmsWorker.addRequest(WorkQueue.VC_TASK_NO_DELAY, request);
               }
            }

            break;
         }
         case VmCloned: {
            refreshNodeWithAction(moId, true,
                  Constants.NODE_ACTION_RECONFIGURE, "Cloned");
            break;
         }
         case VmSuspended: {
            refreshNodeWithAction(moId, true, null, "Suspended");
            break;
         }
         case VmPoweredOff: {
            if (waitForPowerState(moId, PowerState.poweredOff)) {
               refreshNodeWithAction(moId, true, null, "Powered Off");
            }
            break;
         }
         case VmConnected: {
            try {
               refreshNodeWithAction(moId, false, null, type.name());
            } catch (AuroraException ex) {
               // vm is not able to be accessed immediately after it's created,
               // ignore the exception here to continue other event processing
               logger.warn("Catch aurora exception " + ex.getMessage()
                     + ", ignore it.");
            }
            break;
         }
         case VmMigrated: {
            refreshNodeWithAction(moId, false, null, type.name());
            break;
         }
         case VhmError:
         case VhmWarning: {
            EventEx event = (EventEx) e;
            VcVirtualMachine vm =
                  VcCache.getIgnoreMissing(event.getVm().getVm());
            if (vm == null) {
               break;
            }
            if (clusterEntityMgr.getNodeByVmName(vm.getName()) != null) {
               logger.info("received vhm event " + event.getEventTypeId()
                     + " for vm " + vm.getName() + ": " + event.getMessage());
               vm.updateRuntime();
               String clusterName = CommonUtil.getClusterName(vm.getName());
               lockMgr.refreshNodeByVmName(clusterName, moId, vm.getName(),
                     event.getMessage(), true);
            }
            break;
         }
         case VhmInfo: {
            EventEx event = (EventEx) e;
            VcVirtualMachine vm =
                  VcCache.getIgnoreMissing(event.getVm().getVm());
            if (vm == null) {
               break;
            }
            if (clusterEntityMgr.getNodeByVmName(vm.getName()) != null) {
               logger.info("received vhm event " + event.getEventTypeId()
                     + " for vm " + vm.getName() + ": " + event.getMessage());
               vm.updateRuntime();
               String clusterName = CommonUtil.getClusterName(vm.getName());
               lockMgr.refreshNodeByVmName(clusterName, moId, vm.getName(), "",
                     true);
            }
            break;
         }
         default: {
            if (external) {
               VcVirtualMachine vm = VcCache.getIgnoreMissing(moId);
               if (vm == null) {
                  break;
               }
               String clusterName = CommonUtil.getClusterName(vm.getName());
               lockMgr.refreshNodeByVmName(clusterName, moId, vm.getName(),
                     true);
            }
            break;
         }
         }
View Full Code Here

   }

   private boolean waitForPowerState(final String moid, final PowerState state) {
      // only handle poweredOff or PoweredOn
      AuAssert.check(state == PowerState.poweredOff || state == PowerState.poweredOn);
      final VcVirtualMachine vm = VcCache.getIgnoreMissing(moid);
      if (vm == null) {
         return false;
      }

      int timeout = WAIT_FOR_VM_STATE_TIMEOUT_SECS;
      try {
         while (timeout > 0) {
            // udpate VM's runtime state from VC
            vm.updateRuntime();
            // If runtime state matches the claimed power state, done.
            if (((state == PowerState.poweredOn) && vm.isPoweredOn())
                  || (state == PowerState.poweredOff && vm.isPoweredOff())) {
               logger.info("synced power state " + state + " on vm: " + moid);
               return true;
            }

            logger.debug("syncing power state " + state + " on vm: " + moid);
View Full Code Here

   public Void call() throws Exception {
      if (vcVm == null) {
         logger.info("vm not exist. Ignore the enable auto elasticity request.");
         return null;
      }
      final VcVirtualMachine vm = VcCache.getIgnoreMissing(vcVm.getId());
      if (vm == null) {
         logger.info("vm not exist. Ignore the enable auto elasticity request.");
      }
      VcContext.inVcSessionDo(new VcSession<Void>() {
         @Override
         protected Void body() throws Exception {

            List<OptionValue> options = new ArrayList<OptionValue>();
            if (vm.getId().equalsIgnoreCase(masterMoId)) {
               options.add(new OptionValueImpl(VHMConstants.VHM_ENABLE, enableAutoElasticity.toString()));
               options.add(new OptionValueImpl(VHMConstants.VHM_INSTANCERANGE_COMPUTENODE_NUM,
                     (new Integer(minComputeNodeNum)).toString() + ":" + (new Integer(maxComputeNodeNum)).toString()));
               options.add(new OptionValueImpl(VHMConstants.VHM_JOBTRACKER_PORT, jobTrackerPort));
               options.add(new OptionValueImpl(VHMConstants.VHM_CLUSTER_NAME, clusterName));
            }

            options.add(new OptionValueImpl(VHMConstants.VHM_MASTER_MOID, masterMoId.split(":")[2]));
            options.add(new OptionValueImpl(VHMConstants.VHM_MASTER_UUID, masterUUID));
            options.add(new OptionValueImpl(VHMConstants.VHM_SERENGETI_UUID, serengetiUUID));
            options.add(new OptionValueImpl(VHMConstants.VHM_ELASTIC, (new Boolean(isComputeOnlyNode)).toString()));

            OptionValue[] optionValues = options.toArray((OptionValue[]) Array.newInstance(OptionValue.class, options.size()));
            ConfigSpec spec = new ConfigSpecImpl();
            spec.setExtraConfig(optionValues);
            vm.reconfigure(spec);
            logger.info("set autoElasticity, masterMoId=" + masterMoId + ", masterUUID=" + masterUUID + ", isComputeOnlyNode=" + isComputeOnlyNode + ", enable="
                  + enableAutoElasticity + ", jobTrackerPort=" + jobTrackerPort + ", minComputeNodeNum=" + minComputeNodeNum + ", maxComputeNodeNum=" + maxComputeNodeNum);
            return null;
         }
         protected boolean isTaskSession() {
View Full Code Here

      return false;
   }

   private void refreshNodeWithAction(String moId, boolean setAction,
         String action, String eventName) throws Exception {
      VcVirtualMachine vm = VcCache.getIgnoreMissing(moId);
      if (vm == null) {
         return;
      }
      if (clusterEntityMgr.getNodeByVmName(vm.getName()) != null) {
         logger.info("received vm " + eventName + " event for vm: "
               + vm.getName());
         vm.updateRuntime();
         String clusterName = CommonUtil.getClusterName(vm.getName());
         if (setAction) {
            lockMgr.refreshNodeByVmName(clusterName, moId, vm.getName(),
                  action, true);
         } else {
            lockMgr.refreshNodeByVmName(clusterName, moId, vm.getName(), true);
         }
      }
      return;
   }
View Full Code Here

      vm.reconfigure(configSpec);
   }

   @Override
   public Void call() throws Exception {
      final VcVirtualMachine oldVm = VcCache.getIgnoreMissing(oldVmId);
      if (oldVm == null) {
         logger.info("vm " + oldVmId
               + " is not found in VC, ignore this disk fix.");
         return null;
      }
View Full Code Here

         this.addDisks = addDisks;
      }

      @Override
      public Void call() throws Exception {
         VcVirtualMachine vm = VcCache.get(vmId);
         if (!(removeDisks == null && addDisks == null)) {
            vm.changeDisks(removeDisks, addDisks);
         }
         return null;
      }
View Full Code Here

               return true;
            }

            @Override
            protected Void body() throws Exception {
               VcVirtualMachine template = VcCache.get(srcVmId);
               VcSnapshot snap = template.getSnapshotByName(snapName);

               CreateSpec vmSpec =
                     new CreateSpec(newVmName, snap, targetRp, targetDs, true, null);

               DeviceId[] removeSet = removeDisks;
               VcVirtualMachine newVm = template.cloneVm(vmSpec, removeSet);
               newVm.changeDisks(null, addDisks);
               //newVm.powerOn();

               // retrieve the resulting VcObject instance
               dstVmId = newVm.getId();
               vcVm = newVm;
               return null;
            }
         });
         return null;
View Full Code Here

         this.description = description;
      }

      @Override
      public Void call() throws Exception {
         final VcVirtualMachine vm = VcCache.get(vmId);

         VcContext.inVcSessionDo(new VcSession<Void>() {
            @Override
            protected boolean isTaskSession() {
               return true;
            }

            @Override
            protected Void body() throws Exception {
               vm.createSnapshot(name, description);
               return null;
            }
         });
         return null;
      }
View Full Code Here

TOP

Related Classes of com.vmware.aurora.vc.VcVirtualMachine

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.