Examples of VcVirtualMachine


Examples of com.vmware.aurora.vc.VcVirtualMachine

   public static void setUp() throws Exception {
      service = new ClusteringService();
      service.setResMgr(new MockResourceManager());

      // mock a VcVm
      VcVirtualMachine vm = Mockito.mock(VcVirtualMachine.class);
      Mockito.when(vm.getName()).thenReturn("template-vm");
      Mockito.when(vm.getDatacenter()).thenReturn(
            Mockito.mock(VcDatacenter.class));

      // set vcVm field
      Field field = service.getClass().getDeclaredField("templateVm");
      field.setAccessible(true);
View Full Code Here

Examples of com.vmware.aurora.vc.VcVirtualMachine

      }
   }

   private HashMap<String, Disk.Operation> createVm() throws Exception {
      // Find the template and template snapshot to clone from
      final VcVirtualMachine template =
            VcCache.get(vmSchema.diskSchema.getParent());
      VcSnapshot snap =
            template.getSnapshotByName(vmSchema.diskSchema.getParentSnap());
      if (snap == null) {
         // this is a blocking call
         snap = template.createSnapshot(vmSchema.diskSchema.getParentSnap(),
               "Serengeti template Root Snapshot");
      }
      ConfigSpecImpl configSpec = new ConfigSpecImpl();

      // Resource schema
      ResourceSchemaUtil.setResourceSchema(configSpec, vmSchema.resourceSchema);

      // Add managed-by information
      // VmConfigUtil.addManagedByToConfigSpec(
      //      newConfigSpec, VcContext.getService().getExtensionKey(), "dbvm");

      HashMap<String, Disk.Operation> diskMap =
            new HashMap<String, Disk.Operation>();
      if (requireClone()) {
         VcVirtualMachine.CreateSpec vmSpec =
               new VcVirtualMachine.CreateSpec(newVmName, snap, targetRp,
                     targetDs, vmFolder, host, linkedClone, configSpec);
         // Clone from the template
         vcVm = template.cloneVm(vmSpec, null);
      } else {
         // copy parent vm's version/product info/vapp options
         copyParentVmSettings(template, configSpec);

         vcVm = targetRp.createVm(configSpec, targetDs, vmFolder);
View Full Code Here

Examples of com.vmware.aurora.vc.VcVirtualMachine

            return true;
         }

         @Override
         protected Void body() throws Exception {
            VcVirtualMachine vm = VcCache.get("null:VirtualMachine:vm-97169");

            InputStreamReader reader = new InputStreamReader(System.in);
            char[] cbuf = new char[10];
            int num = reader.read(cbuf);
            while (num != -1) {
               Map<String, String> variables = vm.getGuestVariables();
               System.out.println("All guest variables.");
               for (String key : variables.keySet()) {
                  System.out.println("key:" + key + ", value:" + variables.get(key));
               }
            }
View Full Code Here

Examples of com.vmware.aurora.vc.VcVirtualMachine

   private void checkVcFolders(final String folderName) {
      String rootFolderName = ConfigInfo.getSerengetiRootFolder();
      String serverMobId =
            Configuration.getString(Constants.SERENGETI_SERVER_VM_MOBID);
      VcVirtualMachine serverVm = VcCache.get(serverMobId);
      List<String> folderList = new ArrayList<String>(1);
      folderList.add(rootFolderName);
      Folder rootFolder =
            VcResourceUtils.findFolderByNameList(serverVm.getDatacenter(),
                  folderList);
      Folder childFolder =
            VcResourceUtils.findFolderByName(rootFolder, folderName);
      Assert.assertNotNull(childFolder, "Folder " + folderName
            + " is not exist.");
View Full Code Here

Examples of com.vmware.aurora.vc.VcVirtualMachine

         }
      }
   }

   private boolean stopVcVm(final String rpPath, final String vmName) {
      final VcVirtualMachine vm =
            VcResourceUtils.findVmInVcCluster(vcCluster, rpPath, vmName);
      if (vm == null) {
         return false;
      }
      boolean stopped = VcContext.inVcSessionDo(new VcSession<Boolean>() {
         @Override
         protected boolean isTaskSession() {
            return true;
         }

         @Override
         protected Boolean body() throws Exception {
            if (vm != null && vm.isPoweredOn()) {
               vm.powerOff();
               logger.info("power off vm: " + vm.getName()
                     + " to make cluster creation failed.");
               return true;
            } else {
               return false;
            }
View Full Code Here

Examples of com.vmware.aurora.vc.VcVirtualMachine

   private void assertFolderRemoved(String folderName) throws Exception {
      String rootFolderName = ConfigInfo.getSerengetiRootFolder();
      String serverMobId =
            Configuration.getString(Constants.SERENGETI_SERVER_VM_MOBID);
      VcVirtualMachine serverVm = VcCache.get(serverMobId);
      List<String> folderList = new ArrayList<String>(1);
      folderList.add(rootFolderName);
      Folder rootFolder =
            VcResourceUtils.findFolderByNameList(serverVm.getDatacenter(),
                  folderList);
      Folder childFolder =
            VcResourceUtils.findFolderByName(rootFolder, folderName);
      Assert.assertNull(childFolder, "Folder " + folderName
            + " is not removed.");
View Full Code Here

Examples of com.vmware.aurora.vc.VcVirtualMachine

      Assert.assertNotNull(rp);
   }

   @Test
   public void testFindVmInVcCluster() {
      VcVirtualMachine vm = VcResourceUtils.findVmInVcCluster("cluster1", "rp1", "vm2");
      Assert.assertNull(vm);
      vm = VcResourceUtils.findVmInVcCluster("cluster1", "rp1", "vm1");
      Assert.assertNotNull(vm);
   }
View Full Code Here

Examples of com.vmware.aurora.vc.VcVirtualMachine

         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);
         Mockito.when(vm.getName()).thenReturn("vm1");
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
      return clusters;
   }
View Full Code Here

Examples of com.vmware.aurora.vc.VcVirtualMachine

   }

   private void initRootFolder() {
      String serverMobId =
            Configuration.getString(Constants.SERENGETI_SERVER_VM_MOBID);
      VcVirtualMachine serverVm = VcCache.get(serverMobId);
      String root = ConfigInfo.getSerengetiRootFolder();
      List<String> folderNames = new ArrayList<String>();
      folderNames.add(root);
      this.rootSerengetiFolder =
            VcResourceUtils.findFolderByNameList(serverVm.getDatacenter(),
                  folderNames);
      if (rootSerengetiFolder == null) {
         logger.info("VM root folder" + root
               + " is not created yet. Ignore external VM event.");
      }
View Full Code Here

Examples of com.vmware.aurora.vc.VcVirtualMachine

         throws Exception {
      if (clusterEntityMgr.getNodeByMobId(moId) != null) {
         return true;
      }
      if (type != VcEventType.VmRemoved) {
         VcVirtualMachine vm = VcCache.getIgnoreMissing(e.getVm().getVm());
         if (vm == null) {
            return false;
         }
         logger.debug("Event received for VM not managed by Serengeti");
         if (rootSerengetiFolder == null) {
            initRootFolder();
         }
         if (rootSerengetiFolder == null) {
            return false;
         }
         if (clusterEntityMgr.getNodeByVmName(vm.getName()) != null
               && VcResourceUtils.insidedRootFolder(rootSerengetiFolder, vm)) {
            logger.info("VM " + vm.getName()
                  + " is Serengeti created VM, add it into meta-db");
            return true;
         }
      }
      return false;
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.