Examples of VirtualMachineManager


Examples of com.cloud.vm.VirtualMachineManager

    StateMachine2<Volume.State, Volume.Event, Volume> _stateMachine = Volume.State.getStateMachine();
   
    ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
    VolumeDao volDao = locator.getDao(VolumeDao.class);
    VMInstanceDao vmDao = locator.getDao(VMInstanceDao.class);
    VirtualMachineManager vmMgr = locator.getManager(VirtualMachineManager.class);
    Long vmInstanceId = null;
    boolean success = true;
    Transaction txn = Transaction.open(Transaction.CLOUD_DB);

    try {
      txn.start();
      for (Long volumeId : _volumesIds) {
        VolumeVO volume = volDao.findById(volumeId);
        if (volume == null) {
          continue;
        }
        vmInstanceId = volume.getInstanceId();
        if (_migrateState == StorageMigrationState.MIGRATING && volume.getState() == Volume.State.Migrating) {
          try {
            _stateMachine.transitTo(volume, Volume.Event.OperationFailed, null, volDao);
          } catch (NoTransitionException e) {
            s_logger.debug("Failed to transit volume state: " + e.toString());
            success = false;
            break;
          }
        }
      }
      if (vmInstanceId != null) {
        VMInstanceVO vm = vmDao.findById(vmInstanceId);
        if (vm != null && vm.getState() == VirtualMachine.State.Migrating) {
          try {
            vmMgr.stateTransitTo(vm, VirtualMachine.Event.AgentReportStopped, null);
          } catch (NoTransitionException e) {
            s_logger.debug("Failed to transit vm state");
            success = false;
          }
        }
View Full Code Here

Examples of com.cybozu.vmbkp.soap.VirtualMachineManager

    public static void createSnapshot()
        throws Exception
    {
        String snapName = "snapshot-test";
       
        VirtualMachineManager vmm = gm_.searchVmWithName(vmName_);
        assert vmm != null;
        vmm.createSnapshot(snapName);

        SnapshotManager spm = vmm.searchSnapshotWithName(snapName);
        System.out.printf("-----disk list of %s of %s-----\n",
                          spm.getName(), spm.getVirtualMachine().getName());
        Utility.printList(spm.getConfig().getAllDiskNameList());

        System.out.printf("-----vmdkinfo list-----\n");
View Full Code Here

Examples of com.cybozu.vmbkp.soap.VirtualMachineManager

     */
    public static void deleteSnapshot()
        throws Exception
    {
        String snapName = "snapshot-test";
        VirtualMachineManager vmm = gm_.searchVmWithName(vmName_);
        assert vmm != null;
        vmm.deleteSnapshot(snapName);
    }
View Full Code Here

Examples of com.cybozu.vmbkp.soap.VirtualMachineManager

     * Ovf export of a virtual machine.
     */
    public static void exportOvf(String vmName)
        throws Exception
    {
        VirtualMachineManager vmm = gm_.searchVmWithName(vmName);
        if (vmm != null) {
            String ret = vmm.exportOvf();
            FileWriter fw = new FileWriter("ovf/" + vmm.getName() + ".ovf2");
            fw.write(ret);
            fw.close();
               
            VmbkpOvf ovf = new VmbkpOvf(ret);
            ovf.replaceFileLinkInReferences();
            String ret2 = ovf.toString();
            FileWriter fw2 = new FileWriter("ovf/" + vmm.getName() + ".ovf3");
            fw2.write(ret2);
            fw2.close();
        }
    }
View Full Code Here

Examples of com.cybozu.vmbkp.soap.VirtualMachineManager

    public static void deleteAllRestoredVm(int num)
        throws Exception
    {
        for (int i = 0; i < num; ++ i) {
            String vmName = "ovftest-" + String.valueOf(i);
            VirtualMachineManager vmm = gm_.searchVmWithName(vmName);
            if (vmm != null) {
                System.out.printf("destroy %s...", vmName);
                boolean ret = gm_.destroyVm(vmm);
                if (ret) {
                    System.out.printf("success\n");
View Full Code Here

Examples of com.cybozu.vmbkp.soap.VirtualMachineManager

        BackupInfo backupInfo = new BackupInfo(cmdLine_);
       
        for (String vmMoref: targetVmMorefList_) {
           
            /* Target virtual machine */
            VirtualMachineManager vmm = gm_.searchVmWithMoref(vmMoref);
            VmInfo vmInfo = vmm.getVmInfo();
            VmArchiveManager vmArcMgr =
                new VmArchiveManager(cfgGlobal_, vmInfo);

            boolean ret = false;
            try {
View Full Code Here

Examples of com.cybozu.vmbkp.soap.VirtualMachineManager

            throw new Exception(msg);
        }

        for (String targetVmMoref: targetVmMorefList_) {

            VirtualMachineManager vmm = gm_.searchVmWithMoref(targetVmMoref);
            VmInfo info = vmm.getVmInfo();
            if (gm_.destroyVm(vmm)) {
                System.out.printf
                    ("Destroy %s(%s) succeeded.\n",
                     info.getName(), info.getMoref());
            } else {
View Full Code Here

Examples of com.cybozu.vmbkp.soap.VirtualMachineManager

        assert (morefOfNewVm != null);
        msg = "import succeeded.";
        System.out.println(msg); logger_.info(msg);

        /* 6. Add contorollers and empty disks. */
        VirtualMachineManager vmm = gm_.searchVmWithMoref(morefOfNewVm);
        if (vmm == null) {
            throw new Exception("Could not find newly created vm.");
        }
        vmm.addEmptyDisks(vcmList);
        vmm.reload(); /* reload to get information of added disks
                         for the next step. */
        {
            int numDisks = 0;
            for (VirtualControllerManager vcm : vcmList) {
                numDisks += vcm.getNumOfDisks();
            }
            msg = String.format("add empty %d disks succeeded.", numDisks);
        }
        System.out.println(msg); logger_.info(msg);

        /* 7. Get VmdkInfo list for remote disk path of
              the newly created vmdk files,
              and get the corresponding diskId to restore.
              Then call vmdkbkp command to restore each vmdk file. */
        if (restoreInfo.isNoVmdk) {
            msg = String.format
                ("Disks are not restored because specified --novmdk option.");
            System.out.println(msg); logger_.info(msg);
           
        } else {
            /* Create snapshot and get moref of the snapshot. */
            Calendar cal = Calendar.getInstance();
            String snapName = generateSnapshotName(cal);
            createSnapshot(vmm, snapName);
            msg = String.format
                ("create snapshot name %s succeeded.", snapName);
            System.out.println(msg); logger_.info(msg);
               
            SnapshotManager snap = vmm.getCurrentSnapshot();
            if (snap == null || snapName.equals(snap.getName()) == false) {
                throw new Exception("Could not get snapshot.");
            }
            String snapMoref = snap.getMoref();
           
View Full Code Here

Examples of com.sun.jdi.VirtualMachineManager

        throw new IllegalStateException(e);
      }
    }

    private AttachingConnector getConnector() {
      VirtualMachineManager vmManager = Bootstrap
          .virtualMachineManager();
      for (AttachingConnector connector : vmManager
          .attachingConnectors()) {
        if ("com.sun.jdi.SocketAttach".equals(connector
            .name())) {
          return (AttachingConnector) connector;
        }
View Full Code Here

Examples of com.sun.jdi.VirtualMachineManager

    // either host,port will be set, or name
    private void connect(String host, String port, String name) throws Exception {
        // connect to JVM
        boolean useSocket = (port != null);

        VirtualMachineManager manager = Bootstrap.virtualMachineManager();
        List<AttachingConnector> connectors = manager.attachingConnectors();
        AttachingConnector connector = null;
//      System.err.println("Connectors available");
        for (int i = 0; i < connectors.size(); i++) {
            AttachingConnector tmp = connectors.get(i);
//          System.err.println("conn "+i+"  name="+tmp.name()+" transport="+tmp.transport().name()+
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.