cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [3/5] sdn hosted vpc gateways (using lswitch)
Date Wed, 18 Sep 2013 15:08:05 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2614b00c/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java b/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java
index 8f21c13..1eddedc 100755
--- a/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java
+++ b/plugins/hypervisors/ovm/src/com/cloud/ovm/hypervisor/OvmResourceBase.java
@@ -34,6 +34,8 @@ import org.apache.cloudstack.storage.to.VolumeObjectTO;
 import org.apache.log4j.Logger;
 import org.apache.xmlrpc.XmlRpcException;
 
+import com.trilead.ssh2.SCPClient;
+
 import com.cloud.agent.IAgentControl;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.AttachIsoCommand;
@@ -102,9 +104,9 @@ import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.agent.api.to.VolumeTO;
 import com.cloud.host.Host.Type;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.PhysicalNetworkSetupInfo;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.PhysicalNetworkSetupInfo;
 import com.cloud.ovm.object.Connection;
 import com.cloud.ovm.object.OvmBridge;
 import com.cloud.ovm.object.OvmDisk;
@@ -678,72 +680,72 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
                     }
                 }
             }
-			
-			state = State.Running;
-			return new StartAnswer(cmd);
-		} catch (Exception e ) {
-			s_logger.debug("Start vm " + vmName + " failed", e);
-			cleanup(vmDetails);
-			return new StartAnswer(cmd, e.getMessage());
-		} finally {
-			synchronized (_vms) {
-				//FIXME: where to come to Stopped???
-				if (state != State.Stopped) {
-					_vms.put(vmName, state);
-				} else {
-					_vms.remove(vmName);
-				}
-			}
-		}
-	}
-	
-	protected Answer execute(GetHostStatsCommand cmd) {
-		try {
-			Map<String, String> res = OvmHost.getPerformanceStats(_conn, _publicNetworkName);
-			Double cpuUtil = Double.parseDouble(res.get("cpuUtil"));
-			Double rxBytes = Double.parseDouble(res.get("rxBytes"));
-			Double txBytes = Double.parseDouble(res.get("txBytes"));
-			Double totalMemory = Double.parseDouble(res.get("totalMemory"));
-			Double freeMemory = Double.parseDouble(res.get("freeMemory"));
-			HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, rxBytes,
-					txBytes, "host", totalMemory, freeMemory, 0, 0);
-			return new GetHostStatsAnswer(cmd, hostStats);
-		} catch (Exception e) {
-			s_logger.debug("Get host stats of " + cmd.getHostName() + " failed", e);
-			return new Answer(cmd, false, e.getMessage());
-		}
-		
-	}
-	
-	@Override
-	public StopAnswer execute(StopCommand cmd) {
-		String vmName = cmd.getVmName();
-		State state = null;
-        synchronized(_vms) {
+
+            state = State.Running;
+            return new StartAnswer(cmd);
+        } catch (Exception e) {
+            s_logger.debug("Start vm " + vmName + " failed", e);
+            cleanup(vmDetails);
+            return new StartAnswer(cmd, e.getMessage());
+        } finally {
+            synchronized (_vms) {
+                //FIXME: where to come to Stopped???
+                if (state != State.Stopped) {
+                    _vms.put(vmName, state);
+                } else {
+                    _vms.remove(vmName);
+                }
+            }
+        }
+    }
+
+    protected Answer execute(GetHostStatsCommand cmd) {
+        try {
+            Map<String, String> res = OvmHost.getPerformanceStats(_conn, _publicNetworkName);
+            Double cpuUtil = Double.parseDouble(res.get("cpuUtil"));
+            Double rxBytes = Double.parseDouble(res.get("rxBytes"));
+            Double txBytes = Double.parseDouble(res.get("txBytes"));
+            Double totalMemory = Double.parseDouble(res.get("totalMemory"));
+            Double freeMemory = Double.parseDouble(res.get("freeMemory"));
+            HostStatsEntry hostStats = new HostStatsEntry(cmd.getHostId(), cpuUtil, rxBytes,
+                    txBytes, "host", totalMemory, freeMemory, 0, 0);
+            return new GetHostStatsAnswer(cmd, hostStats);
+        } catch (Exception e) {
+            s_logger.debug("Get host stats of " + cmd.getHostName() + " failed", e);
+            return new Answer(cmd, false, e.getMessage());
+        }
+
+    }
+
+    @Override
+    public StopAnswer execute(StopCommand cmd) {
+        String vmName = cmd.getVmName();
+        State state = null;
+        synchronized (_vms) {
             state = _vms.get(vmName);
             _vms.put(vmName, State.Stopping);
         }
-        
+
         try {
-        	OvmVm.Details vm = null;
-        	try {
-        		vm = OvmVm.getDetails(_conn, vmName);   
-        	} catch (XmlRpcException e) {
-        		s_logger.debug("Unable to get details of vm: " + vmName + ", treating it as stopped", e);
-        		return new StopAnswer(cmd, "success", 0, true);
-        	}
-        	
-        	deleteAllNetworkRulesForVm(vmName);    
-        	OvmVm.stop(_conn, vmName);
-        	cleanup(vm);
-        	
-        	state = State.Stopped;
-        	return new StopAnswer(cmd, "success", 0, true);
+            OvmVm.Details vm = null;
+            try {
+                vm = OvmVm.getDetails(_conn, vmName);
+            } catch (XmlRpcException e) {
+                s_logger.debug("Unable to get details of vm: " + vmName + ", treating it as stopped", e);
+                return new StopAnswer(cmd, "success", 0, true);
+            }
+
+            deleteAllNetworkRulesForVm(vmName);
+            OvmVm.stop(_conn, vmName);
+            cleanup(vm);
+
+            state = State.Stopped;
+            return new StopAnswer(cmd, "success", 0, true);
         } catch (Exception e) {
-        	s_logger.debug("Stop " + vmName + "failed", e);
-        	return new StopAnswer(cmd, e.getMessage(), false);
+            s_logger.debug("Stop " + vmName + "failed", e);
+            return new StopAnswer(cmd, e.getMessage(), false);
         } finally {
-        	synchronized(_vms) {
+            synchronized (_vms) {
                 if (state != null) {
                     _vms.put(vmName, state);
                 } else {
@@ -751,115 +753,115 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
                 }
             }
         }
-	}
-	
-	@Override
-	public RebootAnswer execute(RebootCommand cmd) {
-		String vmName = cmd.getVmName();
-		synchronized(_vms) {
-    		_vms.put(vmName, State.Starting);
-    	}
-		
-		try {
-			Map<String, String> res = OvmVm.reboot(_conn, vmName);
-			Integer vncPort = Integer.parseInt(res.get("vncPort"));
-			return new RebootAnswer(cmd, null, vncPort);
-		} catch (Exception e) {
-			s_logger.debug("Reboot " + vmName + " failed", e);
-			return new RebootAnswer(cmd, e.getMessage(), false);
-		} finally {
-    		synchronized(_vms) {
-    			_vms.put(cmd.getVmName(), State.Running);
-    		}
-		}
-	}
-	
-	private State toState(String vmName, String s) {
-		State state = _stateMaps.get(s);
-		if (state == null) {
-			s_logger.debug("Unkown state " + s + " for " + vmName);
-			state = State.Unknown;
-		}
-		return state;
-	}
-	
-	protected HashMap<String, State> getAllVms() throws XmlRpcException {
-		final HashMap<String, State> vmStates = new HashMap<String, State>();
-		Map<String, String> vms = OvmHost.getAllVms(_conn);
-		for (final Map.Entry<String, String> entry : vms.entrySet()) {
-        	State state = toState(entry.getKey(), entry.getValue());
-        	vmStates.put(entry.getKey(), state);
+    }
+
+    @Override
+    public RebootAnswer execute(RebootCommand cmd) {
+        String vmName = cmd.getVmName();
+        synchronized (_vms) {
+            _vms.put(vmName, State.Starting);
         }
-		return vmStates;
-	}
-	
-	protected HashMap<String, State> sync() {
+
+        try {
+            Map<String, String> res = OvmVm.reboot(_conn, vmName);
+            Integer vncPort = Integer.parseInt(res.get("vncPort"));
+            return new RebootAnswer(cmd, null, vncPort);
+        } catch (Exception e) {
+            s_logger.debug("Reboot " + vmName + " failed", e);
+            return new RebootAnswer(cmd, e.getMessage(), false);
+        } finally {
+            synchronized (_vms) {
+                _vms.put(cmd.getVmName(), State.Running);
+            }
+        }
+    }
+
+    private State toState(String vmName, String s) {
+        State state = _stateMaps.get(s);
+        if (state == null) {
+            s_logger.debug("Unkown state " + s + " for " + vmName);
+            state = State.Unknown;
+        }
+        return state;
+    }
+
+    protected HashMap<String, State> getAllVms() throws XmlRpcException {
+        final HashMap<String, State> vmStates = new HashMap<String, State>();
+        Map<String, String> vms = OvmHost.getAllVms(_conn);
+        for (final Map.Entry<String, String> entry : vms.entrySet()) {
+            State state = toState(entry.getKey(), entry.getValue());
+            vmStates.put(entry.getKey(), state);
+        }
+        return vmStates;
+    }
+
+    protected HashMap<String, State> sync() {
         HashMap<String, State> newStates;
         HashMap<String, State> oldStates = null;
-        
+
         try {
-			final HashMap<String, State> changes = new HashMap<String, State>();
-			newStates = getAllVms();
-			if (newStates == null) {
-				s_logger.debug("Unable to get the vm states so no state sync at this point.");
-				return null;
-			}
+            final HashMap<String, State> changes = new HashMap<String, State>();
+            newStates = getAllVms();
+            if (newStates == null) {
+                s_logger.debug("Unable to get the vm states so no state sync at this point.");
+                return null;
+            }
 
-			synchronized (_vms) {
-				oldStates = new HashMap<String, State>(_vms.size());
-				oldStates.putAll(_vms);
+            synchronized (_vms) {
+                oldStates = new HashMap<String, State>(_vms.size());
+                oldStates.putAll(_vms);
 
-				for (final Map.Entry<String, State> entry : newStates
-						.entrySet()) {
-					final String vm = entry.getKey();
+                for (final Map.Entry<String, State> entry : newStates
+                        .entrySet()) {
+                    final String vm = entry.getKey();
 
-					State newState = entry.getValue();
-					final State oldState = oldStates.remove(vm);
+                    State newState = entry.getValue();
+                    final State oldState = oldStates.remove(vm);
 
                     if (s_logger.isTraceEnabled()) {
                         s_logger.trace("VM " + vm + ": ovm has state " + newState + " and we have state " + (oldState != null ? oldState.toString() : "null"));
-					}
+                    }
 
-					/*
-					 * TODO: what is migrating ??? if
-					 * (vm.startsWith("migrating")) {
-					 * s_logger.debug("Migrating from xen detected.  Skipping");
-					 * continue; }
-					 */
-
-					if (oldState == null) {
-						_vms.put(vm, newState);
-						s_logger.debug("Detecting a new state but couldn't find a old state so adding it to the changes: "
-								+ vm);
-						changes.put(vm, newState);
-					} else if (oldState == State.Starting) {
-						if (newState == State.Running) {
-							_vms.put(vm, newState);
-						} else if (newState == State.Stopped) {
-							s_logger.debug("Ignoring vm " + vm
-									+ " because of a lag in starting the vm.");
-						}
-					} else if (oldState == State.Migrating) {
-						if (newState == State.Running) {
-							s_logger.debug("Detected that an migrating VM is now running: "
-									+ vm);
-							_vms.put(vm, newState);
-						}
-					} else if (oldState == State.Stopping) {
-						if (newState == State.Stopped) {
-							_vms.put(vm, newState);
-						} else if (newState == State.Running) {
-							s_logger.debug("Ignoring vm " + vm
-									+ " because of a lag in stopping the vm. ");
-						}
-					} else if (oldState != newState) {
-						_vms.put(vm, newState);
-						if (newState == State.Stopped) {
-							//TODO: need anything here?
-						}
-						changes.put(vm, newState);
-					}
-				}
+                    /*
+                     * TODO: what is migrating ??? if
+                     * (vm.startsWith("migrating")) {
+                     * s_logger.debug("Migrating from xen detected.  Skipping");
+                     * continue; }
+                     */
+
+                    if (oldState == null) {
+                        _vms.put(vm, newState);
+                        s_logger.debug("Detecting a new state but couldn't find a old state so adding it to the changes: "
+                                + vm);
+                        changes.put(vm, newState);
+                    } else if (oldState == State.Starting) {
+                        if (newState == State.Running) {
+                            _vms.put(vm, newState);
+                        } else if (newState == State.Stopped) {
+                            s_logger.debug("Ignoring vm " + vm
+                                    + " because of a lag in starting the vm.");
+                        }
+                    } else if (oldState == State.Migrating) {
+                        if (newState == State.Running) {
+                            s_logger.debug("Detected that an migrating VM is now running: "
+                                    + vm);
+                            _vms.put(vm, newState);
+                        }
+                    } else if (oldState == State.Stopping) {
+                        if (newState == State.Stopped) {
+                            _vms.put(vm, newState);
+                        } else if (newState == State.Running) {
+                            s_logger.debug("Ignoring vm " + vm
+                                    + " because of a lag in stopping the vm. ");
+                        }
+                    } else if (oldState != newState) {
+                        _vms.put(vm, newState);
+                        if (newState == State.Stopped) {
+                            //TODO: need anything here?
+                        }
+                        changes.put(vm, newState);
+                    }
+                }
 
                 for (final Map.Entry<String, State> entry : oldStates.entrySet()) {
                     final String vm = entry.getKey();
@@ -889,90 +891,90 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
 
             return changes;
         } catch (Exception e) {
-        	s_logger.debug("Ovm full sync failed", e);
-        	return null;
+            s_logger.debug("Ovm full sync failed", e);
+            return null;
         }
-	}
-	
-	protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
-		try {
-			OvmStoragePool.Details d = OvmStoragePool.getDetailsByUuid(_conn, cmd.getStorageId());
-			return new GetStorageStatsAnswer(cmd, d.totalSpace, d.usedSpace);
-		} catch (Exception e) {
-			s_logger.debug("GetStorageStatsCommand on pool " + cmd.getStorageId() + " failed", e);
-			return new GetStorageStatsAnswer(cmd, e.getMessage());
-		}
-	}
-	
-	private VmStatsEntry getVmStat(String vmName) throws XmlRpcException {
-		Map<String, String> vmStat = OvmVm.getVmStats(_conn, vmName);
-		int nvcpus = Integer.parseInt(vmStat.get("cpuNum"));
-		float cpuUtil = Float.parseFloat(vmStat.get("cpuUtil"));
-		long rxBytes = Long.parseLong(vmStat.get("rxBytes"));
-		long txBytes = Long.parseLong(vmStat.get("txBytes"));
-		Pair<Long, Long> oldNetworkStat = _vmNetworkStats.get(vmName);
-		
-		long rx = rxBytes;
-		long tx = txBytes;
-		if (oldNetworkStat != null) {
-			rx -= oldNetworkStat.first();
-			tx -= oldNetworkStat.second();
-			oldNetworkStat.set(rxBytes, txBytes);
-		} else {
-			oldNetworkStat = new Pair<Long, Long>(rx, tx);
-		}
-		_vmNetworkStats.put(vmName, oldNetworkStat);
-		
-		VmStatsEntry e = new VmStatsEntry();
-		e.setCPUUtilization(cpuUtil);
-		e.setNumCPUs(nvcpus);
-		e.setNetworkReadKBs(rx);
-		e.setNetworkWriteKBs(tx);
-		e.setEntityType("vm");
-		return e;
-	}
-	
-	protected GetVmStatsAnswer execute(GetVmStatsCommand cmd) {
-		List<String> vmNames = cmd.getVmNames();
-		HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>();
-		for (String vmName : vmNames) {
-			try {
-				VmStatsEntry e = getVmStat(vmName);
-				vmStatsNameMap.put(vmName, e);
-			} catch (XmlRpcException e) {
-				s_logger.debug("Get vm stat for " + vmName + " failed", e);
-				continue;
-			}	
-		}
-		return new GetVmStatsAnswer(cmd, vmStatsNameMap);
-	}
-	
-	protected AttachVolumeAnswer execute(AttachVolumeCommand cmd) {
-		return new AttachVolumeAnswer(cmd, "You must stop " + cmd.getVmName() + " first, OVM doesn't support hotplug datadisk");
-	}
-	
-	public Answer execute(DestroyCommand cmd) {
-		 try {
-			 OvmVolume.destroy(_conn, cmd.getVolume().getPoolUuid(), cmd.getVolume().getPath());
-			 return new Answer(cmd, true, "Success");
-		 } catch (Exception e) {
-			 s_logger.debug("Destroy volume " + cmd.getVolume().getName() + " failed", e);
-			 return new Answer(cmd, false, e.getMessage());
-		 }
-	}
-	
+    }
+
+    protected GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
+        try {
+            OvmStoragePool.Details d = OvmStoragePool.getDetailsByUuid(_conn, cmd.getStorageId());
+            return new GetStorageStatsAnswer(cmd, d.totalSpace, d.usedSpace);
+        } catch (Exception e) {
+            s_logger.debug("GetStorageStatsCommand on pool " + cmd.getStorageId() + " failed", e);
+            return new GetStorageStatsAnswer(cmd, e.getMessage());
+        }
+    }
+
+    private VmStatsEntry getVmStat(String vmName) throws XmlRpcException {
+        Map<String, String> vmStat = OvmVm.getVmStats(_conn, vmName);
+        int nvcpus = Integer.parseInt(vmStat.get("cpuNum"));
+        float cpuUtil = Float.parseFloat(vmStat.get("cpuUtil"));
+        long rxBytes = Long.parseLong(vmStat.get("rxBytes"));
+        long txBytes = Long.parseLong(vmStat.get("txBytes"));
+        Pair<Long, Long> oldNetworkStat = _vmNetworkStats.get(vmName);
+
+        long rx = rxBytes;
+        long tx = txBytes;
+        if (oldNetworkStat != null) {
+            rx -= oldNetworkStat.first();
+            tx -= oldNetworkStat.second();
+            oldNetworkStat.set(rxBytes, txBytes);
+        } else {
+            oldNetworkStat = new Pair<Long, Long>(rx, tx);
+        }
+        _vmNetworkStats.put(vmName, oldNetworkStat);
+
+        VmStatsEntry e = new VmStatsEntry();
+        e.setCPUUtilization(cpuUtil);
+        e.setNumCPUs(nvcpus);
+        e.setNetworkReadKBs(rx);
+        e.setNetworkWriteKBs(tx);
+        e.setEntityType("vm");
+        return e;
+    }
+
+    protected GetVmStatsAnswer execute(GetVmStatsCommand cmd) {
+        List<String> vmNames = cmd.getVmNames();
+        HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>();
+        for (String vmName : vmNames) {
+            try {
+                VmStatsEntry e = getVmStat(vmName);
+                vmStatsNameMap.put(vmName, e);
+            } catch (XmlRpcException e) {
+                s_logger.debug("Get vm stat for " + vmName + " failed", e);
+                continue;
+            }
+        }
+        return new GetVmStatsAnswer(cmd, vmStatsNameMap);
+    }
+
+    protected AttachVolumeAnswer execute(AttachVolumeCommand cmd) {
+        return new AttachVolumeAnswer(cmd, "You must stop " + cmd.getVmName() + " first, OVM doesn't support hotplug datadisk");
+    }
+
+    public Answer execute(DestroyCommand cmd) {
+        try {
+            OvmVolume.destroy(_conn, cmd.getVolume().getPoolUuid(), cmd.getVolume().getPath());
+            return new Answer(cmd, true, "Success");
+        } catch (Exception e) {
+            s_logger.debug("Destroy volume " + cmd.getVolume().getName() + " failed", e);
+            return new Answer(cmd, false, e.getMessage());
+        }
+    }
+
     protected PrepareForMigrationAnswer execute(PrepareForMigrationCommand cmd) {
         VirtualMachineTO vm = cmd.getVirtualMachine();
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Preparing host for migrating " + vm);
         }
-        
+
         NicTO[] nics = vm.getNics();
         try {
             for (NicTO nic : nics) {
                 getNetwork(nic);
             }
-            
+
             synchronized (_vms) {
                 _vms.put(vm.getName(), State.Migrating);
             }
@@ -982,20 +984,20 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
             return new PrepareForMigrationAnswer(cmd, e);
         }
     }
