Package com.vmware.bdd.placement.entity

Examples of com.vmware.bdd.placement.entity.BaseNode


      List<BaseNode> nodes = new ArrayList<BaseNode>();
      if (nodeEntities == null) {
         return nodes;
      }
      for (NodeEntity nodeEntity : nodeEntities) {
         BaseNode node = convertNode(cluster, group, nodeEntity);
         nodes.add(node);
      }
      return nodes;
   }
View Full Code Here


      logger.debug("convert node " + entity.getVmName());
      VcVirtualMachine vcVm = null;
      if (entity.getMoId() != null) {
         vcVm = VcCache.getIgnoreMissing(entity.getMoId());
      }
      BaseNode node = new BaseNode(entity.getVmName());
      node.setTargetHost(entity.getHostName());
      if (entity.getVcRp() != null) {
         node.setTargetVcCluster(entity.getVcRp().getVcCluster());
         node.setTargetRp(entity.getVcRp().getVcResourcePool());
      }
      node.setTargetRack(entity.getRack());
      node.setCluster(cluster);
      node.setNodeGroup(group);
      node.setVmMobId(entity.getMoId());
      node.setVmFolder(entity.getNodeGroup().getVmFolderPath());
      if (vcVm != null) {
         node.setNics(convertNics(entity.getNics()));
         node.setGuestHostName(entity.getGuestHostName());
      }
      return node;
   }
View Full Code Here

      processor.stop();
      elasticityScheduleMgr.shutdown();
   }

   private void convertTemplateVm() {
      templateNode = new BaseNode(templateVm.getName());
      List<DiskSpec> diskSpecs = new ArrayList<DiskSpec>();
      for (DeviceId slot : templateVm.getVirtualDiskIds()) {
         VirtualDisk vmdk = (VirtualDisk) templateVm.getVirtualDevice(slot);
         DiskSpec spec = new DiskSpec();
         spec.setSize((int) (vmdk.getCapacityInKB() / (1024 * 1024)));
 
View Full Code Here

      List<VmCreateResult<?>> results =
            cloneService.createCopies(sourceSpec, cloneConcurrency, specs,
                  callback);
      if (results == null || results.isEmpty()) {
         for (VmCreateSpec spec : specs) {
            BaseNode node = nodeMap.get(spec.getVmName());
            node.setFinished(true);
            node.setSuccess(false);
         }
         return false;
      }
      boolean success = true;
      int total = 0;
      for (VmCreateResult<?> result : results) {
         VmCreateSpec spec = (VmCreateSpec) result.getSpec();
         BaseNode node = nodeMap.get(spec.getVmName());
         node.setVmMobId(spec.getVmId());
         node.setSuccess(true);
         node.setFinished(true);
         boolean vmSucc = VcVmUtil.setBaseNodeForVm(node, spec.getVmId());
         if (!vmSucc || !result.isSuccess()) {
            success = false;
            node.setSuccess(false);
            if (result.getErrMessage() != null) {
               node.setErrMessage(result.getErrTimestamp() + " "
                     + result.getErrMessage());
            } else if (!node.getErrMessage().isEmpty()) {
               node.setErrMessage(CommonUtil.getCurrentTimestamp() + " "
                     + node.getNodeAction());
            }
         } else {
            total++;
         }
      }
View Full Code Here

      Set<String> deletedNodeNames = new HashSet<String>();
      for (BaseNode vNode : vcDeletedNodes) {
         deletedNodeNames.add(vNode.getVmName());
      }
      for (Iterator<BaseNode> ite = existingNodes.iterator(); ite.hasNext();) {
         BaseNode vNode = ite.next();
         if (deletedNodeNames.contains(vNode.getVmName())) {
            JobUtils.adjustOccupiedIpSets(occupiedIpSets, vNode, false);
            ite.remove();
         }
      }
   }
View Full Code Here

         StatusUpdater statusUpdator, boolean ignoreUnavailableNodes) {
      logger.info("syncDeleteVMs, start to create store procedures.");
      List<Callable<Void>> storeProcedures = new ArrayList<Callable<Void>>();
      List<BaseNode> toBeDeleted = new ArrayList<BaseNode>();
      for (int i = 0; i < badNodes.size(); i++) {
         BaseNode node = badNodes.get(i);
         if (node.getVmMobId() == null) {
            // vm is already deleted
            node.setSuccess(true);
            continue;
         }
         DeleteVmByIdSP deleteSp = new DeleteVmByIdSP(node.getVmMobId());
         storeProcedures.add(deleteSp);
         toBeDeleted.add(node);
      }
      try {
         if (storeProcedures.isEmpty()) {
            logger.info("no VM is created. Return directly.");
            return true;
         }
         Callable<Void>[] storeProceduresArray =
               storeProcedures.toArray(new Callable[0]);
         // execute store procedures to delete VMs
         logger.info("ClusteringService, start to delete vms.");
         BaseProgressCallback callback =
               new BaseProgressCallback(statusUpdator, 0, 50);
         ExecutionResult[] result =
               Scheduler
                     .executeStoredProcedures(
                           com.vmware.aurora.composition.concurrent.Priority.BACKGROUND,
                           storeProceduresArray, callback);
         if (result == null) {
            logger.error("No VM is deleted.");
            return false;
         }

         int total = 0;
         boolean failed = false;
         for (int i = 0; i < storeProceduresArray.length; i++) {
            BaseNode vNode = toBeDeleted.get(i);
            vNode.setFinished(true);
            if (result[i].finished && result[i].throwable == null) {
               vNode.setSuccess(true);
               vNode.setVmMobId(null);
               ++total;
            } 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;
                  }
               }
               logger.error("Failed to delete VM " + vNode.getVmName(),
                     result[i].throwable);
               failed = true;
            }
            vNode.setFinished(true);
         }
         logger.info(total + " VMs are deleted.");
         return !failed;
      } catch (InterruptedException e) {
         logger.error("error in deleting VMs", e);
View Full Code Here

         throw e;
      }
   }

   public static BaseNode getTemplateNode() {
      BaseNode template = new BaseNode("template-node");

      List<DiskSpec> disks = new ArrayList<DiskSpec>();

      DiskSpec systemDisk = new DiskSpec();
      systemDisk.setName("OS.vmdk");
      systemDisk.setSeparable(false);
      systemDisk.setDiskType(DiskType.SYSTEM_DISK);
      systemDisk.setSize(SYSTEM_DISK_SIZE);

      disks.add(systemDisk);
      template.setDisks(disks);
      return template;
   }
