Package com.vmware.aurora.vc

Examples of com.vmware.aurora.vc.VcVirtualMachine


               return true;
            }

            @Override
            protected Void body() throws Exception {
               VcVirtualMachine vm = VcCache.get(vmId);
               VcSnapshot snap = vm.getSnapshotByName(snapName);
               snap.remove();
               return null;
            }
         });
         return null;
View Full Code Here


      return null;
   }

   private void executeOnce() throws Exception {
      AuAssert.check(vmId != null);
      final VcVirtualMachine vcVm = VcCache.getIgnoreMissing(vmId);
      if (vcVm == null) {
         logger.info("vm: " + vmId + " is not found.");
         return;
      }
      if (vcVm.isPoweredOn()) {
         logger.info("vm " + vcVm.getName() + " is already powered on.");
         executePostPowerOn(vcVm);
         return;
      }

      // scale up/down its memory will replace its swap disk, in this case, we still
      // need to add volumes info into machine id to re-mount this new swap disk.
      executePrePowerOn(vcVm);
      VcContext.inVcSessionDo(new VcSession<Void>() {
         @Override
         protected Void body() throws Exception {
            vcVm.powerOn(host);
            return null;
         }

         protected boolean isTaskSession() {
            return true;
View Full Code Here

               return true;
            }

            @Override
            protected Void body() throws Exception {
               VcVirtualMachine vm = VcCache.get(vmId);
               vm.destroy();
               return null;
            }
         });
         return null;
      }
View Full Code Here

public class TestSnapshot extends AbstractTmTest {
   private VcSnapshot snapshot;

   @Test
   public void takeSnapshot() throws Exception {
      VcVirtualMachine vm = util.testImportVM(vmName, rp).getResult();
      CreateSnapshotSP sp = new CreateSnapshotSP(vm, "name", "TestSnpshot");
      sp.call();
      snapshot = sp.getResult();
   }
View Full Code Here

               return true;
            }

            @Override
            public Void body() throws Exception {
               VcVirtualMachine vm = VcCache.getIgnoreMissing(moid);
               if (vm == null) {
                  logger.error("failed to get vm: " + moid);
                  return null;
               }
               VcVmUtil.inspectNicInfoWithoutSession(vm, pgName, nicEntity);
View Full Code Here

         vNode.setNodeAction(Constants.NODE_ACTION_CLONING_FAILED);
         vNode.setErrMessage(CommonUtil.getCurrentTimestamp() + " "
               + vNode.getNodeAction());
         return false;
      }
      VcVirtualMachine vm = VcCache.getIgnoreMissing(vmId);
      if (vm == null) {
         logger.info("vm " + vmId + " is created, and then removed afterwards.");
         vNode.setNodeAction(Constants.NODE_ACTION_CLONING_FAILED);
         vNode.setErrMessage(CommonUtil.getCurrentTimestamp() + " "
               + vNode.getNodeAction());
         return false;
      }
      boolean success = true;
      for (String portGroup : vNode.getNics().keySet()) {
         String ipv4Address =
               VcVmUtil.getIpAddressOfPortGroup(vm, portGroup, false);

         // currently only care  ipv4 address
         vNode.updateNicOfPortGroup(portGroup, ipv4Address, null, null);
      }
      if (vNode.ipsReadyV4()) {
         vNode.setSuccess(true);
         vNode.setGuestHostName(VcVmUtil.getGuestHostName(vm, false));
         vNode.setTargetHost(vm.getHost().getName());
         vNode.setVmMobId(vm.getId());
         if (vm.isPoweredOn()) {
            vNode.setNodeStatus(NodeStatus.VM_READY);
            vNode.setNodeAction(null);
         } else {
            vNode.setNodeStatus(NodeStatus.POWERED_OFF);
            vNode.setNodeAction(Constants.NODE_ACTION_CREATION_FAILED);
            vNode.setErrMessage(CommonUtil.getCurrentTimestamp() + " "
                  + vNode.getNodeAction());
         }
      } else {
         vNode.setSuccess(false);
         // in static ip case, vNode contains the allocated address,
         // here reset the value in case the ip is unavailable from vc
         vNode.resetIpsV4();
         if (vm != null) {
            vNode.setVmMobId(vm.getId());
            if (vm.isPoweredOn()) {
               vNode.setNodeStatus(NodeStatus.POWERED_ON);
               vNode.setNodeAction(Constants.NODE_ACTION_GET_IP_FAILED);
               vNode.setErrMessage(CommonUtil.getCurrentTimestamp() + " "
                     + vNode.getNodeAction());
            } else {
               vNode.setNodeStatus(NodeStatus.POWERED_OFF);
               vNode.setNodeAction(Constants.NODE_ACTION_CREATION_FAILED);
               vNode.setErrMessage(CommonUtil.getCurrentTimestamp() + " "
                     + vNode.getNodeAction());
            }
         }
         success = false;
         logger.error("Failed to get ip address of VM " + vNode.getVmName());
      }
      if (success) {
         String haFlag = vNode.getNodeGroup().getHaFlag();
         if (haFlag != null
               && Constants.HA_FLAG_FT.equals(haFlag.toLowerCase())
               && !verifyFTState(vm)) {
            // FT is enabled and ft status is incorrect
            logger.error("Failed to power on FT secondary VM for node "
                  + vm.getName() + ", " + "FT state " + vm.getFTState()
                  + " is unexpected.");
            vNode.setNodeAction(Constants.NODE_ACTION_WRONG_FT_STATUS);
            vNode.setErrMessage(CommonUtil.getCurrentTimestamp() + " "
                  + vNode.getNodeAction());
            return false;
View Full Code Here

      }
      return true;
   }

   public static VirtualDisk findVirtualDisk(String vmMobId, String externalAddr) {
      VcVirtualMachine vm = VcCache.getIgnoreMissing(vmMobId);

      DeviceId diskId = new DeviceId(externalAddr);
      VirtualDevice device = vm.getVirtualDevice(diskId);
      if (device == null)
         return null;

      AuAssert.check(device instanceof VirtualDisk);
      return (VirtualDisk) device;
View Full Code Here

         return true;
      return false;
   }

   public static void updateVm(String vmId) {
      final VcVirtualMachine vm = VcCache.getIgnoreMissing(vmId);
      try {
         VcContext.inVcSessionDo(new VcSession<Void>() {
            @Override
            protected boolean isTaskSession() {
               return true;
            }

            @Override
            protected Void body() throws Exception {
               vm.update();
               return null;
            }
         });
      } catch (Exception e) {
         logger.info("failed to update vm " + vm.getName()
               + ", ignore this error.");
      }
   }