-    
+
     protected MigrateAnswer execute(final MigrateCommand cmd) {
         final String vmName = cmd.getVmName();
         State state = null;
-        
+
         synchronized (_vms) {
             state = _vms.get(vmName);
             _vms.put(vmName, State.Stopping);
         }
-        
+
         try {
-        	OvmVm.Details vm = OvmVm.getDetails(_conn, vmName);
-        	String destIp = cmd.getDestinationIp();
-        	OvmVm.migrate(_conn, vmName, destIp);
+            OvmVm.Details vm = OvmVm.getDetails(_conn, vmName);
+            String destIp = cmd.getDestinationIp();
+            OvmVm.migrate(_conn, vmName, destIp);
             state = State.Stopping;
             cleanup(vm);
             return new MigrateAnswer(cmd, true, "migration succeeded", null);
@@ -1009,125 +1011,127 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
             }
         }
     }
-    
+
     protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
         final String vmName = cmd.getVmName();
         try {
-        	Map<String, String> res = OvmVm.register(_conn, vmName);
-        	Integer vncPort = Integer.parseInt(res.get("vncPort"));
-        	HashMap<String, State> states = getAllVms();
-        	State vmState = states.get(vmName);
-        	if (vmState == null) {
-        		s_logger.warn("Check state of " + vmName + " return null in CheckVirtualMachineCommand");
-        		vmState = State.Stopped;
-        	}
-        	
+            Map<String, String> res = OvmVm.register(_conn, vmName);
+            Integer vncPort = Integer.parseInt(res.get("vncPort"));
+            HashMap<String, State> states = getAllVms();
+            State vmState = states.get(vmName);
+            if (vmState == null) {
+                s_logger.warn("Check state of " + vmName + " return null in CheckVirtualMachineCommand");
+                vmState = State.Stopped;
+            }
+
             if (vmState == State.Running) {
                 synchronized (_vms) {
                     _vms.put(vmName, State.Running);
                 }
             }
-                
+
             return new CheckVirtualMachineAnswer(cmd, vmState, vncPort);
         } catch (Exception e) {
-        	s_logger.debug("Check migration for " + vmName + " failed", e);
-        	 return new CheckVirtualMachineAnswer(cmd, State.Stopped, null);
+            s_logger.debug("Check migration for " + vmName + " failed", e);
+            return new CheckVirtualMachineAnswer(cmd, State.Stopped, null);
         }
     }
