1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Migrate VMWare VMs working.

Debug optional in IM VMWare drivers.

git-svn-id: http://svn.opennebula.org/one/trunk@688 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
Constantino Vázquez Blanco 2009-07-14 15:56:02 +00:00
parent 70e55ccb94
commit 0618de54e4
4 changed files with 55 additions and 126 deletions

View File

@ -30,10 +30,15 @@ class OneImVmware extends Thread
private String[] arguments;
boolean debug;
// Entry point - main procedure
public static void main(String[] args)
{
boolean debug_flag;
// first, make redirection
PrintStream stdout = System.out;
@ -41,13 +46,25 @@ class OneImVmware extends Thread
System.setOut(stderr);
System.setErr(stdout);
OneImVmware oiv = new OneImVmware(args);
if (System.getProperty("debug").equals("1"))
{
debug_flag=true;
}
else
{
debug_flag=false;
}
OneImVmware oiv = new OneImVmware(args,debug_flag);
oiv.loop();
}
// Constructor
OneImVmware(String[] args)
OneImVmware(String[] args,boolean _debug)
{
debug = _debug;
arguments = args;
}
@ -192,7 +209,10 @@ class OneImVmware extends Thread
catch(Exception e)
{
System.out.println("Failed monitoring host " + hostToMonitor);
e.printStackTrace();
if(debug)
{
e.printStackTrace();
}
System.err.println("MONITOR FAILURE " + hid_str + " Failed monitoring host " +
hostToMonitor + ". Please check the VM log.");

View File

@ -47,9 +47,9 @@ fi
# Execute the actual MAD
if [ -n "${ONE_MAD_DEBUG}" ]; then
exec nice -n $PRIORITY java -cp $ONE_LOCATION/lib/mads:$CLASSPATH -Ddatastore=$VMWARE_DATASTORE -Ddatacenter=$VMWARE_DATACENTER -Djavax.net.ssl.trustStore=$VMWARE_TRUSTORE -Xmx1024M $MAD_FILE $* 2>> $MAD_LOG_PATH
exec nice -n $PRIORITY java -cp $ONE_LOCATION/lib/mads:$CLASSPATH -Ddebug=$ONE_MAD_DEBUG -Ddatastore=$VMWARE_DATASTORE -Ddatacenter=$VMWARE_DATACENTER -Djavax.net.ssl.trustStore=$VMWARE_TRUSTORE -Xmx1024M $MAD_FILE $* 2>> $MAD_LOG_PATH
else
exec nice -n $PRIORITY java -cp $ONE_LOCATION/lib/mads:$CLASSPATH -Ddatastore=$VMWARE_DATASTORE -Ddatacenter=$VMWARE_DATACENTER -Djavax.net.ssl.trustStore=$VMWARE_TRUSTORE -Xmx1024M $MAD_FILE $* 2> /dev/null
exec nice -n $PRIORITY java -cp $ONE_LOCATION/lib/mads:$CLASSPATH -Ddebug=$ONE_MAD_DEBUG -Ddatastore=$VMWARE_DATASTORE -Ddatacenter=$VMWARE_DATACENTER -Djavax.net.ssl.trustStore=$VMWARE_TRUSTORE -Xmx1024M $MAD_FILE $* 2> /dev/null
fi

View File

@ -27,7 +27,8 @@ class OneVmmVmware extends Thread
{
private String[] arguments;
OperationsOverVM oVM;
DeployVM dVM;
boolean debug;
// Helpers from VI samples
@ -147,7 +148,7 @@ class OneVmmVmware extends Thread
ParseXML pXML = new ParseXML(fileName);
// First, register the VM
DeployVM dVM = new DeployVM(arguments,
dVM = new DeployVM(arguments,
hostName,
vid_str,
pXML,
@ -334,6 +335,17 @@ class OneVmmVmware extends Thread
System.err.println(action + " FAILURE " + vid_str + " Failed suspending VM in host " +
hostName);
}
continue;
}
if(!oVM.deregisterVM(vmName))
{
synchronized (System.err)
{
System.err.println(action + " FAILURE " + vid_str + " Failed deregistering of " +vmName
+ " in host " + hostName +".");
}
continue;
}
else
{
@ -422,6 +434,17 @@ class OneVmmVmware extends Thread
try
{
oVM = new OperationsOverVM(arguments,hostName);
dVM = new DeployVM(arguments,
hostName,
vmName,
System.getProperty("datastore"),
System.getProperty("datacenter"));
if(!dVM.registerVirtualMachine())
{
// We will skip this error, it may be pre-registered
}
}
catch(Exception e)
{
@ -476,125 +499,11 @@ class OneVmmVmware extends Thread
if (action.equals("MIGRATE"))
{
if (str_split.length < 4)
synchronized (System.err)
{
System.out.println("FAILURE Wrong number of arguments for MIGRATE " +
"action. Number args = [" + str_split.length + "].");
synchronized (System.err)
{
System.err.println(action + " FAILURE " + vid_str);
continue;
}
}
else
{
vid_str = str_split[1];
String sourceHostName = str_split[2];
String vmName = str_split[3];
String destHostName = str_split[4];
// First, create the checkpoint
try
{
oVM = new OperationsOverVM(arguments,sourceHostName);
}
catch(Exception e)
{
synchronized (System.err)
{
System.err.println(action + " FAILURE " + vid_str + " Failed connection to host " +
sourceHostName +". Reason: " + e.getMessage());
if(debug)
{
e.printStackTrace();
}
}
continue;
}
// First, checkpoint the running virtual machine
if(!oVM.save(vmName))
{
synchronized (System.err)
{
System.err.println(action + " FAILURE " + vid_str + " Failed saving VM in host " +
sourceHostName);
continue;
}
}
// Now, we stop it
if(!oVM.powerOff(vmName))
{
synchronized (System.err)
{
System.err.println(action + " FAILURE " + vid_str + " Failed shutdown VM in host " +
sourceHostName);
}
}
// Now, register machine in new host
DeployVM dVM;
try
{
oVM = new OperationsOverVM(arguments,destHostName);
dVM = new DeployVM(arguments,
destHostName,
vmName,
System.getProperty("datastore"),
System.getProperty("datacenter"));
if(!dVM.registerVirtualMachine())
{
// We will skip this error, it may be pre-registered
}
// Power it On
if(!oVM.powerOn(vmName))
{
throw new Exception();
}
}
catch(Exception e)
{
synchronized (System.err)
{
System.err.println(action + " FAILURE " + vid_str + " Failed registering VM ["
+ vmName + "] in host " + destHostName);
if(debug)
{
e.printStackTrace();
}
}
continue;
}
// Restore the virtual machine checkpoint
if(!oVM.restoreCheckpoint(vmName))
{
synchronized (System.err)
{
System.err.println(action + " FAILURE " + vid_str + " Failed restoring VM [" +
vmName + "] in host " + destHostName);
}
}
else
{
synchronized (System.err)
{
System.err.println(action + " SUCCESS " + vid_str);
}
}
System.err.println(action + " FAILURE " + vid_str + " Action not implemented.");
continue;
}
}
} // if (action.equals("MIGRATE"))
if (action.equals("POLL"))

View File

@ -183,7 +183,7 @@ public class OperationsOverVM
}
catch(Exception e)
{
System.out.println("Error checkpointing VirtualMachine [" + vmName + "]. Reason:" + e.getMessage());
System.out.println("Error checkpointing VirtualMachine " + vmName + ". Reason:" + e.getMessage());
return false;
}
}
@ -245,7 +245,7 @@ public class OperationsOverVM
}
catch(Exception e)
{
System.out.println("Error checkpointing VirtualMachine [" + vmName + "]. Reason:" + e.getMessage());
System.out.println("Error restoring checkpoint of VirtualMachine " + vmName + ". Reason:" + e.getMessage());
return false;
}
}