View Full Code Here

      }
   }

   public static boolean configIOShares(final String vmId,
         final Priority ioShares) {
      final VcVirtualMachine vcVm = VcCache.getIgnoreMissing(vmId);

      if (vcVm == null) {
         logger.info("vm " + vmId + " is not found.");
         return false;
      }
      VcContext.inVcSessionDo(new VcSession<Void>() {
         @Override
         protected Void body() throws Exception {
            List<VirtualDeviceSpec> deviceSpecs =
                  new ArrayList<VirtualDeviceSpec>();
            for (DeviceId slot : vcVm.getVirtualDiskIds()) {
               SharesInfo shares = new SharesInfoImpl();
               shares.setLevel(Level.valueOf(ioShares.toString().toLowerCase()));
               IOAllocationInfo allocationInfo = new IOAllocationInfoImpl();
               allocationInfo.setShares(shares);
               VirtualDisk vmdk = (VirtualDisk) vcVm.getVirtualDevice(slot);
               vmdk.setStorageIOAllocation(allocationInfo);
               VirtualDeviceSpec spec = new VirtualDeviceSpecImpl();
               spec.setOperation(VirtualDeviceSpec.Operation.edit);
               spec.setDevice(vmdk);
               deviceSpecs.add(spec);
            }
            logger.info("reconfiguring disks in vm " + vmId
                  + " io share level to " + ioShares);
            vcVm.reconfigure(VmConfigUtil.createConfigSpec(deviceSpecs));
            logger.info("reconfigured disks in vm " + vmId
                  + " io share level to " + ioShares);
            return null;
         }
View Full Code Here

   public static boolean runSPOnSingleVM(NodeEntity node, Callable<Void> call) {
      if (node.getMoId() == null) {
         logger.info("VC vm does not exist for node: " + node.getVmName());
         return false;
      }
      VcVirtualMachine vcVm = VcCache.getIgnoreMissing(node.getMoId());
      if (vcVm == null) {
         // cannot find VM
         logger.info("VC vm does not exist for node: " + node.getVmName());
         return false;
      }
View Full Code Here

TOP

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

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.