Package com.vmware.aurora.vc

Examples of com.vmware.aurora.vc.VcCluster


         public Void body() throws Exception {
            for (VcCluster cluster : VcInventory.getClusters()) {
               System.out.println(cluster);
               for (VcResourcePool rp : cluster.getQualifiedRPs()) {
                  System.out.println(rp);
                  VcCluster c = rp.getVcCluster();
                  AuAssert.check(c.getId().equals(cluster.getId()));
               }
               if (exceptions < numExceptions) {
                  exceptions++;
                  throw new MyException(exceptions, "bad code");
               }
View Full Code Here


   private int receivedEventCount;

   @Test
   public void testEventListener() throws Exception {
      List<VcCluster> clusters = VcInventory.getClusters();
      VcCluster cluster;         // Will pick the first cluster.
      VcEventListener eventListener = VcContext.getEventListener();

      receivedEventCount = 0;
      /* GeneralUser is a "fake" event not triggered by any cms vc task. */
      VcEventListener.installExtEventHandler(VcEventType.GeneralUser, this);

      if (clusters != null && (cluster = clusters.get(0)) != null) {
         int eventCount = 1;     // Take it easy - can't delete individual events from VC.
         AuAssert.check(eventListener != null);

         for (int i = 0; i < eventCount; i++ ) {
            System.out.println("Posting GeneralUserEvent to cluster: " + cluster.getName());
            eventListener.postGeneralUserEvent(cluster, "FakeGeneralUserEvent", "" +
                  "CMS -> VC GeneralUserEvent", "Administrator");
         }
         System.out.println("Waiting for GeneralUserEvent");
         while (getReceivedEventCount() < eventCount) {
View Full Code Here

      });
   }

   public static VcCluster findVcCluster(final String clusterName) {
      logger.debug("find vc cluster: " + clusterName);
      VcCluster vcCluster = VcContext.inVcSessionDo(new VcSession<VcCluster>() {
         @Override
         protected VcCluster body() throws Exception {
            List<VcCluster> vcClusters = VcInventory.getClusters();
            for (VcCluster vcCluster : vcClusters) {
               if (clusterName.equals(vcCluster.getName())) {
                  return vcCluster;
               }
            }
            return null;
         }
View Full Code Here

      List<NodeGroupCreate> nodeGroups = null;
      int resourcePoolNameCount = 0;
      int nodeGroupNameCount = 0;
      for (BaseNode baseNode : vNodes) {
         String vcCluster = baseNode.getTargetVcCluster();
         VcCluster cluster = VcResourceUtils.findVcCluster(vcCluster);
         if (!cluster.getConfig().getDRSEnabled()) {
            logger.debug("DRS disabled for cluster " + vcCluster
                  + ", do not create child rp for this cluster.");
            continue;
         }
         AuAssert.check(!CommonUtil.isBlank(vcCluster),
View Full Code Here

         Callable<Void>[] clusterSPs = new Callable[resourcePoolNameCount];
         int i = 0;
         for (Entry<String, List<String>> vcClusterRpNamesEntry : vcClusterRpNamesMap
               .entrySet()) {
            String vcClusterName = vcClusterRpNamesEntry.getKey();
            VcCluster vcCluster = VcResourceUtils.findVcCluster(vcClusterName);
            if (vcCluster == null) {
               String errorMsg =
                     "Cannot find the vCenter Server cluster " + vcClusterName
                           + ".";
               logger.error(errorMsg);
               throw ClusteringServiceException
                     .CANNOT_FIND_VC_CLUSTER(vcClusterName);
            }
            List<String> resourcePoolNames = vcClusterRpNamesEntry.getValue();
            for (String resourcePoolName : resourcePoolNames) {
               VcResourcePool parentVcResourcePool =
                     VcResourceUtils.findRPInVCCluster(vcClusterName,
                           resourcePoolName);
               if (parentVcResourcePool == null) {
                  String errorMsg =
                        "Cannot find the vCenter Server resource pool "
                              + resourcePoolName + ".";
                  logger.error(errorMsg);
                  throw ClusteringServiceException
                        .CANNOT_FIND_VC_RESOURCE_POOL(resourcePoolName);
               }
               CreateResourcePoolSP clusterSP =
                     new CreateResourcePoolSP(parentVcResourcePool,
                           clusterRpName);
               clusterSPs[i] = clusterSP;
               i++;
            }
         }

         // execute store procedures to create cluster resource pool(s)
         logger.info("ClusteringService, start to create cluster resource pool(s).");
         executeResourcePoolStoreProcedures(clusterSPs, "cluster", clusterName);

         /*
          * define node group store procedures of resource pool(s)
          */
         int nodeGroupNameCount = countResult.get("nodeGroupNameCount");
         Callable<Void>[] nodeGroupSPs = new Callable[nodeGroupNameCount];
         i = 0;
         for (Entry<String, List<String>> vcClusterRpNamesEntry : vcClusterRpNamesMap
               .entrySet()) {
            String vcClusterName = vcClusterRpNamesEntry.getKey();
            VcCluster vcCluster = VcResourceUtils.findVcCluster(vcClusterName);
            if (vcCluster == null) {
               String errorMsg =
                     "Cannot find the vCenter Server cluster " + vcClusterName
                           + ".";
               logger.error(errorMsg);
               throw ClusteringServiceException
                     .CANNOT_FIND_VC_CLUSTER(vcClusterName);
            }
            if (!vcCluster.getConfig().getDRSEnabled()) {
               continue;
            }
            List<String> resourcePoolNames = vcClusterRpNamesEntry.getValue();
            for (String resourcePoolName : resourcePoolNames) {
               VcResourcePool parentVcResourcePool = null;
View Full Code Here

   private VcResourcePool getVcResourcePool(BaseNode vNode,
         final String clusterRpName) {
      try {
         String vcRPName = "";
         VcCluster cluster =
               VcResourceUtils.findVcCluster(vNode.getTargetVcCluster());
         if (!cluster.getConfig().getDRSEnabled()) {
            logger.debug("DRS disabled for cluster "
                  + vNode.getTargetVcCluster()
                  + ", put VM under cluster directly.");
            return cluster.getRootRP();
         }
         if (CommonUtil.isBlank(vNode.getTargetRp())) {
            vcRPName = clusterRpName + "/" + vNode.getNodeGroup().getName();
         } else {
            vcRPName =
View Full Code Here

   }

   @Mock
   public static VcCluster findVcCluster(final String clusterName) {
      if (flag) {
         VcCluster vcCluster = Mockito.mock(VcCluster.class);
         VcClusterConfig config = Mockito.mock(VcClusterConfig.class);
         Mockito.when(vcCluster.getConfig()).thenReturn(config);
         Mockito.when(config.getDRSEnabled()).thenReturn(true);
         return vcCluster;
      } else {
         return null;
      }
View Full Code Here

            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);
View Full Code Here

       * disks are to be added, not modified. However, it appears that changing
       * disk mode to independent_persistent is not supported in vSphere 5.1.
       * That means we can no longer mark the OS and BIN disks to independent_persistent
       * so that they are not snapshoted
       */
      VcCluster cluster = rp.getVcCluster();

      HashMap<VcHost, Integer> hostCount = new HashMap<VcHost, Integer>();

      int numDisks = 0;
      for (DiskSchema.Disk disk : diskSchema.getDisks()) {
         if (disk.vmdkPath != null && !disk.vmdkPath.isEmpty()) {
            // existed virtual disk, no need to create, need to attach.
            continue;
         }
         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 {
View Full Code Here

@MockClass(realClass = VcInventory.class)
public class MockVcInventory {
   @Mock
   static public List<VcCluster> getClusters() {
      VcCluster cluster1 = Mockito.mock(VcCluster.class);
      VcDatastore ds1 = Mockito.mock(VcDatastore.class);
      Mockito.when(ds1.getName()).thenReturn("test_1");
      List<VcDatastore> dsList1 = new ArrayList<VcDatastore>();
      dsList1.add(ds1);
      Mockito.when(cluster1.getAllDatastores()).thenReturn(dsList1);
      List<VcCluster> clusters = new ArrayList<VcCluster>();
      clusters.add(cluster1);
      Mockito.when(cluster1.getDatastore("test_1")).thenReturn(ds1);
     
      List<VcNetwork> nets = new ArrayList<VcNetwork>();
      VcNetwork net1 = Mockito.mock(VcNetwork.class);
      Mockito.when(net1.getName()).thenReturn("port1");
      nets.add(net1);
      Mockito.when(cluster1.getAllNetworks()).thenReturn(nets);

      Mockito.when(cluster1.getName()).thenReturn("cluster1");
      List<VcHost> hosts = new ArrayList<VcHost>();
      VcHost host1 = Mockito.mock(VcHost.class);
      hosts.add(host1);
      try {
         Mockito.when(cluster1.getHosts()).thenReturn(hosts);

         VcResourcePool rp1 = Mockito.mock(VcResourcePool.class);
         Mockito.when(cluster1.searchRP("[cluster1]/rp1")).thenReturn(rp1);
         VcResourcePool clusterRP = Mockito.mock(VcResourcePool.class);
         Mockito.when(cluster1.searchRP("[cluster1]")).thenReturn(clusterRP);
        
         List<VcVirtualMachine> vms = new ArrayList<VcVirtualMachine>();
         VcVirtualMachine vm = Mockito.mock(VcVirtualMachine.class);
         vms.add(vm);
         Mockito.when(rp1.getChildVMs()).thenReturn(vms);
View Full Code Here

TOP

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

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.