-    
-	protected MaintainAnswer execute(MaintainCommand cmd) {
-		return new MaintainAnswer(cmd);
-	}
-	
-	protected GetVncPortAnswer execute(GetVncPortCommand cmd) {
-		try {
-			Integer vncPort = OvmVm.getVncPort(_conn, cmd.getName());
-			return new GetVncPortAnswer(cmd, _ip, vncPort);
-		} catch (Exception e) {
-			s_logger.debug("get vnc port for " + cmd.getName() + " failed", e);
-			return new GetVncPortAnswer(cmd, e.getMessage());
-		}
-	}
-	
-	protected Answer execute(PingTestCommand cmd) {
-		try {
-			if (cmd.getComputingHostIp() != null) {
-				OvmHost.pingAnotherHost(_conn, cmd.getComputingHostIp());
-			} else {
-				return new Answer(cmd, false, "why asks me to ping router???");
-			}
-			
-			return new Answer(cmd, true, "success");
-		} catch (Exception e) {
-			s_logger.debug("Ping " + cmd.getComputingHostIp() + " failed", e);
-			return new Answer(cmd, false, e.getMessage());
-		}
-	}
-	
-	protected FenceAnswer execute(FenceCommand cmd) {
-		try {
-			Boolean res = OvmHost.fence(_conn, cmd.getHostIp());
-			return new FenceAnswer(cmd, res, res.toString());
-		} catch (Exception e) {
-			s_logger.debug("fence " + cmd.getHostIp() + " failed", e);
-			return new FenceAnswer(cmd, false, e.getMessage());
-		}
-	}
-	
-	protected Answer execute(AttachIsoCommand cmd) {
-		try {
-			URI iso = new URI(cmd.getIsoPath());
-			String isoPath = iso.getHost() + ":" + iso.getPath();
-			OvmVm.detachOrAttachIso(_conn, cmd.getVmName(), isoPath, cmd.isAttach());
-			return new Answer(cmd);
-		} catch (Exception e) {
-			s_logger.debug("Attach or detach ISO " + cmd.getIsoPath() + " for " + cmd.getVmName() + " attach:" + cmd.isAttach() + " failed", e);
-			return new Answer(cmd, false, e.getMessage());
-		}
-	}
-	
-	private Answer execute(SecurityGroupRulesCmd cmd) {
-        boolean result = false;        
+
+    protected MaintainAnswer execute(MaintainCommand cmd) {
+        return new MaintainAnswer(cmd);
+    }
+
+    protected GetVncPortAnswer execute(GetVncPortCommand cmd) {
+        try {
+            Integer vncPort = OvmVm.getVncPort(_conn, cmd.getName());
+            return new GetVncPortAnswer(cmd, _ip, vncPort);
+        } catch (Exception e) {
+            s_logger.debug("get vnc port for " + cmd.getName() + " failed", e);
+            return new GetVncPortAnswer(cmd, e.getMessage());
+        }
+    }
+
+    protected Answer execute(PingTestCommand cmd) {
+        try {
+            if (cmd.getComputingHostIp() != null) {
+                OvmHost.pingAnotherHost(_conn, cmd.getComputingHostIp());
+            } else {
+                return new Answer(cmd, false, "why asks me to ping router???");
+            }
+
+            return new Answer(cmd, true, "success");
+        } catch (Exception e) {
+            s_logger.debug("Ping " + cmd.getComputingHostIp() + " failed", e);
+            return new Answer(cmd, false, e.getMessage());
+        }
+    }
+
+    protected FenceAnswer execute(FenceCommand cmd) {
+        try {
+            Boolean res = OvmHost.fence(_conn, cmd.getHostIp());
+            return new FenceAnswer(cmd, res, res.toString());
+        } catch (Exception e) {
+            s_logger.debug("fence " + cmd.getHostIp() + " failed", e);
+            return new FenceAnswer(cmd, false, e.getMessage());
+        }
+    }
+
+    protected Answer execute(AttachIsoCommand cmd) {
         try {
-        	OvmVif.Details vif = getVifFromVm(cmd.getVmName(), null);
-    	    String vifDeviceName = vif.name;
+            URI iso = new URI(cmd.getIsoPath());
+            String isoPath = iso.getHost() + ":" + iso.getPath();
+            OvmVm.detachOrAttachIso(_conn, cmd.getVmName(), isoPath, cmd.isAttach());
+            return new Answer(cmd);
+        } catch (Exception e) {
+            s_logger.debug("Attach or detach ISO " + cmd.getIsoPath() + " for " + cmd.getVmName() + " attach:" + cmd.isAttach() + " failed", e);
+            return new Answer(cmd, false, e.getMessage());
+        }
+    }
+
+    private Answer execute(SecurityGroupRulesCmd cmd) {
+        boolean result = false;
+        try {
+            OvmVif.Details vif = getVifFromVm(cmd.getVmName(), null);
+            String vifDeviceName = vif.name;
             String bridgeName = vif.bridge;
-        	result = addNetworkRules(cmd.getVmName(), Long.toString(cmd.getVmId()), cmd.getGuestIp(), cmd.getSignature(), String.valueOf(cmd.getSeqNum()), cmd.getGuestMac(), cmd.stringifyRules(), vifDeviceName, bridgeName);
+            result = addNetworkRules(cmd.getVmName(), Long.toString(cmd.getVmId()), cmd.getGuestIp(), cmd.getSignature(), String.valueOf(cmd.getSeqNum()), cmd.getGuestMac(),
+                    cmd.stringifyRules(), vifDeviceName, bridgeName);
         } catch (XmlRpcException e) {
-        	s_logger.error(e);
-        	result = false;
+            s_logger.error(e);
+            result = false;
         }
 
         if (!result) {
             s_logger.warn("Failed to program network rules for vm " + cmd.getVmName());
             return new SecurityGroupRuleAnswer(cmd, false, "programming network rules failed");
         } else {
-            s_logger.info("Programmed network rules for vm " + cmd.getVmName() + " guestIp=" + cmd.getGuestIp() + ":ingress num rules=" + cmd.getIngressRuleSet().length + ":egress num rules=" + cmd.getEgressRuleSet().length);
+            s_logger.info("Programmed network rules for vm " + cmd.getVmName() + " guestIp=" + cmd.getGuestIp() + ":ingress num rules=" + cmd.getIngressRuleSet().length
+                    + ":egress num rules=" + cmd.getEgressRuleSet().length);
             return new SecurityGroupRuleAnswer(cmd);
-        }	    
-    }	
-	
-	private Answer execute(CleanupNetworkRulesCmd cmd) {		
-	    boolean result = false;
-	    try {
-	    	result =  cleanupNetworkRules();
-	    } catch (XmlRpcException e) {
-	    	s_logger.error(e);
-	    	result = false;
-	    }
-	    
-	    if (result) {
-	        return new Answer(cmd);
-	    } else {
-	        return new Answer(cmd, result, "Failed to cleanup network rules.");
-	    }
+        }
     }
