Examples of VcDatastore


Examples of com.vmware.aurora.vc.VcDatastore

            datastore = disk.getTargetDs();
         }
      }
      AuAssert.check(datastore != null);

      VcDatastore ds = VcResourceUtils.findDSInVcByName(datastore);
      if (ds != null) {
         return ds;
      }
      logger.error("target data store " + datastore + " is not found.");
      throw ClusteringServiceException.TARGET_VC_DATASTORE_NOT_FOUND(datastore);
View Full Code Here

Examples of com.vmware.aurora.vc.VcDatastore

            });
      return result;
   }

   public static VcDatastore findDSInVcByName(String dsName) {
      VcDatastore ds = null;
      for (VcCluster cluster : VcInventory.getClusters()) {
         ds = cluster.getDatastore(dsName);
         if (ds != null) {
            return ds;
         }
View Full Code Here

Examples of com.vmware.aurora.vc.VcDatastore

      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;
         logger.info("new swap disk size(MB): " + newSwapSizeInMB);
View Full Code Here

Examples of com.vmware.aurora.vc.VcDatastore

                  .getName());
      NodeGroupCreate ngSpec =
            clusterSpec.getNodeGroup(node.getNodeGroup().getName());

      // use current DS if it has enough space
      VcDatastore currentDs =
            VcResourceUtils.findDSInVcByName(swapDisk.getDatastoreName());
      if (!currentDs.isAccessible()) {
         throw ScaleServiceException.CURRENT_DATASTORE_UNACCESSIBLE(currentDs
               .getName());
      }
      if ((int) (currentDs.getFreeSpace() >> 20) > newSwapSizeInMB
            - swapDisk.getSizeInMB()) {
         return currentDs;
      }

      // else find a valid datastore with largest free space
      VcHost locateHost = VcResourceUtils.findHost(node.getHostName());

      // swap disk should use image store pattern
      String[] dsNamePatterns =
            NodeGroupCreate.getImagestoreNamePattern(clusterSpec, ngSpec);
      VcDatastore targetDs = null;
      for (VcDatastore ds : locateHost.getDatastores()) {
         if (!ds.isAccessible()) {
            continue;
         }
         for (String pattern : dsNamePatterns) {
            if (ds.getName().matches(pattern)) {
               if (targetDs == null
                     || targetDs.getFreeSpace() < ds.getFreeSpace()) {
                  targetDs = ds;
               }
               break;
            }
         }
      }

      if (targetDs != null
            && (int) (targetDs.getFreeSpace() >> 20) > newSwapSizeInMB) {
         return targetDs;
      }

      logger.warn("cannot find a proper datastore to scale up swap disk of vm: "
            + node.getVmName());
View Full Code Here

Examples of com.vmware.aurora.vc.VcDatastore

      return prePowerOn;
   }

   private static VcDatastore getVcDatastore(BaseNode vNode) {
      VcDatastore ds = VcResourceUtils.findDSInVcByName(vNode.getTargetDs());
      if (ds != null) {
         return ds;
      }
      logger.error("target data store " + vNode.getTargetDs()
            + " is not found.");
View Full Code Here

Examples of com.vmware.aurora.vc.VcDatastore

   public static class MockVcResourceUtilsForHeal {
      @Mock
      public static VcHost findHost(final String hostName) {
         List<VcDatastore> datastores = new ArrayList<VcDatastore>(4);
         for (int i = 0; i < 4; i++) {
            VcDatastore ds = Mockito.mock(VcDatastore.class);
            if (i == 0) {
               Mockito.when(ds.isAccessible()).thenReturn(false);
            } else {
               Mockito.when(ds.isAccessible()).thenReturn(true);
            }
            // 100 GB available for each datastore
            Mockito.when(ds.getFreeSpace()).thenReturn(
                  100 * 1024 * 1024 * 1024L);
            Mockito.when(ds.getName()).thenReturn(LOCAL_DS_NAME_PREFIX + i);
            datastores.add(ds);
         }
         VcHost host = Mockito.mock(VcHost.class);
         Mockito.when(host.getDatastores()).thenReturn(datastores);

View Full Code Here

Examples of com.vmware.aurora.vc.VcDatastore

   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);
     
      ds = scaleService.getTargetDsForSwapDisk(nodeEntity, swapDisk, 6 * 1024);
      Assert.assertTrue("should select DS: " + DS3_NAME, ds.getName() == DS3_NAME);
     
      ds = scaleService.getTargetDsForSwapDisk(nodeEntity, swapDisk, 20 * 1024);
      Assert.assertEquals(ds, null);
     
   }
View Full Code Here

Examples of com.vmware.aurora.vc.VcDatastore

  
   @MockClass(realClass = VcResourceUtils.class)
   public static class MockVcResourceUtilsForScale {
      @Mock
      public static VcDatastore findDSInVcByName(final String dsName) {
         VcDatastore ds = Mockito.mock(VcDatastore.class);
         Mockito.when(ds.isAccessible()).thenReturn(true);
         Mockito.when(ds.getFreeSpace()).thenReturn(4 * 1024 * 1024 * 1024L);
         Mockito.when(ds.getName()).thenReturn(dsName);
         return ds;
      }
View Full Code Here

Examples of com.vmware.aurora.vc.VcDatastore

     
      @Mock
      public static VcHost findHost(final String hostName) {
         List<VcDatastore> datastores = new ArrayList<VcDatastore>(2);
        
         VcDatastore ds1 = Mockito.mock(VcDatastore.class);
         Mockito.when(ds1.isAccessible()).thenReturn(true);
         Mockito.when(ds1.getName()).thenReturn(DS1_NAME);
         Mockito.when(ds1.getFreeSpace()).thenReturn((long) (4 * 1024 * 1024 * 1024L));
        
         VcDatastore ds2 = Mockito.mock(VcDatastore.class);
         Mockito.when(ds2.isAccessible()).thenReturn(true);
         Mockito.when(ds2.getName()).thenReturn(DS2_NAME);
         Mockito.when(ds2.getFreeSpace()).thenReturn((long) (8 * 1024 * 1024 * 1024L));
        
         VcDatastore ds3 = Mockito.mock(VcDatastore.class);
         Mockito.when(ds3.isAccessible()).thenReturn(true);
         Mockito.when(ds3.getName()).thenReturn(DS3_NAME);
         Mockito.when(ds3.getFreeSpace()).thenReturn((long) (10 * 1024 * 1024 * 1024L));
        
         datastores.add(ds1);
         datastores.add(ds2);
         datastores.add(ds3);
        
View Full Code Here

Examples of com.vmware.aurora.vc.VcDatastore

         if (DiskType.OS.getTypeName().equals(disk.type)) {
            // system disk is either be cloned or attached, it will never be added.
            continue;
         }
         numDisks++;
         VcDatastore diskDs = null;
         if (!disk.datastore.equals("")) {
            // Find the right datastore from the list of cluster datastores
            diskDs = cluster.getDatastore(disk.datastore);
            AuAssert.check(diskDs != null);
            for (VcHost h : diskDs.getHosts()) {
               if (hostCount.containsKey(h)) {
                  hostCount.put(h, hostCount.get(h) + 1);
               } else {
                  hostCount.put(h, 1);
               }
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.