View Full Code Here

   }

   @Test
   public void testGetBaseNodeNames() {
      VirtualNode vNode = new VirtualNode();
      vNode.addNode(new BaseNode("base1"));
      vNode.addNode(new BaseNode("base2"));
      Assert.assertEquals(
            PlacementUtil.getBaseNodeNames(vNode), Arrays.asList("base1", "base2")
      );
   }
View Full Code Here

   @Test(groups = { "TestClusteringService" }, dependsOnMethods = { "testReserveResource" })
   public void testCreateDhcpVmFolderFailed() {
      List<NetworkAdd> networkAdds = createNetworkAdd();
      List<BaseNode> vNodes = new ArrayList<BaseNode>();
      BaseNode node = new BaseNode("test-master-0");
      ClusterCreate spec = createClusterSpec();
      node.setCluster(spec);
      VmSchema vmSchema = createVmSchema();
      node.setVmSchema(vmSchema);
      vNodes.add(node);
      MockTmScheduler.setFlag(VmOperation.CREATE_FOLDER, false);
      try {
         service.createVcVms(networkAdds, vNodes, null, false, null);
         Assert.assertTrue(false, "should throw exception but not.");
View Full Code Here

   @Test(groups = { "TestClusteringService" }, dependsOnMethods = { "testCreateDhcpVmFolderFailed" })
   public void testCreateDhcpVmNullResult() {
      List<NetworkAdd> networkAdds = createNetworkAdd();
      List<BaseNode> vNodes = new ArrayList<BaseNode>();
      BaseNode node = new BaseNode("test-master-0");
      ClusterCreate spec = createClusterSpec();
      node.setCluster(spec);
      VmSchema vmSchema = createVmSchema();
      node.setVmSchema(vmSchema);
      vNodes.add(node);
      MockTmScheduler.setFlag(VmOperation.CREATE_FOLDER, true);
      MockTmScheduler.setResultIsNull(true);
      try {
         service.createVcVms(networkAdds, vNodes, null, false, null);
View Full Code Here

TOP

Related Classes of com.vmware.bdd.placement.entity.BaseNode

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.