Package com.vmware.bdd.entity

Examples of com.vmware.bdd.entity.DiskEntity


         // set disk entities, include system/swap/data disk
         Set<DiskEntity> diskEntities = nodeEntity.getDisks();

         // system disk
         DiskEntity systemDisk = nodeEntity.findSystemDisk();
         if (systemDisk == null)
            systemDisk = new DiskEntity(nodeEntity.getVmName() + ".vmdk");
         systemDisk.setDiskType(DiskType.SYSTEM_DISK.getType());
         systemDisk.setExternalAddress(DiskEntity
               .getSystemDiskExternalAddress());
         systemDisk.setNodeEntity(nodeEntity);
         systemDisk.setDatastoreName(vNode.getTargetDs());
         VcVmUtil.populateDiskInfo(systemDisk, vNode.getVmMobId());
         diskEntities.add(systemDisk);

         // swap and data disk
         for (Disk disk : vNode.getVmSchema().diskSchema.getDisks()) {
            DiskEntity newDisk = nodeEntity.findDisk(disk.name);
            if (newDisk == null) {
               newDisk = new DiskEntity(disk.name);
               diskEntities.add(newDisk);
            }
            newDisk.setSizeInMB(disk.initialSizeMB);
            newDisk.setAllocType(disk.allocationType.toString());
            newDisk.setDatastoreName(disk.datastore);
            newDisk.setDiskType(disk.type);
            newDisk.setExternalAddress(disk.externalAddress);
            newDisk.setNodeEntity(nodeEntity);

            // get vm object and find the vmdk path
            VcVmUtil.populateDiskInfo(newDisk, vNode.getVmMobId());
         }
      }
View Full Code Here


   public boolean scaleNodeResource(String nodeName, int cpuNumber, long memory) {
      logger.info("scale node: " + nodeName + ", cpu number: " + cpuNumber
            + ", memory: " + memory);
      NodeEntity node = clusterEntityMgr.findNodeByName(nodeName);

      DiskEntity swapDisk = findSwapDisk(node);
      VcDatastore targetDs = null;
      long newSwapSizeInMB = 0;
      if (memory > 0) {
         newSwapSizeInMB =
               (((long) Math.ceil(memory * node.getNodeGroup().getSwapRatio()) + 1023) / 1024) * 1024;
 
View Full Code Here

                  swapDisk, newSwapSizeInMB);
      return VcVmUtil.runSPOnSingleVM(node, scaleVMSP);
   }

   public DiskEntity findSwapDisk(NodeEntity node) {
      DiskEntity swapDisk = null;
      Set<DiskEntity> diskEntities = node.getDisks();
      for (DiskEntity diskEntity : diskEntities) {
         if (diskEntity.getDiskType().equals(DiskType.SWAP_DISK.getType())) {
            swapDisk = diskEntity;
            break;
View Full Code Here

    */
   @Override
   public void updateSwapDisk(String nodeName) {
      logger.info("update swap disk meta data for node: " + nodeName);
      NodeEntity node = clusterEntityMgr.findNodeByName(nodeName);
      DiskEntity swapDisk = findSwapDisk(node);
      VcVmUtil.populateDiskInfo(swapDisk, node.getMoId());
   }
View Full Code Here

      IClusterEntityManager entityMgr = Mockito.mock(IClusterEntityManager.class);

      // mock getDisks
      List<DiskEntity> disks = new ArrayList<DiskEntity>();
      for (int i = 0; i < 3; i++) {
         DiskEntity disk = new DiskEntity(DATA_DISK_NAME_PREFIX + i);
         disk.setVmdkPath(LOCAL_DS_MOID_PREFIX + i + "/" + disk.getName());
         disk.setDatastoreName(LOCAL_DS_NAME_PREFIX + i);
         disk.setDatastoreMoId(LOCAL_DS_MOID_PREFIX + i);
         disk.setSizeInMB(20 * 1024);
         disk.setDiskType(DiskType.SYSTEM_DISK.type);
         disks.add(disk);
      }
      Mockito.when(entityMgr.getDisks("bj-worker-1")).thenReturn(disks);

      // mock findByName(String, String, String)
View Full Code Here

   public static void setUp() throws Exception {
      scaleService = new ScaleService();
     
      // mock getDisks
      Set<DiskEntity> disks = new HashSet<DiskEntity>();
      DiskEntity swapDisk =  new DiskEntity(SWAP_DISK_NAME);
      swapDisk.setVmdkPath(DS1_NAME + "/" + NODE_NAME + "/" + SWAP_DISK_NAME);
      swapDisk.setDatastoreName(DS1_NAME);
      swapDisk.setDatastoreMoId(DS1_MOID);
      swapDisk.setSizeInMB(2 * 1024);
      swapDisk.setDiskType("SWAP");
     
      DiskEntity dataDisk =  new DiskEntity(DATA_DISK_NAME);
      dataDisk.setVmdkPath(DS2_NAME + "/" + NODE_NAME + "/" + DATA_DISK_NAME);
      dataDisk.setDatastoreName(DS2_NAME);
      dataDisk.setDatastoreMoId(DS2_MOID);
      dataDisk.setSizeInMB(20 * 1024);
      dataDisk.setDiskType("DATA");
     
      disks.add(swapDisk);
      disks.add(dataDisk);
     
      nodeEntity = Mockito.mock(NodeEntity.class);
View Full Code Here

   }
  
   @Test(groups = { "TestScaleService" })
   public void testFindSwapDisk() {
      logger.info("test findSwapDisk");
      DiskEntity swapDisk = scaleService.findSwapDisk(nodeEntity);
      Assert.assertTrue("swap disk should be " + SWAP_DISK_NAME, swapDisk.getName() == SWAP_DISK_NAME);
   }
View Full Code Here

   }
  
   @Test(groups = { "TestScaleService" }, dependsOnMethods = { "testFindSwapDisk" })
   public void testGetTargetDsForSwapDisk() {
      logger.info("test getTargetDsForSwapDisk");
      DiskEntity swapDisk = scaleService.findSwapDisk(nodeEntity);
     
      nodeEntity.getNodeGroup();
      VcDatastore ds = scaleService.getTargetDsForSwapDisk(nodeEntity, swapDisk, 3 * 1024);
      Assert.assertTrue("should select the original DS: " + DS1_NAME, ds.getName() == DS1_NAME);
     
View Full Code Here

      System.out.println(volumes);
   }

   @Test
   public void testGetVolumesByDiskEntities() {
      DiskEntity sysDisk = new DiskEntity();
      sysDisk.setName("sys.vmdk");
      sysDisk.setExternalAddress("LSI0:0");
      sysDisk.setDiskType("OS");
      DiskEntity swapDisk = new DiskEntity();
      swapDisk.setName("swap.vmdk");
      swapDisk.setExternalAddress("LSI0:1");
      swapDisk.setDiskType("SWAP");
      DiskEntity dataDisk0 = new DiskEntity();
      dataDisk0.setName("data0.vmdk");
      dataDisk0.setExternalAddress("PARA0:0");
      dataDisk0.setDiskType("DATA");
      DiskEntity dataDisk1 = new DiskEntity();
      dataDisk1.setName("data1.vmdk");
      dataDisk1.setExternalAddress("PARA1:0");
      dataDisk1.setDiskType("DATA");
      Set<DiskEntity> disks = new HashSet<DiskEntity>();
      disks.add(sysDisk);
      disks.add(swapDisk);
      disks.add(dataDisk0);
      disks.add(dataDisk1);
View Full Code Here

TOP

Related Classes of com.vmware.bdd.entity.DiskEntity

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.