-	
+
+    private Answer execute(CleanupNetworkRulesCmd cmd) {
+        boolean result = false;
+        try {
+            result = cleanupNetworkRules();
+        } catch (XmlRpcException e) {
+            s_logger.error(e);
+            result = false;
+        }
+
+        if (result) {
+            return new Answer(cmd);
+        } else {
+            return new Answer(cmd, result, "Failed to cleanup network rules.");
+        }
+    }
+
     protected boolean defaultNetworkRulesForUserVm(String vmName, Long vmId, NicTO nic) throws XmlRpcException {
         if (!_canBridgeFirewall) {
             return false;
         }
-        
+
         OvmVif.Details vif = getVifFromVm(vmName, nic.getDeviceId());
         String ipAddress = nic.getIp();
         String macAddress = vif.mac;
@@ -1136,172 +1140,173 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
 
         return OvmSecurityGroup.defaultNetworkRulesForUserVm(_conn, vmName, String.valueOf(vmId), ipAddress, macAddress, vifName, bridgeName);
     }
-    
+
     protected boolean deleteAllNetworkRulesForVm(String vmName) throws XmlRpcException {
         if (!_canBridgeFirewall) {
             return false;
         }
-        
+
         String vif = getVifFromVm(vmName, null).name;
         return OvmSecurityGroup.deleteAllNetworkRulesForVm(_conn, vmName, vif);
     }
-    
-    protected boolean addNetworkRules(String vmName, String vmId, String guestIp, String signature, String seqno, String vifMacAddress, String rules, String vifDeviceName, String bridgeName) throws XmlRpcException {
+
+    protected boolean addNetworkRules(String vmName, String vmId, String guestIp, String signature, String seqno, String vifMacAddress, String rules, String vifDeviceName,
+            String bridgeName) throws XmlRpcException {
         if (!_canBridgeFirewall) {
             return false;
         }
-                
-        String newRules = rules.replace(" ", ";");        
+
+        String newRules = rules.replace(" ", ";");
         return OvmSecurityGroup.addNetworkRules(_conn, vmName, vmId, guestIp, signature, seqno, vifMacAddress, newRules, vifDeviceName, bridgeName);
     }
-    
+
     protected boolean cleanupNetworkRules() throws XmlRpcException {
         if (!_canBridgeFirewall) {
             return false;
         }
-        
+
         return OvmSecurityGroup.cleanupNetworkRules(_conn);
     }
-	
-	protected boolean canBridgeFirewall() throws XmlRpcException {
-	    return OvmSecurityGroup.canBridgeFirewall(_conn);
-	}
-	
-	protected OvmVif.Details getVifFromVm(String vmName, Integer deviceId) throws XmlRpcException {
-		String vif = null;
+
+    protected boolean canBridgeFirewall() throws XmlRpcException {
+        return OvmSecurityGroup.canBridgeFirewall(_conn);
+    }
+
+    protected OvmVif.Details getVifFromVm(String vmName, Integer deviceId) throws XmlRpcException {
         List<OvmVif.Details> vifs = null;
-        
+
         try {
-            vifs = getInterfaces(vmName);   
+            vifs = getInterfaces(vmName);
         } catch (XmlRpcException e) {
             s_logger.error("Failed to get VIFs for VM " + vmName, e);
-           	throw e;
+            throw e;
         }
-        
+
         if (deviceId != null && vifs.size() > deviceId) {
-        	return vifs.get(deviceId);
+            return vifs.get(deviceId);
         } else if (deviceId == null && vifs.size() > 0) {
-        	return vifs.get(0);
+            return vifs.get(0);
         } else {
-        	return null;
+            return null;
         }
-	}
-	
-	protected  List<OvmVif.Details> getInterfaces(String vmName) throws XmlRpcException {
-	    OvmVm.Details vmDetails = OvmVm.getDetails(_conn, vmName);
-	    return vmDetails.vifs;
     }
-	
-	protected Answer execute(PrepareOCFS2NodesCommand cmd) {
-	    List<Ternary<Integer, String, String>> nodes = cmd.getNodes();
-	    StringBuffer params = new StringBuffer();
-	    for (Ternary<Integer, String, String> node : nodes) {
-	        String param = String.format("%1$s:%2$s:%3$s", node.first(), node.second(), node.third());
-	        params.append(param);
-	        params.append(";");
-	    }
-	    
-	    try {
+
+    protected List<OvmVif.Details> getInterfaces(String vmName) throws XmlRpcException {
+        OvmVm.Details vmDetails = OvmVm.getDetails(_conn, vmName);
+        return vmDetails.vifs;
+    }
+
+    protected Answer execute(PrepareOCFS2NodesCommand cmd) {
+        List<Ternary<Integer, String, String>> nodes = cmd.getNodes();
+        StringBuffer params = new StringBuffer();
+        for (Ternary<Integer, String, String> node : nodes) {
+            String param = String.format("%1$s:%2$s:%3$s", node.first(), node.second(), node.third());
+            params.append(param);
+            params.append(";");
+        }
+
+        try {
             OvmStoragePool.prepareOCFS2Nodes(_conn, cmd.getClusterName(), params.toString());
             return new Answer(cmd, true, "Success");
         } catch (XmlRpcException e) {
             s_logger.debug("OCFS2 prepare nodes failed", e);
             return new Answer(cmd, false, e.getMessage());
         }
-	}
-	
-	protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromVolumeCommand cmd) {
+    }
+
+    protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromVolumeCommand cmd) {
         String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
-		String volumePath = cmd.getVolumePath();
-		Long accountId = cmd.getAccountId();
-		Long templateId = cmd.getTemplateId();
-		int wait = cmd.getWait();
-		if (wait == 0) {
-			/* Defaut timeout 2 hours */
-			wait = 7200;
-		}
-		 
-		try {
-			URI uri;
+        String volumePath = cmd.getVolumePath();
+        Long accountId = cmd.getAccountId();
+        Long templateId = cmd.getTemplateId();
+        int wait = cmd.getWait();
+        if (wait == 0) {
+            /* Defaut timeout 2 hours */
+            wait = 7200;
+        }
+
+        try {
+            URI uri;
             uri = new URI(secondaryStorageUrl);
-			String secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath();
-			String installPath = "template/tmpl/" + accountId + "/" + templateId;
-			Map<String, String> res = OvmStoragePool.createTemplateFromVolume(_conn, secondaryStorageMountPath, installPath, volumePath, wait);
-			return new CreatePrivateTemplateAnswer(cmd, true, null, res.get("installPath"), Long.valueOf(res.get("virtualSize")), Long.valueOf(res.get("physicalSize")), res.get("templateFileName"), ImageFormat.RAW);
-		} catch (Exception e) {
-			s_logger.debug("Create template failed", e);
-			return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage());
-		}
-	}
-	
-	protected CopyVolumeAnswer execute(CopyVolumeCommand cmd) {
-	    String volumePath = cmd.getVolumePath();
-	    String secondaryStorageURL = cmd.getSecondaryStorageURL();
-	    int wait = cmd.getWait();
-	    if (wait == 0) {
-	    	wait = 7200;
-	    }
-	    
-	    try {
-	    	URI uri = new URI(secondaryStorageURL);
-	    	String secStorageMountPath = uri.getHost() + ":" + uri.getPath();
-	    	String volumeFolderOnSecStorage = "volumes/" + String.valueOf(cmd.getVolumeId());
-	    	String storagePoolUuid = cmd.getPool().getUuid();
-	    	Boolean toSec = cmd.toSecondaryStorage();
-	    	String res = OvmStoragePool.copyVolume(_conn, secStorageMountPath, volumeFolderOnSecStorage, volumePath, storagePoolUuid, toSec, wait);
-	    	return new CopyVolumeAnswer(cmd, true, null, null, res);
-	    } catch (Exception e) {
-	    	s_logger.debug("Copy volume failed", e);
-	    	return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null);
-	    }
-	}
-	
-	protected Answer execute(DeleteStoragePoolCommand cmd) {
-		try {
-			OvmStoragePool.delete(_conn, cmd.getPool().getUuid());
-		} catch (Exception e) {
-			s_logger.debug("Delete storage pool on host " + _ip + " failed, however, we leave to user for cleanup and tell managment server it succeeded", e);
-		}
-		
-		return new Answer(cmd);
-	}
-	
-	protected CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
+            String secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath();
+            String installPath = "template/tmpl/" + accountId + "/" + templateId;
+            Map<String, String> res = OvmStoragePool.createTemplateFromVolume(_conn, secondaryStorageMountPath, installPath, volumePath, wait);
+            return new CreatePrivateTemplateAnswer(cmd, true, null, res.get("installPath"), Long.valueOf(res.get("virtualSize")), Long.valueOf(res.get("physicalSize")),
+                    res.get("templateFileName"), ImageFormat.RAW);
+        } catch (Exception e) {
+            s_logger.debug("Create template failed", e);
+            return new CreatePrivateTemplateAnswer(cmd, false, e.getMessage());
+        }
+    }
+
+    protected CopyVolumeAnswer execute(CopyVolumeCommand cmd) {
+        String volumePath = cmd.getVolumePath();
+        String secondaryStorageURL = cmd.getSecondaryStorageURL();
+        int wait = cmd.getWait();
+        if (wait == 0) {
+            wait = 7200;
+        }
+
+        try {
+            URI uri = new URI(secondaryStorageURL);
+            String secStorageMountPath = uri.getHost() + ":" + uri.getPath();
+            String volumeFolderOnSecStorage = "volumes/" + String.valueOf(cmd.getVolumeId());
+            String storagePoolUuid = cmd.getPool().getUuid();
+            Boolean toSec = cmd.toSecondaryStorage();
+            String res = OvmStoragePool.copyVolume(_conn, secStorageMountPath, volumeFolderOnSecStorage, volumePath, storagePoolUuid, toSec, wait);
+            return new CopyVolumeAnswer(cmd, true, null, null, res);
+        } catch (Exception e) {
+            s_logger.debug("Copy volume failed", e);
+            return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null);
+        }
+    }
+
+    protected Answer execute(DeleteStoragePoolCommand cmd) {
+        try {
+            OvmStoragePool.delete(_conn, cmd.getPool().getUuid());
+        } catch (Exception e) {
+            s_logger.debug("Delete storage pool on host " + _ip + " failed, however, we leave to user for cleanup and tell managment server it succeeded", e);
+        }
+
+        return new Answer(cmd);
+    }
+
+    protected CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Checking if network name setup is done on the resource");
         }
 
