- vm0.start();
- vm0.setLoad(90);
-
- String[] args = new String[3];
-
- args[0] = "vm0";
- args[1] = "host1";
- args[2] = "host2";
- new Process(host1, "Migrate-" + new Random().nextDouble(), args) {
- public void main(String[] args) {
- Host destHost = null;
- Host sourceHost = null;
-
- try {
- sourceHost = Host.getByName(args[1]);
- destHost = Host.getByName(args[2]);
- } catch (Exception e) {
- e.printStackTrace();
- System.err.println("You are trying to migrate from/to a non existing node");
- }
- if (destHost != null) {
- if (sourceHost.isOn() && destHost.isOn()) {
-
- try {
- Msg.info("Migrate vm "+args[0]+" to node "+destHost.getName());
- VM.getVMByName(args[0]).migrate(destHost);
- } catch (HostFailureException e) {
- e.printStackTrace();
- Msg.info("Something occurs during the migration that cannot validate the operation");
- }
- }
- }
-
- }
- }.start();
-
- // Wait killAt ms before killing thehost
- Process.sleep(killAt);
- hostToKill.off();
- Process.sleep(5);
- Msg.info("The migration process should be stopped and we should catch an exception\n");
- Process.sleep(5);
-
- Process.sleep(50000);
- Msg.info("Destroy VMs");
- vm0.shutdown();
- vm0.destroy();
- Process.sleep(20000);
- }
-
-
- public static void test_vm_shutdown_destroy () throws HostFailureException {
-
- Msg.info("**** **** **** ***** ***** Test shutdown /destroy a VM ***** ***** **** **** ****");
- Msg.info("Turn on host1, assign a VM on host1, launch a process inside the VM, and turn off the vm, " +
- "destroy it and check whether you can reallocate the same VM");
-
-
- // Create VM0
- int dpRate = 70;
- XVM vm0 = null;
- vm0 = new XVM(
- host1,
- "vm0",
- 1, // Nb of vcpu
- 2048, // Ramsize,
- 125, // Net Bandwidth
- null, //VM disk image
- -1, //size of disk image,
- 125, // Net bandwidth,
- dpRate // Memory intensity
+ vm0.start();
+ vm0.setLoad(90);
+
+ String[] args = new String[3];
+
+ args[0] = "vm0";
+ args[1] = "PM1";
+ args[2] = "PM2";
+ new Process(host1, "Migrate-" + killAt, args) {
+ public void main(String[] args) {
+ Host destHost = null;
+ Host sourceHost = null;
+
+ try {
+ sourceHost = Host.getByName(args[1]);
+ destHost = Host.getByName(args[2]);
+ } catch (HostNotFoundException e) {
+ Msg.error("You are trying to migrate from/to a non existing node: " + e.getMessage());
+ e.printStackTrace();
+ }
+ if (destHost != null && sourceHost.isOn() && destHost.isOn()) {
+ try {
+ Msg.info("Migrate vm "+args[0]+" to node "+destHost.getName());
+ VM.getVMByName(args[0]).migrate(destHost);
+ } catch (HostFailureException e) {
+ Msg.error("Something occurs during the migration that cannot validate the operation: " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+ }
+ }.start();
+
+ // Wait killAt ms before killing thehost
+ Process.sleep(killAt);
+ Msg.info("The migration process should be stopped and we should catch an exception");
+ hostToKill.off();
+
+ Process.sleep(50000);
+ Msg.info("Destroy VMs");
+ vm0.shutdown();
+ Process.sleep(20000);
+ }
+
+ public void testVMShutdownDestroy () throws HostFailureException {
+ Msg.info("**** **** **** ***** ***** Test shutdown a VM ***** ***** **** **** ****");
+ Msg.info("Turn on host1, assign a VM on host1, launch a process inside the VM, and turn off the vm, " +
+ "and check whether you can reallocate the same VM");
+
+ // Create VM0
+ int dpRate = 70;
+ XVM vm0 = new XVM(host1, "vm0",
+ 1, // Nb of vcpu
+ 2048, // Ramsize,
+ 125, // Net Bandwidth
+ null, //VM disk image
+ -1, //size of disk image,
+ 125, // Net bandwidth,
+ dpRate // Memory intensity