Examples of Vm


Examples of com.xensource.xenapi.VM

            s_vms.put(_cluster, _name, vmName, State.Stopping);
        }

        try {
            Set<VM> vms = VM.getByNameLabel(connection, vmSpec.getName());
            VM vmToMigrate = vms.iterator().next();
            Map<String, String> other = new HashMap<String, String>();
            other.put("live", "true");

            // Create the vdi map which tells what volumes of the vm need to go on which sr on the destination.
            Map<VDI, SR> vdiMap = new HashMap<VDI, SR>();
            for (Map.Entry<VolumeTO, Object> entry : volumeToSr.entrySet()) {
                if  (entry.getValue() instanceof SR) {
                    SR sr = (SR)entry.getValue();
                    VDI vdi = getVDIbyUuid(connection, entry.getKey().getPath());
                    vdiMap.put(vdi, sr);
                } else {
                    throw new CloudRuntimeException("The object " + entry.getValue() + " passed is not of type SR.");
                }
            }

            // Create the vif map.
            Map<VIF, Network> vifMap = new HashMap<VIF, Network>();
            for (Map.Entry<NicTO, Object> entry : nicToNetwork.entrySet()) {
                if (entry.getValue() instanceof Network) {
                    Network network = (Network)entry.getValue();
                    VIF vif = getVifByMac(connection, vmToMigrate, entry.getKey().getMac());
                    vifMap.put(vif, network);
                } else {
                    throw new CloudRuntimeException("The object " + entry.getValue() + " passed is not of type Network.");
                }
            }

            // Check migration with storage is possible.
            task = vmToMigrate.assertCanMigrateAsync(connection, token, true, vdiMap, vifMap, other);
            try {
                // poll every 1 seconds.
                long timeout = (_migratewait) * 1000L;
                waitForTask(connection, task, 1000, timeout);
                checkForSuccess(connection, task);
            } catch (Types.HandleInvalid e) {
                s_logger.error("Error while checking if vm " + vmName + " can be migrated.", e);
                throw new CloudRuntimeException("Error while checking if vm " + vmName + " can be migrated.", e);
            }

            // Migrate now.
            task = vmToMigrate.migrateSendAsync(connection, token, true, vdiMap, vifMap, other);
            try {
                // poll every 1 seconds.
                long timeout = (_migratewait) * 1000L;
                waitForTask(connection, task, 1000, timeout);
                checkForSuccess(connection, task);
View Full Code Here

Examples of com.xensource.xenapi.VM

        VirtualMachineTO vmSpec = cmd.getVirtualMachine();

        try {
            Host host = Host.getByUuid(connection, _host.uuid);
            Set<VM> vms = VM.getByNameLabel(connection, vmSpec.getName());
            VM migratedVm = vms.iterator().next();

            // Check the vm is present on the new host.
            if (migratedVm == null) {
                throw new CloudRuntimeException("Couldn't find the migrated vm " + vmSpec.getName() +
                        " on the destination host.");
            }

            // Volume paths would have changed. Return that information.
            List<VolumeObjectTO > volumeToSet = getUpdatedVolumePathsOfMigratedVm(connection, migratedVm, vmSpec.getDisks());
            migratedVm.setAffinity(connection, host);

            synchronized (_cluster.intern()) {
                s_vms.put(_cluster, _name, vmSpec.getName(), State.Running);
            }
View Full Code Here

Examples of net.sf.jabref.bst.VM


public class TestVM extends TestCase {

  public void testAbbrv() throws RecognitionException, IOException {
    VM vm = new VM(new File("src/tests/net/sf/jabref/bst/abbrv.bst"));
    Vector<BibtexEntry> v = new Vector<BibtexEntry>();
    v.add(t1BibtexEntry());
   
    String expected = "\\begin{thebibliography}{1}\\bibitem{canh05}K.~Crowston, H.~Annabi, J.~Howison, and C.~Masango.\\newblock Effective work practices for floss development: A model and  propositions.\\newblock In {\\em Hawaii International Conference On System Sciences (HICSS)}, 2005.\\end{thebibliography}";
   
    assertEquals(expected.replaceAll("\\s", ""), vm.run(v).replaceAll("\\s", ""));
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    assertEquals(expected.replaceAll("\\s", ""), vm.run(v).replaceAll("\\s", ""));
  }

  public void testVMSimple() throws RecognitionException, IOException {

    VM vm = new VM("" + "ENTRY  { " + "  address " + "  author " + "  title " + "  type "
      + "}  {}  { label }" + "INTEGERS { output.state before.all"
      + " mid.sentence after.sentence after.block }"
      + "FUNCTION {init.state.consts}{ #0 'before.all := "
      + " #1 'mid.sentence :=  #2 'after.sentence :=  #3 'after.block := } "
      + "STRINGS { s t } " + "READ");

    Vector<BibtexEntry> v = new Vector<BibtexEntry>();
    v.add(t1BibtexEntry());

    vm.run(v);

    assertEquals(2, vm.getStrings().size());
    assertEquals(7, vm.getIntegers().size());
    assertEquals(1, vm.getEntries().size());
    assertEquals(5, (vm.getEntries().get(0)).getFields().size());
    assertEquals(38, vm.getFunctions().size());

  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

  }

  public void testLabel() throws RecognitionException, IOException {

    VM vm = new VM("" + "ENTRY  { title }  {}  { label } "
      + "FUNCTION { test } { label #0 = title 'label := #5 label #6 pop$ } " + "READ "
      + "ITERATE { test }");

    Vector<BibtexEntry> v = new Vector<BibtexEntry>();
    v.add(t1BibtexEntry());

    vm.run(v);

    assertEquals("Effective work practices for floss development: A model and propositions", vm
      .getStack().pop());

  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

  }

  public void testQuote() throws RecognitionException, IOException {

    VM vm = new VM("FUNCTION {a}{ quote$ quote$ * } EXECUTE {a}");

    Vector<BibtexEntry> v = new Vector<BibtexEntry>();
    vm.run(v);

    assertEquals("\"\"", vm.getStack().pop());
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    assertEquals("\"\"", vm.getStack().pop());
  }

  public void testVMFunction1() throws RecognitionException, IOException {

    VM vm = new VM("FUNCTION {init.state.consts}{ #0 'before.all := } ");

    Vector<BibtexEntry> v = new Vector<BibtexEntry>();
    vm.run(v);

    assertEquals(38, vm.getFunctions().size());

    assertTrue(vm.getFunctions().get("init.state.consts") instanceof StackFunction);

    StackFunction fun = (StackFunction) vm.getFunctions().get("init.state.consts");
    assertEquals(3, fun.getTree().getChildCount());
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

  }

  public void testVMExecuteSimple() throws RecognitionException, IOException {

    {
      VM vm = new VM("" + "INTEGERS { variable.a } "
        + "FUNCTION {init.state.consts}{ #5 'variable.a := } "
        + "EXECUTE {init.state.consts}");

      Vector<BibtexEntry> v = new Vector<BibtexEntry>();
      vm.run(v);
      assertEquals(new Integer(5), vm.getIntegers().get("variable.a"));
    }
    {
      VM vm = new VM("FUNCTION {a}{ #5 #5 = " + "#1 #2 = " + "#3 #4 < " + "#4 #3 < "
        + "#4 #4 < " + "#3 #4 > " + "#4 #3 > " + "#4 #4 > " + "\"H\" \"H\" = "
        + "\"H\" \"Ha\" = } " + "EXECUTE {a}");

      Vector<BibtexEntry> v = new Vector<BibtexEntry>();
      vm.run(v);

      assertEquals(VM.FALSE, vm.getStack().pop());
      assertEquals(VM.TRUE, vm.getStack().pop());
      assertEquals(VM.FALSE, vm.getStack().pop());
      assertEquals(VM.TRUE, vm.getStack().pop());
      assertEquals(VM.FALSE, vm.getStack().pop());
      assertEquals(VM.FALSE, vm.getStack().pop());
      assertEquals(VM.FALSE, vm.getStack().pop());
      assertEquals(VM.TRUE, vm.getStack().pop());
      assertEquals(VM.FALSE, vm.getStack().pop());
      assertEquals(VM.TRUE, vm.getStack().pop());
      assertEquals(0, vm.getStack().size());
    }
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

      assertEquals(0, vm.getStack().size());
    }
  }

  public void testVMIfSkipPop() throws RecognitionException, IOException {
    VM vm = new VM("FUNCTION {not}  {   { #0 }      { #1 }  if$  }"
      + "FUNCTION {and}  {   'skip$      { pop$ #0 }    if$  }"
      + "FUNCTION {or}  {   { pop$ #1 }      'skip$    if$  }" + "FUNCTION {test} { "
      + "#1 #1 and #0 #1 and #1 #0 and #0 #0 and " + "#0 not #1 not "
      + "#1 #1 or #0 #1 or #1 #0 or #0 #0 or }" + "EXECUTE {test}");

    Vector<BibtexEntry> v = new Vector<BibtexEntry>();
    vm.run(v);
    assertEquals(VM.FALSE, vm.getStack().pop());
    assertEquals(VM.TRUE, vm.getStack().pop());
    assertEquals(VM.TRUE, vm.getStack().pop());
    assertEquals(VM.TRUE, vm.getStack().pop());
    assertEquals(VM.FALSE, vm.getStack().pop());
    assertEquals(VM.TRUE, vm.getStack().pop());
    assertEquals(VM.FALSE, vm.getStack().pop());
    assertEquals(VM.FALSE, vm.getStack().pop());
    assertEquals(VM.FALSE, vm.getStack().pop());
    assertEquals(VM.TRUE, vm.getStack().pop());
    assertEquals(0, vm.getStack().size());
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    assertEquals(0, vm.getStack().size());
  }

  public void testVMArithmetic() throws RecognitionException, IOException {
    {
      VM vm = new VM("FUNCTION {test} { " + "#1 #1 + #5 #2 - }" + "EXECUTE {test}");

      Vector<BibtexEntry> v = new Vector<BibtexEntry>();
      vm.run(v);
      assertEquals(new Integer(3), vm.getStack().pop());
      assertEquals(new Integer(2), vm.getStack().pop());
      assertEquals(0, vm.getStack().size());
    }
    {
      VM vm = new VM("FUNCTION {test} { " + "#1 \"HELLO\" + #5 #2 - }" + "EXECUTE {test}");

      Vector<BibtexEntry> v = new Vector<BibtexEntry>();

      try {
        vm.run(v);
        fail();
      } catch (VMException e) {

      }
    }
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.