-		List<PhysicalNetworkSetupInfo> infoList = cmd.getPhysicalNetworkInfoList();
+        List<PhysicalNetworkSetupInfo> infoList = cmd.getPhysicalNetworkInfoList();
 
-		boolean errorout = false;
-		String msg = "";
-		for (PhysicalNetworkSetupInfo info : infoList) {
-			if (!isNetworkSetupByName(info.getGuestNetworkName())) {
-				msg = "For Physical Network id:" + info.getPhysicalNetworkId() + ", Guest Network is not configured on the backend by name "
-				        + info.getGuestNetworkName();
-				errorout = true;
-				break;
-			}
-			if (!isNetworkSetupByName(info.getPrivateNetworkName())) {
-				msg = "For Physical Network id:" + info.getPhysicalNetworkId() + ", Private Network is not configured on the backend by name "
-				        + info.getPrivateNetworkName();
-				errorout = true;
-				break;
-			}
-			if (!isNetworkSetupByName(info.getPublicNetworkName())) {
-				msg = "For Physical Network id:" + info.getPhysicalNetworkId() + ", Public Network is not configured on the backend by name "
-				        + info.getPublicNetworkName();
-				errorout = true;
-				break;
-			}
-		}
-		
-		if (errorout) {
-			s_logger.error(msg);
-			return new CheckNetworkAnswer(cmd, false, msg);
-		} else {
-			return new CheckNetworkAnswer(cmd, true, "Network Setup check by names is done");
-		}
+        boolean errorout = false;
+        String msg = "";
+        for (PhysicalNetworkSetupInfo info : infoList) {
+            if (!isNetworkSetupByName(info.getGuestNetworkName())) {
+                msg = "For Physical Network id:" + info.getPhysicalNetworkId() + ", Guest Network is not configured on the backend by name "
+                        + info.getGuestNetworkName();
+                errorout = true;
+                break;
+            }
+            if (!isNetworkSetupByName(info.getPrivateNetworkName())) {
+                msg = "For Physical Network id:" + info.getPhysicalNetworkId() + ", Private Network is not configured on the backend by name "
+                        + info.getPrivateNetworkName();
+                errorout = true;
+                break;
+            }
+            if (!isNetworkSetupByName(info.getPublicNetworkName())) {
+                msg = "For Physical Network id:" + info.getPhysicalNetworkId() + ", Public Network is not configured on the backend by name "
+                        + info.getPublicNetworkName();
+                errorout = true;
+                break;
+            }
+        }
+
+        if (errorout) {
+            s_logger.error(msg);
+            return new CheckNetworkAnswer(cmd, false, msg);
+        } else {
+            return new CheckNetworkAnswer(cmd, true, "Network Setup check by names is done");
+        }
     }
 
     private boolean isNetworkSetupByName(String nameTag) {
@@ -1312,118 +1317,118 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
             return _bridges.contains(nameTag);
         }
         return true;
-    }    
-    
-	@Override
-	public Answer executeRequest(Command cmd) {
-		Class<? extends Command> clazz = cmd.getClass();
-		if (clazz == ReadyCommand.class) {
-			return execute((ReadyCommand)cmd);
-		} else if (clazz == CreateStoragePoolCommand.class) {
-			return execute((CreateStoragePoolCommand)cmd);
-		} else if (clazz == ModifyStoragePoolCommand.class) {
-			return execute((ModifyStoragePoolCommand)cmd);
-		} else if (clazz == PrimaryStorageDownloadCommand.class) {
-			return execute((PrimaryStorageDownloadCommand)cmd);
-		} else if (clazz == CreateCommand.class) {
-			return execute((CreateCommand)cmd);
-		} else if (clazz == GetHostStatsCommand.class) {
-			return execute((GetHostStatsCommand)cmd);
-		} else if (clazz == StopCommand.class) {
-			return execute((StopCommand)cmd);
-		} else if (clazz == RebootCommand.class) {
-			return execute((RebootCommand)cmd);
-		} else if (clazz == GetStorageStatsCommand.class) { 
-			return execute((GetStorageStatsCommand)cmd);
-		} else if (clazz == GetVmStatsCommand.class) {
-			return execute((GetVmStatsCommand)cmd);
-		} else if (clazz == AttachVolumeCommand.class) {
-			return execute((AttachVolumeCommand)cmd);
-		} else if (clazz == DestroyCommand.class) {
-			return execute((DestroyCommand)cmd);
-		} else if (clazz == PrepareForMigrationCommand.class) {
-			return execute((PrepareForMigrationCommand)cmd);
-		} else if (clazz == MigrateCommand.class) {
-			return execute((MigrateCommand)cmd);
-		} else if (clazz == CheckVirtualMachineCommand.class) {
-			return execute((CheckVirtualMachineCommand)cmd);
-		} else if (clazz == MaintainCommand.class) {
-			return execute((MaintainCommand)cmd);
-		} else if (clazz == StartCommand.class) {
-			return execute((StartCommand)cmd);
-		} else if (clazz == GetVncPortCommand.class) {
-			return execute((GetVncPortCommand)cmd);
-		} else if (clazz == PingTestCommand.class) {
-			return execute((PingTestCommand)cmd);
-		} else if (clazz == FenceCommand.class) {
-			return execute((FenceCommand)cmd);
-		} else if (clazz == AttachIsoCommand.class) {
-			return execute((AttachIsoCommand)cmd);
-		} else if (clazz == SecurityGroupRulesCmd.class) {
-		    return execute((SecurityGroupRulesCmd) cmd);
-		} else if (clazz == CleanupNetworkRulesCmd.class) {
-		    return execute((CleanupNetworkRulesCmd) cmd);
-		} else if (clazz == PrepareOCFS2NodesCommand.class) {
-		    return execute((PrepareOCFS2NodesCommand)cmd);
-		} else if (clazz == CreatePrivateTemplateFromVolumeCommand.class) {
-			return execute((CreatePrivateTemplateFromVolumeCommand)cmd);
-		} else if (clazz == CopyVolumeCommand.class) {
-			return execute((CopyVolumeCommand)cmd);
-		} else if (clazz == DeleteStoragePoolCommand.class) {
-			return execute((DeleteStoragePoolCommand)cmd);
-		} else if (clazz == CheckNetworkCommand.class) {
-			return execute((CheckNetworkCommand)cmd);
-		} else {
-			return Answer.createUnsupportedCommandAnswer(cmd);
-		}
-	}
+    }
 
-	@Override
-	public void disconnected() {
-		// TODO Auto-generated method stub
+    @Override
+    public Answer executeRequest(Command cmd) {
+        Class<? extends Command> clazz = cmd.getClass();
+        if (clazz == ReadyCommand.class) {
+            return execute((ReadyCommand)cmd);
+        } else if (clazz == CreateStoragePoolCommand.class) {
+            return execute((CreateStoragePoolCommand)cmd);
+        } else if (clazz == ModifyStoragePoolCommand.class) {
+            return execute((ModifyStoragePoolCommand)cmd);
+        } else if (clazz == PrimaryStorageDownloadCommand.class) {
+            return execute((PrimaryStorageDownloadCommand)cmd);
+        } else if (clazz == CreateCommand.class) {
+            return execute((CreateCommand)cmd);
+        } else if (clazz == GetHostStatsCommand.class) {
+            return execute((GetHostStatsCommand)cmd);
+        } else if (clazz == StopCommand.class) {
+            return execute((StopCommand)cmd);
+        } else if (clazz == RebootCommand.class) {
+            return execute((RebootCommand)cmd);
+        } else if (clazz == GetStorageStatsCommand.class) {
+            return execute((GetStorageStatsCommand)cmd);
+        } else if (clazz == GetVmStatsCommand.class) {
+            return execute((GetVmStatsCommand)cmd);
+        } else if (clazz == AttachVolumeCommand.class) {
+            return execute((AttachVolumeCommand)cmd);
+        } else if (clazz == DestroyCommand.class) {
+            return execute((DestroyCommand)cmd);
+        } else if (clazz == PrepareForMigrationCommand.class) {
+            return execute((PrepareForMigrationCommand)cmd);
+        } else if (clazz == MigrateCommand.class) {
+            return execute((MigrateCommand)cmd);
+        } else if (clazz == CheckVirtualMachineCommand.class) {
+            return execute((CheckVirtualMachineCommand)cmd);
+        } else if (clazz == MaintainCommand.class) {
+            return execute((MaintainCommand)cmd);
+        } else if (clazz == StartCommand.class) {
+            return execute((StartCommand)cmd);
+        } else if (clazz == GetVncPortCommand.class) {
+            return execute((GetVncPortCommand)cmd);
+        } else if (clazz == PingTestCommand.class) {
+            return execute((PingTestCommand)cmd);
+        } else if (clazz == FenceCommand.class) {
+            return execute((FenceCommand)cmd);
+        } else if (clazz == AttachIsoCommand.class) {
+            return execute((AttachIsoCommand)cmd);
+        } else if (clazz == SecurityGroupRulesCmd.class) {
+            return execute((SecurityGroupRulesCmd)cmd);
+        } else if (clazz == CleanupNetworkRulesCmd.class) {
+            return execute((CleanupNetworkRulesCmd)cmd);
+        } else if (clazz == PrepareOCFS2NodesCommand.class) {
+            return execute((PrepareOCFS2NodesCommand)cmd);
+        } else if (clazz == CreatePrivateTemplateFromVolumeCommand.class) {
+            return execute((CreatePrivateTemplateFromVolumeCommand)cmd);
+        } else if (clazz == CopyVolumeCommand.class) {
+            return execute((CopyVolumeCommand)cmd);
+        } else if (clazz == DeleteStoragePoolCommand.class) {
+            return execute((DeleteStoragePoolCommand)cmd);
+        } else if (clazz == CheckNetworkCommand.class) {
+            return execute((CheckNetworkCommand)cmd);
+        } else {
+            return Answer.createUnsupportedCommandAnswer(cmd);
+        }
+    }
 
-	}
+    @Override
+    public void disconnected() {
+        // TODO Auto-generated method stub
 
-	@Override
-	public IAgentControl getAgentControl() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    }
 
