Package com.vmware.aurora.vc

Examples of com.vmware.aurora.vc.VcVirtualMachine


         ConfigInfo.save();
      }
   }

   private void prepareTemplateVM() {
      final VcVirtualMachine templateVM = getTemplateVm();

      if (templateVM == null) {
         throw ClusteringServiceException.TEMPLATE_VM_NOT_FOUND();
      }
View Full Code Here


      String serengetiUUID = ConfigInfo.getSerengetiRootFolder();
      int minComputeNodeNum = cluster.getVhmMinNum();
      int maxComputeNodeNum = cluster.getVhmMaxNum();
      String jobTrackerPort = cluster.getVhmJobTrackerPort();

      VcVirtualMachine vcVm = VcCache.getIgnoreMissing(masterMoId);
      if (vcVm == null) {
         logger.error("cannot find vhm master node");
         return false;
      }
      String masterUUID = vcVm.getConfig().getUuid();

      Callable<Void>[] storeProcedures = new Callable[nodes.size()];
      int i = 0;
      for (NodeEntity node : nodes) {
         VcVirtualMachine vm = VcCache.getIgnoreMissing(node.getMoId());
         if (vm == null) {
            logger.error("cannot find node: " + node.getVmName());
            continue;
         }
         if (!refreshAllNodes && !vm.getId().equalsIgnoreCase(masterMoId)) {
            continue;
         }
         List<String> roles =
               new Gson().fromJson(node.getNodeGroup().getRoles(), List.class);
         SoftwareManager softMgr =
View Full Code Here

         NodeEntity node = nodes.get(i);
         if (node.getMoId() == null) {
            logger.info("VC vm does not exist for node: " + node.getVmName());
            continue;
         }
         VcVirtualMachine vcVm = VcCache.getIgnoreMissing(node.getMoId());
         if (vcVm == null) {
            // cannot find VM
            logger.info("VC vm does not exist for node: " + node.getVmName());
            continue;
         }

         StartVmSP.StartVmPrePowerOn prePowerOn = new StartVmSP.StartVmPrePowerOn(isMapDistro,
               (new Gson()).toJson(node.getVolumns()));
         StartVmPostPowerOn query =
               new StartVmPostPowerOn(node.fetchAllPortGroups(),
                     Constants.VM_POWER_ON_WAITING_SEC, clusterEntityMgr);
         VcHost host = null;
         if (node.getHostName() != null) {
            host = VcResourceUtils.findHost(node.getHostName());
         }
         StartVmSP startSp = new StartVmSP(vcVm, prePowerOn, query, host);
         storeProcedures.add(startSp);
         nodesStatus.put(node.getVmName(),
               new NodeOperationStatus(node.getVmName()));
      }

      try {
         if (storeProcedures.isEmpty()) {
            logger.info("no VM is available. Return directly.");
            return true;
         }
         Callable<Void>[] storeProceduresArray =
               storeProcedures.toArray(new Callable[0]);
         // execute store procedures to start VMs
         logger.info("ClusteringService, start to start vms.");
         BaseProgressCallback callback = new BaseProgressCallback(statusUpdator);
         ExecutionResult[] result =
               Scheduler
                     .executeStoredProcedures(
                           com.vmware.aurora.composition.concurrent.Priority.BACKGROUND,
                           storeProceduresArray, callback);
         if (result == null) {
            for (NodeOperationStatus status : nodesStatus.values()) {
               status.setSucceed(false);
            }
            logger.error("No VM is started.");
            failedNodes.addAll(nodesStatus.values());
            return false;
         }

         boolean success = true;
         int total = 0;
         for (int i = 0; i < storeProceduresArray.length; i++) {
            StartVmSP sp = (StartVmSP) storeProceduresArray[i];
            NodeOperationStatus status = nodesStatus.get(sp.getVmName());
            VcVirtualMachine vm = sp.getVcVm();
            if (result[i].finished && result[i].throwable == null) {
               ++total;
               nodesStatus.remove(status.getNodeName()); // do not return success node
            } else if (result[i].throwable != null) {
               status.setSucceed(false);
               status.setErrorMessage(getErrorMessage(result[i].throwable));
               if (vm != null
                     && vm.isPoweredOn() && VcVmUtil.checkIpAddresses(vm)) {
                  ++total;
                  nodesStatus.remove(status.getNodeName()); // do not return success node status
               } else {
                  if (!vm.isConnected()
                        || vm.getHost().isUnavailbleForManagement()) {
                     logger.error("Cannot start VM " + vm.getName()
                           + " in connection state " + vm.getConnectionState()
                           + " or in maintenance mode. "
                           + "Ignore this VM and continue cluster operations.");
                     continue;
                  }
                  logger.error(
View Full Code Here

         NodeEntity node = nodes.get(i);
         if (node.getMoId() == null) {
            logger.info("VC vm does not exist for node: " + node.getVmName());
            continue;
         }
         VcVirtualMachine vcVm = VcCache.getIgnoreMissing(node.getMoId());

         if (vcVm == null) {
            logger.info("VC vm does not exist for node: " + node.getVmName());
            continue;
         }
         StopVmSP stopSp = new StopVmSP(vcVm);
         storeProcedures.add(stopSp);
         nodesStatus.put(node.getVmName(),
               new NodeOperationStatus(node.getVmName()));
      }

      try {
         if (storeProcedures.isEmpty()) {
            logger.info("no VM is available. Return directly.");
            return true;
         }
         Callable<Void>[] storeProceduresArray =
               storeProcedures.toArray(new Callable[0]);
         // execute store procedures to start VMs
         logger.info("ClusteringService, start to stop vms.");
         BaseProgressCallback callback = new BaseProgressCallback(statusUpdator);

         ExecutionResult[] result =
               Scheduler
                     .executeStoredProcedures(
                           com.vmware.aurora.composition.concurrent.Priority.BACKGROUND,
                           storeProceduresArray, callback);
         if (result == null) {
            logger.error("No VM is stoped.");
            for (NodeOperationStatus status : nodesStatus.values()) {
               status.setSucceed(false);
            }
            failedNodes.addAll(nodesStatus.values());
            return false;
         }

         boolean success = true;
         int total = 0;
         for (int i = 0; i < storeProceduresArray.length; i++) {
            StopVmSP sp = (StopVmSP) storeProceduresArray[i];
            NodeOperationStatus status = nodesStatus.get(sp.getVmName());
            if (result[i].finished && result[i].throwable == null) {
               ++total;
               nodesStatus.remove(status.getNodeName()); // do not return success node
            } else if (result[i].throwable != null) {
               status.setSucceed(false);
               status.setErrorMessage(getErrorMessage(result[i].throwable));
               VcVirtualMachine vm = sp.getVcVm();
               if (vm == null || vm.isPoweredOff()) {
                  ++total;
                  nodesStatus.remove(status.getNodeName()); // do not return success node
               } else {
                  if (!vm.isConnected()
                        || vm.getHost().isUnavailbleForManagement()) {
                     logger.error("Cannot stop VM " + vm.getName()
                           + " in connection state " + vm.getConnectionState()
                           + " or in maintenance mode. "
                           + "Ignore this VM and continue cluster operations.");
                     continue;
                  }
                  logger.error("Failed to stop VM " + nodes.get(i).getVmName(),
View Full Code Here

            } else if (result[i].throwable != null) {
               vNode.setSuccess(false);
               vNode.setErrMessage(getErrorMessage(result[i].throwable));
               if (ignoreUnavailableNodes) {
                  DeleteVmByIdSP sp = (DeleteVmByIdSP) storeProceduresArray[i];
                  VcVirtualMachine vcVm = sp.getVcVm();
                  if (!vcVm.isConnected()
                        || vcVm.getHost().isUnavailbleForManagement()) {
                     logger.error("Failed to delete VM " + vcVm.getName()
                           + " in connection state "
                           + vcVm.getConnectionState()
                           + "  or in maintenance mode.");
                     logger.error("Ignore this failure and continue cluster operations.");
                     continue;
                  }
               }
View Full Code Here

      VcHost host = null;
      if (node.getHostName() != null) {
         host = VcResourceUtils.findHost(node.getHostName());
      }

      VcVirtualMachine vcVm = VcCache.getIgnoreMissing(node.getMoId());
      if (vcVm == null) {
         logger.info("VC vm does not exist for node: " + node.getVmName());
         return false;
      }
      StartVmSP startVMSP = new StartVmSP(vcVm, prePowerOn, query, host);
View Full Code Here

      NodeEntity node = this.clusterEntityMgr.findNodeByName(nodeName);
      if (node.getMoId() == null) {
         logger.error("vm mobid for node " + node.getVmName() + " is null");
         return false;
      }
      VcVirtualMachine vcVm = VcCache.getIgnoreMissing(node.getMoId());
      if (vcVm == null) {
         logger.info("VC vm does not exist for node: " + node.getVmName());
         return false;
      }
      StopVmSP stopVMSP;
View Full Code Here

      String mobId = node.getMoId();
      if (mobId == null) {
         setNotExist(node);
         return;
      }
      VcVirtualMachine vcVm = VcCache.getIgnoreMissing(mobId);
      if (vcVm == null) {
         // vm is deleted
         setNotExist(node);
         return;
      }
      if (!vcVm.isConnected() || vcVm.getHost().isUnavailbleForManagement()) {
         node.setUnavailableConnection();
         return;
      }
      // TODO: consider more status
      if (!vcVm.isPoweredOn()) {
         node.setStatus(NodeStatus.POWERED_OFF);
         node.resetNicsInfo();
      } else {
         node.setStatus(NodeStatus.POWERED_ON);
      }

      if (vcVm.isPoweredOn()) {
         //update ip address
         for (NicEntity nicEntity : node.getNics()) {
            VcVmUtil.populateNicInfo(nicEntity, node.getMoId(), nicEntity
                  .getNetworkEntity().getPortGroup());
         }

         if (node.nicsReady()) {
            node.setStatus(NodeStatus.VM_READY);
            if (node.getAction() != null
                  && (node.getAction().equals(Constants.NODE_ACTION_WAITING_IP) || node
                        .getAction().equals(Constants.NODE_ACTION_RECONFIGURE))) {
               node.setAction(null);
            }
         }
         String guestHostName = VcVmUtil.getGuestHostName(vcVm, inSession);
         if (guestHostName != null) {
            node.setGuestHostName(guestHostName);
         }
      }
      node.setHostName(vcVm.getHost().getName());
      update(node);
   }
View Full Code Here

   static public <T extends VcObject> T getIgnoreMissing(String id) {
      if (cache.containsKey(id)) {
         return (T)cache.get(id);
      }
      if (id != null && id.contains(TestPreConfigAop.VM_MOB_PREFIX)) {
         VcVirtualMachine vm = Mockito.mock(VcVirtualMachine.class);
         Mockito.when(vm.getName()).thenReturn(id);
         ConfigInfo config = Mockito.mock(ConfigInfo.class);
         Mockito.when(vm.getConfig()).thenReturn(config);
         Mockito.when(config.getUuid()).thenReturn("test-uuid");
         Mockito.when(vm.getId()).thenReturn(id);
         cache.put(id, vm);
         return (T)vm;
      } else if (getFlag) {
         if (id != null && id.equals("create-vm-succ")) {
            VcVirtualMachine vm = Mockito.mock(VcVirtualMachine.class);
            VcHost host = Mockito.mock(VcHost.class);
            Mockito.when(vm.getHost()).thenReturn(host);
            Mockito.when(host.getName()).thenReturn("host1.eng.vmware.com");
            VcResourcePool rp = Mockito.mock(VcResourcePool.class);
            Mockito.when(vm.getResourcePool()).thenReturn(rp);
            VcCluster cluster = Mockito.mock(VcCluster.class);
            Mockito.when(rp.getVcCluster()).thenReturn(cluster);
            Mockito.when(cluster.getName()).thenReturn("cluster-ws");
            return (T)vm;
         } else {
            VcVirtualMachine vm = Mockito.mock(VcVirtualMachine.class);
            Mockito.when(vm.getName()).thenReturn(id);
            ConfigInfo config = Mockito.mock(ConfigInfo.class);
            Mockito.when(vm.getConfig()).thenReturn(config);
            Mockito.when(config.getUuid()).thenReturn("test-uuid");
            Mockito.when(vm.getId()).thenReturn(id);
            return (T)vm;
         }
      } else {
         return null;
      }
View Full Code Here

   }

   @Mock
   static public <T extends VcObject> T getIgnoreMissing(ManagedObjectReference moRef) {
      if (getFlag) {
         VcVirtualMachine vm = Mockito.mock(VcVirtualMachine.class);
         String vmName = moRef.getValue();
         Mockito.when(vm.getName()).thenReturn(vmName);
         return (T)vm;
      } else {
         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.