-	@Override
-	public void setAgentControl(IAgentControl agentControl) {
-		// TODO Auto-generated method stub
+    @Override
+    public IAgentControl getAgentControl() {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
-	}
+    @Override
+    public void setAgentControl(IAgentControl agentControl) {
+        // TODO Auto-generated method stub
 
-	@Override
-	public void setName(String name) {
-		// TODO Auto-generated method stub
-		
-	}
+    }
 
-	@Override
-	public void setConfigParams(Map<String, Object> params) {
-		// TODO Auto-generated method stub
-		
-	}
+    @Override
+    public void setName(String name) {
+        // TODO Auto-generated method stub
 
-	@Override
-	public Map<String, Object> getConfigParams() {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    }
 
-	@Override
-	public int getRunLevel() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
+    @Override
+    public void setConfigParams(Map<String, Object> params) {
+        // TODO Auto-generated method stub
 
-	@Override
-	public void setRunLevel(int level) {
-		// TODO Auto-generated method stub
-		
-	}
+    }
+
+    @Override
+    public Map<String, Object> getConfigParams() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public int getRunLevel() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setRunLevel(int level) {
+        // TODO Auto-generated method stub
+
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2614b00c/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 2253586..2d40417 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -1793,7 +1793,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
     }
 
     protected void assignPublicIpAddress(VirtualMachineMO vmMo, final String vmName, final String privateIpAddress, final String publicIpAddress, final boolean add, final boolean firstIP,
-            final boolean sourceNat, final String vlanId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress) throws Exception {
+            final boolean sourceNat, final String broadcastId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress) throws Exception {
+
+        /**
+         * TODO support other networks
+         */
+        URI broadcastUri = BroadcastDomainType.fromString(broadcastId);
+        if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
+            throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + broadcastId);
+        }
+        String vlanId = BroadcastDomainType.getValue(broadcastUri);
 
         String publicNeworkName = HypervisorHostHelper.getPublicNetworkNamePrefix(vlanId);
         Pair<Integer, VirtualDevice> publicNicInfo = vmMo.getNicDeviceIndex(publicNeworkName);
@@ -2011,7 +2020,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             }
 
             for (IpAddressTO ip : ips) {
-                assignPublicIpAddress(vmMo, routerName, controlIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getVlanId(), ip.getVlanGateway(), ip.getVlanNetmask(),
+                assignPublicIpAddress(vmMo, routerName, controlIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getBroadcastUri(), ip.getVlanGateway(), ip.getVlanNetmask(),
                         ip.getVifMacAddress());
                 results[i++] = ip.getPublicIp() + " - success";
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2614b00c/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 3cc60db..76016c7 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -1062,7 +1062,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             return network.getNetwork();
         } else if (type == BroadcastDomainType.Pvlan) {
             assert BroadcastDomainType.getSchemeValue(uri) == BroadcastDomainType.Pvlan;
-            // TODO considder moving this NetUtils method to BroadcastDomainType
+            // should we consider moving this NetUtils method to BroadcastDomainType?
             long vlan = Long.parseLong(NetUtils.getPrimaryPvlanFromUri(uri));
             return enableVlanNetwork(conn, vlan, network);
         }
@@ -2445,7 +2445,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             IpAddressTO[] ips = cmd.getIpAddresses();
             for (IpAddressTO ip : ips) {
 
-                assignPublicIpAddress(conn, routerName, routerIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getVlanId(),
+                assignPublicIpAddress(conn, routerName, routerIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getBroadcastUri(),
                         ip.getVlanGateway(), ip.getVlanNetmask(), ip.getVifMacAddress(), ip.getNetworkRate(), ip.getTrafficType(), ip.getNetworkName());
                 results[i++] = ip.getPublicIp() + " - success";
             }
@@ -4202,10 +4202,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         NicTO nic = new NicTO();
         nic.setType(ip.getTrafficType());
         nic.setName(ip.getNetworkName());
-        if (ip.getVlanId() == null) {
+        if (ip.getBroadcastUri() == null) {
             nic.setBroadcastType(BroadcastDomainType.Native);
         } else {
-            URI uri = BroadcastDomainType.fromString(ip.getVlanId());
+            URI uri = BroadcastDomainType.fromString(ip.getBroadcastUri());
             nic.setBroadcastType(BroadcastDomainType.getSchemeValue(uri));
             nic.setBroadcastUri(uri);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2614b00c/plugins/network-elements/bigswitch-vns/src/com/cloud/network/guru/BigSwitchVnsGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/guru/BigSwitchVnsGuestNetworkGuru.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/guru/BigSwitchVnsGuestNetworkGuru.java
index daf65a1..9e9dfca 100644
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/guru/BigSwitchVnsGuestNetworkGuru.java
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/guru/BigSwitchVnsGuestNetworkGuru.java
@@ -247,7 +247,7 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
         String tenantId = profile.getNetworkDomain();
 
         DeleteVnsNetworkCommand cmd = new DeleteVnsNetworkCommand(tenantId,
-                        networkObject.getBroadcastUri().getSchemeSpecificPart());
+                BroadcastDomainType.getValue(networkObject.getBroadcastUri()));
         _agentMgr.easySend(bigswitchVnsHost.getId(), cmd);
 
         super.shutdown(profile, offering);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2614b00c/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
index c053856..e27a059 100644
--- a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
+++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
@@ -132,8 +132,8 @@ import com.cloud.vm.VirtualMachineProfile;
 
 @Local(value = NetworkElement.class)
 public class CiscoVnmcElement extends AdapterBase implements SourceNatServiceProvider, FirewallServiceProvider,
-    PortForwardingServiceProvider, IpDeployer, StaticNatServiceProvider, ResourceStateAdapter, NetworkElement,
-    CiscoVnmcElementService, CiscoAsa1000vService {
+        PortForwardingServiceProvider, IpDeployer, StaticNatServiceProvider, ResourceStateAdapter, NetworkElement,
+        CiscoVnmcElementService, CiscoAsa1000vService {
     private static final Logger s_logger = Logger.getLogger(CiscoVnmcElement.class);
     private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
 
@@ -375,7 +375,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
                 try {
                     outsideIp = _ipAddrMgr.associateIPToGuestNetwork(outsideIp.getId(), network.getId(), true);
                 } catch (ResourceAllocationException e) {
-                    s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " + vlanId + ". Exception details " + e);
+                    s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " + vlanId + ". Exception details "
+                            + e);
                     return false;
                 }
             }
@@ -532,7 +533,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
         }
         long zoneId = physicalNetwork.getDataCenterId();
 
-        PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(), networkDevice.getNetworkServiceProvder());
+        PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(),
+                networkDevice.getNetworkServiceProvder());
         if (ntwkSvcProvider == null) {
             throw new CloudRuntimeException("Network Service Provider: " + networkDevice.getNetworkServiceProvder() +
                     " is not enabled in the physical network: " + physicalNetworkId + "to add this device");
@@ -545,7 +547,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
             throw new CloudRuntimeException("A Cisco Vnmc device is already configured on this physical network");
         }
 
-        Map<String, String> params = new HashMap<String,String>();
+        Map<String, String> params = new HashMap<String, String>();
         params.put("guid", UUID.randomUUID().toString());
         params.put("zoneId", String.valueOf(physicalNetwork.getDataCenterId()));
         params.put("physicalNetworkId", String.valueOf(physicalNetwork.getId()));
@@ -554,7 +556,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
         params.put("username", cmd.getUsername());
         params.put("password", cmd.getPassword());
 
-        Map<String, Object> hostdetails = new HashMap<String,Object>();
+        Map<String, Object> hostdetails = new HashMap<String, Object>();
         hostdetails.putAll(params);
 
         ServerResource resource = new CiscoVnmcResource();
@@ -568,7 +570,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
 
                 ciscoVnmcResource = new CiscoVnmcControllerVO(host.getId(), physicalNetworkId, ntwkSvcProvider.getProviderName(), deviceName);
                 _ciscoVnmcDao.persist((CiscoVnmcControllerVO)ciscoVnmcResource);
-                
+
                 DetailVO detail = new DetailVO(host.getId(), "deviceid", String.valueOf(ciscoVnmcResource.getId()));
                 _hostDetailsDao.persist(detail);
 
@@ -614,7 +616,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
             if (responseList.size() > 0) {
                 throw new CloudRuntimeException(
                         "Cisco VNMC appliance with id " + vnmcResourceId +
-                        " cannot be deleted as there Cisco ASA 1000v appliances using it");
+                                " cannot be deleted as there Cisco ASA 1000v appliances using it");
             }
         }
 
@@ -687,7 +689,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
         }
 
         if (network.getState() == Network.State.Allocated) {
-            s_logger.debug("External firewall was asked to apply firewall rules for network with ID " + network.getId() + "; this network is not implemented. Skipping backend commands.");
+            s_logger.debug("External firewall was asked to apply firewall rules for network with ID " + network.getId()
+                    + "; this network is not implemented. Skipping backend commands.");
             return true;
         }
 
@@ -745,7 +748,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
         }
 
         if (network.getState() == Network.State.Allocated) {
-            s_logger.debug("External firewall was asked to apply port forwarding rules for network with ID " + network.getId() + "; this network is not implemented. Skipping backend commands.");
+            s_logger.debug("External firewall was asked to apply port forwarding rules for network with ID " + network.getId()
+                    + "; this network is not implemented. Skipping backend commands.");
             return true;
         }
 
@@ -800,7 +804,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
         }
 
         if (network.getState() == Network.State.Allocated) {
-            s_logger.debug("External firewall was asked to apply static NAT rules for network with ID " + network.getId() + "; this network is not implemented. Skipping backend commands.");
+            s_logger.debug("External firewall was asked to apply static NAT rules for network with ID " + network.getId()
+                    + "; this network is not implemented. Skipping backend commands.");
             return true;
         }
 
@@ -913,7 +918,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
         if (networkAsaMap != null) {
             throw new CloudRuntimeException(
                     "Cisco ASA 1000v appliance with id " + asaResourceId +
-                    " cannot be deleted as it is associated with guest network");
+                            " cannot be deleted as it is associated with guest network");
         }
 
         _ciscoAsa1000vDao.remove(asaResourceId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2614b00c/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java b/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java
index ffddd30..211edde 100644
--- a/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java
+++ b/plugins/network-elements/f5/src/com/cloud/network/resource/F5BigIpResource.java
@@ -294,8 +294,9 @@ public class F5BigIpResource implements ServerResource {
             try {		
                 IpAddressTO[] ips = cmd.getIpAddresses();
                 for (IpAddressTO ip : ips) {
-                // TODO BroadcastDomain.getValue(ip.getVlanId) ???
-                    long guestVlanTag = Long.valueOf(ip.getVlanId());
+                // is it saver to use Long.valueOf(BroadcastDomain.getValue(ip.getBroadcastUri())) ???
+                    // i.o.w. can this contain vlan:// then change !!!
+                    long guestVlanTag = Long.valueOf(ip.getBroadcastUri());
                     // It's a hack, using isOneToOneNat field for indicate if it's inline or not
                     boolean inline = ip.isOneToOneNat();
                     String vlanSelfIp = inline ? tagAddressWithRouteDomain(ip.getVlanGateway(), guestVlanTag) : ip.getVlanGateway();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2614b00c/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java b/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java
index 46ef332..e021ad9 100644
--- a/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java
+++ b/plugins/network-elements/juniper-srx/src/com/cloud/network/resource/JuniperSrxResource.java
@@ -68,6 +68,7 @@ import com.cloud.host.Host;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.FirewallRule.Purpose;
+import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.resource.ServerResource;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.exception.ExecutionException;
@@ -697,11 +698,11 @@ public class JuniperSrxResource implements ServerResource {
             String guestVlanSubnet = NetUtils.getCidrSubNet(guestVlanGateway, cidrSize);    
             
             Long publicVlanTag = null;
-            if (ip.getVlanId() != null && !ip.getVlanId().equals("untagged")) {
+            if (ip.getBroadcastUri() != null && !ip.getBroadcastUri().equals("untagged")) {
             	try {
                     publicVlanTag = Long.parseLong(BroadcastDomainType.getValue(ip.getVlanId()));
             	} catch (Exception e) {
-            		throw new ExecutionException("Could not parse public VLAN tag: " + ip.getVlanId());
+			throw new ExecutionException("Could not parse public VLAN tag: " + ip.getBroadcastUri());
             	}
             } 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2614b00c/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
index 58541c6..fe072e1 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
@@ -442,7 +442,7 @@ public class NetscalerResource implements ServerResource {
         try {
             IpAddressTO[] ips = cmd.getIpAddresses();
             for (IpAddressTO ip : ips) {
-                long guestVlanTag = Long.valueOf(ip.getVlanId());
+                long guestVlanTag = Long.valueOf(ip.getBroadcastUri());
                 String vlanSelfIp = ip.getVlanGateway();
                 String vlanNetmask = ip.getVlanNetmask();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2614b00c/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
index 686f79c..5400dd4 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
@@ -127,9 +127,9 @@ import com.cloud.vm.dao.NicDao;
         SourceNatServiceProvider.class, StaticNatServiceProvider.class,
         PortForwardingServiceProvider.class, IpDeployer.class} )
 public class NiciraNvpElement extends AdapterBase implements
-ConnectivityProvider, SourceNatServiceProvider,
-PortForwardingServiceProvider, StaticNatServiceProvider,
-NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
+        ConnectivityProvider, SourceNatServiceProvider,
+        PortForwardingServiceProvider, StaticNatServiceProvider,
+        NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
     private static final Logger s_logger = Logger
             .getLogger(NiciraNvpElement.class);
 
@@ -216,8 +216,8 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
     @Override
     public boolean implement(Network network, NetworkOffering offering,
             DeployDestination dest, ReservationContext context)
-                    throws ConcurrentOperationException, ResourceUnavailableException,
-                    InsufficientCapacityException {
+            throws ConcurrentOperationException, ResourceUnavailableException,
+            InsufficientCapacityException {
         s_logger.debug("entering NiciraNvpElement implement function for network "
                 + network.getDisplayText()
                 + " (state "
@@ -276,10 +276,10 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
                     BroadcastDomainType.getValue(network.getBroadcastUri()),
                     "router-" + network.getDisplayText(), publicCidr,
                     sourceNatIp.getGateway(), internalCidr, context
-                    .getDomain().getName()
-                    + "-"
-                    + context.getAccount().getAccountName());
-            CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer) _agentMgr
+                            .getDomain().getName()
+                            + "-"
+                            + context.getAccount().getAccountName());
+            CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer)_agentMgr
                     .easySend(niciraNvpHost.getId(), cmd);
             if (answer.getResult() == false) {
                 s_logger.error("Failed to create Logical Router for network "
@@ -293,7 +293,6 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
             _niciraNvpRouterMappingDao.persist(routermapping);
         }
 
-
         return true;
     }
 
@@ -331,7 +330,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
             FindLogicalSwitchPortCommand findCmd = new FindLogicalSwitchPortCommand(
                     existingNicMap.getLogicalSwitchUuid(),
                     existingNicMap.getLogicalSwitchPortUuid());
-            FindLogicalSwitchPortAnswer answer = (FindLogicalSwitchPortAnswer) _agentMgr
+            FindLogicalSwitchPortAnswer answer = (FindLogicalSwitchPortAnswer)_agentMgr
                     .easySend(niciraNvpHost.getId(), findCmd);
 
             if (answer.getResult()) {
@@ -343,7 +342,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
                         BroadcastDomainType.getValue(network.getBroadcastUri()),
                         nicVO.getUuid(), context.getDomain().getName() + "-"
                                 + context.getAccount().getAccountName(),
-                                nic.getName());
+                        nic.getName());
                 _agentMgr.easySend(niciraNvpHost.getId(), cmd);
                 return true;
             } else {
@@ -358,7 +357,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
                 BroadcastDomainType.getValue(network.getBroadcastUri()),
                 nicVO.getUuid(), context.getDomain().getName() + "-"
                         + context.getAccount().getAccountName(), nic.getName());
-        CreateLogicalSwitchPortAnswer answer = (CreateLogicalSwitchPortAnswer) _agentMgr
+        CreateLogicalSwitchPortAnswer answer = (CreateLogicalSwitchPortAnswer)_agentMgr
                 .easySend(niciraNvpHost.getId(), cmd);
 
         if (answer == null || !answer.getResult()) {
@@ -410,7 +409,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
         DeleteLogicalSwitchPortCommand cmd = new DeleteLogicalSwitchPortCommand(
                 nicMap.getLogicalSwitchUuid(),
                 nicMap.getLogicalSwitchPortUuid());
-        DeleteLogicalSwitchPortAnswer answer = (DeleteLogicalSwitchPortAnswer) _agentMgr
+        DeleteLogicalSwitchPortAnswer answer = (DeleteLogicalSwitchPortAnswer)_agentMgr
                 .easySend(niciraNvpHost.getId(), cmd);
 
         if (answer == null || !answer.getResult()) {
@@ -458,7 +457,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
 
             DeleteLogicalRouterCommand cmd = new DeleteLogicalRouterCommand(routermapping.getLogicalRouterUuid());
             DeleteLogicalRouterAnswer answer =
-                    (DeleteLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
+                    (DeleteLogicalRouterAnswer)_agentMgr.easySend(niciraNvpHost.getId(), cmd);
             if (answer.getResult() == false) {
                 s_logger.error("Failed to delete LogicalRouter for network "
                         + network.getDisplayText());
@@ -489,7 +488,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
     @Override
     public boolean shutdownProviderInstances(
             PhysicalNetworkServiceProvider provider, ReservationContext context)
-                    throws ConcurrentOperationException, ResourceUnavailableException {
+            throws ConcurrentOperationException, ResourceUnavailableException {
         // Nothing to do here.
         return true;
     }
@@ -763,7 +762,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
                 .listByPhysicalNetwork(physicalNetworkId);
 
         // Networks with broadcast type lswitch are ours
-        List<NetworkVO> responseList  = new ArrayList<NetworkVO>();
+        List<NetworkVO> responseList = new ArrayList<NetworkVO>();
         for (NetworkVO network : networkList) {
             if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.Lswitch) {
                 responseList.add(network);
@@ -820,7 +819,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
     @Override
     public boolean applyIps(Network network,
             List<? extends PublicIpAddress> ipAddress, Set<Service> services)
-                    throws ResourceUnavailableException {
+            throws ResourceUnavailableException {
         if (services.contains(Service.SourceNat)) {
             // Only if we need to provide SourceNat we need to configure the logical router
             // SourceNat is required for StaticNat and PortForwarding
@@ -854,7 +853,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
             }
             ConfigurePublicIpsOnLogicalRouterCommand cmd = new ConfigurePublicIpsOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(),
                     niciraNvpHost.getDetail("l3gatewayserviceuuid"), cidrs);
-            ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
+            ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer)_agentMgr.easySend(niciraNvpHost.getId(), cmd);
             //FIXME answer can be null if the host is down
             return answer.getResult();
         }
@@ -871,7 +870,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
     @Override
     public boolean applyStaticNats(Network network,
             List<? extends StaticNat> rules)
-                    throws ResourceUnavailableException {
+            throws ResourceUnavailableException {
         if (!canHandle(network, Service.StaticNat)) {
             return false;
         }
@@ -909,7 +908,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
 
         ConfigureStaticNatRulesOnLogicalRouterCommand cmd =
                 new ConfigureStaticNatRulesOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), staticNatRules);
-        ConfigureStaticNatRulesOnLogicalRouterAnswer answer = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
+        ConfigureStaticNatRulesOnLogicalRouterAnswer answer = (ConfigureStaticNatRulesOnLogicalRouterAnswer)_agentMgr.easySend(niciraNvpHost.getId(), cmd);
 
         return answer.getResult();
     }
@@ -952,7 +951,7 @@ NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
 
         ConfigurePortForwardingRulesOnLogicalRouterCommand cmd =
                 new ConfigurePortForwardingRulesOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), portForwardingRules);
-        ConfigurePortForwardingRulesOnLogicalRouterAnswer answer = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer answer = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)_agentMgr.easySend(niciraNvpHost.getId(), cmd);
 
         return answer.getResult();
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2614b00c/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
index fc1ecd0..51c59bf 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
@@ -41,11 +41,11 @@ import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.host.dao.HostDetailsDao;
 import com.cloud.network.Network;
+import com.cloud.network.Network.GuestType;
 import com.cloud.network.Network.Service;
+import com.cloud.network.Network.State;
 import com.cloud.network.NetworkModel;
 import com.cloud.network.NetworkProfile;
-import com.cloud.network.Network.GuestType;
-import com.cloud.network.Network.State;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.NiciraNvpDeviceVO;
 import com.cloud.network.PhysicalNetwork;
@@ -65,12 +65,11 @@ import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
-@Local(value=NetworkGuru.class)
+@Local(value = NetworkGuru.class)
 public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
     private static final Logger s_logger = Logger.getLogger(NiciraNvpGuestNetworkGuru.class);
-    
-   
-    @Inject 
+
+    @Inject
     NetworkModel _networkModel;
     @Inject
     NetworkDao _networkDao;
@@ -85,24 +84,24 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
     @Inject
     HostDao _hostDao;
     @Inject
-    ResourceManager _resourceMgr;    
+    ResourceManager _resourceMgr;
     @Inject
     AgentManager _agentMgr;
     @Inject
     HostDetailsDao _hostDetailsDao;
     @Inject
     NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
-    
+
     public NiciraNvpGuestNetworkGuru() {
         super();
-        _isolationMethods = new IsolationMethod[] { IsolationMethod.STT };
+        _isolationMethods = new IsolationMethod[] {IsolationMethod.STT};
     }
 
     @Override
     protected boolean canHandle(NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) {
         // This guru handles only Guest Isolated network that supports Source nat service
-        if (networkType == NetworkType.Advanced 
-                && isMyTrafficType(offering.getTrafficType()) 
+        if (networkType == NetworkType.Advanced
+                && isMyTrafficType(offering.getTrafficType())
                 && offering.getGuestType() == Network.GuestType.Isolated
                 && isMyIsolationMethod(physicalNetwork)
                 && _ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(offering.getId(), Service.Connectivity)) {
@@ -112,14 +111,14 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
             return false;
         }
     }
-    
+
     @Override
     public Network design(NetworkOffering offering, DeploymentPlan plan,
             Network userSpecified, Account owner) {
         // Check of the isolation type of the related physical network is STT
         PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
         DataCenter dc = _dcDao.findById(plan.getDataCenterId());
-        if (!canHandle(offering,dc.getNetworkType(),physnet)) {
+        if (!canHandle(offering, dc.getNetworkType(), physnet)) {
             s_logger.debug("Refusing to design this network");
             return null;
         }
@@ -131,14 +130,14 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
         }
         s_logger.debug("Nicira Nvp " + devices.get(0).getUuid() + " found on physical network " + physnet.getId());
 
-        s_logger.debug("Physical isolation type is STT, asking GuestNetworkGuru to design this network");        
-        NetworkVO networkObject = (NetworkVO) super.design(offering, plan, userSpecified, owner);
+        s_logger.debug("Physical isolation type is STT, asking GuestNetworkGuru to design this network");
+        NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner);
         if (networkObject == null) {
             return null;
         }
         // Override the broadcast domain type
         networkObject.setBroadcastDomainType(BroadcastDomainType.Lswitch);
-        
+
         return networkObject;
     }
 
@@ -152,9 +151,9 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
 
         //get physical network id
         Long physicalNetworkId = network.getPhysicalNetworkId();
-        
+
         // physical network id can be null in Guest Network in Basic zone, so locate the physical network
-        if (physicalNetworkId == null) {        
+        if (physicalNetworkId == null) {
             physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
         }
 
@@ -168,16 +167,16 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
         if (network.getCidr() != null) {
             implemented.setCidr(network.getCidr());
         }
-        
+
         // Name is either the given name or the uuid
         String name = network.getName();
         if (name == null || name.isEmpty()) {
             name = ((NetworkVO)network).getUuid();
         }
-        if (name.length() > 40 ) {
+        if (name.length() > 40) {
             name = name.substring(0, 39); // max length 40
         }
-        
+
         List<NiciraNvpDeviceVO> devices = _niciraNvpDao.listByPhysicalNetwork(physicalNetworkId);
         if (devices.isEmpty()) {
             s_logger.error("No NiciraNvp Controller on physical network " + physicalNetworkId);
@@ -188,16 +187,16 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
         _hostDao.loadDetails(niciraNvpHost);
         String transportzoneuuid = niciraNvpHost.getDetail("transportzoneuuid");
         String transportzoneisotype = niciraNvpHost.getDetail("transportzoneisotype");
-        
+
         CreateLogicalSwitchCommand cmd = new CreateLogicalSwitchCommand(transportzoneuuid, transportzoneisotype, name,
                 context.getDomain().getName() + "-" + context.getAccount().getAccountName());
-        CreateLogicalSwitchAnswer answer = (CreateLogicalSwitchAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
-        
+        CreateLogicalSwitchAnswer answer = (CreateLogicalSwitchAnswer)_agentMgr.easySend(niciraNvpHost.getId(), cmd);
+
         if (answer == null || !answer.getResult()) {
-            s_logger.error ("CreateLogicalSwitchCommand failed");
+            s_logger.error("CreateLogicalSwitchCommand failed");
             return null;
         }
-        
+
         try {
             implemented.setBroadcastUri(new URI("lswitch", answer.getLogicalSwitchUuid(), null));
             implemented.setBroadcastDomainType(BroadcastDomainType.Lswitch);
@@ -206,7 +205,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
             s_logger.error("Unable to store logical switch id in broadcast uri, uuid = " + implemented.getUuid(), e);
             return null;
         }
-        
+
         return implemented;
     }
 
@@ -229,14 +228,14 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
     }
 
     @Override
-    public void shutdown(NetworkProfile profile, NetworkOffering offering) {    
+    public void shutdown(NetworkProfile profile, NetworkOffering offering) {
         NetworkVO networkObject = _networkDao.findById(profile.getId());
         if (networkObject.getBroadcastDomainType() != BroadcastDomainType.Lswitch ||
                 networkObject.getBroadcastUri() == null) {
             s_logger.warn("BroadcastUri is empty or incorrect for guestnetwork " + networkObject.getDisplayText());
             return;
         }
-        
+
         List<NiciraNvpDeviceVO> devices = _niciraNvpDao.listByPhysicalNetwork(networkObject.getPhysicalNetworkId());
         if (devices.isEmpty()) {
             s_logger.error("No NiciraNvp Controller on physical network " + networkObject.getPhysicalNetworkId());
@@ -244,12 +243,12 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
         }
         NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
         HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
-        
+
         DeleteLogicalSwitchCommand cmd = new DeleteLogicalSwitchCommand(BroadcastDomainType.getValue(networkObject.getBroadcastUri()));
         DeleteLogicalSwitchAnswer answer = (DeleteLogicalSwitchAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
-        
+
         if (answer == null || !answer.getResult()) {
-            s_logger.error ("DeleteLogicalSwitchCommand failed");
+            s_logger.error("DeleteLogicalSwitchCommand failed");
         }
 
         super.shutdown(profile, offering);
@@ -259,9 +258,5 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru {
     public boolean trash(Network network, NetworkOffering offering) {
         return super.trash(network, offering);
     }
-    
-    
-    
-    
-    
+
 }


Mime
View raw message