You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by tu...@apache.org on 2013/12/09 17:52:27 UTC

[01/21] git commit: updated refs/heads/master to 267ff79

Updated Branches:
  refs/heads/master 587f58762 -> 267ff79bf


fix rebase master


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/015ab6af
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/015ab6af
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/015ab6af

Branch: refs/heads/master
Commit: 015ab6af8a7656084596923cdf905ad3ec0debb2
Parents: 9f82757
Author: tuna <ng...@gmail.com>
Authored: Wed Oct 2 08:12:35 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 .../apache/cloudstack/api/ResponseGenerator.java    |  4 ----
 .../admin/router/ConfigureOvsElementCmd.java        |  4 ++--
 .../src/com/cloud/network/element/OvsElement.java   |  4 ++--
 .../com/cloud/network/guru/OvsGuestNetworkGuru.java | 16 ++++++++--------
 .../com/cloud/network/ovs/OvsTunnelManagerImpl.java |  3 +--
 server/src/com/cloud/api/ApiResponseHelper.java     |  1 -
 .../src/com/cloud/network/NetworkServiceImpl.java   |  4 ++++
 .../cloud/network/element/VirtualRouterElement.java | 12 +++++-------
 tools/apidoc/gen_toc.py                             |  2 +-
 9 files changed, 23 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015ab6af/api/src/org/apache/cloudstack/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
index 64b703e..e7a1b35 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -119,9 +119,7 @@ import org.apache.cloudstack.region.PortableIpRange;
 import org.apache.cloudstack.region.Region;
 import org.apache.cloudstack.usage.Usage;
 
-import com.cloud.async.AsyncJob;
 import com.cloud.capacity.Capacity;
-import com.cloud.configuration.Configuration;
 import com.cloud.configuration.ResourceCount;
 import com.cloud.configuration.ResourceLimit;
 import com.cloud.dc.DataCenter;
@@ -359,8 +357,6 @@ public interface ResponseGenerator {
 
 	OvsProviderResponse createOvsProviderResponse(OvsProvider result);
 
-    LDAPConfigResponse createLDAPConfigResponse(String hostname, Integer port, Boolean useSSL, String queryFilter, String baseSearch, String dn);
-
     StorageNetworkIpRangeResponse createStorageNetworkIpRangeResponse(StorageNetworkIpRange result);
 
     RegionResponse createRegionResponse(Region region);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015ab6af/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java
index 0419154..a72dbef 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java
@@ -12,6 +12,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.OvsProviderResponse;
+import org.apache.cloudstack.context.CallContext;
 import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
@@ -21,7 +22,6 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.OvsProvider;
 import com.cloud.network.element.VirtualRouterElementService;
 import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 
 @APICommand(name = "configureOvsElement", responseObject = OvsProviderResponse.class, description = "Configures an ovs element.")
 public class ConfigureOvsElementCmd extends BaseAsyncCmd {
@@ -101,7 +101,7 @@ public class ConfigureOvsElementCmd extends BaseAsyncCmd {
 	@Override
 	public void execute() throws ConcurrentOperationException,
 			ResourceUnavailableException, InsufficientCapacityException {
-		UserContext.current().setEventDetails("Ovs element: " + id);
+		CallContext.current().setEventDetails("Ovs element: " + id);
 		OvsProvider result = _service.get(0).configure(this);
 		if (result != null) {
 			OvsProviderResponse ovsResponse = _responseGenerator

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015ab6af/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index 93b631f..2b625a9 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -154,7 +154,7 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 
 	@Override
 	public boolean prepare(Network network, NicProfile nic,
-			VirtualMachineProfile<? extends VirtualMachine> vm,
+			VirtualMachineProfile vm,
 			DeployDestination dest, ReservationContext context)
 			throws ConcurrentOperationException, ResourceUnavailableException,
 			InsufficientCapacityException {
@@ -177,7 +177,7 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 
 	@Override
 	public boolean release(Network network, NicProfile nic,
-			VirtualMachineProfile<? extends VirtualMachine> vm,
+			VirtualMachineProfile vm,
 			ReservationContext context) throws ConcurrentOperationException,
 			ResourceUnavailableException {
 		if (!canHandle(network, Service.Connectivity)) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015ab6af/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
index 939f98a..59de8e7 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
@@ -20,8 +20,8 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.context.CallContext;
+import org.springframework.stereotype.Component;
 
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
@@ -46,6 +46,7 @@ import com.cloud.network.ovs.OvsTunnelManager;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
 import com.cloud.user.Account;
+import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
@@ -162,7 +163,7 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
 
 	@Override
 	public void reserve(NicProfile nic, Network network,
-			VirtualMachineProfile<? extends VirtualMachine> vm,
+			VirtualMachineProfile vm,
 			DeployDestination dest, ReservationContext context)
 			throws InsufficientVirtualNetworkCapcityException,
 			InsufficientAddressCapacityException {
@@ -172,7 +173,7 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
 
 	@Override
 	public boolean release(NicProfile nic,
-			VirtualMachineProfile<? extends VirtualMachine> vm,
+			VirtualMachineProfile vm,
 			String reservationId) {
 		// TODO Auto-generated method stub
 		return super.release(nic, vm, reservationId);
@@ -192,9 +193,8 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
 	}
 
 	@Override
-	public boolean trash(Network network, NetworkOffering offering,
-			Account owner) {
-		return super.trash(network, offering, owner);
+	public boolean trash(Network network, NetworkOffering offering) {
+		return super.trash(network, offering);
 	}
 
 	@Override
@@ -204,7 +204,7 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
 		if (network.getBroadcastUri() == null) {
 			String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId,
 					network.getAccountId(), reservationId,
-					canUseSystemGuestVlan(network.getAccountId()));
+					UseSystemGuestVlans.valueIn(network.getAccountId()));
 			if (vnet == null) {
 				throw new InsufficientVirtualNetworkCapcityException(
 						"Unable to allocate vnet as a part of network "
@@ -214,7 +214,7 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
 			implemented
 					.setBroadcastUri(BroadcastDomainType.Vswitch.toUri(vnet));
 			ActionEventUtils.onCompletedActionEvent(
-					UserContext.current().getCallerUserId(),
+					CallContext.current().getCallingUserId(),
 					network.getAccountId(),
 					EventVO.LEVEL_INFO,
 					EventTypes.EVENT_ZONE_VLAN_ASSIGN,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015ab6af/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
index 505f57d..bab96a8 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
@@ -440,8 +440,7 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 	}
 
     @Override
-    public void VmCheckAndCreateTunnel(
-    		VirtualMachineProfile<? extends VirtualMachine> vm,
+    public void VmCheckAndCreateTunnel(VirtualMachineProfile vm,
     		Network nw, DeployDestination dest) {
         CheckAndCreateTunnel(vm.getVirtualMachine(), nw, dest);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015ab6af/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index c2a0491..6a99fa6 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -272,7 +272,6 @@ import com.cloud.storage.Snapshot;
 import com.cloud.storage.SnapshotVO;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.StoragePool;
-import com.cloud.storage.Swift;
 import com.cloud.storage.Upload;
 import com.cloud.storage.UploadVO;
 import com.cloud.storage.VMTemplateVO;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015ab6af/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index c24b650..cf4a1c5 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -303,6 +303,10 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
     NetworkACLDao _networkACLDao;
 	@Inject
 	OvsProviderDao _ovsProviderDao;
+	@Inject
+	IpAddressManager _ipAddrMgr;
+	@Inject
+	EntityManager _entityMgr;
 
     int _cidrLimit;
     boolean _allowSubdomainNetworkAccess;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015ab6af/server/src/com/cloud/network/element/VirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java
index 7ceb9a4..37d14f2 100755
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -970,22 +970,20 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     }
 
 	@Override
-	public List<? extends OvsProvider> searchForOvsElement(
-			ListOvsElementsCmd cmd) {
+	public List<? extends OvsProvider> searchForOvsElement(ListOvsElementsCmd cmd) {
 		Long id = cmd.getId();
 		Long nspId = cmd.getNspId();
 		Boolean enabled = cmd.getEnabled();
+		QueryBuilder<OvsProviderVO> sc = QueryBuilder.create(OvsProviderVO.class);
 
-		SearchCriteriaService<OvsProviderVO, OvsProviderVO> sc = SearchCriteria2
-				.create(OvsProviderVO.class);
 		if (id != null) {
-			sc.addAnd(sc.getEntity().getId(), Op.EQ, id);
+			sc.and(sc.entity().getId(), Op.EQ, id);
 		}
 		if (nspId != null) {
-			sc.addAnd(sc.getEntity().getNspId(), Op.EQ, nspId);
+			sc.and(sc.entity().getNspId(), Op.EQ, nspId);
 		}
 		if (enabled != null) {
-			sc.addAnd(sc.getEntity().isEnabled(), Op.EQ, enabled);
+			sc.and(sc.entity().isEnabled(), Op.EQ, enabled);
 		}
 
 		return sc.list();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015ab6af/tools/apidoc/gen_toc.py
----------------------------------------------------------------------
diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py
index dcf132d..d612ac4 100644
--- a/tools/apidoc/gen_toc.py
+++ b/tools/apidoc/gen_toc.py
@@ -159,7 +159,7 @@ known_categories = {
     'UCS' : 'UCS',
     'Ucs' : 'UCS',
     'CacheStores' : 'Cache Stores',
-    'CacheStore' : 'Cache Store'
+    'CacheStore' : 'Cache Store',
     'OvsElement' : 'Ovs Element'
     }
 


[14/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
make SDN GRE work with XCP 1.6


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/79a7ce87
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/79a7ce87
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/79a7ce87

Branch: refs/heads/master
Commit: 79a7ce871eb69531d45ec7ef2137e460fd592956
Parents: 587f587
Author: tuna <ng...@gmail.com>
Authored: Wed Jul 10 22:18:18 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 framework/rest/.gitignore                       |  1 +
 .../xen/resource/CitrixResourceBase.java        | 35 +++++++++++---
 scripts/vm/hypervisor/xenserver/ovstunnel       | 49 ++++++++++++++++----
 scripts/vm/hypervisor/xenserver/xcposs/patch    |  4 ++
 scripts/vm/hypervisor/xenserver/xcpserver/patch |  4 ++
 .../vm/hypervisor/xenserver/xenserver56/patch   |  3 ++
 .../hypervisor/xenserver/xenserver56fp1/patch   |  4 ++
 7 files changed, 84 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79a7ce87/framework/rest/.gitignore
----------------------------------------------------------------------
diff --git a/framework/rest/.gitignore b/framework/rest/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/framework/rest/.gitignore
@@ -0,0 +1 @@
+/target

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79a7ce87/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 6bc8326..4845969 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
@@ -936,8 +936,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 } else {
                     vswitchNw = networks.iterator().next();
                 }
-
-                enableXenServerNetwork(conn, vswitchNw, "vswitch", "vswitch network");
+                if (!is_xcp())
+                	enableXenServerNetwork(conn, vswitchNw, "vswitch", "vswitch network");
                 _host.vswitchNetwork = vswitchNw;
             }
             return _host.vswitchNetwork;
@@ -971,7 +971,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
                 rec.otherConfig = otherConfig;
                 nw = Network.create(conn, rec);
                 // Plug dom0 vif only when creating network
-                enableXenServerNetwork(conn, nw, nwName, "tunnel network for account " + key);
+                if (!is_xcp())
+                	enableXenServerNetwork(conn, nw, nwName, "tunnel network for account " + key);
                 s_logger.debug("### Xen Server network for tunnels created:" + nwName);
             } else {
                 nw = networks.iterator().next();
@@ -1007,10 +1008,12 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
             }
             if (!configured) {
                 // Plug dom0 vif only if not done before for network and host
-                enableXenServerNetwork(conn, nw, nwName, "tunnel network for account " + key);
-                String result =
-                    callHostPlugin(conn, "ovstunnel", "setup_ovs_bridge", "bridge", bridge, "key", String.valueOf(key), "xs_nw_uuid", nw.getUuid(conn), "cs_host_id",
-                        ((Long)hostId).toString());
+            	if (!is_xcp())
+            		enableXenServerNetwork(conn, nw, nwName, "tunnel network for account " + key);
+                String result = callHostPlugin(conn, "ovstunnel", "setup_ovs_bridge", "bridge", bridge,
+                        "key", String.valueOf(key),
+                        "xs_nw_uuid", nw.getUuid(conn),
+                        "cs_host_id", ((Long)hostId).toString());
                 //Note down the fact that the ovs bridge has been setup
                 String[] res = result.split(":");
                 if (res.length != 2 || !res[0].equalsIgnoreCase("SUCCESS")) {
@@ -5864,6 +5867,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     private OvsFetchInterfaceAnswer execute(OvsFetchInterfaceCommand cmd) {
 
         String label = cmd.getLabel();
+        //FIXME: this is a tricky to pass the network checking in XCP. I temporary get default label from Host.
+        if (is_xcp()) {
+        	label = getLabel();
+        }
         s_logger.debug("Will look for network with name-label:" + label + " on host " + _host.ip);
         Connection conn = getConnection();
         try {
@@ -8734,4 +8741,18 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     @Override
     public void setRunLevel(int level) {
     }
+    
+    private boolean is_xcp() {
+    	Connection conn = getConnection();
+    	String result = callHostPlugin(conn, "ovstunnel", "is_xcp");
+    	if (result.equals("XCP"))
+    		return true;
+    	return false;
+    }
+    
+    private String getLabel() {
+    	Connection conn = getConnection();
+    	String result = callHostPlugin(conn, "ovstunnel", "getLabel");
+    	return result;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79a7ce87/scripts/vm/hypervisor/xenserver/ovstunnel
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/ovstunnel b/scripts/vm/hypervisor/xenserver/ovstunnel
index ddcaa5b..9a89630 100755
--- a/scripts/vm/hypervisor/xenserver/ovstunnel
+++ b/scripts/vm/hypervisor/xenserver/ovstunnel
@@ -22,6 +22,7 @@
 
 import cloudstack_pluginlib as lib
 import logging
+import commands
 import os
 import sys
 import subprocess
@@ -107,14 +108,15 @@ def setup_ovs_bridge(session, args):
                    "other-config:ovs-host-setup=%s" % conf_hosts])
 
         # BLOCK IPv6 - Flow spec changes with ovs version
-        host_list_cmd = [lib.XE_PATH, 'host-list', '--minimal']
-        host_list_str = lib.do_cmd(host_list_cmd)
-        host_uuid = host_list_str.split(',')[0].strip()
-        version_cmd = [lib.XE_PATH, 'host-param-get', 'uuid=%s' % host_uuid,
-                                   'param-name=software-version',
-                                   'param-key=product_version']
-        version = lib.do_cmd(version_cmd).split('.')[0]
-        block_ipv6_handlers[version](bridge)
+        # Temporarily no need BLOCK IPv6
+#        host_list_cmd = [lib.XE_PATH, 'host-list', '--minimal']
+#        host_list_str = lib.do_cmd(host_list_cmd)
+#        host_uuid = host_list_str.split(',')[0].strip()
+#        version_cmd = [lib.XE_PATH, 'host-param-get', 'uuid=%s' % host_uuid,
+#                                   'param-name=software-version',
+#                                   'param-key=product_version']
+#        version = lib.do_cmd(version_cmd).split('.')[0]
+#        block_ipv6_handlers[version](bridge)
     logging.debug("Setup_ovs_bridge completed with result:%s" % result)
     return result
 
@@ -253,9 +255,38 @@ def get_field_of_interface(iface_name, field):
     res = lib.do_cmd(get_iface_cmd)
     return res
 
+def is_xcp(session, args):
+    host_list_cmd = [lib.XE_PATH, 'host-list', '--minimal']
+    host_list_str = lib.do_cmd(host_list_cmd)
+    host_uuid = host_list_str.split(',')[0].strip()
+
+    status, output = commands.getstatusoutput("xe host-param-list uuid="+host_uuid+" | grep platform_name")
+    if (status != 0):
+       return "FALSE"
+
+    platform_cmd = [lib.XE_PATH, 'host-param-get', 'uuid=%s' % host_uuid,
+                               'param-name=software-version',
+                               'param-key=platform_name']
+    platform = lib.do_cmd(platform_cmd).split('.')[0]
+    return platform                           
+
+def getLabel(session, args):
+    pif_list_cmd = [lib.XE_PATH, 'pif-list', '--minimal']
+    pif_list_str = lib.do_cmd(pif_list_cmd)
+    pif_uuid = pif_list_str.split(',')[0].strip()
+    network_cmd = [lib.XE_PATH, 'pif-param-get', 'uuid=%s' % pif_uuid,
+                               'param-name=network-uuid']
+    network_uuid = lib.do_cmd(network_cmd).split('.')[0]
+
+    label_cmd = [lib.XE_PATH, 'network-param-get', 'uuid=%s' % network_uuid,
+                               'param-name=name-label']
+    label = lib.do_cmd(label_cmd).split('.')[0]
+    return label
 
 if __name__ == "__main__":
     XenAPIPlugin.dispatch({"create_tunnel": create_tunnel,
                            "destroy_tunnel": destroy_tunnel,
                            "setup_ovs_bridge": setup_ovs_bridge,
-                           "destroy_ovs_bridge": destroy_ovs_bridge})
+                           "destroy_ovs_bridge": destroy_ovs_bridge,
+                           "is_xcp": is_xcp,
+                           "getLabel": getLabel})

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79a7ce87/scripts/vm/hypervisor/xenserver/xcposs/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xcposs/patch b/scripts/vm/hypervisor/xenserver/xcposs/patch
index aa551de..efb4a18 100644
--- a/scripts/vm/hypervisor/xenserver/xcposs/patch
+++ b/scripts/vm/hypervisor/xenserver/xcposs/patch
@@ -66,3 +66,7 @@ getDomRVersion.sh=../../../../network/domr/,0755,/opt/cloud/bin
 router_proxy.sh=../../../../network/domr/,0755,/opt/cloud/bin
 createipAlias.sh=..,0755,/opt/cloud/bin
 deleteipAlias.sh=..,0755,/opt/cloud/bin
+
+###add cloudstack plugin script for XCP
+cloudstack_plugins.conf=..,0644,/etc/xensource
+cloudstack_pluginlib.py=..,0755,/etc/xapi.d/plugins

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79a7ce87/scripts/vm/hypervisor/xenserver/xcpserver/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xcpserver/patch b/scripts/vm/hypervisor/xenserver/xcpserver/patch
index 478807f..45ff59d 100644
--- a/scripts/vm/hypervisor/xenserver/xcpserver/patch
+++ b/scripts/vm/hypervisor/xenserver/xcpserver/patch
@@ -64,3 +64,7 @@ getRouterStatus.sh=../../../../network/domr/,0755,/opt/cloud/bin
 bumpUpPriority.sh=../../../../network/domr/,0755,/opt/cloud/bin
 getDomRVersion.sh=../../../../network/domr/,0755,/opt/cloud/bin
 add_to_vcpus_params_live.sh=..,0755,/opt/cloud/bin
+
+###add cloudstack plugin script for XCP
+cloudstack_plugins.conf=..,0644,/etc/xensource
+cloudstack_pluginlib.py=..,0755,/etc/xapi.d/plugins

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79a7ce87/scripts/vm/hypervisor/xenserver/xenserver56/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xenserver56/patch b/scripts/vm/hypervisor/xenserver/xenserver56/patch
index e593a5c..602cb99 100644
--- a/scripts/vm/hypervisor/xenserver/xenserver56/patch
+++ b/scripts/vm/hypervisor/xenserver/xenserver56/patch
@@ -66,3 +66,6 @@ swiftxen=..,0755,/etc/xapi.d/plugins
 s3xen=..,0755,/etc/xapi.d/plugins
 add_to_vcpus_params_live.sh=..,0755,/opt/cloud/bin
 
+###add cloudstack plugin script for XCP
+cloudstack_plugins.conf=..,0644,/etc/xensource
+cloudstack_pluginlib.py=..,0755,/etc/xapi.d/plugins

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79a7ce87/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch
index b210a88..8e72c00 100644
--- a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch
+++ b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch
@@ -65,3 +65,7 @@ swiftxen=..,0755,/etc/xapi.d/plugins
 s3xen=..,0755,/etc/xapi.d/plugins
 add_to_vcpus_params_live.sh=..,0755,/opt/cloud/bin
 
+###add cloudstack plugin script for XCP
+cloudstack_plugins.conf=..,0644,/etc/xensource
+cloudstack_pluginlib.py=..,0755,/etc/xapi.d/plugins
+


[21/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
remove unused code


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/61e80f03
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/61e80f03
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/61e80f03

Branch: refs/heads/master
Commit: 61e80f030ae27e1c08360c8c2153c56a25c095ae
Parents: 7efab20
Author: tuna <ng...@gmail.com>
Authored: Mon Nov 4 18:22:54 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:15 2013 +0700

----------------------------------------------------------------------
 api/src/com/cloud/event/EventTypes.java         |   3 -
 client/pom.xml                                  |   7 -
 client/tomcatconf/applicationContext.xml.in     | 940 -------------------
 client/tomcatconf/commands.properties.in        |   6 -
 .../kvm/resource/LibvirtComputingResource.java  |   9 +-
 .../xen/resource/CitrixResourceBase.java        |  26 +-
 .../cloud/network/guru/OvsGuestNetworkGuru.java |   7 +-
 plugins/pom.xml                                 |   1 -
 .../network/guru/ExternalGuestNetworkGuru.java  |  35 -
 utils/conf/db.properties                        |   2 +-
 10 files changed, 16 insertions(+), 1020 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e80f03/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index 5d6ee6f..d3c29e9 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -400,9 +400,6 @@ public class EventTypes {
     public static final String EVENT_EXTERNAL_NVP_CONTROLLER_CONFIGURE = "PHYSICAL.NVPCONTROLLER.CONFIGURE";
     public static final String EVENT_EXTERNAL_OVS_CONTROLLER_ADD = "PHYSICAL.OVSCONTROLLER.ADD";
     public static final String EVENT_EXTERNAL_OVS_CONTROLLER_DELETE = "PHYSICAL.OVSCONTROLLER.DELETE";
-	public static final String EVENT_EXTERNAL_ODL_CONTROLLER_ADD = "PHYSICAL.ODLCONTROLLER.ADD";
-	public static final String EVENT_EXTERNAL_ODL_CONTROLLER_DELETE = "PHYSICAL.ODLCONTROLLER.DELETE";
-	public static final String EVENT_EXTERNAL_ODL_CONTROLLER_CONFIGURE = "PHYSICAL.ODLCONTROLLER.CONFIGURE";
 
     // AutoScale
     public static final String EVENT_COUNTER_CREATE = "COUNTER.CREATE";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e80f03/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 1f01693..fc01113 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -85,13 +85,6 @@
       <artifactId>cloud-plugin-network-nvp</artifactId>
       <version>${project.version}</version>
     </dependency>
-<!--     
-    <dependency>
-      <groupId>org.apache.cloudstack</groupId>
-      <artifactId>cloud-plugin-network-odl</artifactId>
-      <version>${project.version}</version>
-    </dependency>
- -->    
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-plugin-network-contrail</artifactId>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e80f03/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
deleted file mode 100644
index b610227..0000000
--- a/client/tomcatconf/applicationContext.xml.in
+++ /dev/null
@@ -1,940 +0,0 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements. See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership. The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License. You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied. See the License for the
-  specific language governing permissions and limitations
-  under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:context="http://www.springframework.org/schema/context"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-
-
-
-
-                      http://www.springframework.org/schema/context
-                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">                     
-
-  <context:annotation-config />
-
-<!--=====================================================================================================-->
-<!--                                                                                                     -->
-<!--                           core OSS/non-OSS Common components                                        -->  
-<!--                                                                                                     -->
-<!--=====================================================================================================-->
-
-  <!--
-    @DB support
-  -->
-  <bean id="componentContext" class="com.cloud.utils.component.ComponentContext" />
-  <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
-  <bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
-
-  <bean id="instantiatePostProcessor" class="com.cloud.utils.component.ComponentInstantiationPostProcessor">
-    <property name="Interceptors">
-        <list>
-            <ref bean="transactionContextBuilder" />
-            <ref bean="actionEventInterceptor" />
-        </list>
-    </property>
-  </bean>
-
-  <!--
-    RPC/Async/EventBus
-  -->
-
-  <bean id="onwireRegistry" class="org.apache.cloudstack.framework.serializer.OnwireClassRegistry"
-    init-method="scan" >
-    <property name="packages">
-      <list>
-        <value>org.apache.cloudstack.framework</value>
-      </list>
-    </property>
-  </bean>
-  
-  <bean id="messageSerializer" class="org.apache.cloudstack.framework.serializer.JsonMessageSerializer">
-    <property name="onwireClassRegistry" ref="onwireRegistry" />
-  </bean>
-
-  <bean id="transportProvider" class="org.apache.cloudstack.framework.server.ServerTransportProvider"  init-method="initialize">
-    <property name="workerPoolSize" value="5" />
-    <property name="nodeId" value="Node1" />
-    <property name="messageSerializer" ref="messageSerializer" />
-  </bean>
-  
-  <bean id="rpcProvider" class="org.apache.cloudstack.framework.rpc.RpcProviderImpl" init-method="initialize">
-    <constructor-arg ref="transportProvider" />
-    <property name="messageSerializer" ref="messageSerializer" />
-  </bean>
-
-  <bean id="messageBus" class = "org.apache.cloudstack.framework.messagebus.MessageBusBase" />
-  <bean id="configDepot" class = "org.apache.cloudstack.framework.config.impl.ConfigDepotImpl" />
-
-  <!--
-    DAO with customized configuration
-  -->
-  <bean id="serviceOfferingDaoImpl" class="com.cloud.service.dao.ServiceOfferingDaoImpl">
-    <property name="configParams">
-      <map>
-        <entry key="cache.size" value="50" />
-        <entry key="cache.time.to.live" value="600" />
-      </map>
-    </property>  
-  </bean>
-
-  <bean id="diskOfferingDaoImpl" class="com.cloud.storage.dao.DiskOfferingDaoImpl">
-    <property name="configParams">
-      <map>
-        <entry key="cache.size" value="50" />
-        <entry key="cache.time.to.live" value="600" />
-      </map>
-    </property>  
-  </bean>
-
-  <bean id="dataCenterDaoImpl" class="com.cloud.dc.dao.DataCenterDaoImpl">
-    <property name="configParams">
-      <map>
-        <entry key="cache.size" value="50" />
-        <entry key="cache.time.to.live" value="600" />
-      </map>
-    </property>  
-  </bean>
-
-  <bean id="hostPodDaoImpl" class="com.cloud.dc.dao.HostPodDaoImpl">
-    <property name="configParams">
-      <map>
-        <entry key="cache.size" value="50" />
-        <entry key="cache.time.to.live" value="600" />
-      </map>
-    </property>  
-  </bean>
-
-  <bean id="vlanDaoImpl" class="com.cloud.dc.dao.VlanDaoImpl">
-    <property name="configParams">
-      <map>
-        <entry key="cache.size" value="30" />
-        <entry key="cache.time.to.live" value="3600" />
-      </map>
-    </property>  
-  </bean>
-
-  <bean id="userDaoImpl" class="com.cloud.user.dao.UserDaoImpl">
-    <property name="configParams">
-      <map>
-        <entry key="cache.size" value="5000" />
-        <entry key="cache.time.to.live" value="300" />
-      </map>
-    </property>  
-  </bean>
-
-  <bean id="VMTemplateDaoImpl" class="com.cloud.storage.dao.VMTemplateDaoImpl">
-    <property name="configParams">
-      <map>
-        <entry key="cache.size" value="100" />
-        <entry key="cache.time.to.live" value="600" />
-      </map>
-    </property>  
-  </bean>
-
-  <bean id="hypervisorCapabilitiesDaoImpl" class="com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl">
-    <property name="configParams">
-      <map>
-        <entry key="cache.size" value="100" />
-        <entry key="cache.time.to.live" value="600" />
-      </map>
-    </property>  
-  </bean>
-  <bean id="dedicatedResourceDaoImpl" class="com.cloud.dc.dao.DedicatedResourceDaoImpl">
-    <property name="configParams">
-      <map>
-        <entry key="cache.size" value="30" />
-        <entry key="cache.time.to.live" value="3600" />
-      </map>
-    </property>
-  </bean>
-  
-  <!--
-    DAOs with default configuration
-  -->
-  <bean id="accountDaoImpl" class="com.cloud.user.dao.AccountDaoImpl" />
-  <bean id="accountDetailsDaoImpl" class="com.cloud.user.AccountDetailsDaoImpl" />
-  <bean id="accountJoinDaoImpl" class="com.cloud.api.query.dao.AccountJoinDaoImpl" />
-  <bean id="accountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl" />
-  <bean id="accountVlanMapDaoImpl" class="com.cloud.dc.dao.AccountVlanMapDaoImpl" />
-  <bean id="alertDaoImpl" class="com.cloud.alert.dao.AlertDaoImpl" />
-  <bean id="asyncJobJoinDaoImpl" class="com.cloud.api.query.dao.AsyncJobJoinDaoImpl" />
-  <bean id="autoScalePolicyConditionMapDaoImpl" class="com.cloud.network.as.dao.AutoScalePolicyConditionMapDaoImpl" />
-  <bean id="autoScalePolicyDaoImpl" class="com.cloud.network.as.dao.AutoScalePolicyDaoImpl" />
-  <bean id="autoScaleVmGroupDaoImpl" class="com.cloud.network.as.dao.AutoScaleVmGroupDaoImpl" />
-  <bean id="autoScaleVmGroupPolicyMapDaoImpl" class="com.cloud.network.as.dao.AutoScaleVmGroupPolicyMapDaoImpl" />
-  <bean id="autoScaleVmProfileDaoImpl" class="com.cloud.network.as.dao.AutoScaleVmProfileDaoImpl" />
-  <bean id="capacityDaoImpl" class="com.cloud.capacity.dao.CapacityDaoImpl" />
-  <bean id="certificateDaoImpl" class="com.cloud.certificate.dao.CertificateDaoImpl" />
-  <bean id="clusterDaoImpl" class="com.cloud.dc.dao.ClusterDaoImpl" />
-  <bean id="clusterDetailsDaoImpl" class="com.cloud.dc.ClusterDetailsDaoImpl" />
-  <bean id="clusterVSMMapDaoImpl" class="com.cloud.dc.dao.ClusterVSMMapDaoImpl" />
-  <bean id="commandExecLogDaoImpl" class="com.cloud.secstorage.CommandExecLogDaoImpl" />
-  <bean id="conditionDaoImpl" class="com.cloud.network.as.dao.ConditionDaoImpl" />
-  <bean id="consoleProxyDaoImpl" class="com.cloud.vm.dao.ConsoleProxyDaoImpl" />
-  <bean id="counterDaoImpl" class="com.cloud.network.as.dao.CounterDaoImpl" />
-  <bean id="dataCenterIpAddressDaoImpl" class="com.cloud.dc.dao.DataCenterIpAddressDaoImpl" />
-  <bean id="dataCenterJoinDaoImpl" class="com.cloud.api.query.dao.DataCenterJoinDaoImpl" />
-  <bean id="dataCenterLinkLocalIpAddressDaoImpl" class="com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl" />
-  <bean id="dataCenterVnetDaoImpl" class="com.cloud.dc.dao.DataCenterVnetDaoImpl" />
-  <bean id="dcDetailsDaoImpl" class="com.cloud.dc.dao.DcDetailsDaoImpl" />
-  <bean id="engineDcDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.DcDetailsDaoImpl" />
-  <bean id="diskOfferingJoinDaoImpl" class="com.cloud.api.query.dao.DiskOfferingJoinDaoImpl" />
-  <bean id="domainDaoImpl" class="com.cloud.domain.dao.DomainDaoImpl" />
-  <bean id="domainRouterDaoImpl" class="com.cloud.vm.dao.DomainRouterDaoImpl" />
-  <bean id="domainRouterJoinDaoImpl" class="com.cloud.api.query.dao.DomainRouterJoinDaoImpl" />
-  <bean id="elasticLbVmMapDaoImpl" class="com.cloud.network.lb.dao.ElasticLbVmMapDaoImpl" />
-  <bean id="engineClusterDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDaoImpl" />
-  <bean id="engineDataCenterDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDaoImpl" />
-  <bean id="engineHostDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDaoImpl" />
-  <bean id="engineHostPodDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDaoImpl" />
-  <bean id="eventDaoImpl" class="com.cloud.event.dao.EventDaoImpl" />
-  <bean id="eventJoinDaoImpl" class="com.cloud.event.dao.EventJoinDaoImpl" />
-  <bean id="externalFirewallDeviceDaoImpl" class="com.cloud.network.dao.ExternalFirewallDeviceDaoImpl" />
-  <bean id="externalLoadBalancerDeviceDaoImpl" class="com.cloud.network.dao.ExternalLoadBalancerDeviceDaoImpl" />
-  <bean id="externalPublicIpStatisticsDaoImpl" class="com.cloud.usage.dao.ExternalPublicIpStatisticsDaoImpl" />
-  <bean id="firewallRulesCidrsDaoImpl" class="com.cloud.network.dao.FirewallRulesCidrsDaoImpl" />
-  <bean id="firewallRulesDaoImpl" class="com.cloud.network.dao.FirewallRulesDaoImpl" />
-  <bean id="globalLoadBalancerDaoImpl" class="org.apache.cloudstack.region.gslb.GlobalLoadBalancerDaoImpl" />
-  <bean id="globalLoadBalancerLbRuleMapDaoImpl" class="org.apache.cloudstack.region.gslb.GlobalLoadBalancerLbRuleMapDaoImpl" />
-  <bean id="guestOSCategoryDaoImpl" class="com.cloud.storage.dao.GuestOSCategoryDaoImpl" />
-  <bean id="guestOSDaoImpl" class="com.cloud.storage.dao.GuestOSDaoImpl" />
-  <bean id="guestOSHypervisorDaoImpl" class="com.cloud.storage.dao.GuestOSHypervisorDaoImpl" />
-  <bean id="highAvailabilityDaoImpl" class="com.cloud.ha.dao.HighAvailabilityDaoImpl" />
-  <bean id="hostDaoImpl" class="com.cloud.host.dao.HostDaoImpl" />
-  <bean id="engineHostDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostDetailsDaoImpl" />
-  <bean id="hostDetailsDaoImpl" class="com.cloud.host.dao.HostDetailsDaoImpl" />
-  <bean id="hostJoinDaoImpl" class="com.cloud.api.query.dao.HostJoinDaoImpl" />
-  <bean id="engineHostTagsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostTagsDaoImpl" />
-  <bean id="hostTagsDaoImpl" class="com.cloud.host.dao.HostTagsDaoImpl" />
-  <bean id="hostTransferMapDaoImpl" class="com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl" />
-  <bean id="iPAddressDaoImpl" class="com.cloud.network.dao.IPAddressDaoImpl" />
-  <bean id="identityDaoImpl" class="com.cloud.uuididentity.dao.IdentityDaoImpl" />
-  <bean id="imageStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDaoImpl" />
-  <bean id="imageStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDetailsDaoImpl" /> 
-  <bean id="imageStoreJoinDaoImpl" class="com.cloud.api.query.dao.ImageStoreJoinDaoImpl" />   
-  <bean id="snapshotDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.SnapshotDataStoreDaoImpl" /> 
-  <bean id="templateDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.TemplateDataStoreDaoImpl" /> 
-  <bean id="templateJoinDaoImpl" class="com.cloud.api.query.dao.TemplateJoinDaoImpl" />
-  <bean id="volumeDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.VolumeDataStoreDaoImpl" />   
-  <bean id="inlineLoadBalancerNicMapDaoImpl" class="com.cloud.network.dao.InlineLoadBalancerNicMapDaoImpl" />
-  <bean id="instanceGroupDaoImpl" class="com.cloud.vm.dao.InstanceGroupDaoImpl" />
-  <bean id="instanceGroupJoinDaoImpl" class="com.cloud.api.query.dao.InstanceGroupJoinDaoImpl" />
-  <bean id="instanceGroupVMMapDaoImpl" class="com.cloud.vm.dao.InstanceGroupVMMapDaoImpl" />
-  <bean id="itWorkDaoImpl" class="com.cloud.vm.ItWorkDaoImpl" />
-  <bean id="keystoreDaoImpl" class="com.cloud.keystore.KeystoreDaoImpl" />
-  <bean id="lBHealthCheckPolicyDaoImpl" class="com.cloud.network.dao.LBHealthCheckPolicyDaoImpl" />
-  <bean id="lBStickinessPolicyDaoImpl" class="com.cloud.network.dao.LBStickinessPolicyDaoImpl" />
-  <bean id="launchPermissionDaoImpl" class="com.cloud.storage.dao.LaunchPermissionDaoImpl" />
-  <bean id="loadBalancerDaoImpl" class="com.cloud.network.dao.LoadBalancerDaoImpl" />
-  <bean id="loadBalancerVMMapDaoImpl" class="com.cloud.network.dao.LoadBalancerVMMapDaoImpl" />
-  <bean id="managementServerHostDaoImpl" class="com.cloud.cluster.dao.ManagementServerHostDaoImpl" />
-  <bean id="managementServerHostPeerDaoImpl" class="com.cloud.cluster.dao.ManagementServerHostPeerDaoImpl" />
-  <bean id="networkAccountDaoImpl" class="com.cloud.network.dao.NetworkAccountDaoImpl" />
-  <bean id="networkACLDaoImpl" class="com.cloud.network.vpc.dao.NetworkACLDaoImpl" />
-  <bean id="networkACLItemDaoImpl" class="com.cloud.network.vpc.dao.NetworkACLItemDaoImpl" />
-  <bean id="networkDaoImpl" class="com.cloud.network.dao.NetworkDaoImpl" />
-  <bean id="networkDomainDaoImpl" class="com.cloud.network.dao.NetworkDomainDaoImpl" />
-  <bean id="networkExternalFirewallDaoImpl" class="com.cloud.network.dao.NetworkExternalFirewallDaoImpl" />
-  <bean id="networkExternalLoadBalancerDaoImpl" class="com.cloud.network.dao.NetworkExternalLoadBalancerDaoImpl" />
-  <bean id="networkOfferingDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingDaoImpl" />
-  <bean id="networkOfferingServiceMapDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingServiceMapDaoImpl" />
-  <bean id="networkOpDaoImpl" class="com.cloud.network.dao.NetworkOpDaoImpl" />
-  <bean id="networkRuleConfigDaoImpl" class="com.cloud.network.dao.NetworkRuleConfigDaoImpl" />
-  <bean id="networkServiceMapDaoImpl" class="com.cloud.network.dao.NetworkServiceMapDaoImpl" />
-  <bean id="nicDaoImpl" class="com.cloud.vm.dao.NicDaoImpl" />
-  <bean id="nicDetailDaoImpl" class="com.cloud.vm.dao.NicDetailDaoImpl" />
-  <bean id="nicSecondaryIpDaoImpl" class="com.cloud.vm.dao.NicSecondaryIpDaoImpl" />
-  <bean id="nicIpAliasDaoImpl" class="com.cloud.vm.dao.NicIpAliasDaoImpl" />
-  <bean id="objectInDataStoreDaoImpl" class="org.apache.cloudstack.storage.db.ObjectInDataStoreDaoImpl" />
-  <bean id="ovsTunnelInterfaceDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" />
-  <bean id="ovsTunnelNetworkDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" />
-  <bean id="physicalNetworkDaoImpl" class="com.cloud.network.dao.PhysicalNetworkDaoImpl" />
-  <bean id="physicalNetworkIsolationMethodDaoImpl" class="com.cloud.network.dao.PhysicalNetworkIsolationMethodDaoImpl" />
-  <bean id="physicalNetworkServiceProviderDaoImpl" class="com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl" />
-  <bean id="physicalNetworkTagDaoImpl" class="com.cloud.network.dao.PhysicalNetworkTagDaoImpl" />
-  <bean id="physicalNetworkTrafficTypeDaoImpl" class="com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl" />
-  <bean id="podVlanDaoImpl" class="com.cloud.dc.dao.PodVlanDaoImpl" />
-  <bean id="podVlanMapDaoImpl" class="com.cloud.dc.dao.PodVlanMapDaoImpl" />
-  <bean id="PortableIpDaoImpl" class="org.apache.cloudstack.region.PortableIpDaoImpl" />
-  <bean id="PortableIpRangeDaoImpl" class="org.apache.cloudstack.region.PortableIpRangeDaoImpl" />
-  <bean id="portForwardingRulesDaoImpl" class="com.cloud.network.rules.dao.PortForwardingRulesDaoImpl" />
-  <bean id="portProfileDaoImpl" class="com.cloud.network.dao.PortProfileDaoImpl" />
-  <bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" />
-  <bean id="primaryDataStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.volume.db.PrimaryDataStoreDetailsDaoImpl" />
-  <bean id="privateIpDaoImpl" class="com.cloud.network.vpc.dao.PrivateIpDaoImpl" />
-  <bean id="projectAccountDaoImpl" class="com.cloud.projects.dao.ProjectAccountDaoImpl" />
-  <bean id="projectAccountJoinDaoImpl" class="com.cloud.api.query.dao.ProjectAccountJoinDaoImpl" />
-  <bean id="projectDaoImpl" class="com.cloud.projects.dao.ProjectDaoImpl" />
-  <bean id="projectInvitationDaoImpl" class="com.cloud.projects.dao.ProjectInvitationDaoImpl" />
-  <bean id="projectInvitationJoinDaoImpl" class="com.cloud.api.query.dao.ProjectInvitationJoinDaoImpl" />
-  <bean id="projectJoinDaoImpl" class="com.cloud.api.query.dao.ProjectJoinDaoImpl" />
-  <bean id="regionDaoImpl" class="org.apache.cloudstack.region.dao.RegionDaoImpl" />
-  <bean id="remoteAccessVpnDaoImpl" class="com.cloud.network.dao.RemoteAccessVpnDaoImpl" />
-  <bean id="resourceCountDaoImpl" class="com.cloud.configuration.dao.ResourceCountDaoImpl" />
-  <bean id="resourceLimitDaoImpl" class="com.cloud.configuration.dao.ResourceLimitDaoImpl" />
-  <bean id="resourceTagJoinDaoImpl" class="com.cloud.api.query.dao.ResourceTagJoinDaoImpl" />
-  <bean id="resourceTagsDaoImpl" class="com.cloud.tags.dao.ResourceTagsDaoImpl" />
-  <bean id="routerNetworkDaoImpl" class="com.cloud.network.dao.RouterNetworkDaoImpl" />
-  <bean id="sSHKeyPairDaoImpl" class="com.cloud.user.dao.SSHKeyPairDaoImpl" />
-  <bean id="secondaryStorageVmDaoImpl" class="com.cloud.vm.dao.SecondaryStorageVmDaoImpl" />
-  <bean id="securityGroupDaoImpl" class="com.cloud.network.security.dao.SecurityGroupDaoImpl" />
-  <bean id="securityGroupJoinDaoImpl" class="com.cloud.api.query.dao.SecurityGroupJoinDaoImpl" />
-  <bean id="securityGroupRuleDaoImpl" class="com.cloud.network.security.dao.SecurityGroupRuleDaoImpl" />
-  <bean id="securityGroupRulesDaoImpl" class="com.cloud.network.security.dao.SecurityGroupRulesDaoImpl" />
-  <bean id="securityGroupVMMapDaoImpl" class="com.cloud.network.security.dao.SecurityGroupVMMapDaoImpl" />
-  <bean id="securityGroupWorkDaoImpl" class="com.cloud.network.security.dao.SecurityGroupWorkDaoImpl" />
-  <bean id="serviceOfferingJoinDaoImpl" class="com.cloud.api.query.dao.ServiceOfferingJoinDaoImpl" />
-  <bean id="site2SiteCustomerGatewayDaoImpl" class="com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl" />
-  <bean id="site2SiteVpnConnectionDaoImpl" class="com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl" />
-  <bean id="site2SiteVpnGatewayDaoImpl" class="com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl" />
-  <bean id="snapshotDaoImpl" class="com.cloud.storage.dao.SnapshotDaoImpl" />
-  <bean id="snapshotPolicyDaoImpl" class="com.cloud.storage.dao.SnapshotPolicyDaoImpl" />
-  <bean id="snapshotScheduleDaoImpl" class="com.cloud.storage.dao.SnapshotScheduleDaoImpl" />
-  <bean id="staticRouteDaoImpl" class="com.cloud.network.vpc.dao.StaticRouteDaoImpl" />
-  <bean id="storageNetworkIpAddressDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpAddressDaoImpl" />
-  <bean id="storageNetworkIpRangeDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpRangeDaoImpl" />
-  <bean id="storagePoolDetailsDaoImpl" class="com.cloud.storage.dao.StoragePoolDetailsDaoImpl" />
-  <bean id="storagePoolHostDaoImpl" class="com.cloud.storage.dao.StoragePoolHostDaoImpl" />
-  <bean id="storagePoolJoinDaoImpl" class="com.cloud.api.query.dao.StoragePoolJoinDaoImpl" />
-  <bean id="storagePoolWorkDaoImpl" class="com.cloud.storage.dao.StoragePoolWorkDaoImpl" />
-  <bean id="templatePrimaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDaoImpl" />
-  <bean id="uploadDaoImpl" class="com.cloud.storage.dao.UploadDaoImpl" />
-  <bean id="usageDaoImpl" class="com.cloud.usage.dao.UsageDaoImpl" />
-  <bean id="usageEventDaoImpl" class="com.cloud.event.dao.UsageEventDaoImpl" />
-  <bean id="usageIPAddressDaoImpl" class="com.cloud.usage.dao.UsageIPAddressDaoImpl" />
-  <bean id="usageJobDaoImpl" class="com.cloud.usage.dao.UsageJobDaoImpl" />
-  <bean id="usageLoadBalancerPolicyDaoImpl" class="com.cloud.usage.dao.UsageLoadBalancerPolicyDaoImpl" />
-  <bean id="usageNetworkDaoImpl" class="com.cloud.usage.dao.UsageNetworkDaoImpl" />
-  <bean id="usageNetworkOfferingDaoImpl" class="com.cloud.usage.dao.UsageNetworkOfferingDaoImpl" />
-  <bean id="usagePortForwardingRuleDaoImpl" class="com.cloud.usage.dao.UsagePortForwardingRuleDaoImpl" />
-  <bean id="usageSecurityGroupDaoImpl" class="com.cloud.usage.dao.UsageSecurityGroupDaoImpl" />
-  <bean id="usageStorageDaoImpl" class="com.cloud.usage.dao.UsageStorageDaoImpl" />
-  <bean id="usageVMInstanceDaoImpl" class="com.cloud.usage.dao.UsageVMInstanceDaoImpl" />
-  <bean id="usageVPNUserDaoImpl" class="com.cloud.usage.dao.UsageVPNUserDaoImpl" />
-  <bean id="usageVolumeDaoImpl" class="com.cloud.usage.dao.UsageVolumeDaoImpl" />
-  <bean id="usageVmDiskDaoImpl" class="com.cloud.usage.dao.UsageVmDiskDaoImpl" />
-  <bean id="userAccountDaoImpl" class="com.cloud.user.dao.UserAccountDaoImpl" />
-  <bean id="userAccountJoinDaoImpl" class="com.cloud.api.query.dao.UserAccountJoinDaoImpl" />
-  <bean id="userIpv6AddressDaoImpl" class="com.cloud.network.dao.UserIpv6AddressDaoImpl" />
-  <bean id="userStatisticsDaoImpl" class="com.cloud.user.dao.UserStatisticsDaoImpl" />
-  <bean id="userStatsLogDaoImpl" class="com.cloud.user.dao.UserStatsLogDaoImpl" />
-  <bean id="userVmDiskStatsDaoImpl" class="com.cloud.user.dao.VmDiskStatisticsDaoImpl" />
-  <bean id="userVmCloneSettingDaoImpl" class="com.cloud.vm.dao.UserVmCloneSettingDaoImpl" />
-  <bean id="userVmDaoImpl" class="com.cloud.vm.dao.UserVmDaoImpl" />
-  <bean id="userVmDetailsDaoImpl" class="com.cloud.vm.dao.UserVmDetailsDaoImpl" />
-  <bean id="userVmJoinDaoImpl" class="com.cloud.api.query.dao.UserVmJoinDaoImpl" />
-  <bean id="vMComputeTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMComputeTagDaoImpl" />
-  <bean id="vMEntityDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDaoImpl" />
-  <bean id="vMInstanceDaoImpl" class="com.cloud.vm.dao.VMInstanceDaoImpl" />
-  <bean id="vMNetworkMapDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMNetworkMapDaoImpl" />
-  <bean id="vMReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDaoImpl" />
-  <bean id="vMRootDiskTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMRootDiskTagDaoImpl" />
-  <bean id="vMSnapshotDaoImpl" class="com.cloud.vm.snapshot.dao.VMSnapshotDaoImpl" />
-  <bean id="vMTemplateDetailsDaoImpl" class="com.cloud.storage.dao.VMTemplateDetailsDaoImpl" />
-  <bean id="vMTemplateHostDaoImpl" class="com.cloud.storage.dao.VMTemplateHostDaoImpl" />
-  <bean id="vMTemplatePoolDaoImpl" class="com.cloud.storage.dao.VMTemplatePoolDaoImpl" />
-  <bean id="vMTemplateZoneDaoImpl" class="com.cloud.storage.dao.VMTemplateZoneDaoImpl" />
-  <bean id="versionDaoImpl" class="com.cloud.upgrade.dao.VersionDaoImpl" />
-  <bean id="virtualRouterProviderDaoImpl" class="com.cloud.network.dao.VirtualRouterProviderDaoImpl" />
-  <bean id="ovsProviderDaoImpl" class="com.cloud.network.dao.OvsProviderDaoImpl" />
-  <bean id="vmRulesetLogDaoImpl" class="com.cloud.network.security.dao.VmRulesetLogDaoImpl" />
-  <bean id="volumeDaoImpl" class="com.cloud.storage.dao.VolumeDaoImpl" />
-  <bean id="volumeDetailsDaoImpl" class="com.cloud.storage.dao.VolumeDetailsDaoImpl" />
-  <bean id="volumeHostDaoImpl" class="com.cloud.storage.dao.VolumeHostDaoImpl" />
-  <bean id="volumeJoinDaoImpl" class="com.cloud.api.query.dao.VolumeJoinDaoImpl" />
-  <bean id="volumeReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VolumeReservationDaoImpl" />
-  <bean id="vpcDaoImpl" class="com.cloud.network.vpc.dao.VpcDaoImpl" />
-  <bean id="vpcGatewayDaoImpl" class="com.cloud.network.vpc.dao.VpcGatewayDaoImpl" />
-  <bean id="vpcOfferingDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingDaoImpl" />
-  <bean id="vpcOfferingServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingServiceMapDaoImpl" />
-  <bean id="vpcServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcServiceMapDaoImpl" />
-  <bean id="vpnUserDaoImpl" class="com.cloud.network.dao.VpnUserDaoImpl" />
-  <bean id="applicationLbRuleDaoImpl" class="org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDaoImpl" />
-  <bean id="networkOfferingDetailsDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingDetailsDaoImpl" />
-  <bean id="serviceOfferingDetailsDaoImpl" class="com.cloud.service.dao.ServiceOfferingDetailsDaoImpl"/>
-
-  <!--
-    Checkers
-  -->
-  <bean id="encryptionSecretKeyChecker" class="com.cloud.utils.crypt.EncryptionSecretKeyChecker" />
-  <bean id="StaticRoleBasedAPIAccessChecker" class="org.apache.cloudstack.acl.StaticRoleBasedAPIAccessChecker"/>
-  <bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
-  <bean id="domainChecker" class="com.cloud.acl.DomainChecker" />
-  <bean id="affinityGroupAccessChecker" class="com.cloud.acl.AffinityGroupAccessChecker" />
-  
-  <!--
-    Authenticators
-  --> 
-  <bean id="basicAgentAuthManager" class="com.cloud.agent.manager.authn.impl.BasicAgentAuthManager">
-    <property name="name" value="BASIC"/>
-  </bean>
-  <bean id="MD5UserAuthenticator" class="com.cloud.server.auth.MD5UserAuthenticator">
-    <property name="name" value="MD5"/>
-  </bean>
-  <bean id="LdapAuthenticator" class="org.apache.cloudstack.ldap.LdapAuthenticator">
-    <property name="name" value="LDAP"/>
-  </bean>
-  <bean id="SHA256SaltedUserAuthenticator" class="com.cloud.server.auth.SHA256SaltedUserAuthenticator">
-    <property name="name" value="SHA256SALT"/>
-  </bean>
-  <bean id="PlainTextUserAuthenticator" class="com.cloud.server.auth.PlainTextUserAuthenticator">
-    <property name="name" value="PLAINTEXT"/>
-  </bean>
-  <bean id="LdapManager" class="org.apache.cloudstack.ldap.LdapManagerImpl" />
-  <bean id="LdapUserManager" class="org.apache.cloudstack.ldap.LdapUserManager" />
-  <bean id="LdapContextFactory" class="org.apache.cloudstack.ldap.LdapContextFactory" />
-  <bean id="LdapConfigurationDao" class="org.apache.cloudstack.ldap.dao.LdapConfigurationDaoImpl" />
-  <bean id="LdapConfiguration" class="org.apache.cloudstack.ldap.LdapConfiguration" />
-
-  <!--
-      Network Elements
-  -->
-  <bean id="Ovs" class="com.cloud.network.element.OvsElement">
-    <property name="name" value="Ovs"/>
-  </bean>
-  <bean id="SecurityGroupProvider" class="com.cloud.network.element.SecurityGroupElement">
-    <property name="name" value="SecurityGroupProvider"/>
-  </bean>
-  <bean id="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement">
-    <property name="name" value="VirtualRouter"/>
-  </bean>
-  <bean id="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement">
-    <property name="name" value="VpcVirtualRouter"/>
-  </bean>
-  <bean id="elasticLoadBalancerElement" class="com.cloud.network.element.ElasticLoadBalancerElement">
-    <property name="name" value="ElasticLoadBalancerElement"/>
-  </bean>
-  <bean id="InternalLbVm" class="org.apache.cloudstack.network.element.InternalLoadBalancerElement">
-    <property name="name" value="InternalLbVm"/>
-  </bean>
-
-  <!-- 
-    General allocators
-  -->             
-  <bean id="firstFitAllocator" class="com.cloud.agent.manager.allocator.impl.FirstFitAllocator" />
-  <bean id="randomAllocator" class="com.cloud.agent.manager.allocator.impl.RandomAllocator" />
-
-  <!--
-     Host Allocators
-  -->
-  <bean id="FirstFitRouting" class="com.cloud.agent.manager.allocator.impl.FirstFitRoutingAllocator">
-    <property name="name" value="FirstFitRouting"/>
-  </bean>
-  
-  <!--
-    Storage pool allocators
-  -->
-  <bean id="LocalStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.LocalStoragePoolAllocator">
-    <property name="name" value="LocalStorage"/>
-  </bean>
-  <bean id="clusterScopeStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ClusterScopeStoragePoolAllocator" />
-  <bean id="zoneWideStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ZoneWideStoragePoolAllocator" />
-  <bean id="garbageCollectingStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.GarbageCollectingStoragePoolAllocator">
-    <property name="name" value="GCStorage"/>
-  </bean>
-
-  <bean id="UserConcentratedAllocator" class="com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator">
-    <property name="name" value="UserFirst"/>
-  </bean>
-  
-  
-  <bean id="recreatableFencer" class="com.cloud.ha.RecreatableFencer" />
-  <bean id="recreateHostAllocator" class="com.cloud.agent.manager.allocator.impl.RecreateHostAllocator" />
-  <bean id="secondaryStorageVmDefaultAllocator" class="com.cloud.storage.secondary.SecondaryStorageVmDefaultAllocator" />
-
-
-  <!--
-    Misc allocator & Adapters
-  -->
-  <bean id="ConsoleProxyAllocator" class="com.cloud.consoleproxy.ConsoleProxyBalanceAllocator">
-    <property name="name" value="Balance"/>
-  </bean>
-
-  <bean id="ExternalIpAddressAllocator" class="com.cloud.network.ExternalIpAddressAllocator">
-    <property name="name" value="Basic"/>
-  </bean>
-
-  <bean id="hypervisorTemplateAdapter" class="com.cloud.template.HypervisorTemplateAdapter" />
-  <bean id="clusterAlertAdapter" class="com.cloud.alert.ClusterAlertAdapter" />
-  <bean id="consoleProxyAlertAdapter" class="com.cloud.alert.ConsoleProxyAlertAdapter" />
-  <bean id="secondaryStorageVmAlertAdapter" class="com.cloud.alert.SecondaryStorageVmAlertAdapter" />
-  <bean id="clusterServiceServletAdapter" class="com.cloud.cluster.ClusterServiceServletAdapter" />
-
-  <!--
-    Investigators
-  -->
-  <bean id="CheckOnAgentInvestigator" class="com.cloud.ha.CheckOnAgentInvestigator">
-    <property name="name" value="SimpleInvestigator"/>
-  </bean>
-
-  <bean id="XenServerInvestigator" class="com.cloud.ha.XenServerInvestigator">
-    <property name="name" value="XenServerInvestigator"/>
-  </bean>
-  
-  <bean id="KVMInvestigator" class="com.cloud.ha.KVMInvestigator">
-    <property name="name" value="KVMInvestigator"/>
-  </bean>
-
-  <bean id="UserVmDomRInvestigator" class="com.cloud.ha.UserVmDomRInvestigator">
-    <property name="name" value="PingInvestigator"/>
-  </bean>
-
-  <bean id="ManagementIPSystemVMInvestigator" class="com.cloud.ha.ManagementIPSystemVMInvestigator">
-    <property name="name" value="ManagementIPSysVMInvestigator"/>
-  </bean>
-
-  <!--
-    Fencers
-  -->
-  <bean id="XenServerFencer" class="com.cloud.ha.XenServerFencer">
-    <property name="name" value="XenServerFenceBuilder"/>
-  </bean>
-  <bean id="KVMFencer" class="com.cloud.ha.KVMFencer">
-    <property name="name" value="KVMFenceBuilder"/>
-  </bean>
-  <bean id="OvmFencer" class="com.cloud.ovm.hypervisor.OvmFencer">
-    <property name="name" value="OvmFenceBuilder"/>
-  </bean>
-
-  <!--
-    Discovers
-  -->
-  <bean id="XcpServerDiscoverer" class="com.cloud.hypervisor.xen.discoverer.XcpServerDiscoverer">
-    <property name="name" value="XCP Agent"/>
-  </bean>
-
-  <bean id="SecondaryStorageDiscoverer" class="org.apache.cloudstack.storage.resource.SecondaryStorageDiscoverer">
-    <property name="name" value="SecondaryStorage"/>
-  </bean>
-
-  <bean id="KvmServerDiscoverer" class="com.cloud.hypervisor.kvm.discoverer.KvmServerDiscoverer">
-    <property name="name" value="KVM Agent"/>
-  </bean>
-
-  <bean id="LxcServerDiscoverer" class="com.cloud.hypervisor.kvm.discoverer.LxcServerDiscoverer">
-    <property name="name" value="Lxc Discover"/>
-  </bean>
-
-  <bean id="OvmDiscoverer" class="com.cloud.ovm.hypervisor.OvmDiscoverer">
-    <property name="name" value="Ovm Discover"/>
-  </bean>
-
-  <bean id="dummyHostDiscoverer" class="com.cloud.resource.DummyHostDiscoverer">
-    <property name="name" value="dummyHostDiscoverer" />
-  </bean>
-
-  <!--
-    Deployment planners
-  -->
-  <bean id="UserDispersingPlanner" class="com.cloud.deploy.UserDispersingPlanner">
-    <property name="name" value="UserDispersingPlanner"/>
-  </bean>
-  
-  <bean id="UserConcentratedPodPlanner" class="com.cloud.deploy.UserConcentratedPodPlanner">
-    <property name="name" value="UserConcentratedPodPlanner"/>
-  </bean>
-
-  <bean id="ImplicitDedicationPlanner" class="com.cloud.deploy.ImplicitDedicationPlanner">
-    <property name="name" value="ImplicitDedicationPlanner"/>
-  </bean>
-
-  <bean id="clusterBasedAgentLoadBalancerPlanner" class="com.cloud.cluster.agentlb.ClusterBasedAgentLoadBalancerPlanner">
-    <property name="name" value="ClusterBasedAgentLoadBalancerPlanner"/>
-  </bean>
-
-  <!--
-    Network Gurus
-  -->
-  <bean id="StorageNetworkGuru" class="com.cloud.network.guru.StorageNetworkGuru">
-    <property name="name" value="StorageNetworkGuru"/>
-  </bean>
-  <bean id="ExternalGuestNetworkGuru" class="com.cloud.network.guru.ExternalGuestNetworkGuru">
-    <property name="name" value="ExternalGuestNetworkGuru"/>
-  </bean>
-  <bean id="PublicNetworkGuru" class="com.cloud.network.guru.PublicNetworkGuru">
-    <property name="name" value="PublicNetworkGuru"/>
-  </bean>
-  <bean id="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru">
-    <property name="name" value="PodBasedNetworkGuru"/>
-  </bean>
-  <bean id="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru">
-    <property name="name" value="ControlNetworkGuru"/>
-  </bean>
-  <bean id="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru">
-    <property name="name" value="DirectNetworkGuru"/>
-  </bean>
-  <bean id="DirectPodBasedNetworkGuru" class="com.cloud.network.guru.DirectPodBasedNetworkGuru">
-    <property name="name" value="DirectPodBasedNetworkGuru"/>
-  </bean>
-  <bean id="OvsGuestNetworkGuru" class="com.cloud.network.guru.OvsGuestNetworkGuru">
-    <property name="name" value="OvsGuestNetworkGuru"/>
-  </bean>
-  <bean id="PrivateNetworkGuru" class="com.cloud.network.guru.PrivateNetworkGuru">
-    <property name="name" value="PrivateNetworkGuru"/>
-  </bean>
- 
-  <!--
-   Hypervisor Gurus
-  -->
-  <bean id="XenServerGuru" class="com.cloud.hypervisor.XenServerGuru">
-    <property name="name" value="XenServerGuru"/>
-  </bean>
-  
-  <bean id="KVMGuru" class="com.cloud.hypervisor.KVMGuru">
-    <property name="name" value="KVMGuru"/>
-  </bean>
-
-  <bean id="LXCGuru" class="com.cloud.hypervisor.LXCGuru">
-    <property name="name" value="LXCGuru"/>
-  </bean>
-
-  <bean id="OvmGuru" class="com.cloud.ovm.hypervisor.OvmGuru">
-    <property name="name" value="OvmGuru"/>
-  </bean>
-
-  <!--=====================================================================================================-->
-  <!--                                                                                                     -->
-  <!--                           Storage Subsystem Components and Helpers                                  -->
-  <!--                                                                                                     -->
-  <!--=====================================================================================================-->
-
-  <!--Filesystem types-->
-  <bean id="iSCSI" class="org.apache.cloudstack.storage.datastore.type.ISCSI" />
-  <bean id="networkFileSystem" class="org.apache.cloudstack.storage.datastore.type.NetworkFileSystem" />
-
-  <!--Image formats-->
-  <bean id="ISO" class="org.apache.cloudstack.storage.image.format.ISO" />
-  <bean id="OVA" class="org.apache.cloudstack.storage.image.format.OVA" />
-  <bean id="QCOW2" class="org.apache.cloudstack.storage.image.format.QCOW2" />
-  <bean id="VHD" class="org.apache.cloudstack.storage.image.format.VHD" />
-  <bean id="VHDX" class="org.apache.cloudstack.storage.image.format.VHDX" />
-  <bean id="unknown" class="org.apache.cloudstack.storage.image.format.Unknown" />
-
-  <!--Data Store Services -->
-  <bean id="snapshotServiceImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotServiceImpl"
-        depends-on="snapshotStateMachineManagerImpl, snapshotDataFactoryImpl, dataStoreManagerImpl, dataMotionServiceImpl, objectInDataStoreManagerImpl"/>
-  <bean id="templateServiceImpl" class="org.apache.cloudstack.storage.image.TemplateServiceImpl"
-        depends-on="dataObjectManagerImpl, dataStoreManagerImpl, dataMotionServiceImpl, objectInDataStoreManagerImpl, defaultEndPointSelector, templateDataFactoryImpl"/>
-  <bean id="volumeServiceImpl" class="org.apache.cloudstack.storage.volume.VolumeServiceImpl"
-        depends-on="snapshotManagerImpl, dataMotionServiceImpl"/>
-
-  <bean id="xenserverSnapshotStrategy" class="org.apache.cloudstack.storage.snapshot.XenserverSnapshotStrategy" />
-
-  <!--Data Store Factory-->
-  <bean id="templateDataFactoryImpl" class="org.apache.cloudstack.storage.image.TemplateDataFactoryImpl" />
-  <bean id="snapshotDataFactoryImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotDataFactoryImpl"
-        depends-on="dataStoreManagerImpl, snapshotDataStoreDaoImpl, volumeDataFactoryImpl"/>
-  <bean id="volumeDataFactoryImpl" class="org.apache.cloudstack.storage.volume.VolumeDataFactoryImpl" />
-
-  <bean id="objectInDataStoreManagerImpl" class="org.apache.cloudstack.storage.datastore.ObjectInDataStoreManagerImpl" />
-  <bean id="dataObjectManagerImpl" class="org.apache.cloudstack.storage.datastore.DataObjectManagerImpl" />
-
-  <!--Data Store Helpers-->
-  <bean id="primaryDataStoreHelper" class="org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper" />
-  <bean id="imageStoreHelper" class="org.apache.cloudstack.storage.image.datastore.ImageStoreHelper" />
-  <bean id="imageFormatHelper" class="org.apache.cloudstack.storage.image.format.ImageFormatHelper" />
-
-  <bean id="storageCacheRandomAllocator" class="org.apache.cloudstack.storage.cache.allocator.StorageCacheRandomAllocator" />
-  <bean id="storageCacheManagerImpl" class="org.apache.cloudstack.storage.cache.manager.StorageCacheManagerImpl"  />
-  <bean id="StorageCacheReplacementAlgorithm" class="org.apache.cloudstack.storage.cache.manager.StorageCacheReplacementAlgorithmLRU" />
-
-  <bean id="snapshotStateMachineManagerImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotStateMachineManagerImpl" />
-  <bean id="defaultEndPointSelector" class="org.apache.cloudstack.storage.endpoint.DefaultEndPointSelector" />
-
-
-  <bean id="ancientDataMotionStrategy" class="org.apache.cloudstack.storage.motion.AncientDataMotionStrategy" />
-  <bean id="xenserverStorageMotionStrategy" class="org.apache.cloudstack.storage.motion.XenServerStorageMotionStrategy" />
-
-  <!--Data Motion Services-->
-  <bean id="dataMotionServiceImpl" class="org.apache.cloudstack.storage.motion.DataMotionServiceImpl">
-    <property name="strategies">
-      <list>
-        <ref local="ancientDataMotionStrategy"/>
-        <ref local="xenserverStorageMotionStrategy"/>
-      </list>
-    </property>
-  </bean>
-
-  <!--
-    Data Store Provider Manager
-  -->
-  <bean id="primaryDataStoreProviderMgr"
-        class="org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreProviderManagerImpl"/>
-  <bean id="imageStoreProviderMgr" class="org.apache.cloudstack.storage.image.manager.ImageStoreProviderManagerImpl"/>
-
-  <bean id="dataStoreManagerImpl" class="org.apache.cloudstack.storage.datastore.DataStoreManagerImpl"
-        depends-on="dataStoreProviderManager">
-    <property name="primaryStoreMgr" ref="primaryDataStoreProviderMgr"/>
-    <property name="imageDataStoreMgr" ref="imageStoreProviderMgr"/>
-  </bean>
-
-  <bean id="cloudStackPrimaryDataStoreProviderImpl"
-        class="org.apache.cloudstack.storage.datastore.provider.CloudStackPrimaryDataStoreProviderImpl"/>
-
-  <bean id="dataStoreProviderManager"
-        class="org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManagerImpl">
-    <property name="providers">
-      <list>
-        <!--Data Store Providers-->
-        <ref bean="cloudStackPrimaryDataStoreProviderImpl"/>
-      </list>
-    </property>
-  </bean>
-
-  <!--
-    Managers
-  -->
-  <bean id="accountManagerImpl" class="com.cloud.user.AccountManagerImpl" >
-    <property name="UserAuthenticators" value="#{userAuthenticators.Adapters}" />
-    <property name="UserPasswordEncoders" value="#{userPasswordEncoders.Adapters}" />
-    <property name="SecurityCheckers" value="#{securityCheckers.Adapters}" />
-  </bean>
-
-  <bean id="managementServerImpl" class ="com.cloud.server.ManagementServerImpl">
-    <property name="UserAuthenticators" value="#{userAuthenticators.Adapters}" />
-    <property name="UserPasswordEncoders" value="#{userPasswordEncoders.Adapters}" />
-    <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
-    <property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
-    <property name="Planners" value="#{deploymentPlanners.Adapters}" />
-  </bean>
-
-  <bean id="storageManagerImpl" class="com.cloud.storage.StorageManagerImpl"/>
-  
-  <bean id="volumeOrchestrator" class="org.apache.cloudstack.engine.orchestration.VolumeOrchestrator">
-    <property name="PodAllocators" value="#{podAllocators.Adapters}" />
-    <property name="StoragePoolAllocators" value="#{storagePoolAllocators.Adapters}" />
-  </bean>
-
-  <bean id="FirstFitPlanner" class="com.cloud.deploy.FirstFitPlanner">
-    <property name="name" value="FirstFitPlanner"/>
-  </bean>
-
-  <bean id="resourceManagerImpl" class="com.cloud.resource.ResourceManagerImpl" >
-    <property name="Discoverers" value="#{resourceDiscoverers.Adapters}" />
-  </bean>
-
-  <bean id="highAvailabilityManagerExtImpl" class="com.cloud.ha.HighAvailabilityManagerExtImpl" >
-    <property name="Investigators" value="#{haInvestigators.Adapters}" />
-    <property name="FenceBuilders" value="#{haFenceBuilders.Adapters}" />
-  </bean>
-
-  <bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl" >
-    <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
-  </bean>
-
-  <bean id="networkOrchestrator" class="org.apache.cloudstack.engine.orchestration.NetworkOrchestrator" >
-    <property name="NetworkGurus" value="#{networkGurus.Adapters}" />
-    <property name="NetworkElements" value="#{networkElements.Adapters}" />
-    <property name="IpDeployers" value="#{ipDeployers.Adapters}" />
-    <property name="DhcpProviders" value="#{dhcpProviders.Adapters}" />
-  </bean>
-
-  <bean id="ipAddressManagerImpl" class="com.cloud.network.IpAddressManagerImpl" >
-  </bean>
-  <bean id="networkModelImpl" class="com.cloud.network.NetworkModelImpl">
-    <property name="NetworkElements" value="#{networkElements.Adapters}" />
-  </bean>
-
-  <bean id="configurationServerImpl" class="com.cloud.server.ConfigurationServerImpl" />
-
-  <bean id="clusterManagerImpl" class="com.cloud.cluster.ClusterManagerImpl" />
-  <bean id="clusteredAgentManagerImpl" class="com.cloud.agent.manager.ClusteredAgentManagerImpl" />
-
-  <bean id="userVmManagerImpl" class="com.cloud.vm.UserVmManagerImpl" />
-  <bean id="consoleProxyManagerImpl" class="com.cloud.consoleproxy.ConsoleProxyManagerImpl" />
-  <bean id="securityGroupManagerImpl2" class="com.cloud.network.security.SecurityGroupManagerImpl2" />
-  <bean id="premiumSecondaryStorageManagerImpl" class="com.cloud.secstorage.PremiumSecondaryStorageManagerImpl" />
-
-  <bean id="ipv6AddressManagerImpl" class="com.cloud.network.Ipv6AddressManagerImpl" />
-
-  <bean id="apiRateLimitServiceImpl" class="org.apache.cloudstack.ratelimit.ApiRateLimitServiceImpl"/>
-  <bean id="alertManagerImpl" class="com.cloud.alert.AlertManagerImpl" />
-  <bean id="autoScaleManagerImpl" class="com.cloud.network.as.AutoScaleManagerImpl" />
-  <bean id="capacityManagerImpl" class="com.cloud.capacity.CapacityManagerImpl" />
-  <bean id="clusterFenceManagerImpl" class="com.cloud.cluster.ClusterFenceManagerImpl" />
-  <bean id="configurationManagerImpl" class="com.cloud.configuration.ConfigurationManagerImpl" />
-
-  <bean id="elasticLoadBalancerManagerImpl" class="com.cloud.network.lb.ElasticLoadBalancerManagerImpl" />
-  <bean id="entityManagerImpl" class="com.cloud.dao.EntityManagerImpl" />
-  <bean id="externalDeviceUsageManagerImpl" class="com.cloud.network.ExternalDeviceUsageManagerImpl" />
-  <bean id="externalNetworkDeviceManagerImpl" class="com.cloud.network.ExternalNetworkDeviceManagerImpl" />
-  <bean id="firewallManagerImpl" class="com.cloud.network.firewall.FirewallManagerImpl" />
-  <bean id="hypervisorGuruManagerImpl" class="com.cloud.hypervisor.HypervisorGuruManagerImpl" />
-  <bean id="identityServiceImpl" class="com.cloud.uuididentity.IdentityServiceImpl" />
-  <bean id="keystoreManagerImpl" class="com.cloud.keystore.KeystoreManagerImpl" />
-  <bean id="loadBalancingRulesManagerImpl" class="com.cloud.network.lb.LoadBalancingRulesManagerImpl" />
-  <bean id="networkACLManagerImpl" class="com.cloud.network.vpc.NetworkACLManagerImpl" />
-  <bean id="networkACLServiceImpl" class="com.cloud.network.vpc.NetworkACLServiceImpl" />
-  <bean id="networkServiceImpl" class="com.cloud.network.NetworkServiceImpl" />
-  <bean id="networkUsageManagerImpl" class="com.cloud.network.NetworkUsageManagerImpl" />
-  <bean id="oCFS2ManagerImpl" class="com.cloud.storage.OCFS2ManagerImpl" />
-  <bean id="ovsTunnelManagerImpl" class="com.cloud.network.ovs.OvsTunnelManagerImpl" />
-  <bean id="projectManagerImpl" class="com.cloud.projects.ProjectManagerImpl" />
-  <bean id="queryManagerImpl" class="com.cloud.api.query.QueryManagerImpl" />
-  <bean id="regionManagerImpl" class="org.apache.cloudstack.region.RegionManagerImpl" />
-  <bean id="regionServiceImpl" class="org.apache.cloudstack.region.RegionServiceImpl" />
-  <bean id="remoteAccessVpnManagerImpl" class="com.cloud.network.vpn.RemoteAccessVpnManagerImpl" />
-  <bean id="resourceLimitManagerImpl" class="com.cloud.resourcelimit.ResourceLimitManagerImpl" />
-  <bean id="rulesManagerImpl" class="com.cloud.network.rules.RulesManagerImpl" />
-    <bean id="site2SiteVpnManagerImpl" class="com.cloud.network.vpn.Site2SiteVpnManagerImpl" />
-  <bean id="snapshotManagerImpl" class="com.cloud.storage.snapshot.SnapshotManagerImpl" />
-  <bean id="snapshotSchedulerImpl" class="com.cloud.storage.snapshot.SnapshotSchedulerImpl" />
-  <bean id="storageNetworkManagerImpl" class="com.cloud.network.StorageNetworkManagerImpl" />
-  <bean id="taggedResourceManagerImpl" class="com.cloud.tags.TaggedResourceManagerImpl" />
-  <bean id="resourceMetaDataManagerImpl" class="com.cloud.metadata.ResourceMetaDataManagerImpl" />
-  <bean id="templateManagerImpl" class="com.cloud.template.TemplateManagerImpl" />
-  <bean id="uploadMonitorImpl" class="com.cloud.storage.upload.UploadMonitorImpl" />
-  <bean id="usageServiceImpl" class="com.cloud.usage.UsageServiceImpl" />
-  <bean id="virtualNetworkApplianceManagerImpl" class="com.cloud.network.router.VirtualNetworkApplianceManagerImpl" />
-  <bean id="vpcManagerImpl" class="com.cloud.network.vpc.VpcManagerImpl" />
-  <bean id="vpcVirtualNetworkApplianceManagerImpl" class="com.cloud.network.router.VpcVirtualNetworkApplianceManagerImpl" />
-
-  <!-- Async management -->
-  <bean id="asyncJobDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.AsyncJobDaoImpl" />
-  <bean id="asyncJobJournalDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.AsyncJobJournalDaoImpl" />
-  <bean id="asyncJobJoinMapDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDaoImpl" />
-  <bean id="asyncJobManagerImpl" class="org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl"/>
-  <bean id="asyncJobMonitor" class="org.apache.cloudstack.framework.jobs.impl.AsyncJobMonitor"/>
-  <bean id="syncQueueDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.SyncQueueDaoImpl" />
-  <bean id="syncQueueItemDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDaoImpl" />
-  <bean id="syncQueueManagerImpl" class="org.apache.cloudstack.framework.jobs.impl.SyncQueueManagerImpl" />
-
-  <bean id="ApiAsyncJobDispatcher" class="com.cloud.api.ApiAsyncJobDispatcher">
-    <property name="name" value="ApiAsyncJobDispatcher" />
-  </bean>
-
-
-  <!--
-    Misc components
-  -->
-  <bean id="actionEventUtils" class="com.cloud.event.ActionEventUtils" />
-  <bean id="alertGenerator" class="com.cloud.event.AlertGenerator" />
-  <bean id="apiDBUtils" class="com.cloud.api.ApiDBUtils" />
-  <bean id="apiDiscoveryServiceImpl" class="org.apache.cloudstack.discovery.ApiDiscoveryServiceImpl" />
-  <bean id="apiDispatcher" class="com.cloud.api.ApiDispatcher" />
-  <bean id="apiResponseHelper" class="com.cloud.api.ApiResponseHelper" />
-  <bean id="apiServer" class="com.cloud.api.ApiServer" />
-  <bean id="apiServlet" class="com.cloud.api.ApiServlet" />
-  <bean id="bAREMETAL" class="org.apache.cloudstack.storage.image.format.BAREMETAL" />
-  <bean id="cloudOrchestrator" class="org.apache.cloudstack.engine.orchestration.CloudOrchestrator" />
-  <bean id="clusterRestService" class="org.apache.cloudstack.engine.rest.service.api.ClusterRestService" />
-  <bean id="consoleProxyServlet" class="com.cloud.servlet.ConsoleProxyServlet" />
-  <bean id="dataCenterResourceManagerImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceManagerImpl" />
-  <bean id="dataDisk" class="org.apache.cloudstack.engine.subsystem.api.storage.type.DataDisk" />
-
-
-  <bean id="podRestService" class="org.apache.cloudstack.engine.rest.service.api.PodRestService" />
-  <bean id="iso" class="org.apache.cloudstack.engine.subsystem.api.storage.type.Iso" />
-  <bean id="networkRestService" class="org.apache.cloudstack.engine.rest.service.api.NetworkRestService" />
-  <bean id="provisioningServiceImpl" class="org.apache.cloudstack.engine.service.api.ProvisioningServiceImpl" />
-  <bean id="rootDisk" class="org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk" />
-  <bean id="registerCompleteServlet" class="com.cloud.servlet.RegisterCompleteServlet" />
-  <bean id="statsCollector" class="com.cloud.server.StatsCollector" />
-  <bean id="storagePoolAutomationImpl" class="com.cloud.storage.StoragePoolAutomationImpl" />
-  <bean id="usageEventUtils" class="com.cloud.event.UsageEventUtils" />
-  <bean id="vMEntityManagerImpl" class="org.apache.cloudstack.engine.cloud.entity.api.VMEntityManagerImpl" />
-  <bean id="virtualMachineEntityImpl" class="org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl" />
-  <bean id="virtualMachineRestService" class="org.apache.cloudstack.engine.rest.service.api.VirtualMachineRestService" />
-  <bean id="volumeRestService" class="org.apache.cloudstack.engine.rest.service.api.VolumeRestService" />
-  <bean id="volumeTypeHelper" class="org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper" />
-  <bean id="zoneRestService" class="org.apache.cloudstack.engine.rest.service.api.ZoneRestService" />
-  <bean id="cloudZonesStartupProcessor" class="com.cloud.hypervisor.CloudZonesStartupProcessor" />
-  <bean id="managementServerNode" class="org.apache.cloudstack.utils.identity.ManagementServerNode" />
-  <bean id="testingAllocator" class="com.cloud.agent.manager.allocator.impl.TestingAllocator" />
-  <bean id="domainManagerImpl" class="com.cloud.user.DomainManagerImpl" />
-  <bean id="downloadMonitorImpl" class="com.cloud.storage.download.DownloadMonitorImpl" />
-  <bean id="lBHealthCheckManagerImpl" class="com.cloud.network.lb.LBHealthCheckManagerImpl" />
-  <bean id="volumeApiServiceImpl" class="com.cloud.storage.VolumeApiServiceImpl"/>
-  <bean id="ApplicationLoadBalancerService" class="org.apache.cloudstack.network.lb.ApplicationLoadBalancerManagerImpl" />
-  <bean id="InternalLoadBalancerVMManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl" />
-
-  <bean id="vMSnapshotManagerImpl" class="com.cloud.vm.snapshot.VMSnapshotManagerImpl" />
-
-
-<!--=======================================================================================================-->
-<!--                                                                                                       -->
-<!--                           Module-basis OSS/non-OSS Common components                                  -->
-<!--                                                                                                       -->
-<!--=======================================================================================================-->
-
-  <!--
-    Baremetal components
-  -->
-  
-  <bean id="BareMetalDhcp" class="com.cloud.baremetal.networkservice.BaremetalDhcpElement">
-    <property name="name" value="BareMetalDhcp"/>
-  </bean>
-  <bean id="BareMetalPxe" class="com.cloud.baremetal.networkservice.BaremetalPxeElement">
-    <property name="name" value="BareMetalPxe"/>
-  </bean>
-  <bean id="BareMetalUserdata" class="com.cloud.baremetal.networkservice.BaremetalUserdataElement">
-      <property name="name" value="BareMetalUserdata"/>
-  </bean>
-
-  <bean id="BareMetalTemplateAdapter" class="com.cloud.baremetal.manager.BareMetalTemplateAdapter" />
-
-  <bean id="BareMetalDiscoverer" class="com.cloud.baremetal.manager.BareMetalDiscoverer">
-    <property name="name" value="Bare Metal Agent"/>
-  </bean>
-
-  <bean id="BareMetalPlanner" class="com.cloud.baremetal.manager.BareMetalPlanner">
-    <property name="name" value="BareMetalPlanner"/>
-  </bean>
-  
-  <bean id="BaremetalGuru" class="com.cloud.baremetal.manager.BareMetalGuru">
-    <property name="name" value="BaremetalGuru"/>
-  </bean>
-
-  <bean id="BaremetalManager" class="com.cloud.baremetal.manager.BaremetalManagerImpl"/>
-  <bean id="BaremetalDhcpManager" class="com.cloud.baremetal.networkservice.BaremetalDhcpManagerImpl"/>
-  <bean id="BaremetalKickStartPxeService" class="com.cloud.baremetal.networkservice.BaremetalKickStartServiceImpl"/>
-  <bean id="BaremetalPingPxeService" class="com.cloud.baremetal.networkservice.BareMetalPingServiceImpl" />
-  <bean id="BaremetalPxeManager" class="com.cloud.baremetal.networkservice.BaremetalPxeManagerImpl" /> 
-    
-  <bean id="BAREMETAL" class="org.apache.cloudstack.storage.image.format.BAREMETAL" />
-  <bean id="baremetalDhcpDaoImpl" class="com.cloud.baremetal.database.BaremetalDhcpDaoImpl" />
-  <bean id="baremetalPxeDaoImpl" class="com.cloud.baremetal.database.BaremetalPxeDaoImpl" />
-
-  <bean id="UcsManager" class="com.cloud.ucs.manager.UcsManagerImpl" />
-
-  <bean id="AffinityGroupServiceImpl" class="org.apache.cloudstack.affinity.AffinityGroupServiceImpl">
-  	<property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
-  </bean>
-  <bean id="DeploymentPlanningManager" class="com.cloud.deploy.DeploymentPlanningManagerImpl">
-    <property name="Planners" value="#{deploymentPlanners.Adapters}" />
-	<property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
-    <property name="StoragePoolAllocators" value="#{storagePoolAllocators.Adapters}" />
-    <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
-  </bean>
-  
-  <bean id="AffinityGroupJoinDaoImpl" class="com.cloud.api.query.dao.AffinityGroupJoinDaoImpl">
-  </bean>
-  <bean id="AffinityGroupDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupDaoImpl">
-  </bean>
-  <bean id="AffinityGroupVMMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDaoImpl">
-  </bean>
-  <bean id="AffinityGroupDomainMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDaoImpl">
-  </bean>
-  
-  <bean id="PlannerHostReservationDaoImpl" class="com.cloud.deploy.dao.PlannerHostReservationDaoImpl">
-  </bean>
-  
-</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e80f03/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index bd46fa2..966b7c4 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -596,12 +596,6 @@ addBigSwitchVnsDevice=1
 deleteBigSwitchVnsDevice=1
 listBigSwitchVnsDevices=1
 
-#### ovs commands
-
-addOvsDevice=1
-deleteOvsDevice=1
-listOvsDevices=1
-
 #### host simulator commands
 
 configureSimulator=1

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e80f03/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index cbe4de3..3596f8d 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1303,7 +1303,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-	// Tuna added
     private OvsFetchInterfaceAnswer execute(OvsFetchInterfaceCommand cmd) {
     	String label = cmd.getLabel();
     	s_logger.debug("Will look for network with name-label:" + label);
@@ -1472,7 +1471,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 			return new Answer(cmd, false, e.getMessage());
 		}
 	}
-	// end Tuna added
 
     private CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
         List<PhysicalNetworkSetupInfo> phyNics = cmd.getPhysicalNetworkInfoList();
@@ -3618,12 +3616,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             }
 
             // pass cmdline info to system vms
-			// if (vmSpec.getType() != VirtualMachine.Type.User) {
-			// passCmdLine(vmName, vmSpec.getBootArgs() );
-			// }
-			// merge with master branch
-			// pass cmdline info to system vms
-            if (vmSpec.getType() != VirtualMachine.Type.User) {
+			if (vmSpec.getType() != VirtualMachine.Type.User) {
                 if ((conn.getVersion() < 1001000)) { // CLOUDSTACK-2823: try passCmdLine some times if kernel < 2.6.34 and qemu < 1.1.0 on hypervisor (for instance, CentOS 6.4)
                     //wait for 5 minutes at most
                     String controlIp = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e80f03/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 e093253..015a966 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
@@ -8742,17 +8742,17 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     public void setRunLevel(int level) {
     }
 
-    private boolean is_xcp() {
-    	Connection conn = getConnection();
-    	String result = callHostPlugin(conn, "ovstunnel", "is_xcp");
-    	if (result.equals("XCP"))
-    		return true;
-    	return false;
-    }
-
-    private String getLabel() {
-    	Connection conn = getConnection();
-    	String result = callHostPlugin(conn, "ovstunnel", "getLabel");
-    	return result;
-    }
+	private boolean is_xcp() {
+		Connection conn = getConnection();
+		String result = callHostPlugin(conn, "ovstunnel", "is_xcp");
+		if (result.equals("XCP"))
+			return true;
+		return false;
+	}
+
+	private String getLabel() {
+		Connection conn = getConnection();
+		String result = callHostPlugin(conn, "ovstunnel", "getLabel");
+		return result;
+	}
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e80f03/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
index 59de8e7..7a671a0 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
@@ -92,9 +92,6 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
 	public Network design(NetworkOffering offering, DeploymentPlan plan,
 			Network userSpecified, Account owner) {
 
-		// if (!_ovsTunnelMgr.isOvsTunnelEnabled()) {
-		// return null;
-		// }
 		PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan
 				.getPhysicalNetworkId());
 		DataCenter dc = _dcDao.findById(plan.getDataCenterId());
@@ -119,9 +116,7 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
 			throws InsufficientVirtualNetworkCapcityException {
 		assert (network.getState() == State.Implementing) : "Why are we implementing "
 				+ network;
-		// if (!_ovsTunnelMgr.isOvsTunnelEnabled()) {
-		// return null;
-		// }
+
 		long dcId = dest.getDataCenter().getId();
 		NetworkType nwType = dest.getDataCenter().getNetworkType();
 		// get physical network id

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e80f03/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 0b65b98..17dd8af 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -46,7 +46,6 @@
     <module>network-elements/juniper-contrail</module>
     <module>network-elements/palo-alto</module>
     <module>network-elements/nicira-nvp</module>
-<!--     <module>network-elements/odl</module> -->
     <module>network-elements/bigswitch-vns</module>
     <module>network-elements/midonet</module>
     <module>network-elements/stratosphere-ssp</module>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e80f03/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
index 207f159..bea9428 100644
--- a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
@@ -99,12 +99,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
     @Override
     public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
 
-		// if
-		// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
-		// {
-		// return null;
-		// }
-
         NetworkVO config = (NetworkVO)super.design(offering, plan, userSpecified, owner);
         if (config == null) {
             return null;
@@ -121,12 +115,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
         throws InsufficientVirtualNetworkCapcityException {
         assert (config.getState() == State.Implementing) : "Why are we implementing " + config;
 
-		// if
-		// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
-		// {
-		// return null;
-		// }
-
         if (!_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
             return super.implement(config, offering, dest, context);
         }
@@ -229,12 +217,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
 
         NicProfile profile = super.allocate(config, nic, vm);
 
-		// boolean _isEnabled =
-		// Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
-		// if (_isEnabled) {
-		// return null;
-		// }
-
         if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
             profile.setStrategy(ReservationStrategy.Start);
             /* We won't clear IP address, because router may set gateway as it IP, and it would be updated properly later */
@@ -251,12 +233,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
     public void deallocate(Network config, NicProfile nic, VirtualMachineProfile vm) {
         super.deallocate(config, nic, vm);
 
-		// if
-		// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
-		// {
-		// return;
-		// }
-
         if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
             nic.setIp4Address(null);
             nic.setGateway(null);
@@ -270,11 +246,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
     public void reserve(NicProfile nic, Network config, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
         throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
         assert (nic.getReservationStrategy() == ReservationStrategy.Start) : "What can I do for nics that are not allocated at start? ";
-		// boolean _isEnabled =
-		// Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
-		// if (_isEnabled) {
-		// return;
-		// }
 
         DataCenter dc = _dcDao.findById(config.getDataCenterId());
 
@@ -307,12 +278,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
     @Override
     public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) {
 
-		// if
-		// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
-		// {
-		// return true;
-		// }
-
         NetworkVO network = _networkDao.findById(nic.getNetworkId());
 
         if (network != null && _networkModel.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61e80f03/utils/conf/db.properties
----------------------------------------------------------------------
diff --git a/utils/conf/db.properties b/utils/conf/db.properties
index 709d79e..e1b5fe9 100644
--- a/utils/conf/db.properties
+++ b/utils/conf/db.properties
@@ -25,7 +25,7 @@ region.id=1
 # CloudStack database settings
 db.cloud.username=cloud
 db.cloud.password=cloud
-db.root.password=123
+db.root.password=
 db.cloud.host=localhost
 db.cloud.port=3306
 db.cloud.name=cloud


[13/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
fix white-space


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3a9c9bd7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3a9c9bd7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3a9c9bd7

Branch: refs/heads/master
Commit: 3a9c9bd7178c4af957da7f6bad897da4d680b956
Parents: 79a7ce8
Author: tuna <ng...@gmail.com>
Authored: Fri Jul 12 17:56:00 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 .../com/cloud/hypervisor/xen/resource/CitrixResourceBase.java    | 4 ++--
 scripts/vm/hypervisor/xenserver/ovstunnel                        | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3a9c9bd7/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 4845969..d10791c 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
@@ -8741,7 +8741,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     @Override
     public void setRunLevel(int level) {
     }
-    
+
     private boolean is_xcp() {
     	Connection conn = getConnection();
     	String result = callHostPlugin(conn, "ovstunnel", "is_xcp");
@@ -8749,7 +8749,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     		return true;
     	return false;
     }
-    
+
     private String getLabel() {
     	Connection conn = getConnection();
     	String result = callHostPlugin(conn, "ovstunnel", "getLabel");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3a9c9bd7/scripts/vm/hypervisor/xenserver/ovstunnel
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/ovstunnel b/scripts/vm/hypervisor/xenserver/ovstunnel
index 9a89630..a4760b2 100755
--- a/scripts/vm/hypervisor/xenserver/ovstunnel
+++ b/scripts/vm/hypervisor/xenserver/ovstunnel
@@ -268,7 +268,7 @@ def is_xcp(session, args):
                                'param-name=software-version',
                                'param-key=platform_name']
     platform = lib.do_cmd(platform_cmd).split('.')[0]
-    return platform                           
+    return platform
 
 def getLabel(session, args):
     pif_list_cmd = [lib.XE_PATH, 'pif-list', '--minimal']


[19/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
remove unused table: ovs_nic_map


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0624fe5d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0624fe5d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0624fe5d

Branch: refs/heads/master
Commit: 0624fe5d030f14b1f143db75e45022a4fbf821d0
Parents: c7dab82
Author: tuna <ng...@gmail.com>
Authored: Mon Nov 4 11:05:57 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:15 2013 +0700

----------------------------------------------------------------------
 client/tomcatconf/applicationContext.xml.in     |  1 -
 .../cloud/network/ovs/dao/OvsNicMappingDao.java | 24 ------
 .../network/ovs/dao/OvsNicMappingDaoImpl.java   | 47 -----------
 .../cloud/network/ovs/dao/OvsNicMappingVO.java  | 83 --------------------
 setup/db/db/schema-410to420.sql                 | 10 ---
 5 files changed, 165 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0624fe5d/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index b3778d4..b610227 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -266,7 +266,6 @@
   <bean id="objectInDataStoreDaoImpl" class="org.apache.cloudstack.storage.db.ObjectInDataStoreDaoImpl" />
   <bean id="ovsTunnelInterfaceDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" />
   <bean id="ovsTunnelNetworkDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" />
-  <bean id="ovsNicMappingDaoImpl" class="com.cloud.network.ovs.dao.OvsNicMappingDaoImpl" />
   <bean id="physicalNetworkDaoImpl" class="com.cloud.network.dao.PhysicalNetworkDaoImpl" />
   <bean id="physicalNetworkIsolationMethodDaoImpl" class="com.cloud.network.dao.PhysicalNetworkIsolationMethodDaoImpl" />
   <bean id="physicalNetworkServiceProviderDaoImpl" class="com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl" />

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0624fe5d/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDao.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDao.java
deleted file mode 100644
index b2128eb..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDao.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs.dao;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface OvsNicMappingDao extends GenericDao<OvsNicMappingVO, Long> {
-
-	public OvsNicMappingVO findByNicUuid(String nicUuid);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0624fe5d/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDaoImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDaoImpl.java
deleted file mode 100644
index 87e41b7..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDaoImpl.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs.dao;
-
-import javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Op;
-
-@Component
-@Local(value=OvsNicMappingDao.class)
-public class OvsNicMappingDaoImpl extends GenericDaoBase<OvsNicMappingVO, Long> implements OvsNicMappingDao{
-
-	protected final SearchBuilder<OvsNicMappingVO> nicSearch;
-
-	public OvsNicMappingDaoImpl() {
-        nicSearch = createSearchBuilder();
-        nicSearch.and("nicUuid", nicSearch.entity().getNicUuid(), Op.EQ);
-        nicSearch.done();
-    }
-
-	@Override
-	public OvsNicMappingVO findByNicUuid(String nicUuid) {
-		SearchCriteria<OvsNicMappingVO> sc = nicSearch.create();
-        sc.setParameters("nicUuid", nicUuid);
-        return findOneBy(sc);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0624fe5d/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingVO.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingVO.java
deleted file mode 100644
index dc4a931..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingVO.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs.dao;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import org.apache.cloudstack.api.InternalIdentity;
-
-@Entity
-@Table(name="ovs_nic_map")
-public class OvsNicMappingVO implements InternalIdentity {
-
-	@Id
-	@GeneratedValue(strategy = GenerationType.IDENTITY)
-	@Column(name="id")
-	private long id;
-
-	@Column(name="logicalswitch")
-	private String logicalSwitchUuid;
-
-	@Column(name="logicalswitchport")
-	private String logicalSwitchPortUuid;
-
-	@Column(name="nic")
-	private String nicUuid;
-
-	public OvsNicMappingVO() {
-
-	}
-
-	public OvsNicMappingVO (String logicalSwitchUuid, String logicalSwitchPortUuid, String nicUuid) {
-        this.logicalSwitchUuid = logicalSwitchUuid;
-        this.logicalSwitchPortUuid = logicalSwitchPortUuid;
-        this.nicUuid = nicUuid;
-    }
-
-	public String getLogicalSwitchUuid() {
-        return logicalSwitchUuid;
-    }
-
-	public void setLogicalSwitchUuid(String logicalSwitchUuid) {
-        this.logicalSwitchUuid = logicalSwitchUuid;
-    }
-
-    public String getLogicalSwitchPortUuid() {
-        return logicalSwitchPortUuid;
-    }
-
-    public void setLogicalSwitchPortUuid(String logicalSwitchPortUuid) {
-        this.logicalSwitchPortUuid = logicalSwitchPortUuid;
-    }
-
-    public String getNicUuid() {
-        return nicUuid;
-    }
-
-    public void setNicUuid(String nicUuid) {
-        this.nicUuid = nicUuid;
-    }
-
-    public long getId() {
-        return id;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0624fe5d/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 6ec5723..00ac4d1 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -2103,16 +2103,6 @@ CREATE TABLE `cloud`.`vm_disk_statistics` (
 insert into `cloud`.`vm_disk_statistics`(data_center_id,account_id,vm_id,volume_id) 
 select volumes.data_center_id, volumes.account_id, vm_instance.id, volumes.id from volumes,vm_instance where vm_instance.vm_type="User" and vm_instance.state<>"Expunging" and volumes.instance_id=vm_instance.id order by vm_instance.id;
 
-DROP TABLE IF EXISTS `cloud`.`ovs_nic_map`;
-CREATE TABLE `cloud`.`ovs_nic_map` (
-  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
-  `logicalswitch` varchar(255) NOT NULL COMMENT 'uuid of logical switch this port is provisioned on',
-  `logicalswitchport` varchar(255) UNIQUE COMMENT 'uuid of this logical switch port',
-  `nic` varchar(255) UNIQUE COMMENT 'cloudstack uuid of the nic connected to this logical switch port',
-  PRIMARY KEY (`id`),
-  CONSTRAINT `fk_ovs_nic_map__nic` FOREIGN KEY(`nic`) REFERENCES `nics`(`uuid`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
 DROP TABLE IF EXISTS `cloud`.`ovs_providers`;
 CREATE TABLE `cloud`.`ovs_providers` (
   `id` bigint unsigned NOT NULL auto_increment COMMENT 'id',


[16/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
fix UI


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/32c55e6d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/32c55e6d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/32c55e6d

Branch: refs/heads/master
Commit: 32c55e6d0c80a80c110c13febab9661cb28de777
Parents: 015ab6a
Author: tuna <ng...@gmail.com>
Authored: Sat Oct 5 18:35:18 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:15 2013 +0700

----------------------------------------------------------------------
 ui/scripts/zoneWizard.js | 94 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/32c55e6d/ui/scripts/zoneWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/zoneWizard.js b/ui/scripts/zoneWizard.js
index 000bed3..6c1c814 100755
--- a/ui/scripts/zoneWizard.js
+++ b/ui/scripts/zoneWizard.js
@@ -3022,6 +3022,100 @@
                                                         });
                                                         // ***** Virtual Router ***** (end) *****
 
+                                                         // ***** Ovs ***** (begin) *****
+                                                        var ovsProviderId =  null;
+                                                        $.ajax({
+                                                            url: createURL("listNetworkServiceProviders&name=Ovs&physicalNetworkId=" + thisPhysicalNetwork.id),
+                                                            dataType: "json",
+                                                            async: false,
+                                                            success: function (json) {
+                                                                var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;
+                                                                if (items != null && items.length > 0) {
+                                                                    ovsProviderId = items[0].id;
+                                                                }
+                                                            }
+                                                        });
+                                                        if (ovsProviderId != null) {
+                                                            var ovsElementId = null;
+                                                            $.ajax({
+                                                                url: createURL("listOvsElements&nspid=" + ovsProviderId),
+                                                                dataType: "json",
+                                                                async: false,
+                                                                success: function (json) {
+                                                                    var items = json.listovselementsresponse.ovselement;
+                                                                    if (items != null && items.length > 0) {
+                                                                        ovsElementId = items[0].id;
+                                                                    }
+                                                                }
+                                                            });
+                                                            if (ovsElementId != null) {
+                                                                $.ajax({
+                                                                    url: createURL("configureOvsElement&enabled=true&id=" + ovsElementId),
+                                                                    dataType: "json",
+                                                                    async: false,
+                                                                    success: function (json) {
+                                                                        var jobId = json.configureovselementresponse.jobid;
+                                                                        var enableOvsElementIntervalID = setInterval(function () {
+                                                                            $.ajax({
+                                                                                url: createURL("queryAsyncJobResult&jobId=" + jobId),
+                                                                                dataType: "json",
+                                                                                success: function (json) {
+                                                                                    var result = json.queryasyncjobresultresponse;
+                                                                                    if (result.jobstatus == 0) {
+                                                                                        return; //Job has not completed
+                                                                                    } else {
+                                                                                        clearInterval(enableOvsElementIntervalID);
+
+                                                                                        if (result.jobstatus == 1) { //configureOvsElement succeeded
+                                                                                            $.ajax({
+                                                                                                url: createURL("updateNetworkServiceProvider&state=Enabled&id=" + ovsProviderId),
+                                                                                                dataType: "json",
+                                                                                                async: false,
+                                                                                                success: function (json) {
+                                                                                                    var jobId = json.updatenetworkserviceproviderresponse.jobid;
+                                                                                                    var enableOvsProviderIntervalID = setInterval(function () {
+                                                                                                        $.ajax({
+                                                                                                            url: createURL("queryAsyncJobResult&jobId=" + jobId),
+                                                                                                            dataType: "json",
+                                                                                                            success: function (json) {
+                                                                                                                var result = json.queryasyncjobresultresponse;
+                                                                                                                if (result.jobstatus == 0) {
+                                                                                                                    return; //Job has not completed
+                                                                                                                } else {
+                                                                                                                    clearInterval(enableOvsProviderIntervalID);
+
+                                                                                                                    if (result.jobstatus == 2) {
+                                                                                                                        alert("failed to enable Ovs Provider. Error: " + _s(result.jobresult.errortext));
+                                                                                                                    }
+                                                                                                                }
+                                                                                                            },
+                                                                                                            error: function (XMLHttpResponse) {
+                                                                                                                var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                                                                                alert("updateNetworkServiceProvider failed. Error: " + errorMsg);
+                                                                                                            }
+                                                                                                        });
+                                                                                                    }, g_queryAsyncJobResultInterval);
+                                                                                                }
+                                                                                            });
+                                                                                        } else if (result.jobstatus == 2) {
+                                                                                            alert("configureOvsElement failed. Error: " + _s(result.jobresult.errortext));
+                                                                                        }
+                                                                                    }
+                                                                                },
+                                                                                error: function (XMLHttpResponse) {
+                                                                                    var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                                                    alert("configureOvsElement failed. Error: " + errorMsg);
+                                                                                }
+                                                                            });
+                                                                        }, g_queryAsyncJobResultInterval);
+                                                                    }
+                                                                });
+                                                            }
+
+
+                                                        }
+                                                        // ***** Ovs ***** (end) *****
+
                                                         // ***** Internal LB ***** (begin) *****
                                                         var internalLbProviderId;
                                                         $.ajax({


[02/21] tuna

Posted by tu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 315df5e..aa569fd 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -17916,35 +17916,55 @@
             jsonObj["redundantRouterState"] = "";
         }
     }
-
-    var refreshNspData = function(nspName) {
-        var array1 = [];
-        if (nspName != null)
-            array1.push("&name=" + nspName);
-
-        $.ajax({
-            url: createURL("listNetworkServiceProviders&physicalnetworkid=" + selectedPhysicalNetworkObj.id + array1.join("")),
-            dataType: "json",
-            async: false,
-            success: function(json) {
-                nspMap = {}; //reset
-
-                var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;
-                if (items != null) {
-                    for (var i = 0; i < items.length; i++) {
-                        switch (items[i].name) {
-                            case "VirtualRouter":
-                                nspMap["virtualRouter"] = items[i];
-                                break;
-                            case "InternalLbVm":
-                                nspMap["InternalLbVm"] = items[i];
-                                break;
-                            case "VpcVirtualRouter":
-                                nspMap["vpcVirtualRouter"] = items[i];
-                                break;
-                            case "Netscaler":
-                                nspMap["netscaler"] = items[i];
-                                break;
+  };
+
+	var addExtraPropertiesToClusterObject = function(jsonObj) {
+		if(jsonObj.managedstate == "Managed") {
+			jsonObj.state = jsonObj.allocationstate; //jsonObj.state == Enabled, Disabled
+		}
+		else {
+			jsonObj.state = jsonObj.managedstate; //jsonObj.state == Unmanaged, PrepareUnmanaged, PrepareUnmanagedError
+		}
+  }
+	
+	var addExtraPropertiesToRouterInstanceObject = function(jsonObj) {  		
+		if(jsonObj.isredundantrouter == true)
+			jsonObj["redundantRouterState"] = jsonObj.redundantstate;
+		else
+			jsonObj["redundantRouterState"] = "";				
+  }	
+	
+	var refreshNspData = function(nspName) {	  
+		var array1 = [];
+		if(nspName != null)
+		  array1.push("&name=" + nspName);
+		
+		$.ajax({
+			url: createURL("listNetworkServiceProviders&physicalnetworkid=" + selectedPhysicalNetworkObj.id + array1.join("")),
+			dataType: "json",
+			async: false,
+			success: function(json) {
+			  nspMap = {}; //reset 
+			
+				var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;	        
+        if(items != null) {				
+					for(var i = 0; i < items.length; i++) {
+						switch(items[i].name) {
+							case "VirtualRouter":
+								nspMap["virtualRouter"] = items[i];
+								break;
+              case "Ovs":
+                nspMap["Ovs"] = items[i];
+                break;
+							case "InternalLbVm":
+							  nspMap["InternalLbVm"] = items[i];
+							  break;
+							case "VpcVirtualRouter":
+							  nspMap["vpcVirtualRouter"] = items[i];
+							  break;
+							case "Netscaler":
+								nspMap["netscaler"] = items[i];
+								break;
                             case "MidoNet":
                                 nspMap["midoNet"] = items[i];
                                 break;
@@ -17969,59 +17989,52 @@
                             case "NiciraNvp":
                                 nspMap["niciraNvp"] = items[i];
                                 break;
-                            case "BigSwitchVns":
-                                nspMap["bigswitchVns"] = items[i];
-                                break;
-                        }
-                    }
-                }
-            }
-        });
-
-        nspHardcodingArray = [{
-            id: 'netscaler',
-            name: 'NetScaler',
-            state: nspMap.netscaler ? nspMap.netscaler.state : 'Disabled'
-        }, {
-            id: 'virtualRouter',
-            name: 'Virtual Router',
-            state: nspMap.virtualRouter ? nspMap.virtualRouter.state : 'Disabled'
-        }, {
-            id: 'niciraNvp',
-            name: 'Nicira Nvp',
-            state: nspMap.niciraNvp ? nspMap.niciraNvp.state : 'Disabled'
-        }, {
-            id: 'bigswitchVns',
-            name: 'BigSwitch Vns',
-            state: nspMap.bigswitchVns ? nspMap.bigswitchVns.state : 'Disabled'
-        }, {
-            id: 'BaremetalDhcpProvider',
-            name: 'Baremetal DHCP',
-            state: nspMap.BaremetalDhcpProvider ? nspMap.BaremetalDhcpProvider.state : 'Disabled'
-        }, {
-            id: 'BaremetalPxeProvider',
-            name: 'Baremetal PXE',
-            state: nspMap.BaremetalPxeProvider ? nspMap.BaremetalPxeProvider.state : 'Disabled'
-        }];
-
-        $(window).trigger('cloudStack.system.serviceProviders.makeHarcodedArray', {
-            nspHardcodingArray: nspHardcodingArray,
-            selectedZoneObj: selectedZoneObj,
-            selectedPhysicalNetworkObj: selectedPhysicalNetworkObj
-        });
-
-        if (selectedZoneObj.networktype == "Basic") {
-            nspHardcodingArray.push({
-                id: 'securityGroups',
-                name: 'Security Groups',
-                state: nspMap.securityGroups ? nspMap.securityGroups.state : 'Disabled'
-            });
-        } else if (selectedZoneObj.networktype == "Advanced") {
-            nspHardcodingArray.push({
-                id: 'midoNet',
-                name: 'MidoNet',
-                state: nspMap.midoNet ? nspMap.midoNet.state : 'Disabled'
-            });
+                                                        case "BigSwitchVns":
+                                                                nspMap["bigswitchVns"] = items[i];
+                                                                break;
+						}
+					}
+				}
+			}
+		});
+   
+		nspHardcodingArray = [
+			{
+				id: 'netscaler',
+				name: 'NetScaler',
+				state: nspMap.netscaler? nspMap.netscaler.state : 'Disabled'
+			},
+			{
+				id: 'virtualRouter',
+				name: 'Virtual Router',
+				state: nspMap.virtualRouter ? nspMap.virtualRouter.state : 'Disabled'
+			},
+      {
+        id: 'Ovs',
+        name: 'Ovs',
+        state: nspMap.Ovs ? nspMap.Ovs.state : 'Disabled'
+      },
+            {
+                id: 'niciraNvp',
+                name: 'Nicira Nvp',
+                state: nspMap.niciraNvp ? nspMap.niciraNvp.state : 'Disabled'
+            },
+                        {
+                                id: 'bigswitchVns',
+                                name: 'BigSwitch Vns',
+                                state: nspMap.bigswitchVns ? nspMap.bigswitchVns.state : 'Disabled'
+                        },
+      {
+        id: 'BaremetalDhcpProvider',
+        name: 'Baremetal DHCP',
+        state: nspMap.BaremetalDhcpProvider ? nspMap.BaremetalDhcpProvider.state : 'Disabled'
+      },
+      {
+        id: 'BaremetalPxeProvider',
+        name: 'Baremetal PXE',
+        state: nspMap.BaremetalPxeProvider ? nspMap.BaremetalPxeProvider.state : 'Disabled'
+      }
+		];
 
             nspHardcodingArray.push({
                 id: 'InternalLbVm',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/ui/scripts/zoneWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/zoneWizard.js b/ui/scripts/zoneWizard.js
index 5437fe4..000bed3 100755
--- a/ui/scripts/zoneWizard.js
+++ b/ui/scripts/zoneWizard.js
@@ -219,6 +219,7 @@
             },
 
             storageTrafficIPRange: function(args) {
+
                 var multiEditData = [];
                 var totalIndex = 0;
 
@@ -3056,6 +3057,7 @@
                                                             return;
                                                         }
 
+                                                        var virtualRouterElementId;
                                                         $.ajax({
                                                             url: createURL("configureInternalLoadBalancerElement&enabled=true&id=" + internalLbElementId),
                                                             dataType: "json",
@@ -3119,6 +3121,202 @@
                                                                 }, g_queryAsyncJobResultInterval);
                                                             }
                                                         });
+                                                        // ***** Virtual Router ***** (end) *****
+
+                                                        // ***** Ovs ***** (begin) *****
+                                                        var ovsProviderId =  null;
+                                                        $.ajax({
+                                                            url: createURL("listNetworkServiceProviders&name=Ovs&physicalNetworkId=" + thisPhysicalNetwork.id),
+                                                            dataType: "json",
+                                                            async: false,
+                                                            success: function (json) {
+                                                                var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;
+                                                                if (items != null && items.length > 0) {
+                                                                    ovsProviderId = items[0].id;
+                                                                }
+                                                            }
+                                                        });
+                                                        if (ovsProviderId != null) {
+                                                            var ovsElementId = null;
+                                                            $.ajax({
+                                                                url: createURL("listOvsElements&nspid=" + ovsProviderId),
+                                                                dataType: "json",
+                                                                async: false,
+                                                                success: function (json) {
+                                                                    var items = json.listovselementsresponse.ovselement;
+                                                                    if (items != null && items.length > 0) {
+                                                                        ovsElementId = items[0].id;
+                                                                    }
+                                                                }
+                                                            });
+                                                            if (ovsElementId != null) {
+                                                                $.ajax({
+                                                                    url: createURL("configureOvsElement&enabled=true&id=" + ovsElementId),
+                                                                    dataType: "json",
+                                                                    async: false,
+                                                                    success: function (json) {
+                                                                        var jobId = json.configureovselementresponse.jobid;
+                                                                        var enableOvsElementIntervalID = setInterval(function () {
+                                                                            $.ajax({
+                                                                                url: createURL("queryAsyncJobResult&jobId=" + jobId),
+                                                                                dataType: "json",
+                                                                                success: function (json) {
+                                                                                    var result = json.queryasyncjobresultresponse;
+                                                                                    if (result.jobstatus == 0) {
+                                                                                        return; //Job has not completed
+                                                                                    } else {
+                                                                                        clearInterval(enableOvsElementIntervalID);
+
+                                                                                        if (result.jobstatus == 1) { //configureOvsElement succeeded
+                                                                                            $.ajax({
+                                                                                                url: createURL("updateNetworkServiceProvider&state=Enabled&id=" + ovsProviderId),
+                                                                                                dataType: "json",
+                                                                                                async: false,
+                                                                                                success: function (json) {
+                                                                                                    var jobId = json.updatenetworkserviceproviderresponse.jobid;
+                                                                                                    var enableOvsProviderIntervalID = setInterval(function () {
+                                                                                                        $.ajax({
+                                                                                                            url: createURL("queryAsyncJobResult&jobId=" + jobId),
+                                                                                                            dataType: "json",
+                                                                                                            success: function (json) {
+                                                                                                                var result = json.queryasyncjobresultresponse;
+                                                                                                                if (result.jobstatus == 0) {
+                                                                                                                    return; //Job has not completed
+                                                                                                                } else {
+                                                                                                                    clearInterval(enableOvsProviderIntervalID);
+
+                                                                                                                    if (result.jobstatus == 2) {
+                                                                                                                        alert("failed to enable Ovs Provider. Error: " + _s(result.jobresult.errortext));
+                                                                                                                    }
+                                                                                                                }
+                                                                                                            },
+                                                                                                            error: function (XMLHttpResponse) {
+                                                                                                                var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                                                                                alert("updateNetworkServiceProvider failed. Error: " + errorMsg);
+                                                                                                            }
+                                                                                                        });
+                                                                                                    }, g_queryAsyncJobResultInterval);
+                                                                                                }
+                                                                                            });
+                                                                                        } else if (result.jobstatus == 2) {
+                                                                                            alert("configureOvsElement failed. Error: " + _s(result.jobresult.errortext));
+                                                                                        }
+                                                                                    }
+                                                                                },
+                                                                                error: function (XMLHttpResponse) {
+                                                                                    var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                                                    alert("configureOvsElement failed. Error: " + errorMsg);
+                                                                                }
+                                                                            });
+                                                                        }, g_queryAsyncJobResultInterval);
+                                                                    }
+                                                                });
+                                                            }
+
+
+                                                        }
+
+
+                                                        // ***** Ovs ***** (end) *****
+
+                                                        // ***** Internal LB ***** (begin) *****
+                                                        var internalLbProviderId;
+                                                        $.ajax({
+                                                            url: createURL("listNetworkServiceProviders&name=Internallbvm&physicalNetworkId=" + thisPhysicalNetwork.id),
+                                                            dataType: "json",
+                                                            async: false,
+                                                            success: function (json) {
+                                                                var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;
+                                                                if (items != null && items.length > 0) {
+                                                                    internalLbProviderId = items[0].id;
+                                                                }
+                                                            }
+                                                        });
+                                                        if (internalLbProviderId == null) {
+                                                            alert("error: listNetworkServiceProviders API doesn't return internalLb provider ID");
+                                                            return;
+                                                        }
+
+                                                        var internalLbElementId;
+                                                        $.ajax({
+                                                            url: createURL("listInternalLoadBalancerElements&nspid=" + internalLbProviderId),
+                                                            dataType: "json",
+                                                            async: false,
+                                                            success: function (json) {
+                                                                var items = json.listinternalloadbalancerelementsresponse.internalloadbalancerelement;
+                                                                if (items != null && items.length > 0) {
+                                                                    internalLbElementId = items[0].id;
+                                                                }
+                                                            }
+                                                        });
+                                                        if (internalLbElementId == null) {
+                                                            alert("error: listInternalLoadBalancerElements API doesn't return Internal LB Element Id");
+                                                            return;
+                                                        }
+
+                                                        $.ajax({
+                                                            url: createURL("configureInternalLoadBalancerElement&enabled=true&id=" + internalLbElementId),
+                                                            dataType: "json",
+                                                            async: false,
+                                                            success: function (json) {
+                                                                var jobId = json.configureinternalloadbalancerelementresponse.jobid;
+                                                                var enableInternalLbElementIntervalID = setInterval(function () {
+                                                                    $.ajax({
+                                                                        url: createURL("queryAsyncJobResult&jobId=" + jobId),
+                                                                        dataType: "json",
+                                                                        success: function (json) {
+                                                                            var result = json.queryasyncjobresultresponse;
+                                                                            if (result.jobstatus == 0) {
+                                                                                return; //Job has not completed
+                                                                            } else {
+                                                                                clearInterval(enableInternalLbElementIntervalID);
+
+                                                                                if (result.jobstatus == 1) { //configureVirtualRouterElement succeeded
+                                                                                    $.ajax({
+                                                                                        url: createURL("updateNetworkServiceProvider&state=Enabled&id=" + internalLbProviderId),
+                                                                                        dataType: "json",
+                                                                                        async: false,
+                                                                                        success: function (json) {
+                                                                                            var jobId = json.updatenetworkserviceproviderresponse.jobid;
+                                                                                            var enableInternalLbProviderIntervalID = setInterval(function () {
+                                                                                                $.ajax({
+                                                                                                    url: createURL("queryAsyncJobResult&jobId=" + jobId),
+                                                                                                    dataType: "json",
+                                                                                                    success: function (json) {
+                                                                                                        var result = json.queryasyncjobresultresponse;
+                                                                                                        if (result.jobstatus == 0) {
+                                                                                                            return; //Job has not completed
+                                                                                                        } else {
+                                                                                                            clearInterval(enableInternalLbProviderIntervalID);
+
+                                                                                                            if (result.jobstatus == 1) { //Internal LB has been enabled successfully
+                                                                                                                //don't need to do anything here
+                                                                                                            } else if (result.jobstatus == 2) {
+                                                                                                                alert("failed to enable Internal LB Provider. Error: " + _s(result.jobresult.errortext));
+                                                                                                            }
+                                                                                                        }
+                                                                                                    },
+                                                                                                    error: function (XMLHttpResponse) {
+                                                                                                        var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                                                                        alert("failed to enable Internal LB Provider. Error: " + errorMsg);
+                                                                                                    }
+                                                                                                });
+                                                                                            }, g_queryAsyncJobResultInterval);
+                                                                                        }
+                                                                                    });
+                                                                                } else if (result.jobstatus == 2) {
+                                                                                    alert("configureVirtualRouterElement failed. Error: " + _s(result.jobresult.errortext));
+                                                                                }
+                                                                            }
+                                                                        },
+                                                                        error: function (XMLHttpResponse) {
+                                                                            var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                                            alert("configureVirtualRouterElement failed. Error: " + errorMsg);
+                                                                        }
+                                                                    });
+                                                                }, g_queryAsyncJobResultInterval);
+                                                            }
+                                                        });
                                                         // ***** Internal LB ***** (end) *****
 
                                                         if (args.data.zone.sgEnabled != true) { //Advanced SG-disabled zone
@@ -3128,7 +3326,7 @@
                                                                 url: createURL("listNetworkServiceProviders&name=VpcVirtualRouter&physicalNetworkId=" + thisPhysicalNetwork.id),
                                                                 dataType: "json",
                                                                 async: false,
-                                                                success: function(json) {
+                                                                success: function (json) {
                                                                     var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;
                                                                     if (items != null && items.length > 0) {
                                                                         vpcVirtualRouterProviderId = items[0].id;
@@ -3145,7 +3343,7 @@
                                                                 url: createURL("listVirtualRouterElements&nspid=" + vpcVirtualRouterProviderId),
                                                                 dataType: "json",
                                                                 async: false,
-                                                                success: function(json) {
+                                                                success: function (json) {
                                                                     var items = json.listvirtualrouterelementsresponse.virtualrouterelement;
                                                                     if (items != null && items.length > 0) {
                                                                         vpcVirtualRouterElementId = items[0].id;
@@ -3161,13 +3359,13 @@
                                                                 url: createURL("configureVirtualRouterElement&enabled=true&id=" + vpcVirtualRouterElementId),
                                                                 dataType: "json",
                                                                 async: false,
-                                                                success: function(json) {
+                                                                success: function (json) {
                                                                     var jobId = json.configurevirtualrouterelementresponse.jobid;
-                                                                    var enableVpcVirtualRouterElementIntervalID = setInterval(function() {
+                                                                    var enableVpcVirtualRouterElementIntervalID = setInterval(function () {
                                                                         $.ajax({
                                                                             url: createURL("queryAsyncJobResult&jobId=" + jobId),
                                                                             dataType: "json",
-                                                                            success: function(json) {
+                                                                            success: function (json) {
                                                                                 var result = json.queryasyncjobresultresponse;
                                                                                 if (result.jobstatus == 0) {
                                                                                     return; //Job has not completed
@@ -3179,13 +3377,13 @@
                                                                                             url: createURL("updateNetworkServiceProvider&state=Enabled&id=" + vpcVirtualRouterProviderId),
                                                                                             dataType: "json",
                                                                                             async: false,
-                                                                                            success: function(json) {
+                                                                                            success: function (json) {
                                                                                                 var jobId = json.updatenetworkserviceproviderresponse.jobid;
-                                                                                                var enableVpcVirtualRouterProviderIntervalID = setInterval(function() {
+                                                                                                var enableVpcVirtualRouterProviderIntervalID = setInterval(function () {
                                                                                                     $.ajax({
                                                                                                         url: createURL("queryAsyncJobResult&jobId=" + jobId),
                                                                                                         dataType: "json",
-                                                                                                        success: function(json) {
+                                                                                                        success: function (json) {
                                                                                                             var result = json.queryasyncjobresultresponse;
                                                                                                             if (result.jobstatus == 0) {
                                                                                                                 return; //Job has not completed
@@ -3199,7 +3397,7 @@
                                                                                                                 }
                                                                                                             }
                                                                                                         },
-                                                                                                        error: function(XMLHttpResponse) {
+                                                                                                        error: function (XMLHttpResponse) {
                                                                                                             var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
                                                                                                             alert("failed to enable VPC Virtual Router Provider. Error: " + errorMsg);
                                                                                                         }
@@ -3212,7 +3410,7 @@
                                                                                     }
                                                                                 }
                                                                             },
-                                                                            error: function(XMLHttpResponse) {
+                                                                            error: function (XMLHttpResponse) {
                                                                                 var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
                                                                                 alert("configureVirtualRouterElement failed. Error: " + errorMsg);
                                                                             }
@@ -3221,7 +3419,7 @@
                                                                 }
                                                             });
                                                             // ***** VPC Virtual Router ***** (end) *****
-                                                        } else { //args.data.zone.sgEnabled == true  //Advanced SG-enabled zone
+                                                        } else { //args.data.zone.sgEnabled == true  //Advanced SG-enabled zone                                                         
                                                             message(dictionary['message.enabling.security.group.provider']);
 
                                                             // get network service provider ID of Security Group
@@ -3230,7 +3428,7 @@
                                                                 url: createURL("listNetworkServiceProviders&name=SecurityGroupProvider&physicalNetworkId=" + thisPhysicalNetwork.id),
                                                                 dataType: "json",
                                                                 async: false,
-                                                                success: function(json) {
+                                                                success: function (json) {
                                                                     var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;
                                                                     if (items != null && items.length > 0) {
                                                                         securityGroupProviderId = items[0].id;
@@ -3291,6 +3489,7 @@
                 },
 
                 addNetscalerProvider: function(args) {
+
                     if (selectedNetworkOfferingHavingNetscaler == true) {
                         message(dictionary['message.adding.Netscaler.provider']);
 
@@ -3961,7 +4160,6 @@
                             url = hostname;
                         url += "/" + dcName + "/" + clusterName;
                         array1.push("&url=" + todb(url));
-
                         clusterName = hostname + "/" + dcName + "/" + clusterName; //override clusterName
                     }
                     array1.push("&clustername=" + todb(clusterName));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/utils/conf/db.properties
----------------------------------------------------------------------
diff --git a/utils/conf/db.properties b/utils/conf/db.properties
index e1b5fe9..709d79e 100644
--- a/utils/conf/db.properties
+++ b/utils/conf/db.properties
@@ -25,7 +25,7 @@ region.id=1
 # CloudStack database settings
 db.cloud.username=cloud
 db.cloud.password=cloud
-db.root.password=
+db.root.password=123
 db.cloud.host=localhost
 db.cloud.port=3306
 db.cloud.name=cloud


[03/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
tuna


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d935d386
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d935d386
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d935d386

Branch: refs/heads/master
Commit: d935d3865aa2a4fb39709f6943f02f9f5a422aff
Parents: 4e914b7
Author: tuna <ng...@gmail.com>
Authored: Mon Aug 12 23:19:15 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 api/src/com/cloud/network/Network.java          |   4 +-
 api/src/com/cloud/network/OvsProvider.java      |  10 +
 .../element/VirtualRouterElementService.java    |   6 +
 .../cloudstack/api/ResponseGenerator.java       |   8 +
 .../admin/router/ConfigureOvsElementCmd.java    | 116 +++++
 .../admin/router/ListOvsElementsCmd.java        |  91 ++++
 .../api/response/OvsProviderResponse.java       |  77 ++++
 client/tomcatconf/applicationContext.xml.in     |   1 +
 client/tomcatconf/commands.properties.in        |   5 +
 .../com/cloud/network/dao/OvsProviderDao.java   |  14 +
 .../cloud/network/dao/OvsProviderDaoImpl.java   |  57 +++
 .../cloud/network/element/OvsProviderVO.java    |  83 ++++
 .../xen/resource/CitrixResourceBase.java        |  12 +
 .../cloudstack/ovs/spring-ovs-context.xml       |   1 +
 .../com/cloud/network/element/OvsElement.java   |  87 ++--
 .../cloud/network/guru/OvsGuestNetworkGuru.java |  20 +-
 .../cloud/network/ovs/OvsTunnelManagerImpl.java | 425 ++++++++++++-------
 scripts/vm/hypervisor/xenserver/ovstunnel       |  24 +-
 scripts/vm/hypervisor/xenserver/vhd-util        | Bin 0 -> 318977 bytes
 server/src/com/cloud/api/ApiResponseHelper.java |  19 +
 .../com/cloud/network/NetworkServiceImpl.java   |  31 +-
 .../network/element/VirtualRouterElement.java   |  81 +++-
 .../com/cloud/server/ManagementServerImpl.java  |   4 +
 setup/db/create-schema.sql                      |  10 -
 setup/db/db/schema-410to420.sql                 |  22 +
 tools/apidoc/gen_toc.py                         |   1 +
 ui/scripts/system.js                            | 177 ++++----
 ui/scripts/zoneWizard.js                        | 224 +++++++++-
 utils/conf/db.properties                        |   2 +-
 29 files changed, 1286 insertions(+), 326 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/api/src/com/cloud/network/Network.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java
index 74398e8..d19c999 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -126,8 +126,8 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
         public static final Provider NiciraNvp = new Provider("NiciraNvp", false);
         public static final Provider InternalLbVm = new Provider("InternalLbVm", false);
         public static final Provider CiscoVnmc = new Provider("CiscoVnmc", true);
-		// Ovs
-		public static final Provider Ovs = new Provider("Ovs", false);
+        // add new Ovs provider
+        public static final Provider Ovs = new Provider("Ovs", false);
 
         private final String name;
         private final boolean isExternal;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/api/src/com/cloud/network/OvsProvider.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/OvsProvider.java b/api/src/com/cloud/network/OvsProvider.java
new file mode 100644
index 0000000..c993728
--- /dev/null
+++ b/api/src/com/cloud/network/OvsProvider.java
@@ -0,0 +1,10 @@
+package com.cloud.network;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+public interface OvsProvider extends InternalIdentity, Identity {
+	public boolean isEnabled();
+
+	public long getNspId();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/api/src/com/cloud/network/element/VirtualRouterElementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/element/VirtualRouterElementService.java b/api/src/com/cloud/network/element/VirtualRouterElementService.java
index e929d14..c8d45ca 100644
--- a/api/src/com/cloud/network/element/VirtualRouterElementService.java
+++ b/api/src/com/cloud/network/element/VirtualRouterElementService.java
@@ -18,9 +18,12 @@ package com.cloud.network.element;
 
 import java.util.List;
 
+import org.apache.cloudstack.api.command.admin.router.ConfigureOvsElementCmd;
 import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
+import org.apache.cloudstack.api.command.admin.router.ListOvsElementsCmd;
 import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
 
+import com.cloud.network.OvsProvider;
 import com.cloud.network.VirtualRouterProvider;
 import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.utils.component.PluggableService;
@@ -28,9 +31,12 @@ import com.cloud.utils.component.PluggableService;
 public interface VirtualRouterElementService extends PluggableService {
     VirtualRouterProvider configure(ConfigureVirtualRouterElementCmd cmd);
 
+	OvsProvider configure(ConfigureOvsElementCmd cmd);
     VirtualRouterProvider addElement(Long nspId, Type providerType);
 
     VirtualRouterProvider getCreatedElement(long id);
 
     List<? extends VirtualRouterProvider> searchForVirtualRouterElement(ListVirtualRouterElementsCmd cmd);
+
+	List<? extends OvsProvider> searchForOvsElement(ListOvsElementsCmd cmd);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/api/src/org/apache/cloudstack/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
index 2d37b6a..64b703e 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -67,6 +67,7 @@ import org.apache.cloudstack.api.response.NetworkOfferingResponse;
 import org.apache.cloudstack.api.response.NetworkResponse;
 import org.apache.cloudstack.api.response.NicResponse;
 import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
+import org.apache.cloudstack.api.response.OvsProviderResponse;
 import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 import org.apache.cloudstack.api.response.PodResponse;
 import org.apache.cloudstack.api.response.PortableIpRangeResponse;
@@ -118,7 +119,9 @@ import org.apache.cloudstack.region.PortableIpRange;
 import org.apache.cloudstack.region.Region;
 import org.apache.cloudstack.usage.Usage;
 
+import com.cloud.async.AsyncJob;
 import com.cloud.capacity.Capacity;
+import com.cloud.configuration.Configuration;
 import com.cloud.configuration.ResourceCount;
 import com.cloud.configuration.ResourceLimit;
 import com.cloud.dc.DataCenter;
@@ -134,6 +137,7 @@ import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
 import com.cloud.network.Network.Service;
 import com.cloud.network.Networks.IsolationType;
+import com.cloud.network.OvsProvider;
 import com.cloud.network.PhysicalNetwork;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PhysicalNetworkTrafficType;
@@ -353,6 +357,10 @@ public interface ResponseGenerator {
 
     VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result);
 
+	OvsProviderResponse createOvsProviderResponse(OvsProvider result);
+
+    LDAPConfigResponse createLDAPConfigResponse(String hostname, Integer port, Boolean useSSL, String queryFilter, String baseSearch, String dn);
+
     StorageNetworkIpRangeResponse createStorageNetworkIpRangeResponse(StorageNetworkIpRange result);
 
     RegionResponse createRegionResponse(Region region);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java
new file mode 100644
index 0000000..0419154
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java
@@ -0,0 +1,116 @@
+package org.apache.cloudstack.api.command.admin.router;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.OvsProviderResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.OvsProvider;
+import com.cloud.network.element.VirtualRouterElementService;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "configureOvsElement", responseObject = OvsProviderResponse.class, description = "Configures an ovs element.")
+public class ConfigureOvsElementCmd extends BaseAsyncCmd {
+	public static final Logger s_logger = Logger
+			.getLogger(ConfigureOvsElementCmd.class.getName());
+	private static final String s_name = "configureovselementresponse";
+	@Inject
+	private List<VirtualRouterElementService> _service;
+
+	// ///////////////////////////////////////////////////
+	// ////////////// API parameters /////////////////////
+	// ///////////////////////////////////////////////////
+
+	@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = OvsProviderResponse.class, required = true, description = "the ID of the ovs provider")
+	private Long id;
+
+	@Parameter(name = ApiConstants.ENABLED, type = CommandType.BOOLEAN, required = true, description = "Enabled/Disabled the service provider")
+	private Boolean enabled;
+
+	// ///////////////////////////////////////////////////
+	// ///////////////// Accessors ///////////////////////
+	// ///////////////////////////////////////////////////
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setEnabled(Boolean enabled) {
+		this.enabled = enabled;
+	}
+
+	public Boolean getEnabled() {
+		return enabled;
+	}
+
+	// ///////////////////////////////////////////////////
+	// ///////////// API Implementation///////////////////
+	// ///////////////////////////////////////////////////
+
+	@Override
+	public String getCommandName() {
+		return s_name;
+	}
+
+	public static String getResultObjectName() {
+		return "boolean";
+	}
+
+	@Override
+	public long getEntityOwnerId() {
+		return Account.ACCOUNT_ID_SYSTEM;
+	}
+
+	@Override
+	public String getEventType() {
+		return EventTypes.EVENT_NETWORK_ELEMENT_CONFIGURE;
+	}
+
+	@Override
+	public String getEventDescription() {
+		return "configuring ovs provider: " + id;
+	}
+
+	@Override
+	public ApiCommandJobType getInstanceType() {
+		return ApiCommandJobType.None;
+	}
+
+	@Override
+	public Long getInstanceId() {
+		return id;
+	}
+
+	@Override
+	public void execute() throws ConcurrentOperationException,
+			ResourceUnavailableException, InsufficientCapacityException {
+		UserContext.current().setEventDetails("Ovs element: " + id);
+		OvsProvider result = _service.get(0).configure(this);
+		if (result != null) {
+			OvsProviderResponse ovsResponse = _responseGenerator
+					.createOvsProviderResponse(result);
+			ovsResponse.setResponseName(getCommandName());
+			this.setResponseObject(ovsResponse);
+		} else {
+			throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
+					"Failed to configure the ovs provider");
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/api/src/org/apache/cloudstack/api/command/admin/router/ListOvsElementsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ListOvsElementsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ListOvsElementsCmd.java
new file mode 100644
index 0000000..3e3ee63
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/ListOvsElementsCmd.java
@@ -0,0 +1,91 @@
+package org.apache.cloudstack.api.command.admin.router;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.OvsProviderResponse;
+import org.apache.cloudstack.api.response.ProviderResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.OvsProvider;
+import com.cloud.network.element.VirtualRouterElementService;
+
+@APICommand(name = "listOvsElements", description = "Lists all available ovs elements.", responseObject = OvsProviderResponse.class)
+public class ListOvsElementsCmd extends BaseListCmd {
+	public static final Logger s_logger = Logger
+			.getLogger(ListNetworkOfferingsCmd.class.getName());
+	private static final String _name = "listovselementsresponse";
+	@Inject
+	private List<VirtualRouterElementService> _service;
+	// ///////////////////////////////////////////////////
+	// ////////////// API parameters /////////////////////
+	// ///////////////////////////////////////////////////
+	@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = OvsProviderResponse.class, description = "list ovs elements by id")
+	private Long id;
+
+	@Parameter(name = ApiConstants.NSP_ID, type = CommandType.UUID, entityType = ProviderResponse.class, description = "list ovs elements by network service provider id")
+	private Long nspId;
+
+	@Parameter(name = ApiConstants.ENABLED, type = CommandType.BOOLEAN, description = "list network offerings by enabled state")
+	private Boolean enabled;
+
+	// ///////////////////////////////////////////////////
+	// ///////////////// Accessors ///////////////////////
+	// ///////////////////////////////////////////////////
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setNspId(Long nspId) {
+		this.nspId = nspId;
+	}
+
+	public Long getNspId() {
+		return nspId;
+	}
+
+	public void setEnabled(Boolean enabled) {
+		this.enabled = enabled;
+	}
+
+	public Boolean getEnabled() {
+		return enabled;
+	}
+
+	@Override
+	public String getCommandName() {
+		return _name;
+	}
+	@Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
+        List<? extends OvsProvider> providers = _service.get(0).searchForOvsElement(this);
+        ListResponse<OvsProviderResponse> response = new ListResponse<OvsProviderResponse>();
+        List<OvsProviderResponse> providerResponses = new ArrayList<OvsProviderResponse>();
+        for (OvsProvider provider : providers) {
+        	OvsProviderResponse providerResponse = _responseGenerator.createOvsProviderResponse(provider);
+            providerResponses.add(providerResponse);
+        }
+        response.setResponses(providerResponses);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/api/src/org/apache/cloudstack/api/response/OvsProviderResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/OvsProviderResponse.java b/api/src/org/apache/cloudstack/api/response/OvsProviderResponse.java
new file mode 100644
index 0000000..23e6134
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/OvsProviderResponse.java
@@ -0,0 +1,77 @@
+package org.apache.cloudstack.api.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+
+import com.cloud.network.OvsProvider;
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+@EntityReference(value = OvsProvider.class)
+@SuppressWarnings("unused")
+public class OvsProviderResponse extends BaseResponse implements
+		ControlledEntityResponse {
+	@SerializedName(ApiConstants.ID)
+	@Param(description = "the id of the ovs")
+	private String id;
+	@SerializedName(ApiConstants.NSP_ID)
+	@Param(description = "the physical network service provider id of the provider")
+	private String nspId;
+	@SerializedName(ApiConstants.ENABLED)
+	@Param(description = "Enabled/Disabled the service provider")
+	private Boolean enabled;
+	@SerializedName(ApiConstants.ACCOUNT)
+	@Param(description = "the account associated with the provider")
+	private String accountName;
+	@SerializedName(ApiConstants.PROJECT_ID)
+	@Param(description = "the project id of the ipaddress")
+	private String projectId;
+	@SerializedName(ApiConstants.PROJECT)
+	@Param(description = "the project name of the address")
+	private String projectName;
+	@SerializedName(ApiConstants.DOMAIN_ID)
+	@Param(description = "the domain ID associated with the provider")
+	private String domainId;
+
+	@SerializedName(ApiConstants.DOMAIN)
+	@Param(description = "the domain associated with the provider")
+	private String domainName;
+
+	@Override
+	public void setAccountName(String accountName) {
+		this.accountName = accountName;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	@Override
+	public void setDomainId(String domainId) {
+		this.domainId = domainId;
+	}
+
+	@Override
+	public void setDomainName(String domainName) {
+		this.domainName = domainName;
+	}
+
+	@Override
+	public void setProjectId(String projectId) {
+		this.projectId = projectId;
+	}
+
+	@Override
+	public void setProjectName(String projectName) {
+		this.projectName = projectName;
+	}
+
+	public void setNspId(String nspId) {
+		this.nspId = nspId;
+	}
+
+	public void setEnabled(Boolean enabled) {
+		this.enabled = enabled;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 5260681..b3778d4 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -355,6 +355,7 @@
   <bean id="vMTemplateZoneDaoImpl" class="com.cloud.storage.dao.VMTemplateZoneDaoImpl" />
   <bean id="versionDaoImpl" class="com.cloud.upgrade.dao.VersionDaoImpl" />
   <bean id="virtualRouterProviderDaoImpl" class="com.cloud.network.dao.VirtualRouterProviderDaoImpl" />
+  <bean id="ovsProviderDaoImpl" class="com.cloud.network.dao.OvsProviderDaoImpl" />
   <bean id="vmRulesetLogDaoImpl" class="com.cloud.network.security.dao.VmRulesetLogDaoImpl" />
   <bean id="volumeDaoImpl" class="com.cloud.storage.dao.VolumeDaoImpl" />
   <bean id="volumeDetailsDaoImpl" class="com.cloud.storage.dao.VolumeDetailsDaoImpl" />

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index da4c03f..bd46fa2 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -503,6 +503,11 @@ createVirtualRouterElement=7
 configureVirtualRouterElement=7
 listVirtualRouterElements=7
 
+#### ovs commands
+createOvsElement=7
+configureOvsElement=7
+listOvsElements=7
+
 #### usage commands
 generateUsageRecords=1
 listUsageRecords=7

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/engine/schema/src/com/cloud/network/dao/OvsProviderDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/OvsProviderDao.java b/engine/schema/src/com/cloud/network/dao/OvsProviderDao.java
new file mode 100644
index 0000000..b23e3d3
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/OvsProviderDao.java
@@ -0,0 +1,14 @@
+package com.cloud.network.dao;
+
+import java.util.List;
+
+import com.cloud.network.element.OvsProviderVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface OvsProviderDao extends GenericDao<OvsProviderVO, Long> {
+	public OvsProviderVO findByNspId(long nspId);
+
+	public List<OvsProviderVO> listByEnabled(boolean enabled);
+
+	public OvsProviderVO findByIdAndEnabled(long id, boolean enabled);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/engine/schema/src/com/cloud/network/dao/OvsProviderDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/OvsProviderDaoImpl.java b/engine/schema/src/com/cloud/network/dao/OvsProviderDaoImpl.java
new file mode 100644
index 0000000..b00d5c1
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/dao/OvsProviderDaoImpl.java
@@ -0,0 +1,57 @@
+package com.cloud.network.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.element.OvsProviderVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value = OvsProviderDao.class)
+@DB(txn = false)
+public class OvsProviderDaoImpl extends GenericDaoBase<OvsProviderVO, Long>
+		implements OvsProviderDao {
+	final SearchBuilder<OvsProviderVO> AllFieldsSearch;
+
+	public OvsProviderDaoImpl() {
+		super();
+		AllFieldsSearch = createSearchBuilder();
+		AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(),
+				SearchCriteria.Op.EQ);
+		AllFieldsSearch.and("nsp_id", AllFieldsSearch.entity().getNspId(),
+				SearchCriteria.Op.EQ);
+		AllFieldsSearch.and("uuid", AllFieldsSearch.entity().getUuid(),
+				SearchCriteria.Op.EQ);
+		AllFieldsSearch.and("enabled", AllFieldsSearch.entity().isEnabled(),
+				SearchCriteria.Op.EQ);
+		AllFieldsSearch.done();
+	}
+
+	@Override
+	public OvsProviderVO findByNspId(long nspId) {
+		SearchCriteria<OvsProviderVO> sc = AllFieldsSearch.create();
+		sc.setParameters("nsp_id", nspId);
+		return findOneBy(sc);
+	}
+
+	@Override
+	public List<OvsProviderVO> listByEnabled(boolean enabled) {
+		SearchCriteria<OvsProviderVO> sc = AllFieldsSearch.create();
+		sc.setParameters("enabled", enabled);
+		return listBy(sc);
+	}
+
+	@Override
+	public OvsProviderVO findByIdAndEnabled(long id, boolean enabled) {
+		SearchCriteria<OvsProviderVO> sc = AllFieldsSearch.create();
+		sc.setParameters("id", id);
+		sc.setParameters("enabled", enabled);
+		return findOneBy(sc);
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/engine/schema/src/com/cloud/network/element/OvsProviderVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/element/OvsProviderVO.java b/engine/schema/src/com/cloud/network/element/OvsProviderVO.java
new file mode 100644
index 0000000..bc3455a
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/element/OvsProviderVO.java
@@ -0,0 +1,83 @@
+package com.cloud.network.element;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.network.OvsProvider;
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = ("ovs_providers"))
+public class OvsProviderVO implements OvsProvider {
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	@Column(name = "id")
+	long id;
+
+	@Column(name = "nsp_id")
+	private long nspId;
+
+	@Column(name = "uuid")
+	private String uuid;
+
+	@Column(name = "enabled")
+	private boolean enabled;
+
+	@Column(name = GenericDao.REMOVED_COLUMN)
+	Date removed;
+
+	public OvsProviderVO() {
+		this.uuid = UUID.randomUUID().toString();
+	}
+
+	public OvsProviderVO(long nspId) {
+		this.nspId = nspId;
+		this.uuid = UUID.randomUUID().toString();
+	}
+
+	@Override
+	public long getNspId() {
+		return nspId;
+	}
+
+	public String getUuid() {
+		return uuid;
+	}
+
+	@Override
+	public long getId() {
+		return id;
+	}
+
+	public Date getRemoved() {
+		return removed;
+	}
+
+	public void setEnabled(boolean enabled) {
+		this.enabled = enabled;
+	}
+
+	@Override
+	public boolean isEnabled() {
+		return this.enabled;
+	}
+
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	public void setNspId(long nspId) {
+		this.nspId = nspId;
+	}
+
+	public void setUuid(String uuid) {
+		this.uuid = uuid;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/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 25f30f4..e093253 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
@@ -156,6 +156,18 @@ import com.cloud.agent.api.ModifyStoragePoolAnswer;
 import com.cloud.agent.api.ModifyStoragePoolCommand;
 import com.cloud.agent.api.NetworkRulesSystemVmCommand;
 import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand;
+import com.cloud.agent.api.OvsCreateGreTunnelCommand;
+import com.cloud.agent.api.OvsCreateGreTunnelAnswer;
+import com.cloud.agent.api.OvsCreateTunnelCommand;
+import com.cloud.agent.api.OvsDestroyTunnelCommand;
+import com.cloud.agent.api.OvsSetupBridgeCommand;
+import com.cloud.agent.api.OvsDestroyBridgeCommand;
+import com.cloud.agent.api.OvsCreateTunnelAnswer;
+import com.cloud.agent.api.OvsDeleteFlowCommand;
+import com.cloud.agent.api.OvsSetTagAndFlowAnswer;
+import com.cloud.agent.api.OvsFetchInterfaceAnswer;
+import com.cloud.agent.api.OvsSetTagAndFlowCommand;
+import com.cloud.agent.api.OvsFetchInterfaceCommand;
 import com.cloud.agent.api.PingCommand;
 import com.cloud.agent.api.PingRoutingCommand;
 import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml b/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
index e60d93e..c6012d9 100644
--- a/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
+++ b/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
@@ -38,5 +38,6 @@
     <bean id="ovsTunnelManagerImpl" class="com.cloud.network.ovs.OvsTunnelManagerImpl" />
     <bean id="ovsTunnelInterfaceDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" />
     <bean id="ovsTunnelNetworkDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" />
+    <bean id="ovsProviderDaoImpl" class="com.cloud.network.dao.OvsProviderDaoImpl" />
     
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index 263a214..06965e8 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.network.element;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -46,6 +47,8 @@ import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.ovs.OvsTunnelManager;
+import com.cloud.network.router.VirtualRouter.Role;
+import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
 import com.cloud.network.rules.PortForwardingRule;
 import com.cloud.network.rules.StaticNat;
 import com.cloud.offering.NetworkOffering;
@@ -54,9 +57,11 @@ import com.cloud.resource.ResourceStateAdapter;
 import com.cloud.resource.ServerResource;
 import com.cloud.resource.UnableDeleteHostException;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.DomainRouterDao;
 
 @Local(value = { NetworkElement.class, ConnectivityProvider.class,
 		SourceNatServiceProvider.class, StaticNatServiceProvider.class,
@@ -73,6 +78,10 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 	NetworkServiceMapDao _ntwkSrvcDao;
 	@Inject
 	ResourceManager _resourceMgr;
+	@Inject
+	DomainRouterDao _routerDao;
+	@Inject
+	VpcVirtualNetworkApplianceManager _routerMgr;
 
 	private static final Logger s_logger = Logger.getLogger(OvsElement.class);
 	private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
@@ -130,8 +139,6 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 		if (!canHandle(network, Service.Connectivity)) {
 			return false;
 		}
-		// TODO: implement SourceNat immediately when we code L3 services
-
 		return true;
 	}
 
@@ -221,35 +228,35 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 			return false;
 		}
 
-		if ((services.contains(Service.PortForwarding) || services
-				.contains(Service.StaticNat))
-				&& !services.contains(Service.SourceNat)) {
-			s_logger.warn("Unable to provide StaticNat and/or PortForwarding without the SourceNat service");
-			return false;
-		}
+		// if ((services.contains(Service.PortForwarding) || services
+		// .contains(Service.StaticNat))
+		// && !services.contains(Service.SourceNat)) {
+		// s_logger.warn("Unable to provide StaticNat and/or PortForwarding without the SourceNat service");
+		// return false;
+		// }
 		return true;
 	}
 
 	private static Map<Service, Map<Capability, String>> setCapabilities() {
 		Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
 
-		// we need L3 support for coding L3 services in next period
-
 		// L2 Support : SDN provisioning
 		capabilities.put(Service.Connectivity, null);
 
+		// TODO: we need L3 support for coding L3 services in next period
 		// L3 Support : Generic?
-		capabilities.put(Service.Gateway, null);
+		// capabilities.put(Service.Gateway, null);
 
 		// L3 Support : SourceNat
-		Map<Capability, String> sourceNatCapabilities = new HashMap<Capability, String>();
-		sourceNatCapabilities.put(Capability.SupportedSourceNatTypes,
-				"peraccount");
-		sourceNatCapabilities.put(Capability.RedundantRouter, "false");
-		capabilities.put(Service.SourceNat, sourceNatCapabilities);
+		// Map<Capability, String> sourceNatCapabilities = new
+		// HashMap<Capability, String>();
+		// sourceNatCapabilities.put(Capability.SupportedSourceNatTypes,
+		// "peraccount");
+		// sourceNatCapabilities.put(Capability.RedundantRouter, "false");
+		// capabilities.put(Service.SourceNat, sourceNatCapabilities);
 
 		// L3 Support : Port Forwarding
-		capabilities.put(Service.PortForwarding, null);
+		// capabilities.put(Service.PortForwarding, null);
 
 		// L3 support : StaticNat
 		capabilities.put(Service.StaticNat, null);
@@ -259,7 +266,8 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 
 	@Override
 	public List<Class<?>> getCommands() {
-		return null;
+		List<Class<?>> cmdList = new ArrayList<Class<?>>();
+		return cmdList;
 	}
 
 	@Override
@@ -291,24 +299,53 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 	// TODO: Adding L3 services below
 	@Override
 	public IpDeployer getIpDeployer(Network network) {
-		// TODO Auto-generated method stub
-		return null;
+		return this;
 	}
 
 	@Override
 	public boolean applyIps(Network network,
 			List<? extends PublicIpAddress> ipAddress, Set<Service> services)
 			throws ResourceUnavailableException {
-		// TODO Auto-generated method stub
-		return false;
+		boolean canHandle = true;
+		for (Service service : services) {
+			// check if Ovs can handle services except SourceNat
+			if (!canHandle(network, service) && service != Service.SourceNat) {
+				canHandle = false;
+				break;
+			}
+		}
+		if (canHandle) {
+			List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
+					network.getId(), Role.VIRTUAL_ROUTER);
+			if (routers == null || routers.isEmpty()) {
+				s_logger.debug("Virtual router element doesn't need to associate ip addresses on the backend; virtual "
+						+ "router doesn't exist in the network "
+						+ network.getId());
+				return true;
+			}
+
+			return _routerMgr.associatePublicIP(network, ipAddress, routers);
+		} else {
+			return false;
+		}
 	}
 
 	@Override
-	public boolean applyStaticNats(Network config,
+	public boolean applyStaticNats(Network network,
 			List<? extends StaticNat> rules)
 			throws ResourceUnavailableException {
-		// TODO Auto-generated method stub
-		return false;
+		if (!canHandle(network, Service.StaticNat)) {
+			return false;
+		}
+		List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
+				network.getId(), Role.VIRTUAL_ROUTER);
+		if (routers == null || routers.isEmpty()) {
+			s_logger.debug("Ovs element doesn't need to apply static nat on the backend; virtual "
+					+ "router doesn't exist in the network " + network.getId());
+			return true;
+		}
+
+		return _routerMgr.applyStaticNats(network, rules, routers);
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
index 635aff1..939f98a 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
@@ -91,9 +91,9 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
 	public Network design(NetworkOffering offering, DeploymentPlan plan,
 			Network userSpecified, Account owner) {
 
-		if (!_ovsTunnelMgr.isOvsTunnelEnabled()) {
-			return null;
-		}
+		// if (!_ovsTunnelMgr.isOvsTunnelEnabled()) {
+		// return null;
+		// }
 		PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan
 				.getPhysicalNetworkId());
 		DataCenter dc = _dcDao.findById(plan.getDataCenterId());
@@ -118,10 +118,11 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
 			throws InsufficientVirtualNetworkCapcityException {
 		assert (network.getState() == State.Implementing) : "Why are we implementing "
 				+ network;
-		if (!_ovsTunnelMgr.isOvsTunnelEnabled()) {
-			return null;
-		}
+		// if (!_ovsTunnelMgr.isOvsTunnelEnabled()) {
+		// return null;
+		// }
 		long dcId = dest.getDataCenter().getId();
+		NetworkType nwType = dest.getDataCenter().getNetworkType();
 		// get physical network id
 		Long physicalNetworkId = network.getPhysicalNetworkId();
 		// physical network id can be null in Guest Network in Basic zone, so
@@ -130,6 +131,13 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
 			physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId,
 					offering.getTags(), offering.getTrafficType());
 		}
+		PhysicalNetworkVO physnet = _physicalNetworkDao
+				.findById(physicalNetworkId);
+
+		if (!canHandle(offering, nwType, physnet)) {
+			s_logger.debug("Refusing to design this network");
+			return null;
+		}
 		NetworkVO implemented = (NetworkVO) super.implement(network, offering,
 				dest, context);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
index 81518fb..a03055f 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
@@ -19,7 +19,6 @@ package com.cloud.network.ovs;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 
 import javax.ejb.Local;
@@ -61,7 +60,6 @@ import com.cloud.network.ovs.dao.OvsTunnelInterfaceVO;
 import com.cloud.network.ovs.dao.OvsTunnelNetworkDao;
 import com.cloud.network.ovs.dao.OvsTunnelNetworkVO;
 import com.cloud.utils.component.ManagerBase;
-import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.DomainRouterVO;
@@ -79,32 +77,94 @@ import com.cloud.vm.dao.UserVmDao;
 public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManager {
     public static final Logger s_logger = Logger.getLogger(OvsTunnelManagerImpl.class.getName());
 
-    boolean _isEnabled;
-    ScheduledExecutorService _executorPool;
+	// boolean _isEnabled;
+	ScheduledExecutorService _executorPool;
     ScheduledExecutorService _cleanupExecutor;
 
-    @Inject
-    ConfigurationDao _configDao;
-    @Inject
-    NicDao _nicDao;
-    @Inject
-    HostDao _hostDao;
-    @Inject
-    PhysicalNetworkTrafficTypeDao _physNetTTDao;
-    @Inject
-    UserVmDao _userVmDao;
-    @Inject
-    DomainRouterDao _routerDao;
-    @Inject
-    OvsTunnelNetworkDao _tunnelNetworkDao;
-    @Inject
-    OvsTunnelInterfaceDao _tunnelInterfaceDao;
-    @Inject
-    AgentManager _agentMgr;
-
-    @Override
-    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
-        _isEnabled = Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
+	@Inject ConfigurationDao _configDao;
+	@Inject NicDao _nicDao;
+	@Inject HostDao _hostDao;
+	@Inject PhysicalNetworkTrafficTypeDao _physNetTTDao;
+	@Inject UserVmDao _userVmDao;
+	@Inject DomainRouterDao _routerDao;
+	@Inject OvsTunnelNetworkDao _tunnelNetworkDao;
+	@Inject OvsTunnelInterfaceDao _tunnelInterfaceDao;
+	@Inject AgentManager _agentMgr;
+
+	@Override
+	public boolean configure(String name, Map<String, Object> params)
+			throws ConfigurationException {
+		// _isEnabled =
+		// Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
+		//
+		// if (_isEnabled) {
+		// _executorPool = Executors.newScheduledThreadPool(10, new
+		// NamedThreadFactory("OVS"));
+		// _cleanupExecutor = Executors.newScheduledThreadPool(1, new
+		// NamedThreadFactory("OVS-Cleanup"));
+		// }
+
+		return true;
+	}
+
+	@DB
+	protected OvsTunnelNetworkVO createTunnelRecord(long from, long to, long networkId, int key) {
+		OvsTunnelNetworkVO ta = null;
+		try {
+			ta = new OvsTunnelNetworkVO(from, to, key, networkId);
+			OvsTunnelNetworkVO lock =
+					_tunnelNetworkDao.acquireInLockTable(Long.valueOf(1));
+			if (lock == null) {
+			    s_logger.warn("Cannot lock table ovs_tunnel_account");
+			    return null;
+			}
+			_tunnelNetworkDao.persist(ta);
+			_tunnelNetworkDao.releaseFromLockTable(lock.getId());
+		} catch (EntityExistsException e) {
+			s_logger.debug("A record for the tunnel from " + from +
+						   " to " + to + " already exists");
+		}
+		return ta;
+	}
+
+	@DB
+	protected OvsTunnelInterfaceVO createInterfaceRecord(String ip,
+			String netmask,String mac,long hostId, String label) {
+		OvsTunnelInterfaceVO ti = null;
+		try {
+			ti = new OvsTunnelInterfaceVO(ip, netmask, mac, hostId, label);
+			//TODO: Is locking really necessary here?
+			OvsTunnelInterfaceVO lock =
+					_tunnelInterfaceDao.acquireInLockTable(Long.valueOf(1));
+			if (lock == null) {
+			    s_logger.warn("Cannot lock table ovs_tunnel_account");
+			    return null;
+			}
+			_tunnelInterfaceDao.persist(ti);
+			_tunnelInterfaceDao.releaseFromLockTable(lock.getId());
+		} catch (EntityExistsException e) {
+			s_logger.debug("A record for the interface for network " + label +
+					       " on host id " + hostId + " already exists");
+		}
+		return ti;
+	}
+
+	private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId){
+		OvsFetchInterfaceAnswer ans = (OvsFetchInterfaceAnswer) answers[0];
+		if (ans.getResult()) {
+			if (ans.getIp() != null &&
+				!("".equals(ans.getIp()))) {
+				OvsTunnelInterfaceVO ti =
+						createInterfaceRecord(ans.getIp(), ans.getNetmask(),
+											  ans.getMac(), hostId, ans.getLabel());
+				return ti.getIp();
+			}
+		}
+		// Fetch interface failed!
+	    s_logger.warn("Unable to fetch the IP address for the GRE tunnel endpoint" +
+	    			  ans.getDetails());
+		return null;
+	}
 
         if (_isEnabled) {
             _executorPool = Executors.newScheduledThreadPool(10, new NamedThreadFactory("OVS"));
@@ -174,47 +234,61 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
         long networkId = r.getNetworkId();
         OvsTunnelNetworkVO tunnel = _tunnelNetworkDao.getByFromToNetwork(from, to, networkId);
         if (tunnel == null) {
-            throw new CloudRuntimeException(String.format("Unable find tunnelNetwork record" + "(from=%1$s,to=%2$s, account=%3$s", from, to, networkId));
-        }
-        if (!r.getResult()) {
-            tunnel.setState("FAILED");
-            s_logger.warn("Create GRE tunnel failed due to " + r.getDetails() + s);
-        } else {
-            tunnel.setState("SUCCESS");
-            tunnel.setPortName(r.getInPortName());
-            s_logger.warn("Create GRE tunnel " + r.getDetails() + s);
-        }
-        _tunnelNetworkDao.update(tunnel.getId(), tunnel);
-    }
-
-    private String getGreEndpointIP(Host host, Network nw) throws AgentUnavailableException, OperationTimedoutException {
-        String endpointIp = null;
-        // Fetch fefault name for network label from configuration
-        String physNetLabel = _configDao.getValue(Config.OvsTunnelNetworkDefaultLabel.key());
+            throw new CloudRuntimeException(
+            		String.format("Unable find tunnelNetwork record" +
+            					  "(from=%1$s,to=%2$s, account=%3$s",
+            					  from, to, networkId));
+		}
+		if (!r.getResult()) {
+		    tunnel.setState("FAILED");
+			s_logger.warn("Create GRE tunnel failed due to " +
+					r.getDetails() + s);
+		} else {
+		    tunnel.setState("SUCCESS");
+		    tunnel.setPortName(r.getInPortName());
+		    s_logger.warn("Create GRE tunnel " +
+		    		r.getDetails() + s);
+		}
+		_tunnelNetworkDao.update(tunnel.getId(), tunnel);
+	}
+
+	private String getGreEndpointIP(Host host, Network nw) throws
+		AgentUnavailableException, OperationTimedoutException {
+		String endpointIp = null;
+		// Fetch fefault name for network label from configuration
+		String physNetLabel = _configDao.getValue(Config.OvsTunnelNetworkDefaultLabel.key());
         Long physNetId = nw.getPhysicalNetworkId();
-        PhysicalNetworkTrafficType physNetTT = _physNetTTDao.findBy(physNetId, TrafficType.Guest);
+        PhysicalNetworkTrafficType physNetTT =
+        		_physNetTTDao.findBy(physNetId, TrafficType.Guest);
         HypervisorType hvType = host.getHypervisorType();
 
         switch (hvType) {
-            case XenServer:
-                String label = physNetTT.getXenNetworkLabel();
-                if ((label != null) && (!label.equals(""))) {
-                    physNetLabel = label;
-                }
-                break;
-            default:
-                throw new CloudRuntimeException("Hypervisor " + hvType.toString() + " unsupported by OVS Tunnel Manager");
+        	case XenServer:
+        		String label = physNetTT.getXenNetworkLabel();
+        		if ((label!=null) && (!label.equals(""))) {
+        			physNetLabel = label;
+        		}
+        		break;
+        	default:
+        		throw new CloudRuntimeException("Hypervisor " +
+        				hvType.toString() +
+        				" unsupported by OVS Tunnel Manager");
         }
 
         // Try to fetch GRE endpoint IP address for cloud db
         // If not found, then find it on the hypervisor
-        OvsTunnelInterfaceVO tunnelIface = _tunnelInterfaceDao.getByHostAndLabel(host.getId(), physNetLabel);
+        OvsTunnelInterfaceVO tunnelIface =
+                _tunnelInterfaceDao.getByHostAndLabel(host.getId(),
+                        physNetLabel);
         if (tunnelIface == null) {
             //Now find and fetch configuration for physical interface
-            //for network with label on target host
-            Commands fetchIfaceCmds = new Commands(new OvsFetchInterfaceCommand(physNetLabel));
-            s_logger.debug("Ask host " + host.getId() + " to retrieve interface for phy net with label:" + physNetLabel);
-            Answer[] fetchIfaceAnswers = _agentMgr.send(host.getId(), fetchIfaceCmds);
+        	//for network with label on target host
+			Commands fetchIfaceCmds =
+					new Commands(new OvsFetchInterfaceCommand(physNetLabel));
+			s_logger.debug("Ask host " + host.getId() +
+						   " to retrieve interface for phy net with label:" +
+						   physNetLabel);
+			Answer[] fetchIfaceAnswers = _agentMgr.send(host.getId(), fetchIfaceCmds);
             //And finally save it for future use
             endpointIp = handleFetchInterfaceAnswer(fetchIfaceAnswers, host.getId());
         } else {
@@ -223,51 +297,59 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
         return endpointIp;
     }
 
-    private int getGreKey(Network network) {
-        int key = 0;
-        try {
-            //The GRE key is actually in the host part of the URI
+	private int getGreKey(Network network) {
+		int key = 0;
+		try {
+		//The GRE key is actually in the host part of the URI
             // this is not true for lswitch/NiciraNvp!
             String keyStr = BroadcastDomainType.getValue(network.getBroadcastUri());
             // The key is most certainly and int if network is a vlan.
             // !! not in the case of lswitch/pvlan/(possibly)vswitch
             // So we now feel quite safe in converting it into a string
             // by calling the appropriate BroadcastDomainType method
-            key = Integer.valueOf(keyStr);
-            return key;
-        } catch (NumberFormatException e) {
-            s_logger.debug("Well well, how did '" + key + "' end up in the broadcast URI for the network?");
-            throw new CloudRuntimeException(String.format("Invalid GRE key parsed from" + "network broadcast URI (%s)", network.getBroadcastUri().toString()));
-        }
-    }
-
-    @DB
+    		key = Integer.valueOf(keyStr);
+    		return key;
+		} catch (NumberFormatException e) {
+			s_logger.debug("Well well, how did '" + key +
+					       "' end up in the broadcast URI for the network?");
+			throw new CloudRuntimeException(
+					String.format("Invalid GRE key parsed from" +
+							"network broadcast URI (%s)",
+							network.getBroadcastUri().toString()));
+		}
+	}
+
+	@DB
     protected void CheckAndCreateTunnel(VirtualMachine instance, Network nw, DeployDestination dest) {
-        if (!_isEnabled) {
-            return;
-        }
-
-        s_logger.debug("Creating tunnels with OVS tunnel manager");
-        if (instance.getType() != VirtualMachine.Type.User && instance.getType() != VirtualMachine.Type.DomainRouter) {
-            s_logger.debug("Will not work if you're not" + "an instance or a virtual router");
-            return;
-        }
-
-        long hostId = dest.getHost().getId();
-        int key = getGreKey(nw);
-        // Find active VMs with a NIC on the target network
-        List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(nw.getId(), State.Running, State.Starting, State.Stopping, State.Unknown, State.Migrating);
-        // Find routers for the network
-        List<DomainRouterVO> routers = _routerDao.findByNetwork(nw.getId());
-        List<VMInstanceVO> ins = new ArrayList<VMInstanceVO>();
-        if (vms != null) {
-            ins.addAll(vms);
-        }
-        if (routers.size() != 0) {
-            ins.addAll(routers);
-        }
-        List<Long> toHostIds = new ArrayList<Long>();
-        List<Long> fromHostIds = new ArrayList<Long>();
+		// if (!_isEnabled) {
+		// return;
+		// }
+
+		s_logger.debug("Creating tunnels with OVS tunnel manager");
+		if (instance.getType() != VirtualMachine.Type.User
+				&& instance.getType() != VirtualMachine.Type.DomainRouter) {
+			s_logger.debug("Will not work if you're not" +
+						   "an instance or a virtual router");
+			return;
+		}
+
+		long hostId = dest.getHost().getId();
+		int key = getGreKey(nw);
+		// Find active VMs with a NIC on the target network
+		List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(nw.getId(),
+							  State.Running, State.Starting,
+							  State.Stopping, State.Unknown, State.Migrating);
+		// Find routers for the network
+		List<DomainRouterVO> routers = _routerDao.findByNetwork(nw.getId());
+		List<VMInstanceVO>ins = new ArrayList<VMInstanceVO>();
+		if (vms != null) {
+			ins.addAll(vms);
+		}
+		if (routers.size() != 0) {
+			ins.addAll(routers);
+		}
+		List<Long> toHostIds = new ArrayList<Long>();
+		List<Long> fromHostIds = new ArrayList<Long>();
         for (VMInstanceVO v : ins) {
             Long rh = v.getHostId();
             if (rh == null || rh.longValue() == hostId) {
@@ -285,13 +367,16 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
                 }
             }
 
-            ta = _tunnelNetworkDao.getByFromToNetwork(rh.longValue(), hostId, nw.getId());
+            ta = _tunnelNetworkDao.getByFromToNetwork(rh.longValue(),
+            		hostId, nw.getId());
             // Try and create the tunnel even if a previous attempt failed
             if (ta == null || ta.getState().equals("FAILED")) {
-                s_logger.debug("Attempting to create tunnel from:" + rh.longValue() + " to:" + hostId);
-                if (ta == null) {
-                    this.createTunnelRecord(rh.longValue(), hostId, nw.getId(), key);
-                }
+            	s_logger.debug("Attempting to create tunnel from:" +
+            			rh.longValue() + " to:" + hostId);
+            	if (ta == null) {
+            		this.createTunnelRecord(rh.longValue(), hostId,
+            				nw.getId(), key);
+            	}
                 if (!fromHostIds.contains(rh)) {
                     fromHostIds.add(rh);
                 }
@@ -303,48 +388,62 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
             if (myIp == null)
                 throw new GreTunnelException("Unable to retrieve the source " + "endpoint for the GRE tunnel." + "Failure is on host:" + dest.getHost().getId());
             boolean noHost = true;
-            for (Long i : toHostIds) {
-                HostVO rHost = _hostDao.findById(i);
-                String otherIp = getGreEndpointIP(rHost, nw);
-                if (otherIp == null)
-                    throw new GreTunnelException("Unable to retrieve the remote " + "endpoint for the GRE tunnel." + "Failure is on host:" + rHost.getId());
-                Commands cmds = new Commands(new OvsCreateTunnelCommand(otherIp, key, Long.valueOf(hostId), i, nw.getId(), myIp));
-                s_logger.debug("Ask host " + hostId + " to create gre tunnel to " + i);
-                Answer[] answers = _agentMgr.send(hostId, cmds);
-                handleCreateTunnelAnswer(answers);
-                noHost = false;
-            }
-
-            for (Long i : fromHostIds) {
-                HostVO rHost = _hostDao.findById(i);
-                String otherIp = getGreEndpointIP(rHost, nw);
-                Commands cmds = new Commands(new OvsCreateTunnelCommand(myIp, key, i, Long.valueOf(hostId), nw.getId(), otherIp));
-                s_logger.debug("Ask host " + i + " to create gre tunnel to " + hostId);
-                Answer[] answers = _agentMgr.send(i, cmds);
-                handleCreateTunnelAnswer(answers);
-                noHost = false;
-            }
-            // If no tunnels have been configured, perform the bridge setup anyway
-            // This will ensure VIF rules will be triggered
-            if (noHost) {
-                Commands cmds = new Commands(new OvsSetupBridgeCommand(key, hostId, nw.getId()));
-                s_logger.debug("Ask host " + hostId + " to configure bridge for network:" + nw.getId());
-                Answer[] answers = _agentMgr.send(hostId, cmds);
-                handleSetupBridgeAnswer(answers);
-            }
-        } catch (Exception e) {
-            // I really thing we should do a better handling of these exceptions
-            s_logger.warn("Ovs Tunnel network created tunnel failed", e);
-        }
-    }
+			for (Long i : toHostIds) {
+				HostVO rHost = _hostDao.findById(i);
+				String otherIp = getGreEndpointIP(rHost, nw);
+	            if (otherIp == null)
+	            	throw new GreTunnelException("Unable to retrieve the remote " +
+	            								 "endpoint for the GRE tunnel." +
+	            								 "Failure is on host:" + rHost.getId());
+				Commands cmds = new Commands(
+						new OvsCreateTunnelCommand(otherIp, key,
+								Long.valueOf(hostId), i, nw.getId(), myIp));
+				s_logger.debug("Ask host " + hostId +
+						" to create gre tunnel to " + i);
+				Answer[] answers = _agentMgr.send(hostId, cmds);
+				handleCreateTunnelAnswer(answers);
+				noHost = false;
+			}
+
+			for (Long i : fromHostIds) {
+			    HostVO rHost = _hostDao.findById(i);
+			    String otherIp = getGreEndpointIP(rHost, nw);
+				Commands cmds = new Commands(
+				        new OvsCreateTunnelCommand(myIp, key, i,
+				        						   Long.valueOf(hostId),
+				        		                   nw.getId(), otherIp));
+				s_logger.debug("Ask host " + i +
+						" to create gre tunnel to " + hostId);
+				Answer[] answers = _agentMgr.send(i, cmds);
+				handleCreateTunnelAnswer(answers);
+				noHost = false;
+			}
+			// If no tunnels have been configured, perform the bridge setup anyway
+			// This will ensure VIF rules will be triggered
+			if (noHost) {
+				Commands cmds = new Commands(
+						new OvsSetupBridgeCommand(key, hostId, nw.getId()));
+				s_logger.debug("Ask host " + hostId +
+						" to configure bridge for network:" + nw.getId());
+				Answer[] answers = _agentMgr.send(hostId, cmds);
+				handleSetupBridgeAnswer(answers);
+			}
+		} catch (Exception e) {
+		    // I really thing we should do a better handling of these exceptions
+			s_logger.warn("Ovs Tunnel network created tunnel failed", e);
+		}
+	}
+
+	@Override
+	public boolean isOvsTunnelEnabled() {
+		// return _isEnabled;
+		return true;
+	}
 
     @Override
-    public boolean isOvsTunnelEnabled() {
-        return _isEnabled;
-    }
-
-    @Override
-    public void VmCheckAndCreateTunnel(VirtualMachineProfile vm, Network nw, DeployDestination dest) {
+    public void VmCheckAndCreateTunnel(
+    		VirtualMachineProfile<? extends VirtualMachine> vm,
+    		Network nw, DeployDestination dest) {
         CheckAndCreateTunnel(vm.getVirtualMachine(), nw, dest);
     }
 
@@ -353,22 +452,27 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
         if (ans.getResult()) {
             OvsTunnelNetworkVO lock = _tunnelNetworkDao.acquireInLockTable(Long.valueOf(1));
             if (lock == null) {
-                s_logger.warn(String.format("failed to lock" + "ovs_tunnel_account, remove record of " + "tunnel(from=%1$s, to=%2$s account=%3$s) failed", from, to,
-                    network_id));
+                s_logger.warn(String.format("failed to lock" +
+                		"ovs_tunnel_account, remove record of " +
+                         "tunnel(from=%1$s, to=%2$s account=%3$s) failed",
+                         from, to, network_id));
                 return;
             }
 
             _tunnelNetworkDao.removeByFromToNetwork(from, to, network_id);
             _tunnelNetworkDao.releaseFromLockTable(lock.getId());
 
-            s_logger.debug(String.format("Destroy tunnel(account:%1$s," + "from:%2$s, to:%3$s) successful", network_id, from, to));
+            s_logger.debug(String.format("Destroy tunnel(account:%1$s," +
+            		"from:%2$s, to:%3$s) successful",
+            		network_id, from, to));
         } else {
             s_logger.debug(String.format("Destroy tunnel(account:%1$s," + "from:%2$s, to:%3$s) failed", network_id, from, to));
         }
     }
 
     @DB
-    private void handleDestroyBridgeAnswer(Answer ans, long host_id, long network_id) {
+    private void handleDestroyBridgeAnswer(Answer ans,
+    		long host_id, long network_id) {
 
         if (ans.getResult()) {
             OvsTunnelNetworkVO lock = _tunnelNetworkDao.acquireInLockTable(Long.valueOf(1));
@@ -380,9 +484,11 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
             _tunnelNetworkDao.removeByFromNetwork(host_id, network_id);
             _tunnelNetworkDao.releaseFromLockTable(lock.getId());
 
-            s_logger.debug(String.format("Destroy bridge for" + "network %1$s successful", network_id));
+            s_logger.debug(String.format("Destroy bridge for" +
+            		"network %1$s successful", network_id));
         } else {
-            s_logger.debug(String.format("Destroy bridge for" + "network %1$s failed", network_id));
+        	s_logger.debug(String.format("Destroy bridge for" +
+        			"network %1$s failed", network_id));
         }
     }
 
@@ -393,9 +499,9 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 
     @Override
     public void CheckAndDestroyTunnel(VirtualMachine vm, Network nw) {
-        if (!_isEnabled) {
-            return;
-        }
+		// if (!_isEnabled) {
+		// return;
+		// }
 
         List<UserVmVO> userVms = _userVmDao.listByAccountIdAndHostId(vm.getAccountId(), vm.getHostId());
         if (vm.getType() == VirtualMachine.Type.User) {
@@ -422,15 +528,20 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
             handleDestroyBridgeAnswer(ans, vm.getHostId(), nw.getId());
 
             /* Then ask hosts have peer tunnel with me to destroy them */
-            List<OvsTunnelNetworkVO> peers = _tunnelNetworkDao.listByToNetwork(vm.getHostId(), nw.getId());
+            List<OvsTunnelNetworkVO> peers =
+            		_tunnelNetworkDao.listByToNetwork(vm.getHostId(),
+            				nw.getId());
             for (OvsTunnelNetworkVO p : peers) {
-                // If the tunnel was not successfully created don't bother to remove it
-                if (p.getState().equals("SUCCESS")) {
-                    cmd = new OvsDestroyTunnelCommand(p.getNetworkId(), key, p.getPortName());
-                    s_logger.debug("Destroying tunnel to " + vm.getHostId() + " from " + p.getFrom());
-                    ans = _agentMgr.send(p.getFrom(), cmd);
-                    handleDestroyTunnelAnswer(ans, p.getFrom(), p.getTo(), p.getNetworkId());
-                }
+            	// If the tunnel was not successfully created don't bother to remove it
+            	if (p.getState().equals("SUCCESS")) {
+	                cmd = new OvsDestroyTunnelCommand(p.getNetworkId(), key,
+	                		p.getPortName());
+	                s_logger.debug("Destroying tunnel to " + vm.getHostId() +
+	                		" from " + p.getFrom());
+	                ans = _agentMgr.send(p.getFrom(), cmd);
+	                handleDestroyTunnelAnswer(ans, p.getFrom(),
+	                		p.getTo(), p.getNetworkId());
+            	}
             }
         } catch (Exception e) {
             s_logger.warn(String.format("Destroy tunnel(account:%1$s," + "hostId:%2$s) failed", vm.getAccountId(), vm.getHostId()), e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/scripts/vm/hypervisor/xenserver/ovstunnel
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/ovstunnel b/scripts/vm/hypervisor/xenserver/ovstunnel
index a4760b2..2b26ed6 100755
--- a/scripts/vm/hypervisor/xenserver/ovstunnel
+++ b/scripts/vm/hypervisor/xenserver/ovstunnel
@@ -271,17 +271,23 @@ def is_xcp(session, args):
     return platform
 
 def getLabel(session, args):
+    i = 0
     pif_list_cmd = [lib.XE_PATH, 'pif-list', '--minimal']
     pif_list_str = lib.do_cmd(pif_list_cmd)
-    pif_uuid = pif_list_str.split(',')[0].strip()
-    network_cmd = [lib.XE_PATH, 'pif-param-get', 'uuid=%s' % pif_uuid,
-                               'param-name=network-uuid']
-    network_uuid = lib.do_cmd(network_cmd).split('.')[0]
-
-    label_cmd = [lib.XE_PATH, 'network-param-get', 'uuid=%s' % network_uuid,
-                               'param-name=name-label']
-    label = lib.do_cmd(label_cmd).split('.')[0]
-    return label
+    while True:
+		pif_uuid = pif_list_str.split(',')[i].strip()
+		network_cmd = [lib.XE_PATH, 'pif-param-get', 'uuid=%s' % pif_uuid, 'param-name=network-uuid']
+		network_uuid = lib.do_cmd(network_cmd).split('.')[0]
+		iface_cmd = [lib.XE_PATH, 'network-param-get', 'uuid=%s' % network_uuid, 'param-name=bridge']
+		iface = lib.do_cmd(iface_cmd)
+		status,output = commands.getstatusoutput("ifconfig "+iface+" | grep inet")
+		if (status != 0):
+			i += 1
+			continue
+    	label_cmd = [lib.XE_PATH, 'network-param-get', 'uuid=%s' % network_uuid, 'param-name=name-label']
+    	label = lib.do_cmd(label_cmd).split('.')[0]
+    	return label
+    return False
 
 if __name__ == "__main__":
     XenAPIPlugin.dispatch({"create_tunnel": create_tunnel,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/scripts/vm/hypervisor/xenserver/vhd-util
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/vhd-util b/scripts/vm/hypervisor/xenserver/vhd-util
new file mode 100755
index 0000000..46d62dd
Binary files /dev/null and b/scripts/vm/hypervisor/xenserver/vhd-util differ

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 9700b26..c2a0491 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -89,6 +89,7 @@ import org.apache.cloudstack.api.response.NetworkOfferingResponse;
 import org.apache.cloudstack.api.response.NetworkResponse;
 import org.apache.cloudstack.api.response.NicResponse;
 import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
+import org.apache.cloudstack.api.response.OvsProviderResponse;
 import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 import org.apache.cloudstack.api.response.PodResponse;
 import org.apache.cloudstack.api.response.PortableIpRangeResponse;
@@ -206,6 +207,7 @@ import com.cloud.network.NetworkProfile;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.IsolationType;
 import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.OvsProvider;
 import com.cloud.network.PhysicalNetwork;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PhysicalNetworkTrafficType;
@@ -270,6 +272,7 @@ import com.cloud.storage.Snapshot;
 import com.cloud.storage.SnapshotVO;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.StoragePool;
+import com.cloud.storage.Swift;
 import com.cloud.storage.Upload;
 import com.cloud.storage.UploadVO;
 import com.cloud.storage.VMTemplateVO;
@@ -2726,6 +2729,22 @@ public class ApiResponseHelper implements ResponseGenerator {
         return response;
     }
 
+	@Override
+	public OvsProviderResponse createOvsProviderResponse(OvsProvider result) {
+
+		OvsProviderResponse response = new OvsProviderResponse();
+		response.setId(result.getUuid());
+		PhysicalNetworkServiceProvider nsp = ApiDBUtils
+				.findPhysicalNetworkServiceProviderById(result.getNspId());
+		if (nsp != null) {
+			response.setNspId(nsp.getUuid());
+		}
+		response.setEnabled(result.isEnabled());
+
+		response.setObjectName("ovselement");
+		return response;
+	}
+
     @Override
     public LBStickinessResponse createLBStickinessPolicyResponse(StickinessPolicy stickinessPolicy, LoadBalancer lb) {
         LBStickinessResponse spResponse = new LBStickinessResponse();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 6855587..c24b650 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -19,6 +19,7 @@ package com.cloud.network;
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.URI;
+
 import java.net.UnknownHostException;
 import java.security.InvalidParameterException;
 import java.sql.PreparedStatement;
@@ -109,6 +110,7 @@ import com.cloud.network.dao.NetworkDomainDao;
 import com.cloud.network.dao.NetworkDomainVO;
 import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.OvsProviderDao;
 import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
@@ -116,6 +118,7 @@ import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao;
 import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO;
 import com.cloud.network.dao.PhysicalNetworkVO;
 import com.cloud.network.element.NetworkElement;
+import com.cloud.network.element.OvsProviderVO;
 import com.cloud.network.element.VirtualRouterElement;
 import com.cloud.network.element.VpcVirtualRouterElement;
 import com.cloud.network.guru.NetworkGuru;
@@ -298,10 +301,8 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
     VpcDao _vpcDao;
     @Inject
     NetworkACLDao _networkACLDao;
-    @Inject
-    IpAddressManager _ipAddrMgr;
-    @Inject
-    EntityManager _entityMgr;
+	@Inject
+	OvsProviderDao _ovsProviderDao;
 
     int _cidrLimit;
     boolean _allowSubdomainNetworkAccess;
@@ -2511,6 +2512,9 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
                     // add VirtualRouter as the default network service provider
                     addDefaultVirtualRouterToPhysicalNetwork(pNetwork.getId());
 
+                    if (pNetwork.getIsolationMethods().contains("GRE"))
+                        addDefaultOvsToPhysicalNetwork(pNetwork.getId());
+
                     // add security group provider to the physical network
                     addDefaultSecurityGroupProviderToPhysicalNetwork(pNetwork.getId());
 
@@ -2532,7 +2536,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
         }
     }
 
-    @Override
+	@Override
     public Pair<List<? extends PhysicalNetwork>, Integer> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize, String name) {
         Filter searchFilter = new Filter(PhysicalNetworkVO.class, "id", Boolean.TRUE, startIndex, pageSize);
         SearchCriteria<PhysicalNetworkVO> sc = _physicalNetworkDao.createSearchCriteria();
@@ -3756,6 +3760,23 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
         return nsp;
     }
 
+	private PhysicalNetworkServiceProvider addDefaultOvsToPhysicalNetwork(long physicalNetworkId) {
+		PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.Ovs.getName(), null, null);
+		NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.Ovs.getName());
+		if (networkElement == null) {
+            throw new CloudRuntimeException("Unable to find the Network Element implementing the Ovs Provider");
+        }
+		OvsProviderVO element = _ovsProviderDao.findByNspId(nsp.getId());
+		if (element != null) {
+			s_logger.debug("There is already a Ovs element with service provider id "
+					+ nsp.getId());
+			return nsp;
+		}
+		element = new OvsProviderVO(nsp.getId());
+		_ovsProviderDao.persist(element);
+		return nsp;
+	}
+
     protected PhysicalNetworkServiceProvider addDefaultVpcVirtualRouterToPhysicalNetwork(long physicalNetworkId) {
 
         PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.VPCVirtualRouter.getName(), null, null);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/server/src/com/cloud/network/element/VirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java
index bcd4ce2..923094b 100755
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -29,8 +29,10 @@ import org.apache.log4j.Logger;
 
 import com.google.gson.Gson;
 
+import org.apache.cloudstack.api.command.admin.router.ConfigureOvsElementCmd;
 import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
 import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElementCmd;
+import org.apache.cloudstack.api.command.admin.router.ListOvsElementsCmd;
 import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 
@@ -53,6 +55,7 @@ import com.cloud.network.NetworkMigrationResponder;
 import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks;
 import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.OvsProvider;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.RemoteAccessVpn;
@@ -62,6 +65,7 @@ import com.cloud.network.VpnUser;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.LoadBalancerDao;
 import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.OvsProviderDao;
 import com.cloud.network.dao.VirtualRouterProviderDao;
 import com.cloud.network.lb.LoadBalancingRule;
 import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
@@ -96,10 +100,16 @@ import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.UserVmDao;
 
-@Local(value = {NetworkElement.class, FirewallServiceProvider.class, DhcpServiceProvider.class, UserDataServiceProvider.class, StaticNatServiceProvider.class,
-    LoadBalancingServiceProvider.class, PortForwardingServiceProvider.class, IpDeployer.class, RemoteAccessVPNServiceProvider.class, NetworkMigrationResponder.class})
-public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider, UserDataServiceProvider, SourceNatServiceProvider,
-        StaticNatServiceProvider, FirewallServiceProvider, LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer,
+import com.google.gson.Gson;
+
+@Local(value = {NetworkElement.class, FirewallServiceProvider.class,
+		        DhcpServiceProvider.class, UserDataServiceProvider.class,
+		        StaticNatServiceProvider.class, LoadBalancingServiceProvider.class,
+		        PortForwardingServiceProvider.class, IpDeployer.class,
+		        RemoteAccessVPNServiceProvider.class, NetworkMigrationResponder.class} )
+public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider,
+    UserDataServiceProvider, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider,
+        LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer,
         NetworkMigrationResponder {
     private static final Logger s_logger = Logger.getLogger(VirtualRouterElement.class);
 
@@ -137,6 +147,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     @Inject
     VirtualRouterProviderDao _vrProviderDao;
     @Inject
+	OvsProviderDao _ovsProviderDao;
+	@Inject
     IPAddressDao _ipAddressDao;
 
     protected boolean canHandle(Network network, Service service) {
@@ -712,6 +724,21 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         return element;
     }
 
+	@Override
+	public OvsProvider configure(ConfigureOvsElementCmd cmd) {
+		OvsProviderVO element = _ovsProviderDao.findById(cmd.getId());
+		if (element == null) {
+			s_logger.debug("Can't find Ovs element with network service provider id "
+					+ cmd.getId());
+			return null;
+		}
+
+		element.setEnabled(cmd.getEnabled());
+		_ovsProviderDao.persist(element);
+
+		return element;
+	}
+
     @Override
     public VirtualRouterProvider addElement(Long nspId, Type providerType) {
         if (!(providerType == Type.VirtualRouter || providerType == Type.VPCVirtualRouter)) {
@@ -942,20 +969,42 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         return sc.list();
     }
 
+	@Override
+	public List<? extends OvsProvider> searchForOvsElement(
+			ListOvsElementsCmd cmd) {
+		Long id = cmd.getId();
+		Long nspId = cmd.getNspId();
+		Boolean enabled = cmd.getEnabled();
+
+		SearchCriteriaService<OvsProviderVO, OvsProviderVO> sc = SearchCriteria2
+				.create(OvsProviderVO.class);
+		if (id != null) {
+			sc.addAnd(sc.getEntity().getId(), Op.EQ, id);
+		}
+		if (nspId != null) {
+			sc.addAnd(sc.getEntity().getNspId(), Op.EQ, nspId);
+		}
+		if (enabled != null) {
+			sc.addAnd(sc.getEntity().isEnabled(), Op.EQ, enabled);
+		}
+
+		return sc.list();
+	}
+
     @Override
     public boolean verifyServicesCombination(Set<Service> services) {
-        if (!services.contains(Service.SourceNat)) {
-            if (services.contains(Service.StaticNat) || services.contains(Service.Firewall) || services.contains(Service.Lb) ||
-                services.contains(Service.PortForwarding) || services.contains(Service.Vpn)) {
-                String servicesList = "[";
-                for (Service service : services) {
-                    servicesList += service.getName() + " ";
-                }
-                servicesList += "]";
-                s_logger.warn("Virtual router can't enable services " + servicesList + " without source NAT service");
-                return false;
-            }
-        }
+//        if (!services.contains(Service.SourceNat)) {
+//            if (services.contains(Service.StaticNat) || services.contains(Service.Firewall) || services.contains(Service.Lb) ||
+//                    services.contains(Service.PortForwarding) || services.contains(Service.Vpn)) {
+//                String servicesList = "[";
+//                for (Service service : services) {
+//                    servicesList += service.getName() + " ";
+//                }
+//                servicesList += "]";
+//                s_logger.warn("Virtual router can't enable services " + servicesList + " without source NAT service");
+//                return false;
+//            }
+//        }
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index c0f10aa..2b0f0b8 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -138,9 +138,11 @@ import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
 import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
 import org.apache.cloudstack.api.command.admin.resource.ListCapacityCmd;
 import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
+import org.apache.cloudstack.api.command.admin.router.ConfigureOvsElementCmd;
 import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
 import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElementCmd;
 import org.apache.cloudstack.api.command.admin.router.DestroyRouterCmd;
+import org.apache.cloudstack.api.command.admin.router.ListOvsElementsCmd;
 import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
 import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
 import org.apache.cloudstack.api.command.admin.router.RebootRouterCmd;
@@ -2864,6 +2866,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         cmdList.add(AssignCertToLoadBalancerCmd.class);
         cmdList.add(RemoveCertFromLoadBalancerCmd.class);
         cmdList.add(GenerateAlertCmd.class);
+	cmdList.add(ListOvsElementsCmd.class);
+	cmdList.add(ConfigureOvsElementCmd.class);
         return cmdList;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index 8d3aa20..55cb4cc 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -196,7 +196,6 @@ DROP TABLE IF EXISTS `cloud`.`vm_network_map`;
 DROP TABLE IF EXISTS `cloud`.`netapp_volume`;
 DROP TABLE IF EXISTS `cloud`.`netapp_pool`;
 DROP TABLE IF EXISTS `cloud`.`netapp_lun`;
-DROP TABLE IF EXISTS `cloud`.`ovs_nic_map`;
 
 CREATE TABLE `cloud`.`version` (
   `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
@@ -2476,14 +2475,5 @@ CREATE TABLE `cloud`.`nicira_nvp_nic_map` (
   CONSTRAINT `fk_nicira_nvp_nic_map__nic` FOREIGN KEY(`nic`) REFERENCES `nics`(`uuid`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
-CREATE TABLE `cloud`.`ovs_nic_map` (
-  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
-  `logicalswitch` varchar(255) NOT NULL COMMENT 'uuid of logical switch this port is provisioned on',
-  `logicalswitchport` varchar(255) UNIQUE COMMENT 'uuid of this logical switch port',
-  `nic` varchar(255) UNIQUE COMMENT 'cloudstack uuid of the nic connected to this logical switch port',
-  PRIMARY KEY (`id`),
-  CONSTRAINT `fk_ovs_nic_map__nic` FOREIGN KEY(`nic`) REFERENCES `nics`(`uuid`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
 SET foreign_key_checks = 1;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 522ccc4..6ec5723 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -2103,6 +2103,28 @@ CREATE TABLE `cloud`.`vm_disk_statistics` (
 insert into `cloud`.`vm_disk_statistics`(data_center_id,account_id,vm_id,volume_id) 
 select volumes.data_center_id, volumes.account_id, vm_instance.id, volumes.id from volumes,vm_instance where vm_instance.vm_type="User" and vm_instance.state<>"Expunging" and volumes.instance_id=vm_instance.id order by vm_instance.id;
 
+DROP TABLE IF EXISTS `cloud`.`ovs_nic_map`;
+CREATE TABLE `cloud`.`ovs_nic_map` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `logicalswitch` varchar(255) NOT NULL COMMENT 'uuid of logical switch this port is provisioned on',
+  `logicalswitchport` varchar(255) UNIQUE COMMENT 'uuid of this logical switch port',
+  `nic` varchar(255) UNIQUE COMMENT 'cloudstack uuid of the nic connected to this logical switch port',
+  PRIMARY KEY (`id`),
+  CONSTRAINT `fk_ovs_nic_map__nic` FOREIGN KEY(`nic`) REFERENCES `nics`(`uuid`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS `cloud`.`ovs_providers`;
+CREATE TABLE `cloud`.`ovs_providers` (
+  `id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
+  `nsp_id` bigint unsigned NOT NULL COMMENT 'Network Service Provider ID',
+  `uuid` varchar(40),
+  `enabled` int(1) NOT NULL COMMENT 'Enabled or disabled',
+  `removed` datetime COMMENT 'date removed if not null',
+  PRIMARY KEY  (`id`),
+  CONSTRAINT `fk_ovs_providers__nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE,
+  CONSTRAINT `uc_ovs_providers__uuid` UNIQUE (`uuid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
 DROP TABLE IF EXISTS `cloud_usage`.`vm_disk_statistics`;
 CREATE TABLE `cloud_usage`.`vm_disk_statistics` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d935d386/tools/apidoc/gen_toc.py
----------------------------------------------------------------------
diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py
index d58252c..dcf132d 100644
--- a/tools/apidoc/gen_toc.py
+++ b/tools/apidoc/gen_toc.py
@@ -160,6 +160,7 @@ known_categories = {
     'Ucs' : 'UCS',
     'CacheStores' : 'Cache Stores',
     'CacheStore' : 'Cache Store'
+    'OvsElement' : 'Ovs Element'
     }
 
 


[08/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
re-factor gre controller

Signed-off-by: tuna <ng...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4e914b70
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4e914b70
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4e914b70

Branch: refs/heads/master
Commit: 4e914b7087da81a090aa9f26c05d69195708dfea
Parents: 96188a3
Author: Tuna <ng...@gmail.com>
Authored: Thu Jul 25 15:46:31 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 api/src/com/cloud/network/Network.java          |   2 +
 client/tomcatconf/applicationContext.xml.in     |   1 -
 .../xen/resource/CitrixResourceBase.java        |  12 -
 .../agent/api/OvsCreateGreTunnelAnswer.java     |  81 ++++
 .../agent/api/OvsCreateGreTunnelCommand.java    |  55 +++
 .../cloud/agent/api/OvsCreateTunnelAnswer.java  |  85 +++++
 .../cloud/agent/api/OvsCreateTunnelCommand.java |  70 ++++
 .../cloud/agent/api/OvsDeleteFlowCommand.java   |  36 ++
 .../agent/api/OvsDestroyBridgeCommand.java      |  44 +++
 .../agent/api/OvsDestroyTunnelCommand.java      |  50 +++
 .../agent/api/OvsFetchInterfaceAnswer.java      |  58 +++
 .../agent/api/OvsFetchInterfaceCommand.java     |  38 ++
 .../cloud/agent/api/OvsSetTagAndFlowAnswer.java |  40 ++
 .../agent/api/OvsSetTagAndFlowCommand.java      |  61 +++
 .../cloud/agent/api/OvsSetupBridgeCommand.java  |  49 +++
 .../com/cloud/agent/api/StartupOvsCommand.java  |  27 ++
 .../cloud/api/response/OvsDeviceResponse.java   |  65 ----
 .../cloud/network/commands/AddOvsDeviceCmd.java | 116 ------
 .../network/commands/DeleteOvsDeviceCmd.java    | 110 ------
 .../network/commands/ListOvsDevicesCmd.java     | 114 ------
 .../com/cloud/network/element/OvsElement.java   | 367 ++++++++++++++-----
 .../network/element/OvsElementService.java      |  15 -
 .../cloud/network/guru/OvsGuestNetworkGuru.java | 238 ++++++++----
 .../ovs/src/com/cloud/network/ovs/OvsApi.java   |  78 ----
 .../com/cloud/network/ovs/OvsApiException.java  |  35 --
 .../network/ovs/OvsCreateGreTunnelCommand.java  |  54 ---
 .../network/ovs/OvsCreateTunnelCommand.java     |  69 ----
 .../cloud/network/ovs/OvsDeleteFlowCommand.java |  36 --
 .../network/ovs/OvsDestroyBridgeCommand.java    |  45 ---
 .../network/ovs/OvsDestroyTunnelCommand.java    |  50 ---
 .../network/ovs/OvsFetchInterfaceAnswer.java    |  57 ---
 .../network/ovs/OvsFetchInterfaceCommand.java   |  38 --
 .../network/ovs/OvsSetTagAndFlowAnswer.java     |  40 --
 .../network/ovs/OvsSetTagAndFlowCommand.java    |  60 ---
 .../network/ovs/OvsSetupBridgeCommand.java      |  50 ---
 .../cloud/network/ovs/OvsTunnelManagerImpl.java |   7 +
 .../cloud/network/ovs/StartupOvsCommand.java    |  27 --
 .../com/cloud/network/ovs/dao/OvsDeviceDao.java |  26 --
 .../cloud/network/ovs/dao/OvsDeviceDaoImpl.java |  49 ---
 .../com/cloud/network/ovs/dao/OvsDeviceVO.java  |  88 -----
 .../com/cloud/network/resource/OvsResource.java | 175 ---------
 setup/db/create-schema.sql                      |  12 -
 42 files changed, 1151 insertions(+), 1579 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/api/src/com/cloud/network/Network.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java
index bb94f81..74398e8 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -126,6 +126,8 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
         public static final Provider NiciraNvp = new Provider("NiciraNvp", false);
         public static final Provider InternalLbVm = new Provider("InternalLbVm", false);
         public static final Provider CiscoVnmc = new Provider("CiscoVnmc", true);
+		// Ovs
+		public static final Provider Ovs = new Provider("Ovs", false);
 
         private final String name;
         private final boolean isExternal;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 1f3571c..5260681 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -266,7 +266,6 @@
   <bean id="objectInDataStoreDaoImpl" class="org.apache.cloudstack.storage.db.ObjectInDataStoreDaoImpl" />
   <bean id="ovsTunnelInterfaceDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" />
   <bean id="ovsTunnelNetworkDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" />
-  <bean id="ovsDeviceDaoImpl" class="com.cloud.network.ovs.dao.OvsDeviceDaoImpl" />
   <bean id="ovsNicMappingDaoImpl" class="com.cloud.network.ovs.dao.OvsNicMappingDaoImpl" />
   <bean id="physicalNetworkDaoImpl" class="com.cloud.network.dao.PhysicalNetworkDaoImpl" />
   <bean id="physicalNetworkIsolationMethodDaoImpl" class="com.cloud.network.dao.PhysicalNetworkIsolationMethodDaoImpl" />

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/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 d10791c..25f30f4 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
@@ -264,18 +264,6 @@ import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.IsolationType;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.PhysicalNetworkSetupInfo;
-import com.cloud.network.ovs.OvsCreateGreTunnelAnswer;
-import com.cloud.network.ovs.OvsCreateGreTunnelCommand;
-import com.cloud.network.ovs.OvsCreateTunnelAnswer;
-import com.cloud.network.ovs.OvsCreateTunnelCommand;
-import com.cloud.network.ovs.OvsDeleteFlowCommand;
-import com.cloud.network.ovs.OvsDestroyBridgeCommand;
-import com.cloud.network.ovs.OvsDestroyTunnelCommand;
-import com.cloud.network.ovs.OvsFetchInterfaceAnswer;
-import com.cloud.network.ovs.OvsFetchInterfaceCommand;
-import com.cloud.network.ovs.OvsSetTagAndFlowAnswer;
-import com.cloud.network.ovs.OvsSetTagAndFlowCommand;
-import com.cloud.network.ovs.OvsSetupBridgeCommand;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.resource.ServerResource;
 import com.cloud.resource.hypervisor.HypervisorResource;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateGreTunnelAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateGreTunnelAnswer.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateGreTunnelAnswer.java
new file mode 100644
index 0000000..7913cc8
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateGreTunnelAnswer.java
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+
+public class OvsCreateGreTunnelAnswer extends Answer {
+	String hostIp;
+	String remoteIp;
+	String bridge;
+	String key;
+	long from;
+	long to;
+	int port;
+
+	public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details) {
+		super(cmd, success, details);
+	}
+
+	public OvsCreateGreTunnelAnswer(Command cmd, boolean success,
+			String details, String hostIp, String bridge) {
+		super(cmd, success, details);
+		OvsCreateGreTunnelCommand c = (OvsCreateGreTunnelCommand) cmd;
+		this.hostIp = hostIp;
+		this.bridge = bridge;
+		this.remoteIp = c.getRemoteIp();
+		this.key = c.getKey();
+		this.port = -1;
+		this.from = c.getFrom();
+		this.to = c.getTo();
+	}
+
+	public OvsCreateGreTunnelAnswer(Command cmd, boolean success,
+			String details, String hostIp, String bridge, int port) {
+		this(cmd, success, details, hostIp, bridge);
+		this.port = port;
+	}
+
+	public String getHostIp() {
+		return hostIp;
+	}
+
+	public String getRemoteIp() {
+		return remoteIp;
+	}
+
+	public String getBridge() {
+		return bridge;
+	}
+
+	public String getKey() {
+		return key;
+	}
+
+	public long getFrom() {
+		return from;
+	}
+
+	public long getTo() {
+		return to;
+	}
+
+	public int getPort() {
+		return port;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateGreTunnelCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateGreTunnelCommand.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateGreTunnelCommand.java
new file mode 100644
index 0000000..588ff51
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateGreTunnelCommand.java
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Command;
+
+public class OvsCreateGreTunnelCommand extends Command {
+	String remoteIp;
+	String key;
+	long from;
+	long to;
+
+	@Override
+	public boolean executeInSequence() {
+		return true;
+	}
+
+	public OvsCreateGreTunnelCommand(String remoteIp, String key, long from,
+			long to) {
+		this.remoteIp = remoteIp;
+		this.key = key;
+		this.from = from;
+		this.to = to;
+	}
+
+	public String getRemoteIp() {
+		return remoteIp;
+	}
+
+	public String getKey() {
+		return key;
+	}
+
+	public long getFrom() {
+		return from;
+	}
+
+	public long getTo() {
+		return to;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateTunnelAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateTunnelAnswer.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateTunnelAnswer.java
new file mode 100644
index 0000000..f921042
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateTunnelAnswer.java
@@ -0,0 +1,85 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+
+public class OvsCreateTunnelAnswer extends Answer {
+	Long from;
+	Long to;
+	long networkId;
+	String inPortName;
+
+	// for debug info
+	String fromIp;
+	String toIp;
+	int key;
+	String bridge;
+
+	public OvsCreateTunnelAnswer(Command cmd, boolean success, String details,
+			String bridge) {
+		super(cmd, success, details);
+		OvsCreateTunnelCommand c = (OvsCreateTunnelCommand) cmd;
+		from = c.getFrom();
+		to = c.getTo();
+		networkId = c.getNetworkId();
+		inPortName = "[]";
+		fromIp = c.getFromIp();
+		toIp = c.getRemoteIp();
+		key = c.getKey();
+		this.bridge = bridge;
+	}
+
+	public OvsCreateTunnelAnswer(Command cmd, boolean success, String details,
+			String inPortName, String bridge) {
+		this(cmd, success, details, bridge);
+		this.inPortName = inPortName;
+	}
+
+	public Long getFrom() {
+		return from;
+	}
+
+	public Long getTo() {
+		return to;
+	}
+
+	public long getNetworkId() {
+		return networkId;
+	}
+
+	public String getInPortName() {
+		return inPortName;
+	}
+
+	public String getFromIp() {
+		return fromIp;
+	}
+
+	public String getToIp() {
+		return toIp;
+	}
+
+	public int getKey() {
+		return key;
+	}
+
+	public String getBridge() {
+		return bridge;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateTunnelCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateTunnelCommand.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateTunnelCommand.java
new file mode 100644
index 0000000..1dc4d82
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsCreateTunnelCommand.java
@@ -0,0 +1,70 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Command;
+
+public class OvsCreateTunnelCommand extends Command {
+	Integer key;
+	String remoteIp;
+	Long from;
+	Long to;
+	long networkId;
+
+	// for debug info
+	String fromIp;
+
+	@Override
+	public boolean executeInSequence() {
+		return true;
+	}
+
+	public OvsCreateTunnelCommand(String remoteIp, Integer key, Long from,
+			Long to, long networkId, String fromIp) {
+		this.remoteIp = remoteIp;
+		this.key = key;
+		this.from = from;
+		this.to = to;
+		this.networkId = networkId;
+		this.fromIp = fromIp;
+	}
+
+	public Integer getKey() {
+		return key;
+	}
+
+	public String getRemoteIp() {
+		return remoteIp;
+	}
+
+	public Long getFrom() {
+		return from;
+	}
+
+	public Long getTo() {
+		return to;
+	}
+
+	public long getNetworkId() {
+		return networkId;
+	}
+
+	public String getFromIp() {
+		return fromIp;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDeleteFlowCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDeleteFlowCommand.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDeleteFlowCommand.java
new file mode 100644
index 0000000..3b5e1c2
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDeleteFlowCommand.java
@@ -0,0 +1,36 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Command;
+
+public class OvsDeleteFlowCommand extends Command {
+	String vmName;
+
+	@Override
+	public boolean executeInSequence() {
+		return true;
+	}
+
+	public String getVmName() {
+		return vmName;
+	}
+
+	public OvsDeleteFlowCommand(String vmName) {
+		this.vmName = vmName;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDestroyBridgeCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDestroyBridgeCommand.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDestroyBridgeCommand.java
new file mode 100644
index 0000000..21b89af
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDestroyBridgeCommand.java
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Command;
+
+public class OvsDestroyBridgeCommand extends Command {
+
+	Long networkId;
+	Integer key;
+
+	public OvsDestroyBridgeCommand(Long networkId, Integer key) {
+		this.networkId = networkId;
+		this.key = key;
+	}
+
+	public Long getNetworkId() {
+		return networkId;
+	}
+
+	public Integer getKey() {
+		return key;
+	}
+
+	@Override
+	public boolean executeInSequence() {
+		return true;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDestroyTunnelCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDestroyTunnelCommand.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDestroyTunnelCommand.java
new file mode 100644
index 0000000..d06acf5
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDestroyTunnelCommand.java
@@ -0,0 +1,50 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Command;
+
+public class OvsDestroyTunnelCommand extends Command {
+
+	Long networkId;
+	Integer key;
+	String inPortName;
+
+	public OvsDestroyTunnelCommand(Long networkId, Integer key,
+			String inPortName) {
+		this.networkId = networkId;
+		this.inPortName = inPortName;
+		this.key = key;
+	}
+
+	public Long getNetworkId() {
+		return networkId;
+	}
+
+	public String getInPortName() {
+		return inPortName;
+	}
+
+	public Integer getKey() {
+		return key;
+	}
+
+	@Override
+	public boolean executeInSequence() {
+		return true;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsFetchInterfaceAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsFetchInterfaceAnswer.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsFetchInterfaceAnswer.java
new file mode 100644
index 0000000..6c7deaa
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsFetchInterfaceAnswer.java
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+
+public class OvsFetchInterfaceAnswer extends Answer {
+	String ip;
+	String netmask;
+	String mac;
+	String label;
+
+	public OvsFetchInterfaceAnswer(Command cmd, boolean success, String details) {
+		super(cmd, success, details);
+		this.label = ((OvsFetchInterfaceCommand) cmd).getLabel();
+	}
+
+	public OvsFetchInterfaceAnswer(Command cmd, boolean success,
+			String details, String ip, String netmask, String mac) {
+		super(cmd, success, details);
+		this.ip = ip;
+		this.netmask = netmask;
+		this.mac = mac;
+		this.label = ((OvsFetchInterfaceCommand) cmd).getLabel();
+	}
+
+	public String getIp() {
+		return ip;
+	}
+
+	public String getNetmask() {
+		return netmask;
+	}
+
+	public String getMac() {
+		return mac;
+	}
+
+	public String getLabel() {
+		return label;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsFetchInterfaceCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsFetchInterfaceCommand.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsFetchInterfaceCommand.java
new file mode 100644
index 0000000..a305d5b
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsFetchInterfaceCommand.java
@@ -0,0 +1,38 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Command;
+
+public class OvsFetchInterfaceCommand extends Command {
+	String label;
+
+	@Override
+	public boolean executeInSequence() {
+		return true;
+	}
+
+	public OvsFetchInterfaceCommand(String label) {
+		this.label = label;
+	}
+
+	public String getLabel() {
+		return label;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetTagAndFlowAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetTagAndFlowAnswer.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetTagAndFlowAnswer.java
new file mode 100644
index 0000000..ee1fe42
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetTagAndFlowAnswer.java
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+
+public class OvsSetTagAndFlowAnswer extends Answer {
+	Long vmId;
+	Long seqno;
+
+	public OvsSetTagAndFlowAnswer(Command cmd, boolean success, String details) {
+		super(cmd, success, details);
+		OvsSetTagAndFlowCommand c = (OvsSetTagAndFlowCommand) cmd;
+		this.vmId = c.getVmId();
+		this.seqno = Long.parseLong(c.getSeqNo());
+	}
+
+	public Long getVmId() {
+		return vmId;
+	}
+
+	public Long getSeqNo() {
+		return seqno;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetTagAndFlowCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetTagAndFlowCommand.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetTagAndFlowCommand.java
new file mode 100644
index 0000000..28a936a
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetTagAndFlowCommand.java
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Command;
+
+public class OvsSetTagAndFlowCommand extends Command {
+	String vlans;
+	String vmName;
+	String seqno;
+	String tag;
+	Long vmId;
+
+	@Override
+	public boolean executeInSequence() {
+		return true;
+	}
+
+	public String getSeqNo() {
+		return seqno;
+	}
+
+	public String getVlans() {
+		return vlans;
+	}
+
+	public String getVmName() {
+		return vmName;
+	}
+
+	public Long getVmId() {
+		return vmId;
+	}
+
+	public String getTag() {
+		return tag;
+	}
+
+	public OvsSetTagAndFlowCommand(String vmName, String tag, String vlans,
+			String seqno, Long vmId) {
+		this.vmName = vmName;
+		this.tag = tag;
+		this.vlans = vlans;
+		this.seqno = seqno;
+		this.vmId = vmId;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetupBridgeCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetupBridgeCommand.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetupBridgeCommand.java
new file mode 100644
index 0000000..6968a4c
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetupBridgeCommand.java
@@ -0,0 +1,49 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.Command;
+
+public class OvsSetupBridgeCommand extends Command {
+	Integer key;
+	Long hostId;
+	Long networkId;
+
+	@Override
+	public boolean executeInSequence() {
+		return true;
+	}
+
+	public OvsSetupBridgeCommand(Integer key, Long hostId, Long networkId) {
+		this.key = key;
+		this.hostId = hostId;
+		this.networkId = networkId;
+	}
+
+	public Integer getKey() {
+		return key;
+	}
+
+	public Long getHostId() {
+		return hostId;
+	}
+
+	public Long getNetworkId() {
+		return networkId;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/agent/api/StartupOvsCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/agent/api/StartupOvsCommand.java b/plugins/network-elements/ovs/src/com/cloud/agent/api/StartupOvsCommand.java
new file mode 100644
index 0000000..766aec2
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/StartupOvsCommand.java
@@ -0,0 +1,27 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api;
+
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.host.Host;
+
+public class StartupOvsCommand extends StartupCommand {
+
+	public StartupOvsCommand() {
+		super(Host.Type.L2Networking);
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/api/response/OvsDeviceResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/api/response/OvsDeviceResponse.java b/plugins/network-elements/ovs/src/com/cloud/api/response/OvsDeviceResponse.java
deleted file mode 100644
index c0901b2..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/api/response/OvsDeviceResponse.java
+++ /dev/null
@@ -1,65 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.api.response;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseResponse;
-import org.apache.cloudstack.api.EntityReference;
-
-import com.cloud.network.ovs.dao.OvsDeviceVO;
-import com.cloud.serializer.Param;
-import com.google.gson.annotations.SerializedName;
-
-@EntityReference(value = OvsDeviceVO.class)
-public class OvsDeviceResponse extends BaseResponse {
-
-	@SerializedName(ApiConstants.OVS_DEVICE_ID)
-	@Param(description = "device id of the Ovs")
-	private String id;
-
-	@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
-	@Param(description = "the physical network to which this device belongs to")
-	private String physicalNetworkId;
-
-	@SerializedName(ApiConstants.OVS_DEVICE_NAME)
-	@Param(description = "device name")
-	private String deviceName;
-
-	@SerializedName(ApiConstants.HOST_NAME)
-	@Param(description = "the controller Ip address")
-	private String hostName;
-
-	public String getId() {
-		return this.id;
-	}
-
-	public void setId(String vnsDeviceId) {
-		this.id = vnsDeviceId;
-	}
-
-	public void setPhysicalNetworkId(String physicalNetworkId) {
-		this.physicalNetworkId = physicalNetworkId;
-	}
-
-	public void setDeviceName(String deviceName) {
-		this.deviceName = deviceName;
-	}
-
-	public void setHostName(String hostName) {
-		this.hostName = hostName;
-	}
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/commands/AddOvsDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/commands/AddOvsDeviceCmd.java b/plugins/network-elements/ovs/src/com/cloud/network/commands/AddOvsDeviceCmd.java
deleted file mode 100644
index 1abc324..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/commands/AddOvsDeviceCmd.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.commands;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
-
-import com.cloud.api.response.OvsDeviceResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.element.OvsElementService;
-import com.cloud.network.ovs.dao.OvsDeviceVO;
-import com.cloud.user.UserContext;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@APICommand(name = "addDevice", responseObject = OvsDeviceResponse.class, description = "Adds a Ovs controller device")
-public class AddOvsDeviceCmd extends BaseAsyncCmd {
-	private static final String s_name = "adddeviceresponse";
-	@Inject
-	OvsElementService _ovsElementService;
-
-	// ///////////////////////////////////////////////////
-	// ////////////// API parameters /////////////////////
-	// ///////////////////////////////////////////////////
-
-	@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, required = true, description = "the Physical Network ID")
-	private Long physicalNetworkId;
-
-	@Parameter(name = ApiConstants.HOST_NAME, type = CommandType.STRING, required = true, description = "Hostname of ip address of the BigSwitch VNS Controller.")
-	private String host;
-
-	// ///////////////////////////////////////////////////
-	// ///////////////// Accessors ///////////////////////
-	// ///////////////////////////////////////////////////
-
-	public Long getPhysicalNetworkId() {
-		return physicalNetworkId;
-	}
-
-	public String getHost() {
-		return host;
-	}
-
-	// ///////////////////////////////////////////////////
-	// ///////////// API Implementation///////////////////
-	// ///////////////////////////////////////////////////
-	@Override
-	public void execute() throws ResourceUnavailableException,
-			InsufficientCapacityException, ServerApiException,
-			ConcurrentOperationException, ResourceAllocationException,
-			NetworkRuleConflictException {
-		try {
-			OvsDeviceVO ovsDeviceVO = _ovsElementService.addOvsDevice(this);
-			if (ovsDeviceVO != null) {
-				OvsDeviceResponse response = _ovsElementService
-						.createOvsDeviceResponse(ovsDeviceVO);
-				response.setObjectName("ovsdevice");
-				response.setResponseName(getCommandName());
-				this.setResponseObject(response);
-			}
-		} catch (InvalidParameterValueException invalidParamExcp) {
-			throw new ServerApiException(ApiErrorCode.PARAM_ERROR,
-					invalidParamExcp.getMessage());
-		} catch (CloudRuntimeException runtimeExcp) {
-			throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
-					runtimeExcp.getMessage());
-		}
-	}
-
-	@Override
-	public String getEventType() {
-		return EventTypes.EVENT_EXTERNAL_OVS_CONTROLLER_ADD;
-	}
-
-	@Override
-	public String getEventDescription() {
-		return "Adding an Ovs Controller";
-	}
-
-	@Override
-	public String getCommandName() {
-		return s_name;
-	}
-
-	@Override
-	public long getEntityOwnerId() {
-		return UserContext.current().getCaller().getId();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/commands/DeleteOvsDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/commands/DeleteOvsDeviceCmd.java b/plugins/network-elements/ovs/src/com/cloud/network/commands/DeleteOvsDeviceCmd.java
deleted file mode 100644
index 87eedfb..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/commands/DeleteOvsDeviceCmd.java
+++ /dev/null
@@ -1,110 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.commands;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.SuccessResponse;
-
-import com.cloud.api.response.OvsDeviceResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.element.OvsElementService;
-import com.cloud.user.UserContext;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@APICommand(name = "deleteOvsDevice", responseObject = SuccessResponse.class, description = " delete a ovs device")
-public class DeleteOvsDeviceCmd extends BaseAsyncCmd {
-	private static final String s_name = "deleteovsdeviceresponse";
-	@Inject
-	OvsElementService _ovsElementService;
-
-	// ///////////////////////////////////////////////////
-	// ////////////// API parameters /////////////////////
-	// ///////////////////////////////////////////////////
-
-	@Parameter(name = ApiConstants.OVS_DEVICE_ID, type = CommandType.UUID, entityType = OvsDeviceResponse.class, required = true, description = "Ovs device ID")
-	private Long ovsDeviceId;
-
-	// ///////////////////////////////////////////////////
-	// ///////////////// Accessors ///////////////////////
-	// ///////////////////////////////////////////////////
-
-	public Long getOvsDeviceId() {
-		return ovsDeviceId;
-	}
-
-	// ///////////////////////////////////////////////////
-	// ///////////// API Implementation///////////////////
-	// ///////////////////////////////////////////////////
-	@Override
-	public void execute() throws ResourceUnavailableException,
-			InsufficientCapacityException, ServerApiException,
-			ConcurrentOperationException, ResourceAllocationException,
-			NetworkRuleConflictException {
-		try {
-			boolean result = _ovsElementService.deleteOvsDevice(this);
-			if (result) {
-				SuccessResponse response = new SuccessResponse(getCommandName());
-				response.setResponseName(getCommandName());
-				this.setResponseObject(response);
-			} else {
-				throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
-						"Failed to delete Ovs device.");
-			}
-
-		} catch (InvalidParameterValueException invalidParamExcp) {
-			throw new ServerApiException(ApiErrorCode.PARAM_ERROR,
-					invalidParamExcp.getMessage());
-		} catch (CloudRuntimeException runtimeExcp) {
-			throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
-					runtimeExcp.getMessage());
-		}
-	}
-
-	@Override
-	public String getEventType() {
-		return EventTypes.EVENT_EXTERNAL_OVS_CONTROLLER_DELETE;
-	}
-
-	@Override
-	public String getEventDescription() {
-		return "Deleting Ovs Controller";
-	}
-
-	@Override
-	public String getCommandName() {
-		return s_name;
-	}
-
-	@Override
-	public long getEntityOwnerId() {
-		return UserContext.current().getCaller().getId();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/commands/ListOvsDevicesCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/commands/ListOvsDevicesCmd.java b/plugins/network-elements/ovs/src/com/cloud/network/commands/ListOvsDevicesCmd.java
deleted file mode 100644
index 2adb33a..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/commands/ListOvsDevicesCmd.java
+++ /dev/null
@@ -1,114 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.ListResponse;
-import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
-import org.apache.log4j.Logger;
-
-import com.cloud.api.response.OvsDeviceResponse;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.element.OvsElementService;
-import com.cloud.network.ovs.dao.OvsDeviceVO;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@APICommand(name = "listOvsDevices", responseObject = OvsDeviceResponse.class, description = "Lists Ovs devices")
-public class ListOvsDevicesCmd extends BaseListCmd {
-	public static final Logger s_logger = Logger
-			.getLogger(ListOvsDevicesCmd.class.getName());
-	private static final String s_name = "listovsdeviceresponse";
-	@Inject
-	OvsElementService _ovsElementService;
-
-	// ///////////////////////////////////////////////////
-	// ////////////// API parameters /////////////////////
-	// ///////////////////////////////////////////////////
-
-	@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the Physical Network ID")
-	private Long physicalNetworkId;
-
-	@Parameter(name = ApiConstants.OVS_DEVICE_ID, type = CommandType.UUID, entityType = OvsDeviceResponse.class, description = "ovs device ID")
-	private Long ovsDeviceId;
-
-	// ///////////////////////////////////////////////////
-	// ///////////////// Accessors ///////////////////////
-	// ///////////////////////////////////////////////////
-
-	public Long getOvsDeviceId() {
-		return ovsDeviceId;
-	}
-
-	public Long getPhysicalNetworkId() {
-		return physicalNetworkId;
-	}
-
-	// ///////////////////////////////////////////////////
-	// ///////////// API Implementation///////////////////
-	// ///////////////////////////////////////////////////
-	@Override
-	public void execute() throws ResourceUnavailableException,
-			InsufficientCapacityException, ServerApiException,
-			ConcurrentOperationException, ResourceAllocationException,
-			NetworkRuleConflictException {
-		try {
-			List<OvsDeviceVO> ovsDevices = _ovsElementService
-					.listOvsDevices(this);
-			ListResponse<OvsDeviceResponse> response = new ListResponse<OvsDeviceResponse>();
-			List<OvsDeviceResponse> ovsDevicesResponse = new ArrayList<OvsDeviceResponse>();
-
-			if (ovsDevices != null && !ovsDevices.isEmpty()) {
-				for (OvsDeviceVO ovsDeviceVO : ovsDevices) {
-					OvsDeviceResponse ovsDeviceResponse = _ovsElementService
-							.createOvsDeviceResponse(ovsDeviceVO);
-					ovsDevicesResponse.add(ovsDeviceResponse);
-				}
-			}
-
-			response.setResponses(ovsDevicesResponse);
-			response.setResponseName(getCommandName());
-			this.setResponseObject(response);
-		} catch (InvalidParameterValueException invalidParamExcp) {
-			throw new ServerApiException(ApiErrorCode.PARAM_ERROR,
-					invalidParamExcp.getMessage());
-		} catch (CloudRuntimeException runtimeExcp) {
-			throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
-					runtimeExcp.getMessage());
-		}
-	}
-
-	@Override
-	public String getCommandName() {
-		return s_name;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index 0ec54e3..263a214 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -16,118 +16,305 @@
 // under the License.
 package com.cloud.network.element;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
+import javax.naming.ConfigurationException;
 
-import com.cloud.api.response.OvsDeviceResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.agent.api.StartupOvsCommand;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.Host;
+import com.cloud.host.HostVO;
 import com.cloud.network.Network;
 import com.cloud.network.Network.Capability;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks;
+import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.network.commands.AddOvsDeviceCmd;
-import com.cloud.network.commands.DeleteOvsDeviceCmd;
-import com.cloud.network.commands.ListOvsDevicesCmd;
+import com.cloud.network.PublicIpAddress;
+import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.ovs.OvsTunnelManager;
-import com.cloud.network.ovs.dao.OvsDeviceVO;
+import com.cloud.network.rules.PortForwardingRule;
+import com.cloud.network.rules.StaticNat;
 import com.cloud.offering.NetworkOffering;
+import com.cloud.resource.ResourceManager;
+import com.cloud.resource.ResourceStateAdapter;
+import com.cloud.resource.ServerResource;
+import com.cloud.resource.UnableDeleteHostException;
 import com.cloud.utils.component.AdapterBase;
-import com.cloud.utils.db.DB;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachineProfile;
 
-@Local(value = {NetworkElement.class})
-public class OvsElement extends AdapterBase implements NetworkElement {
-    @Inject
-    OvsTunnelManager _ovsTunnelMgr;
-
-    @Override
-    public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
-        return true;
-    }
-
-    @Override
-    public Map<Service, Map<Capability, String>> getCapabilities() {
-        return null;
-    }
-
-    @Override
-    public Provider getProvider() {
-        return null;
-    }
-
-    @Override
-    public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
-        ResourceUnavailableException, InsufficientCapacityException {
-        //Consider actually implementing the network here
-        return true;
-    }
-
-    @Override
-    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
-        throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
-        if (nic.getBroadcastType() != Networks.BroadcastDomainType.Vswitch) {
-            return true;
-        }
-
-        if (nic.getTrafficType() != Networks.TrafficType.Guest) {
-            return true;
-        }
-
-        _ovsTunnelMgr.VmCheckAndCreateTunnel(vm, network, dest);
-        //_ovsTunnelMgr.applyDefaultFlow(vm.getVirtualMachine(), dest);
-
-        return true;
-    }
-
-    @Override
-    public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException,
-        ResourceUnavailableException {
-        if (nic.getBroadcastType() != Networks.BroadcastDomainType.Vswitch) {
-            return true;
-        }
-
-        if (nic.getTrafficType() != Networks.TrafficType.Guest) {
-            return true;
-        }
-
-        _ovsTunnelMgr.CheckAndDestroyTunnel(vm.getVirtualMachine(), network);
-        return true;
-    }
-
-    @Override
-    public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException {
-        return true;
-    }
-
-    @Override
-    public boolean isReady(PhysicalNetworkServiceProvider provider) {
-        return true;
-    }
-
-    @Override
-    public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
-        ResourceUnavailableException {
-        return true;
-    }
-
-    @Override
-    public boolean canEnableIndividualServices() {
-        return false;
-    }
-
-    @Override
-    public boolean verifyServicesCombination(Set<Service> services) {
-        return true;
-    }
+@Local(value = { NetworkElement.class, ConnectivityProvider.class,
+		SourceNatServiceProvider.class, StaticNatServiceProvider.class,
+		PortForwardingServiceProvider.class, IpDeployer.class })
+public class OvsElement extends AdapterBase implements NetworkElement,
+		OvsElementService, ConnectivityProvider, ResourceStateAdapter,
+		SourceNatServiceProvider, PortForwardingServiceProvider,
+		StaticNatServiceProvider, IpDeployer {
+	@Inject
+	OvsTunnelManager _ovsTunnelMgr;
+	@Inject
+	NetworkModel _networkModel;
+	@Inject
+	NetworkServiceMapDao _ntwkSrvcDao;
+	@Inject
+	ResourceManager _resourceMgr;
+
+	private static final Logger s_logger = Logger.getLogger(OvsElement.class);
+	private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
+
+	@Override
+	public Map<Service, Map<Capability, String>> getCapabilities() {
+		return capabilities;
+	}
+
+	@Override
+	public Provider getProvider() {
+		return Provider.Ovs;
+	}
+
+	protected boolean canHandle(Network network, Service service) {
+		s_logger.debug("Checking if OvsElement can handle service "
+				+ service.getName() + " on network " + network.getDisplayText());
+		if (network.getBroadcastDomainType() != BroadcastDomainType.Vswitch) {
+			return false;
+		}
+
+		if (!_networkModel.isProviderForNetwork(getProvider(), network.getId())) {
+			s_logger.debug("OvsElement is not a provider for network "
+					+ network.getDisplayText());
+			return false;
+		}
+
+		if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(),
+				service, Network.Provider.Ovs)) {
+			s_logger.debug("OvsElement can't provide the " + service.getName()
+					+ " service on network " + network.getDisplayText());
+			return false;
+		}
+
+		return true;
+	}
+
+	@Override
+	public boolean configure(String name, Map<String, Object> params)
+			throws ConfigurationException {
+		super.configure(name, params);
+		_resourceMgr.registerResourceStateAdapter(name, this);
+		return true;
+	}
+
+	@Override
+	public boolean implement(Network network, NetworkOffering offering,
+			DeployDestination dest, ReservationContext context)
+			throws ConcurrentOperationException, ResourceUnavailableException,
+			InsufficientCapacityException {
+		s_logger.debug("entering OvsElement implement function for network "
+				+ network.getDisplayText() + " (state " + network.getState()
+				+ ")");
+
+		if (!canHandle(network, Service.Connectivity)) {
+			return false;
+		}
+		// TODO: implement SourceNat immediately when we code L3 services
+
+		return true;
+	}
+
+	@Override
+	public boolean prepare(Network network, NicProfile nic,
+			VirtualMachineProfile<? extends VirtualMachine> vm,
+			DeployDestination dest, ReservationContext context)
+			throws ConcurrentOperationException, ResourceUnavailableException,
+			InsufficientCapacityException {
+		if (!canHandle(network, Service.Connectivity)) {
+			return false;
+		}
+
+		if (nic.getBroadcastType() != Networks.BroadcastDomainType.Vswitch) {
+			return false;
+		}
+
+		if (nic.getTrafficType() != Networks.TrafficType.Guest) {
+			return false;
+		}
+
+		_ovsTunnelMgr.VmCheckAndCreateTunnel(vm, network, dest);
+
+		return true;
+	}
+
+	@Override
+	public boolean release(Network network, NicProfile nic,
+			VirtualMachineProfile<? extends VirtualMachine> vm,
+			ReservationContext context) throws ConcurrentOperationException,
+			ResourceUnavailableException {
+		if (!canHandle(network, Service.Connectivity)) {
+			return false;
+		}
+		if (nic.getBroadcastType() != Networks.BroadcastDomainType.Vswitch) {
+			return false;
+		}
+
+		if (nic.getTrafficType() != Networks.TrafficType.Guest) {
+			return false;
+		}
+
+		_ovsTunnelMgr.CheckAndDestroyTunnel(vm.getVirtualMachine(), network);
+		return true;
+	}
+
+	@Override
+	public boolean shutdown(Network network, ReservationContext context,
+			boolean cleanup) throws ConcurrentOperationException,
+			ResourceUnavailableException {
+		if (!canHandle(network, Service.Connectivity)) {
+			return false;
+		}
+		return true;
+	}
+
+	@Override
+	public boolean destroy(Network network, ReservationContext context)
+			throws ConcurrentOperationException, ResourceUnavailableException {
+		if (!canHandle(network, Service.Connectivity)) {
+			return false;
+		}
+		return true;
+	}
+
+	@Override
+	public boolean isReady(PhysicalNetworkServiceProvider provider) {
+		return true;
+	}
+
+	@Override
+	public boolean shutdownProviderInstances(
+			PhysicalNetworkServiceProvider provider, ReservationContext context)
+			throws ConcurrentOperationException, ResourceUnavailableException {
+		return true;
+	}
+
+	@Override
+	public boolean canEnableIndividualServices() {
+		return true;
+	}
+
+	@Override
+	public boolean verifyServicesCombination(Set<Service> services) {
+		if (!services.contains(Service.Connectivity)) {
+			s_logger.warn("Unable to provide services without Connectivity service enabled for this element");
+			return false;
+		}
+
+		if ((services.contains(Service.PortForwarding) || services
+				.contains(Service.StaticNat))
+				&& !services.contains(Service.SourceNat)) {
+			s_logger.warn("Unable to provide StaticNat and/or PortForwarding without the SourceNat service");
+			return false;
+		}
+		return true;
+	}
+
+	private static Map<Service, Map<Capability, String>> setCapabilities() {
+		Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
+
+		// we need L3 support for coding L3 services in next period
+
+		// L2 Support : SDN provisioning
+		capabilities.put(Service.Connectivity, null);
+
+		// L3 Support : Generic?
+		capabilities.put(Service.Gateway, null);
+
+		// L3 Support : SourceNat
+		Map<Capability, String> sourceNatCapabilities = new HashMap<Capability, String>();
+		sourceNatCapabilities.put(Capability.SupportedSourceNatTypes,
+				"peraccount");
+		sourceNatCapabilities.put(Capability.RedundantRouter, "false");
+		capabilities.put(Service.SourceNat, sourceNatCapabilities);
+
+		// L3 Support : Port Forwarding
+		capabilities.put(Service.PortForwarding, null);
+
+		// L3 support : StaticNat
+		capabilities.put(Service.StaticNat, null);
+
+		return capabilities;
+	}
+
+	@Override
+	public List<Class<?>> getCommands() {
+		return null;
+	}
+
+	@Override
+	public HostVO createHostVOForConnectedAgent(HostVO host,
+			StartupCommand[] cmd) {
+		return null;
+	}
+
+	@Override
+	public HostVO createHostVOForDirectConnectAgent(HostVO host,
+			StartupCommand[] startup, ServerResource resource,
+			Map<String, String> details, List<String> hostTags) {
+		if (!(startup[0] instanceof StartupOvsCommand)) {
+			return null;
+		}
+		host.setType(Host.Type.L2Networking);
+		return host;
+	}
+
+	@Override
+	public DeleteHostAnswer deleteHost(HostVO host, boolean isForced,
+			boolean isForceDeleteStorage) throws UnableDeleteHostException {
+		if (!(host.getType() == Host.Type.L2Networking)) {
+			return null;
+		}
+		return new DeleteHostAnswer(true);
+	}
+
+	// TODO: Adding L3 services below
+	@Override
+	public IpDeployer getIpDeployer(Network network) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public boolean applyIps(Network network,
+			List<? extends PublicIpAddress> ipAddress, Set<Service> services)
+			throws ResourceUnavailableException {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean applyStaticNats(Network config,
+			List<? extends StaticNat> rules)
+			throws ResourceUnavailableException {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean applyPFRules(Network network, List<PortForwardingRule> rules)
+			throws ResourceUnavailableException {
+		// TODO Auto-generated method stub
+		return false;
+	}
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElementService.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElementService.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElementService.java
index b55fe6b..c382e62 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElementService.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElementService.java
@@ -1,22 +1,7 @@
 package com.cloud.network.element;
 
-import java.util.List;
-
-import com.cloud.api.response.OvsDeviceResponse;
-import com.cloud.network.commands.AddOvsDeviceCmd;
-import com.cloud.network.commands.DeleteOvsDeviceCmd;
-import com.cloud.network.commands.ListOvsDevicesCmd;
-import com.cloud.network.ovs.dao.OvsDeviceVO;
 import com.cloud.utils.component.PluggableService;
 
 public interface OvsElementService extends PluggableService {
 
-	public OvsDeviceVO addOvsDevice(AddOvsDeviceCmd cmd);
-
-	public OvsDeviceResponse createOvsDeviceResponse(OvsDeviceVO ovsDeviceVO);
-
-	public boolean deleteOvsDevice(DeleteOvsDeviceCmd cmd);
-
-	public List<OvsDeviceVO> listOvsDevices(ListOvsDevicesCmd cmd);
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
index 0690977..635aff1 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
@@ -30,86 +30,190 @@ import com.cloud.deploy.DeploymentPlan;
 import com.cloud.event.ActionEventUtils;
 import com.cloud.event.EventTypes;
 import com.cloud.event.EventVO;
+import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
 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.NetworkProfile;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.PhysicalNetwork;
 import com.cloud.network.PhysicalNetwork.IsolationMethod;
 import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.PhysicalNetworkVO;
 import com.cloud.network.ovs.OvsTunnelManager;
 import com.cloud.offering.NetworkOffering;
+import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
 import com.cloud.user.Account;
 import com.cloud.vm.ReservationContext;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
 
+@Component
 @Local(value = NetworkGuru.class)
 public class OvsGuestNetworkGuru extends GuestNetworkGuru {
-    private static final Logger s_logger = Logger.getLogger(OvsGuestNetworkGuru.class);
-
-    @Inject
-    OvsTunnelManager _ovsTunnelMgr;
-
-    OvsGuestNetworkGuru() {
-        super();
-        _isolationMethods = new IsolationMethod[] {IsolationMethod.GRE, IsolationMethod.L3, IsolationMethod.VLAN};
-    }
-
-    @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()) && offering.getGuestType() == Network.GuestType.Isolated &&
-            isMyIsolationMethod(physicalNetwork)) {
-            return true;
-        } else {
-            s_logger.trace("We only take care of Guest networks of type   " + GuestType.Isolated + " in zone of type " + NetworkType.Advanced);
-            return false;
-        }
-    }
-
-    @Override
-    public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
-
-        if (!_ovsTunnelMgr.isOvsTunnelEnabled()) {
-            return null;
-        }
-
-        NetworkVO config = (NetworkVO)super.design(offering, plan, userSpecified, owner);
-        if (config == null) {
-            return null;
-        }
-
-        config.setBroadcastDomainType(BroadcastDomainType.Vswitch);
-
-        return config;
-    }
-
-    @Override
-    protected void allocateVnet(Network network, NetworkVO implemented, long dcId, long physicalNetworkId, String reservationId)
-        throws InsufficientVirtualNetworkCapcityException {
-        if (network.getBroadcastUri() == null) {
-            String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId, UseSystemGuestVlans.valueIn(network.getAccountId()));
-            if (vnet == null) {
-                throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a part of network " + network + " implement ", DataCenter.class, dcId);
-            }
-            implemented.setBroadcastUri(BroadcastDomainType.Vswitch.toUri(vnet));
-            ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), network.getAccountId(), EventVO.LEVEL_INFO,
-                EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: " + vnet + " Network Id: " + network.getId(), 0);
-        } else {
-            implemented.setBroadcastUri(network.getBroadcastUri());
-        }
-    }
-
-    @Override
-    public Network implement(Network config, NetworkOffering offering, DeployDestination dest, ReservationContext context)
-        throws InsufficientVirtualNetworkCapcityException {
-        assert (config.getState() == State.Implementing) : "Why are we implementing " + config;
-        if (!_ovsTunnelMgr.isOvsTunnelEnabled()) {
-            return null;
-        }
-        NetworkVO implemented = (NetworkVO)super.implement(config, offering, dest, context);
-        return implemented;
-    }
-
+	private static final Logger s_logger = Logger
+			.getLogger(OvsGuestNetworkGuru.class);
+
+	@Inject
+	OvsTunnelManager _ovsTunnelMgr;
+	@Inject
+	NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
+
+	OvsGuestNetworkGuru() {
+		super();
+		_isolationMethods = new IsolationMethod[] { IsolationMethod.GRE,
+				IsolationMethod.L3, IsolationMethod.VLAN };
+	}
+
+	@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())
+				&& offering.getGuestType() == Network.GuestType.Isolated
+				&& isMyIsolationMethod(physicalNetwork)
+				&& _ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(
+						offering.getId(), Service.Connectivity)) {
+			return true;
+		} else {
+			s_logger.trace("We only take care of Guest networks of type   "
+					+ GuestType.Isolated + " in zone of type "
+					+ NetworkType.Advanced);
+			return false;
+		}
+	}
+
+	@Override
+	public Network design(NetworkOffering offering, DeploymentPlan plan,
+			Network userSpecified, Account owner) {
+
+		if (!_ovsTunnelMgr.isOvsTunnelEnabled()) {
+			return null;
+		}
+		PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan
+				.getPhysicalNetworkId());
+		DataCenter dc = _dcDao.findById(plan.getDataCenterId());
+		if (!canHandle(offering, dc.getNetworkType(), physnet)) {
+			s_logger.debug("Refusing to design this network");
+			return null;
+		}
+		NetworkVO config = (NetworkVO) super.design(offering, plan,
+				userSpecified, owner);
+		if (config == null) {
+			return null;
+		}
+
+		config.setBroadcastDomainType(BroadcastDomainType.Vswitch);
+
+		return config;
+	}
+
+	@Override
+	public Network implement(Network network, NetworkOffering offering,
+			DeployDestination dest, ReservationContext context)
+			throws InsufficientVirtualNetworkCapcityException {
+		assert (network.getState() == State.Implementing) : "Why are we implementing "
+				+ network;
+		if (!_ovsTunnelMgr.isOvsTunnelEnabled()) {
+			return null;
+		}
+		long dcId = dest.getDataCenter().getId();
+		// 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) {
+			physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId,
+					offering.getTags(), offering.getTrafficType());
+		}
+		NetworkVO implemented = (NetworkVO) super.implement(network, offering,
+				dest, context);
+
+		if (network.getGateway() != null) {
+			implemented.setGateway(network.getGateway());
+		}
+
+		if (network.getCidr() != null) {
+			implemented.setCidr(network.getCidr());
+		}
+		String name = network.getName();
+		if (name == null || name.isEmpty()) {
+			name = ((NetworkVO) network).getUuid();
+		}
+
+		// do we need to create switch right now?
+
+		implemented.setBroadcastDomainType(BroadcastDomainType.Vswitch);
+
+		return implemented;
+	}
+
+	@Override
+	public void reserve(NicProfile nic, Network network,
+			VirtualMachineProfile<? extends VirtualMachine> vm,
+			DeployDestination dest, ReservationContext context)
+			throws InsufficientVirtualNetworkCapcityException,
+			InsufficientAddressCapacityException {
+		// TODO Auto-generated method stub
+		super.reserve(nic, network, vm, dest, context);
+	}
+
+	@Override
+	public boolean release(NicProfile nic,
+			VirtualMachineProfile<? extends VirtualMachine> vm,
+			String reservationId) {
+		// TODO Auto-generated method stub
+		return super.release(nic, vm, reservationId);
+	}
+
+	@Override
+	public void shutdown(NetworkProfile profile, NetworkOffering offering) {
+		NetworkVO networkObject = _networkDao.findById(profile.getId());
+		if (networkObject.getBroadcastDomainType() != BroadcastDomainType.Vswitch
+				|| networkObject.getBroadcastUri() == null) {
+			s_logger.warn("BroadcastUri is empty or incorrect for guestnetwork "
+					+ networkObject.getDisplayText());
+			return;
+		}
+
+		super.shutdown(profile, offering);
+	}
+
+	@Override
+	public boolean trash(Network network, NetworkOffering offering,
+			Account owner) {
+		return super.trash(network, offering, owner);
+	}
+
+	@Override
+	protected void allocateVnet(Network network, NetworkVO implemented,
+			long dcId, long physicalNetworkId, String reservationId)
+			throws InsufficientVirtualNetworkCapcityException {
+		if (network.getBroadcastUri() == null) {
+			String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId,
+					network.getAccountId(), reservationId,
+					canUseSystemGuestVlan(network.getAccountId()));
+			if (vnet == null) {
+				throw new InsufficientVirtualNetworkCapcityException(
+						"Unable to allocate vnet as a part of network "
+								+ network + " implement ", DataCenter.class,
+						dcId);
+			}
+			implemented
+					.setBroadcastUri(BroadcastDomainType.Vswitch.toUri(vnet));
+			ActionEventUtils.onCompletedActionEvent(
+					UserContext.current().getCallerUserId(),
+					network.getAccountId(),
+					EventVO.LEVEL_INFO,
+					EventTypes.EVENT_ZONE_VLAN_ASSIGN,
+					"Assigned Zone Vlan: " + vnet + " Network Id: "
+							+ network.getId(), 0);
+		} else {
+			implemented.setBroadcastUri(network.getBroadcastUri());
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApi.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApi.java
deleted file mode 100644
index b533312..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApi.java
+++ /dev/null
@@ -1,78 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.log4j.Logger;
-
-public class OvsApi {
-	private static final Logger s_logger = Logger.getLogger(OvsApi.class);
-	private final static String _protocol = "http";
-	private final static MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
-
-	private String _host;
-
-	private final HttpClient _client;
-
-	protected HttpClient createHttpClient() {
-		return new HttpClient(s_httpClientManager);
-	}
-
-	protected HttpMethod createMethod(String type, String uri, int port)
-			throws OvsApiException {
-		String url;
-		try {
-			url = new URL(_protocol, _host, port, uri).toString();
-		} catch (MalformedURLException e) {
-			s_logger.error("Unable to build Ovs API URL", e);
-			throw new OvsApiException("Unable to Ovs API URL", e);
-		}
-
-		if ("post".equalsIgnoreCase(type)) {
-			return new PostMethod(url);
-		} else if ("get".equalsIgnoreCase(type)) {
-			return new GetMethod(url);
-		} else if ("delete".equalsIgnoreCase(type)) {
-			return new DeleteMethod(url);
-		} else if ("put".equalsIgnoreCase(type)) {
-			return new PutMethod(url);
-		} else {
-			throw new OvsApiException("Requesting unknown method type");
-		}
-	}
-
-	public OvsApi() {
-		_client = createHttpClient();
-		_client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
-	}
-
-	public void setControllerAddress(String address) {
-		this._host = address;
-	}
-
-	// TODO: implement requests
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApiException.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApiException.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApiException.java
deleted file mode 100644
index 20603e0..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApiException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-public class OvsApiException extends Exception {
-
-	public OvsApiException() {
-	}
-
-	public OvsApiException(String message) {
-		super(message);
-	}
-
-	public OvsApiException(Throwable cause) {
-		super(cause);
-	}
-
-	public OvsApiException(String message, Throwable cause) {
-		super(message, cause);
-	}
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateGreTunnelCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateGreTunnelCommand.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateGreTunnelCommand.java
deleted file mode 100644
index e2cd2d8..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateGreTunnelCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Command;
-
-public class OvsCreateGreTunnelCommand extends Command {
-    String remoteIp;
-    String key;
-    long from;
-    long to;
-
-    @Override
-    public boolean executeInSequence() {
-        return true;
-    }
-
-    public OvsCreateGreTunnelCommand(String remoteIp, String key, long from, long to) {
-        this.remoteIp = remoteIp;
-        this.key = key;
-        this.from = from;
-        this.to = to;
-    }
-
-    public String getRemoteIp() {
-        return remoteIp;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public long getFrom() {
-        return from;
-    }
-
-    public long getTo() {
-        return to;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateTunnelCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateTunnelCommand.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateTunnelCommand.java
deleted file mode 100644
index 1ececa0..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateTunnelCommand.java
+++ /dev/null
@@ -1,69 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Command;
-
-public class OvsCreateTunnelCommand extends Command {
-    Integer key;
-    String remoteIp;
-    Long from;
-    Long to;
-    long networkId;
-
-    // for debug info
-    String fromIp;
-
-    @Override
-    public boolean executeInSequence() {
-        return true;
-    }
-
-    public OvsCreateTunnelCommand(String remoteIp, Integer key, Long from, Long to, long networkId, String fromIp) {
-        this.remoteIp = remoteIp;
-        this.key = key;
-        this.from = from;
-        this.to = to;
-        this.networkId = networkId;
-        this.fromIp = fromIp;
-    }
-
-    public Integer getKey() {
-        return key;
-    }
-
-    public String getRemoteIp() {
-        return remoteIp;
-    }
-
-    public Long getFrom() {
-        return from;
-    }
-
-    public Long getTo() {
-        return to;
-    }
-
-    public long getNetworkId() {
-        return networkId;
-    }
-
-    public String getFromIp() {
-        return fromIp;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDeleteFlowCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDeleteFlowCommand.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDeleteFlowCommand.java
deleted file mode 100644
index 2a6d5d7..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDeleteFlowCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Command;
-
-public class OvsDeleteFlowCommand extends Command {
-    String vmName;
-
-    @Override
-    public boolean executeInSequence() {
-        return true;
-    }
-
-    public String getVmName() {
-        return vmName;
-    }
-
-    public OvsDeleteFlowCommand(String vmName) {
-        this.vmName = vmName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDestroyBridgeCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDestroyBridgeCommand.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDestroyBridgeCommand.java
deleted file mode 100644
index 7be6776..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDestroyBridgeCommand.java
+++ /dev/null
@@ -1,45 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Command;
-
-public class OvsDestroyBridgeCommand extends Command {
-
-    Long networkId;
-    Integer key;
-
-    public OvsDestroyBridgeCommand(Long networkId, Integer key) {
-        this.networkId = networkId;
-        this.key = key;
-    }
-
-    public Long getNetworkId() {
-        return networkId;
-    }
-
-    public Integer getKey() {
-        return key;
-    }
-
-    @Override
-    public boolean executeInSequence() {
-        return true;
-    }
-
-}


[11/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
add kvm support & LB service


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3df8b912
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3df8b912
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3df8b912

Branch: refs/heads/master
Commit: 3df8b912fc8709de63a6a443facbb06eff536a0b
Parents: 9c702ff
Author: tuna <ng...@gmail.com>
Authored: Mon Sep 16 16:10:56 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 api/src/com/cloud/event/EventTypes.java         |   3 +
 .../org/apache/cloudstack/api/ApiConstants.java |   5 +
 client/pom.xml                                  |   7 +
 plugins/hypervisors/kvm/pom.xml                 |   5 +
 .../kvm/resource/LibvirtComputingResource.java  | 218 +++++-
 .../com/cloud/network/element/OvsElement.java   | 308 +++++++-
 .../cloud/network/ovs/OvsTunnelManagerImpl.java |  13 +-
 plugins/pom.xml                                 |   1 +
 .../vm/hypervisor/kvm/cloudstack_pluginlib.py   | 219 ++++++
 scripts/vm/hypervisor/xenserver/ovstunnel       |  18 +-
 scripts/vm/network/vnet/ovstunnel.py            | 182 +++++
 .../cloud/consoleproxy/ConsoleProxyManager.java |   1 +
 .../src/com/cloud/network/NetworkModelImpl.java |  19 +-
 ui/scripts/system.js                            | 745 ++++++++++++++++---
 14 files changed, 1618 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index d3c29e9..5d6ee6f 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -400,6 +400,9 @@ public class EventTypes {
     public static final String EVENT_EXTERNAL_NVP_CONTROLLER_CONFIGURE = "PHYSICAL.NVPCONTROLLER.CONFIGURE";
     public static final String EVENT_EXTERNAL_OVS_CONTROLLER_ADD = "PHYSICAL.OVSCONTROLLER.ADD";
     public static final String EVENT_EXTERNAL_OVS_CONTROLLER_DELETE = "PHYSICAL.OVSCONTROLLER.DELETE";
+	public static final String EVENT_EXTERNAL_ODL_CONTROLLER_ADD = "PHYSICAL.ODLCONTROLLER.ADD";
+	public static final String EVENT_EXTERNAL_ODL_CONTROLLER_DELETE = "PHYSICAL.ODLCONTROLLER.DELETE";
+	public static final String EVENT_EXTERNAL_ODL_CONTROLLER_CONFIGURE = "PHYSICAL.ODLCONTROLLER.CONFIGURE";
 
     // AutoScale
     public static final String EVENT_COUNTER_CREATE = "COUNTER.CREATE";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 0cde5ba..745a722 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -412,6 +412,11 @@ public class ApiConstants {
     // Ovs controller
     public static final String OVS_DEVICE_ID = "ovsdeviceid";
     public static final String OVS_DEVICE_NAME = "ovsdevicename";
+	// OpenDaylight controller
+	public static final String ODL_DEVICE_ID = "odldeviceid";
+	public static final String ODL_DEVICE_NAME = "odldevicename";
+	public static final String ODL_TRANSPORT_ZONE_UUID = "transportzoneuuid";
+	public static final String ODL_GATEWAYSERVICE_UUID = "l3gatewayserviceuuid";
 
     public static final String EXTERNAL_SWITCH_MGMT_DEVICE_ID = "vsmdeviceid";
     public static final String EXTERNAL_SWITCH_MGMT_DEVICE_NAME = "vsmdevicename";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index fc01113..1f01693 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -85,6 +85,13 @@
       <artifactId>cloud-plugin-network-nvp</artifactId>
       <version>${project.version}</version>
     </dependency>
+<!--     
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-plugin-network-odl</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+ -->    
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-plugin-network-contrail</artifactId>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/plugins/hypervisors/kvm/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/pom.xml b/plugins/hypervisors/kvm/pom.xml
index ebe05e5..81cc372 100644
--- a/plugins/hypervisors/kvm/pom.xml
+++ b/plugins/hypervisors/kvm/pom.xml
@@ -44,6 +44,11 @@
       <version>${cs.libvirt-java.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-plugin-network-ovs</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
       <groupId>com.ceph</groupId>
       <artifactId>rados</artifactId>
       <version>${cs.rados-java.version}</version>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index b951b212..9a680ac 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -132,6 +132,13 @@ import com.cloud.agent.api.NetworkRulesSystemVmCommand;
 import com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand;
 import com.cloud.agent.api.NetworkUsageAnswer;
 import com.cloud.agent.api.NetworkUsageCommand;
+import com.cloud.agent.api.OvsCreateTunnelAnswer;
+import com.cloud.agent.api.OvsCreateTunnelCommand;
+import com.cloud.agent.api.OvsDestroyBridgeCommand;
+import com.cloud.agent.api.OvsDestroyTunnelCommand;
+import com.cloud.agent.api.OvsFetchInterfaceAnswer;
+import com.cloud.agent.api.OvsFetchInterfaceCommand;
+import com.cloud.agent.api.OvsSetupBridgeCommand;
 import com.cloud.agent.api.PingCommand;
 import com.cloud.agent.api.PingRoutingCommand;
 import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
@@ -294,6 +301,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     private String _ovsPvlanDhcpHostPath;
     private String _ovsPvlanVmPath;
     private String _routerProxyPath;
+	private String _ovsTunnelPath;
     private String _host;
     private String _dcId;
     private String _pod;
@@ -599,6 +607,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             throw new ConfigurationException("Unable to find the security_group.py");
         }
 
+	_ovsTunnelPath = Script.findScript(networkScriptsDir, "ovstunnel.py");
+	if (_ovsTunnelPath == null) {
+		throw new ConfigurationException("Unable to find the ovstunnel.py");
+	}
+
         _routerProxyPath = Script.findScript("scripts/network/domr/", "router_proxy.sh");
         if (_routerProxyPath == null) {
             throw new ConfigurationException("Unable to find the router_proxy.sh");
@@ -1271,7 +1284,17 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 return execute((SetMonitorServiceCommand)cmd);
             } else if (cmd instanceof CheckOnHostCommand) {
                 return execute((CheckOnHostCommand)cmd);
-            } else {
+	    } else if (cmd instanceof OvsFetchInterfaceCommand) {
+		return execute((OvsFetchInterfaceCommand) cmd);
+		} else if (cmd instanceof OvsSetupBridgeCommand) {
+			return execute((OvsSetupBridgeCommand) cmd);
+		} else if (cmd instanceof OvsDestroyBridgeCommand) {
+			return execute((OvsDestroyBridgeCommand) cmd);
+		} else if (cmd instanceof OvsCreateTunnelCommand) {
+			return execute((OvsCreateTunnelCommand) cmd);
+		} else if (cmd instanceof OvsDestroyTunnelCommand) {
+			return execute((OvsDestroyTunnelCommand) cmd);
+		} else {
                 s_logger.warn("Unsupported command ");
                 return Answer.createUnsupportedCommandAnswer(cmd);
             }
@@ -1280,6 +1303,188 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
+	// Tuna added
+    private OvsFetchInterfaceAnswer execute(OvsFetchInterfaceCommand cmd) {
+    	String label = cmd.getLabel();
+    	s_logger.debug("Will look for network with name-label:" + label);
+    	try {
+    		String ipadd = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'");
+    		String mask = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f4");
+    		String mac = Script.runSimpleBashScript("ifconfig " + label + " | grep HWaddr | awk -F \" \" '{print $5}'");
+			return new OvsFetchInterfaceAnswer(cmd, true, "Interface " + label
+					+ " retrieved successfully", ipadd, mask, mac);
+
+		} catch (Exception e) {
+			s_logger.warn("Caught execption when fetching interface", e);
+			return new OvsFetchInterfaceAnswer(cmd, false, "EXCEPTION:"
+					+ e.getMessage());
+    	}
+
+    }
+
+	private Answer execute(OvsSetupBridgeCommand cmd) {
+		findOrCreateTunnelNetwork(cmd.getKey());
+		configureTunnelNetwork(cmd.getNetworkId(), cmd.getHostId(),
+				cmd.getKey());
+		s_logger.debug("OVS Bridge configured");
+		return new Answer(cmd, true, null);
+	}
+
+	private Answer execute(OvsDestroyBridgeCommand cmd) {
+		destroyTunnelNetwork(cmd.getKey());
+		s_logger.debug("OVS Bridge destroyed");
+		return new Answer(cmd, true, null);
+	}
+
+	private synchronized void destroyTunnelNetwork(int key) {
+		try {
+			findOrCreateTunnelNetwork(key);
+			String bridge = "OVSTunnel" + key;
+			Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger);
+			cmd.add("destroy_ovs_bridge");
+			cmd.add("--bridge", bridge);
+			String result = cmd.execute();
+			String[] res = result.split(":");
+			if (res.length != 2 || !res[0].equalsIgnoreCase("SUCCESS")) {
+				// TODO: Should make this error not fatal?
+				// Can Concurrent VM shutdown/migration/reboot events can cause
+				// this method
+				// to be executed on a bridge which has already been removed?
+				throw new CloudRuntimeException("Unable to remove OVS bridge "
+						+ bridge + ":" + res);
+			}
+			return;
+		} catch (Exception e) {
+			s_logger.warn("destroyTunnelNetwork failed:", e);
+			return;
+		}
+	}
+
+	private boolean networkExist(String nwName) {
+		Script.runSimpleBashScript("ifconfig " + nwName);
+		String result = Script.runSimpleBashScript("echo $?");
+		return result.equals("0");
+	}
+
+	private synchronized boolean findOrCreateTunnelNetwork(long key) {
+		try {
+			String nwName = "OVSTunnel" + key;
+			if (networkExist(nwName)) {
+				return true;
+			}
+			// if not found, create a new one
+			Map<String, String> otherConfig = new HashMap<String, String>();
+			otherConfig.put("ovs-host-setup", "");
+			Script.runSimpleBashScript("ovs-vsctl -- --may-exist add-br "
+					+ nwName + " -- set bridge " + nwName
+					+ " other_config:ovs_host_setup=\" \"");
+			s_logger.debug("### KVM network for tunnels created:" + nwName);
+		} catch (Exception e) {
+			s_logger.warn("createTunnelNetwork failed", e);
+		}
+		return true;
+	}
+
+	private synchronized boolean configureTunnelNetwork(long networkId,
+			long hostId, int key) {
+		try {
+			findOrCreateTunnelNetwork(key);
+			String nwName = "OVSTunnel" + key;
+			String configuredHosts = Script
+					.runSimpleBashScript("ovs-vsctl get bridge " + nwName
+							+ " other_config:ovs_host_setup");
+			boolean configured = false;
+			if (configuredHosts != null) {
+				String hostIdsStr[] = configuredHosts.split(",");
+				for (String hostIdStr : hostIdsStr) {
+					if (hostIdStr.equals(((Long) hostId).toString())) {
+						configured = true;
+						break;
+					}
+				}
+			}
+			if (!configured) {
+				Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger);
+				cmd.add("setup_ovs_bridge");
+				cmd.add("--key", String.valueOf(key));
+				cmd.add("--cs_host_id", ((Long) hostId).toString());
+				cmd.add("--bridge", nwName);
+				String result = cmd.execute();
+				String[] res = result.split(":");
+				if (res.length != 2 || !res[0].equalsIgnoreCase("SUCCESS")) {
+					throw new CloudRuntimeException(
+							"Unable to pre-configure OVS bridge " + nwName
+									+ " for network ID:" + networkId + " - "
+									+ res);
+				}
+			}
+		} catch (Exception e) {
+			s_logger.warn("createandConfigureTunnelNetwork failed", e);
+			return false;
+		}
+		return true;
+	}
+
+	private OvsCreateTunnelAnswer execute(OvsCreateTunnelCommand cmd) {
+		String bridge = "OVSTunnel" + cmd.getKey();
+		try {
+			if (!findOrCreateTunnelNetwork(cmd.getKey())) {
+				s_logger.debug("Error during bridge setup");
+				return new OvsCreateTunnelAnswer(cmd, false,
+						"Cannot create network", bridge);
+			}
+
+			configureTunnelNetwork(cmd.getNetworkId(), cmd.getFrom(),
+					cmd.getKey());
+			Script command = new Script(_ovsTunnelPath, _timeout, s_logger);
+			command.add("create_tunnel");
+			command.add("--bridge", bridge);
+			command.add("--remote_ip", cmd.getRemoteIp());
+			command.add("--key", cmd.getKey().toString());
+			command.add("--src_host", cmd.getFrom().toString());
+			command.add("--dst_host", cmd.getTo().toString());
+
+			String result = command.execute();
+			String[] res = result.split(":");
+			if (res.length == 2 && res[0].equalsIgnoreCase("SUCCESS")) {
+				return new OvsCreateTunnelAnswer(cmd, true, result, res[1],
+						bridge);
+			} else {
+				return new OvsCreateTunnelAnswer(cmd, false, result, bridge);
+			}
+		} catch (Exception e) {
+			s_logger.debug("Error during tunnel setup");
+			s_logger.warn("Caught execption when creating ovs tunnel", e);
+			return new OvsCreateTunnelAnswer(cmd, false, e.getMessage(), bridge);
+		}
+	}
+
+	private Answer execute(OvsDestroyTunnelCommand cmd) {
+		try {
+			if (!findOrCreateTunnelNetwork(cmd.getKey())) {
+				s_logger.warn("Unable to find tunnel network for GRE key:"
+						+ cmd.getKey());
+				return new Answer(cmd, false, "No network found");
+			}
+
+			String bridge = "OVSTunnel" + cmd.getKey();
+			Script command = new Script(_ovsTunnelPath, _timeout, s_logger);
+			command.add("destroy_tunnel");
+			command.add("--bridge", bridge);
+			command.add("--iface_name", cmd.getInPortName());
+			String result = command.execute();
+			if (result.equalsIgnoreCase("SUCCESS")) {
+				return new Answer(cmd, true, result);
+			} else {
+				return new Answer(cmd, false, result);
+			}
+		} catch (Exception e) {
+			s_logger.warn("caught execption when destroy ovs tunnel", e);
+			return new Answer(cmd, false, e.getMessage());
+		}
+	}
+	// end Tuna added
+
     private CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
         List<PhysicalNetworkSetupInfo> phyNics = cmd.getPhysicalNetworkInfoList();
         String errMsg = null;
@@ -3025,7 +3230,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-    private Answer execute(RebootCommand cmd) {
+
+	private Answer execute(RebootCommand cmd) {
 
         synchronized (_vms) {
             _vms.put(cmd.getVmName(), State.Starting);
@@ -3106,7 +3312,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-    protected Answer execute(StopCommand cmd) {
+
+	protected Answer execute(StopCommand cmd) {
         final String vmName = cmd.getVmName();
 
         State state = null;
@@ -3422,6 +3629,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             }
 
             // pass cmdline info to system vms
+			// if (vmSpec.getType() != VirtualMachine.Type.User) {
+			// passCmdLine(vmName, vmSpec.getBootArgs() );
+			// }
+			// merge with master branch
+			// pass cmdline info to system vms
             if (vmSpec.getType() != VirtualMachine.Type.User) {
                 if ((conn.getVersion() < 1001000)) { // CLOUDSTACK-2823: try passCmdLine some times if kernel < 2.6.34 and qemu < 1.1.0 on hypervisor (for instance, CentOS 6.4)
                     //wait for 5 minutes at most

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index 9af708c..2622bdc 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -30,9 +30,11 @@ import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupOvsCommand;
+import com.cloud.agent.api.to.LoadBalancerTO;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.host.Host;
 import com.cloud.host.HostVO;
@@ -46,9 +48,14 @@ import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.dao.NetworkServiceMapDao;
+import com.cloud.network.lb.LoadBalancingRule;
+import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
 import com.cloud.network.ovs.OvsTunnelManager;
 import com.cloud.network.router.VirtualRouter.Role;
 import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
+import com.cloud.network.rules.LbStickinessMethod;
+import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
+import com.cloud.network.rules.LoadBalancerContainer;
 import com.cloud.network.rules.PortForwardingRule;
 import com.cloud.network.rules.StaticNat;
 import com.cloud.offering.NetworkOffering;
@@ -56,19 +63,22 @@ import com.cloud.resource.ResourceManager;
 import com.cloud.resource.ResourceStateAdapter;
 import com.cloud.resource.ServerResource;
 import com.cloud.resource.UnableDeleteHostException;
+import com.cloud.utils.Pair;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.DomainRouterDao;
+import com.google.gson.Gson;
 
 @Local(value = { NetworkElement.class, ConnectivityProvider.class,
 		SourceNatServiceProvider.class, StaticNatServiceProvider.class,
 		PortForwardingServiceProvider.class, IpDeployer.class })
 public class OvsElement extends AdapterBase implements NetworkElement,
 		OvsElementService, ConnectivityProvider, ResourceStateAdapter,
-		PortForwardingServiceProvider,
+		PortForwardingServiceProvider, LoadBalancingServiceProvider,
 		StaticNatServiceProvider, IpDeployer {
 	@Inject
 	OvsTunnelManager _ovsTunnelMgr;
@@ -237,9 +247,6 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 		// L2 Support : SDN provisioning
 		capabilities.put(Service.Connectivity, null);
 
-		// L3 Support : Generic?
-		// capabilities.put(Service.Gateway, null);
-
 		// L3 Support : SourceNat
 		// Map<Capability, String> sourceNatCapabilities = new
 		// HashMap<Capability, String>();
@@ -254,8 +261,116 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 		// L3 support : StaticNat
 		capabilities.put(Service.StaticNat, null);
 
+		// L3 support : Load Balancer
+        // Set capabilities for LB service
+        Map<Capability, String> lbCapabilities = new HashMap<Capability, String>();
+        lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn,source");
+        lbCapabilities.put(Capability.SupportedLBIsolation, "dedicated");
+        lbCapabilities.put(Capability.SupportedProtocols, "tcp, udp");
+        lbCapabilities.put(Capability.SupportedStickinessMethods, getHAProxyStickinessCapability());
+        lbCapabilities.put(Capability.LbSchemes, LoadBalancerContainer.Scheme.Public.toString());
+
+        capabilities.put(Service.Lb, lbCapabilities);
+
 		return capabilities;
 	}
+	
+    public static String getHAProxyStickinessCapability() {
+        LbStickinessMethod method;
+        List<LbStickinessMethod> methodList = new ArrayList<LbStickinessMethod>(1);
+
+        method = new LbStickinessMethod(StickinessMethodType.LBCookieBased, "This is loadbalancer cookie based stickiness method.");
+        method.addParam("cookie-name", false, "Cookie name passed in http header by the LB to the client.", false);
+        method.addParam("mode", false,
+                "Valid values: insert, rewrite, prefix. Default value: insert.  In the insert mode cookie will be created" +
+                " by the LB. In other modes, cookie will be created by the server and LB modifies it.", false);
+        method.addParam(
+                "nocache",
+                false,
+                "This option is recommended in conjunction with the insert mode when there is a cache between the client" +
+                " and HAProxy, as it ensures that a cacheable response will be tagged non-cacheable if  a cookie needs " +
+                "to be inserted. This is important because if all persistence cookies are added on a cacheable home page" +
+                " for instance, then all customers will then fetch the page from an outer cache and will all share the " +
+                "same persistence cookie, leading to one server receiving much more traffic than others. See also the " +
+                "insert and postonly options. ",
+                true);
+        method.addParam(
+                "indirect",
+                false,
+                "When this option is specified in insert mode, cookies will only be added when the server was not reached" +
+                " after a direct access, which means that only when a server is elected after applying a load-balancing algorithm," +
+                " or after a redispatch, then the cookie  will be inserted. If the client has all the required information" +
+                " to connect to the same server next time, no further cookie will be inserted. In all cases, when the " +
+                "indirect option is used in insert mode, the cookie is always removed from the requests transmitted to " +
+                "the server. The persistence mechanism then becomes totally transparent from the application point of view.",
+                true);
+        method.addParam(
+                "postonly",
+                false,
+                "This option ensures that cookie insertion will only be performed on responses to POST requests. It is an" +
+                " alternative to the nocache option, because POST responses are not cacheable, so this ensures that the " +
+                "persistence cookie will never get cached.Since most sites do not need any sort of persistence before the" +
+                " first POST which generally is a login request, this is a very efficient method to optimize caching " +
+                "without risking to find a persistence cookie in the cache. See also the insert and nocache options.",
+                true);
+        method.addParam(
+                "domain",
+                false,
+                "This option allows to specify the domain at which a cookie is inserted. It requires exactly one parameter:" +
+                " a valid domain name. If the domain begins with a dot, the browser is allowed to use it for any host " +
+                "ending with that name. It is also possible to specify several domain names by invoking this option multiple" +
+                " times. Some browsers might have small limits on the number of domains, so be careful when doing that. " +
+                "For the record, sending 10 domains to MSIE 6 or Firefox 2 works as expected.",
+                false);
+        methodList.add(method);
+
+        method = new LbStickinessMethod(StickinessMethodType.AppCookieBased,
+                "This is App session based sticky method. Define session stickiness on an existing application cookie. " +
+                "It can be used only for a specific http traffic");
+        method.addParam("cookie-name", false, "This is the name of the cookie used by the application and which LB will " +
+        		"have to learn for each new session. Default value: Auto geneared based on ip", false);
+        method.addParam("length", false, "This is the max number of characters that will be memorized and checked in " +
+        		"each cookie value. Default value:52", false);
+        method.addParam(
+                "holdtime",
+                false,
+                "This is the time after which the cookie will be removed from memory if unused. The value should be in " +
+                "the format Example : 20s or 30m  or 4h or 5d . only seconds(s), minutes(m) hours(h) and days(d) are valid," +
+                " cannot use th combinations like 20h30m. Default value:3h ",
+                false);
+        method.addParam(
+                "request-learn",
+                false,
+                "If this option is specified, then haproxy will be able to learn the cookie found in the request in case the server does not specify any in response. This is typically what happens with PHPSESSID cookies, or when haproxy's session expires before the application's session and the correct server is selected. It is recommended to specify this option to improve reliability",
+                true);
+        method.addParam(
+                "prefix",
+                false,
+                "When this option is specified, haproxy will match on the cookie prefix (or URL parameter prefix). " +
+                "The appsession value is the data following this prefix. Example : appsession ASPSESSIONID len 64 timeout 3h prefix  This will match the cookie ASPSESSIONIDXXXX=XXXXX, the appsession value will be XXXX=XXXXX.",
+                true);
+        method.addParam(
+                "mode",
+                false,
+                "This option allows to change the URL parser mode. 2 modes are currently supported : - path-parameters " +
+                ": The parser looks for the appsession in the path parameters part (each parameter is separated by a semi-colon), " +
+                "which is convenient for JSESSIONID for example.This is the default mode if the option is not set. - query-string :" +
+                " In this mode, the parser will look for the appsession in the query string.",
+                false);
+        methodList.add(method);
+
+        method = new LbStickinessMethod(StickinessMethodType.SourceBased, "This is source based Stickiness method, " +
+        		"it can be used for any type of protocol.");
+        method.addParam("tablesize", false, "Size of table to store source ip addresses. example: tablesize=200k or 300m" +
+        		" or 400g. Default value:200k", false);
+        method.addParam("expire", false, "Entry in source ip table will expire after expire duration. units can be s,m,h,d ." +
+        		" example: expire=30m 20s 50h 4d. Default value:3h", false);
+        methodList.add(method);
+
+        Gson gson = new Gson();
+        String capability = gson.toJson(methodList);
+        return capability;
+    }
 
 	@Override
 	public List<Class<?>> getCommands() {
@@ -355,4 +470,189 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 
 		return _routerMgr.applyFirewallRules(network, rules, routers);
 	}
+
+	@Override
+	public boolean applyLBRules(Network network, List<LoadBalancingRule> rules)
+			throws ResourceUnavailableException {
+		if (canHandle(network, Service.Lb)) {
+			if (!canHandleLbRules(rules)) {
+				return false;
+			}
+
+			List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
+					network.getId(), Role.VIRTUAL_ROUTER);
+			if (routers == null || routers.isEmpty()) {
+				s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual "
+						+ "router doesn't exist in the network "
+						+ network.getId());
+				return true;
+			}
+
+			if (!_routerMgr.applyLoadBalancingRules(network, rules, routers)) {
+				throw new CloudRuntimeException(
+						"Failed to apply load balancing rules in network "
+								+ network.getId());
+			} else {
+				return true;
+			}
+		} else {
+			return false;
+		}
+	}
+
+	@Override
+	public boolean validateLBRule(Network network, LoadBalancingRule rule) {
+		List<LoadBalancingRule> rules = new ArrayList<LoadBalancingRule>();
+		rules.add(rule);
+		if (canHandle(network, Service.Lb) && canHandleLbRules(rules)) {
+			List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
+					network.getId(), Role.VIRTUAL_ROUTER);
+			if (routers == null || routers.isEmpty()) {
+				return true;
+			}
+			return validateHAProxyLBRule(rule);
+		}
+		return true;
+	}
+
+	@Override
+	public List<LoadBalancerTO> updateHealthChecks(Network network,
+			List<LoadBalancingRule> lbrules) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	private boolean canHandleLbRules(List<LoadBalancingRule> rules) {
+		Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
+		if (!lbCaps.isEmpty()) {
+			String schemeCaps = lbCaps.get(Capability.LbSchemes);
+			if (schemeCaps != null) {
+				for (LoadBalancingRule rule : rules) {
+					if (!schemeCaps.contains(rule.getScheme().toString())) {
+						s_logger.debug("Scheme " + rules.get(0).getScheme()
+								+ " is not supported by the provider "
+								+ this.getName());
+						return false;
+					}
+				}
+			}
+		}
+		return true;
+	}
+
+	public static boolean validateHAProxyLBRule(LoadBalancingRule rule) {
+		String timeEndChar = "dhms";
+
+		for (LbStickinessPolicy stickinessPolicy : rule.getStickinessPolicies()) {
+			List<Pair<String, String>> paramsList = stickinessPolicy
+					.getParams();
+
+			if (StickinessMethodType.LBCookieBased.getName().equalsIgnoreCase(
+					stickinessPolicy.getMethodName())) {
+
+			} else if (StickinessMethodType.SourceBased.getName()
+					.equalsIgnoreCase(stickinessPolicy.getMethodName())) {
+				String tablesize = "200k"; // optional
+				String expire = "30m"; // optional
+
+				/* overwrite default values with the stick parameters */
+				for (Pair<String, String> paramKV : paramsList) {
+					String key = paramKV.first();
+					String value = paramKV.second();
+					if ("tablesize".equalsIgnoreCase(key))
+						tablesize = value;
+					if ("expire".equalsIgnoreCase(key))
+						expire = value;
+				}
+				if ((expire != null)
+						&& !containsOnlyNumbers(expire, timeEndChar)) {
+					throw new InvalidParameterValueException(
+							"Failed LB in validation rule id: " + rule.getId()
+									+ " Cause: expire is not in timeformat: "
+									+ expire);
+				}
+				if ((tablesize != null)
+						&& !containsOnlyNumbers(tablesize, "kmg")) {
+					throw new InvalidParameterValueException(
+							"Failed LB in validation rule id: "
+									+ rule.getId()
+									+ " Cause: tablesize is not in size format: "
+									+ tablesize);
+
+				}
+			} else if (StickinessMethodType.AppCookieBased.getName()
+					.equalsIgnoreCase(stickinessPolicy.getMethodName())) {
+				/*
+				 * FORMAT : appsession <cookie> len <length> timeout <holdtime>
+				 * [request-learn] [prefix] [mode
+				 * <path-parameters|query-string>]
+				 */
+				/* example: appsession JSESSIONID len 52 timeout 3h */
+				String cookieName = null; // optional
+				String length = null; // optional
+				String holdTime = null; // optional
+
+				for (Pair<String, String> paramKV : paramsList) {
+					String key = paramKV.first();
+					String value = paramKV.second();
+					if ("cookie-name".equalsIgnoreCase(key))
+						cookieName = value;
+					if ("length".equalsIgnoreCase(key))
+						length = value;
+					if ("holdtime".equalsIgnoreCase(key))
+						holdTime = value;
+				}
+
+				if ((length != null) && (!containsOnlyNumbers(length, null))) {
+					throw new InvalidParameterValueException(
+							"Failed LB in validation rule id: " + rule.getId()
+									+ " Cause: length is not a number: "
+									+ length);
+				}
+				if ((holdTime != null)
+						&& (!containsOnlyNumbers(holdTime, timeEndChar) && !containsOnlyNumbers(
+								holdTime, null))) {
+					throw new InvalidParameterValueException(
+							"Failed LB in validation rule id: " + rule.getId()
+									+ " Cause: holdtime is not in timeformat: "
+									+ holdTime);
+				}
+			}
+		}
+		return true;
+	}
+
+	/*
+	 * This function detects numbers like 12 ,32h ,42m .. etc,. 1) plain number
+	 * like 12 2) time or tablesize like 12h, 34m, 45k, 54m , here last
+	 * character is non-digit but from known characters .
+	 */
+	private static boolean containsOnlyNumbers(String str, String endChar) {
+		if (str == null)
+			return false;
+
+		String number = str;
+		if (endChar != null) {
+			boolean matchedEndChar = false;
+			if (str.length() < 2)
+				return false; // atleast one numeric and one char. example:
+								// 3h
+			char strEnd = str.toCharArray()[str.length() - 1];
+			for (char c : endChar.toCharArray()) {
+				if (strEnd == c) {
+					number = str.substring(0, str.length() - 1);
+					matchedEndChar = true;
+					break;
+				}
+			}
+			if (!matchedEndChar)
+				return false;
+		}
+		try {
+			int i = Integer.parseInt(number);
+		} catch (NumberFormatException e) {
+			return false;
+		}
+		return true;
+	}
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
index a03055f..bfead90 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
@@ -262,13 +262,20 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
         		_physNetTTDao.findBy(physNetId, TrafficType.Guest);
         HypervisorType hvType = host.getHypervisorType();
 
+        String label = null;
         switch (hvType) {
         	case XenServer:
-        		String label = physNetTT.getXenNetworkLabel();
+        		label = physNetTT.getXenNetworkLabel();
         		if ((label!=null) && (!label.equals(""))) {
         			physNetLabel = label;
         		}
         		break;
+			case KVM:
+				label = physNetTT.getKvmNetworkLabel();
+				if ((label != null) && (!label.equals(""))) {
+					physNetLabel = label;
+				}
+				break;
         	default:
         		throw new CloudRuntimeException("Hypervisor " +
         				hvType.toString() +
@@ -321,9 +328,6 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 
 	@DB
     protected void CheckAndCreateTunnel(VirtualMachine instance, Network nw, DeployDestination dest) {
-		// if (!_isEnabled) {
-		// return;
-		// }
 
 		s_logger.debug("Creating tunnels with OVS tunnel manager");
 		if (instance.getType() != VirtualMachine.Type.User
@@ -436,7 +440,6 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 
 	@Override
 	public boolean isOvsTunnelEnabled() {
-		// return _isEnabled;
 		return true;
 	}
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 17dd8af..0b65b98 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -46,6 +46,7 @@
     <module>network-elements/juniper-contrail</module>
     <module>network-elements/palo-alto</module>
     <module>network-elements/nicira-nvp</module>
+<!--     <module>network-elements/odl</module> -->
     <module>network-elements/bigswitch-vns</module>
     <module>network-elements/midonet</module>
     <module>network-elements/stratosphere-ssp</module>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/scripts/vm/hypervisor/kvm/cloudstack_pluginlib.py
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/kvm/cloudstack_pluginlib.py b/scripts/vm/hypervisor/kvm/cloudstack_pluginlib.py
new file mode 100755
index 0000000..f886aa3
--- /dev/null
+++ b/scripts/vm/hypervisor/kvm/cloudstack_pluginlib.py
@@ -0,0 +1,219 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# cloudstack_pluginlib for openvswitch on KVM hypervisor
+
+import ConfigParser
+import logging
+import os
+import subprocess
+
+from time import localtime, asctime
+
+DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
+DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
+DEFAULT_LOG_FILE = "/var/log/cloudstack_plugins.log"
+
+PLUGIN_CONFIG_PATH = "/usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/cloudstack_plugins.conf"
+OVSDB_PID_PATH = "/var/run/openvswitch/ovsdb-server.pid"
+OVSDB_DAEMON_PATH = "ovsdb-server"
+OVS_PID_PATH = "/var/run/openvswitch/ovs-vswitchd.pid"
+OVS_DAEMON_PATH = "ovs-vswitchd"
+VSCTL_PATH = "/usr/bin/ovs-vsctl"
+OFCTL_PATH = "/usr/bin/ovs-ofctl"
+
+class PluginError(Exception):
+    """Base Exception class for all plugin errors."""
+    def __init__(self, *args):
+        Exception.__init__(self, *args)
+
+
+def setup_logging(log_file=None):
+    debug = False
+    verbose = False
+    log_format = DEFAULT_LOG_FORMAT
+    log_date_format = DEFAULT_LOG_DATE_FORMAT
+    # try to read plugin configuration file
+    if os.path.exists(PLUGIN_CONFIG_PATH):
+        config = ConfigParser.ConfigParser()
+        config.read(PLUGIN_CONFIG_PATH)
+        try:
+            options = config.options('LOGGING')
+            if 'debug' in options:
+                debug = config.getboolean('LOGGING', 'debug')
+            if 'verbose' in options:
+                verbose = config.getboolean('LOGGING', 'verbose')
+            if 'format' in options:
+                log_format = config.get('LOGGING', 'format')
+            if 'date_format' in options:
+                log_date_format = config.get('LOGGING', 'date_format')
+            if 'file' in options:
+                log_file_2 = config.get('LOGGING', 'file')
+        except ValueError:
+            # configuration file contained invalid attributes
+            # ignore them
+            pass
+        except ConfigParser.NoSectionError:
+            # Missing 'Logging' section in configuration file
+            pass
+
+    root_logger = logging.root
+    if debug:
+        root_logger.setLevel(logging.DEBUG)
+    elif verbose:
+        root_logger.setLevel(logging.INFO)
+    else:
+        root_logger.setLevel(logging.WARNING)
+    formatter = logging.Formatter(log_format, log_date_format)
+
+    log_filename = log_file or log_file_2 or DEFAULT_LOG_FILE
+
+    logfile_handler = logging.FileHandler(log_filename)
+    logfile_handler.setFormatter(formatter)
+    root_logger.addHandler(logfile_handler)
+
+
+def do_cmd(cmd):
+    """Abstracts out the basics of issuing system commands. If the command
+    returns anything in stderr, a PluginError is raised with that information.
+    Otherwise, the output from stdout is returned.
+    """
+
+    pipe = subprocess.PIPE
+    logging.debug("Executing:%s", cmd)
+    proc = subprocess.Popen(cmd, shell=False, stdin=pipe, stdout=pipe,
+                            stderr=pipe, close_fds=True)
+    ret_code = proc.wait()
+    err = proc.stderr.read()
+    if ret_code:
+        logging.debug("The command exited with the error code: " +
+                      "%s (stderr output:%s)" % (ret_code, err))
+        raise PluginError(err)
+    output = proc.stdout.read()
+    if output.endswith('\n'):
+        output = output[:-1]
+    return output
+
+
+def _is_process_run(pidFile, name):
+    try:
+        fpid = open(pidFile, "r")
+        pid = fpid.readline()
+        fpid.close()
+    except IOError, e:
+        return -1
+
+    pid = pid[:-1]
+    ps = os.popen("ps -ae")
+    for l in ps:
+        if pid in l and name in l:
+            ps.close()
+            return 0
+
+    ps.close()
+    return -2
+
+
+def _is_tool_exist(name):
+    if os.path.exists(name):
+        return 0
+    return -1
+
+
+def check_switch():
+    global result
+
+    ret = _is_process_run(OVSDB_PID_PATH, OVSDB_DAEMON_PATH)
+    if ret < 0:
+        if ret == -1:
+            return "NO_DB_PID_FILE"
+        if ret == -2:
+            return "DB_NOT_RUN"
+
+    ret = _is_process_run(OVS_PID_PATH, OVS_DAEMON_PATH)
+    if ret < 0:
+        if ret == -1:
+            return "NO_SWITCH_PID_FILE"
+        if ret == -2:
+            return "SWITCH_NOT_RUN"
+
+    if _is_tool_exist(VSCTL_PATH) < 0:
+        return "NO_VSCTL"
+
+    if _is_tool_exist(OFCTL_PATH) < 0:
+        return "NO_OFCTL"
+
+    return "SUCCESS"
+
+
+def _build_flow_expr(**kwargs):
+    is_delete_expr = kwargs.get('delete', False)
+    flow = ""
+    if not is_delete_expr:
+        flow = "hard_timeout=%s,idle_timeout=%s,priority=%s"\
+                % (kwargs.get('hard_timeout', '0'),
+                   kwargs.get('idle_timeout', '0'),
+                   kwargs.get('priority', '1'))
+    in_port = 'in_port' in kwargs and ",in_port=%s" % kwargs['in_port'] or ''
+    dl_type = 'dl_type' in kwargs and ",dl_type=%s" % kwargs['dl_type'] or ''
+    dl_src = 'dl_src' in kwargs and ",dl_src=%s" % kwargs['dl_src'] or ''
+    dl_dst = 'dl_dst' in kwargs and ",dl_dst=%s" % kwargs['dl_dst'] or ''
+    nw_src = 'nw_src' in kwargs and ",nw_src=%s" % kwargs['nw_src'] or ''
+    nw_dst = 'nw_dst' in kwargs and ",nw_dst=%s" % kwargs['nw_dst'] or ''
+    proto = 'proto' in kwargs and ",%s" % kwargs['proto'] or ''
+    ip = ('nw_src' in kwargs or 'nw_dst' in kwargs) and ',ip' or ''
+    flow = (flow + in_port + dl_type + dl_src + dl_dst +
+            (ip or proto) + nw_src + nw_dst)
+    return flow
+
+
+def add_flow(bridge, **kwargs):
+    """
+    Builds a flow expression for **kwargs and adds the flow entry
+    to an Open vSwitch instance
+    """
+    flow = _build_flow_expr(**kwargs)
+    actions = 'actions' in kwargs and ",actions=%s" % kwargs['actions'] or ''
+    flow = flow + actions
+    addflow = [OFCTL_PATH, "add-flow", bridge, flow]
+    do_cmd(addflow)
+
+
+def del_flows(bridge, **kwargs):
+    """
+    Removes flows according to criteria passed as keyword.
+    """
+    flow = _build_flow_expr(delete=True, **kwargs)
+    # out_port condition does not exist for all flow commands
+    out_port = ("out_port" in kwargs and
+                ",out_port=%s" % kwargs['out_port'] or '')
+    flow = flow + out_port
+    delFlow = [OFCTL_PATH, 'del-flows', bridge, flow]
+    do_cmd(delFlow)
+
+
+def del_all_flows(bridge):
+    delFlow = [OFCTL_PATH, "del-flows", bridge]
+    do_cmd(delFlow)
+
+    normalFlow = "priority=0 idle_timeout=0 hard_timeout=0 actions=normal"
+    add_flow(bridge, normalFlow)
+
+
+def del_port(bridge, port):
+    delPort = [VSCTL_PATH, "del-port", bridge, port]
+    do_cmd(delPort)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/scripts/vm/hypervisor/xenserver/ovstunnel
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/ovstunnel b/scripts/vm/hypervisor/xenserver/ovstunnel
index 2b26ed6..a38a066 100755
--- a/scripts/vm/hypervisor/xenserver/ovstunnel
+++ b/scripts/vm/hypervisor/xenserver/ovstunnel
@@ -275,15 +275,15 @@ def getLabel(session, args):
     pif_list_cmd = [lib.XE_PATH, 'pif-list', '--minimal']
     pif_list_str = lib.do_cmd(pif_list_cmd)
     while True:
-		pif_uuid = pif_list_str.split(',')[i].strip()
-		network_cmd = [lib.XE_PATH, 'pif-param-get', 'uuid=%s' % pif_uuid, 'param-name=network-uuid']
-		network_uuid = lib.do_cmd(network_cmd).split('.')[0]
-		iface_cmd = [lib.XE_PATH, 'network-param-get', 'uuid=%s' % network_uuid, 'param-name=bridge']
-		iface = lib.do_cmd(iface_cmd)
-		status,output = commands.getstatusoutput("ifconfig "+iface+" | grep inet")
-		if (status != 0):
-			i += 1
-			continue
+	pif_uuid = pif_list_str.split(',')[i].strip()
+	network_cmd = [lib.XE_PATH, 'pif-param-get', 'uuid=%s' % pif_uuid, 'param-name=network-uuid']
+	network_uuid = lib.do_cmd(network_cmd).split('.')[0]
+	iface_cmd = [lib.XE_PATH, 'network-param-get', 'uuid=%s' % network_uuid, 'param-name=bridge']
+	iface = lib.do_cmd(iface_cmd)
+	status,output = commands.getstatusoutput("ifconfig "+iface+" | grep inet")
+	if (status != 0):
+		i += 1
+		continue
     	label_cmd = [lib.XE_PATH, 'network-param-get', 'uuid=%s' % network_uuid, 'param-name=name-label']
     	label = lib.do_cmd(label_cmd).split('.')[0]
     	return label

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/scripts/vm/network/vnet/ovstunnel.py
----------------------------------------------------------------------
diff --git a/scripts/vm/network/vnet/ovstunnel.py b/scripts/vm/network/vnet/ovstunnel.py
new file mode 100755
index 0000000..67ef89b
--- /dev/null
+++ b/scripts/vm/network/vnet/ovstunnel.py
@@ -0,0 +1,182 @@
+#!/usr/bin/python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+# Creates a tunnel mesh across xenserver hosts
+# Enforces broadcast drop rules on ingress GRE tunnels
+
+import cloudstack_pluginlib as lib
+import logging
+import commands
+import os
+import sys
+import subprocess
+import time
+
+from time import localtime as _localtime, asctime as _asctime
+
+lib.setup_logging("/var/log/ovstunnel.log")
+
+def setup_ovs_bridge(bridge, key, cs_host_id):
+
+    res = lib.check_switch()
+    if res != "SUCCESS":
+        return "FAILURE:%s" % res
+
+    logging.debug("About to manually create the bridge:%s" % bridge)
+    #set gre_key to bridge
+    res = lib.do_cmd([lib.VSCTL_PATH, "set", "bridge", bridge,
+                                     "other_config:gre_key=%s" % key])
+    logging.debug("Bridge has been manually created:%s" % res)
+    if res:
+        result = "FAILURE:%s" % res
+    else:
+        # Verify the bridge actually exists, with the gre_key properly set
+        res = lib.do_cmd([lib.VSCTL_PATH, "get", "bridge",
+                                          bridge, "other_config:gre_key"])
+        if key in res:
+            result = "SUCCESS:%s" % bridge
+        else:
+            result = "FAILURE:%s" % res
+
+	lib.do_cmd([lib.VSCTL_PATH, "set", "bridge", bridge, "other_config:is-ovs-tun-network=True"])
+	#get list of hosts using this bridge
+        conf_hosts = lib.do_cmd([lib.VSCTL_PATH, "get","bridge", bridge,"other_config:ovs-host-setup"])
+	#add cs_host_id to list of hosts using this bridge
+        conf_hosts = cs_host_id + (conf_hosts and ',%s' % conf_hosts or '')
+        lib.do_cmd([lib.VSCTL_PATH, "set", "bridge", bridge,
+                   "other_config:ovs-host-setup=%s" % conf_hosts])
+
+    logging.debug("Setup_ovs_bridge completed with result:%s" % result)
+    return result
+
+def destroy_ovs_bridge(bridge):
+
+    res = lib.check_switch()
+    if res != "SUCCESS":
+        return res
+    res = lib.do_cmd([lib.VSCTL_PATH, "del-br", bridge])
+    logging.debug("Bridge has been manually removed:%s" % res)
+    if res:
+        result = "FAILURE:%s" % res
+    else:
+        result = "SUCCESS:%s" % bridge
+
+    logging.debug("Destroy_ovs_bridge completed with result:%s" % result)
+    return result
+
+def create_tunnel(bridge, remote_ip, gre_key, src_host, dst_host):
+
+    logging.debug("Entering create_tunnel")
+
+    res = lib.check_switch()
+    if res != "SUCCESS":
+        logging.debug("Openvswitch running: NO")
+        return "FAILURE:%s" % res
+
+    # We need to keep the name below 14 characters
+    # src and target are enough - consider a fixed length hash
+    name = "t%s-%s-%s" % (gre_key, src_host, dst_host)
+
+    # Verify the bridge to be created
+    # NOTE: Timeout should not be necessary anymore
+    wait = [lib.VSCTL_PATH, "--timeout=30", "wait-until", "bridge",
+                    bridge, "--", "get", "bridge", bridge, "name"]
+    res = lib.do_cmd(wait)
+    if bridge not in res:
+        logging.debug("WARNING:Can't find bridge %s for creating " +
+                                  "tunnel!" % bridge)
+        return "FAILURE:NO_BRIDGE"
+    logging.debug("bridge %s for creating tunnel - VERIFIED" % bridge)
+    tunnel_setup = False
+    drop_flow_setup = False
+    try:
+        # Create a port and configure the tunnel interface for it
+        add_tunnel = [lib.VSCTL_PATH, "add-port", bridge,
+                                  name, "--", "set", "interface",
+                                  name, "type=gre", "options:key=%s" % gre_key,
+                                  "options:remote_ip=%s" % remote_ip]
+        lib.do_cmd(add_tunnel)
+        tunnel_setup = True
+        # verify port
+        verify_port = [lib.VSCTL_PATH, "get", "port", name, "interfaces"]
+        res = lib.do_cmd(verify_port)
+        # Expecting python-style list as output
+        iface_list = []
+        if len(res) > 2:
+            iface_list = res.strip()[1:-1].split(',')
+        if len(iface_list) != 1:
+            logging.debug("WARNING: Unexpected output while verifying " +
+                                      "port %s on bridge %s" % (name, bridge))
+            return "FAILURE:VERIFY_PORT_FAILED"
+
+        # verify interface
+        iface_uuid = iface_list[0]
+        verify_interface_key = [lib.VSCTL_PATH, "get", "interface",
+                                iface_uuid, "options:key"]
+        verify_interface_ip = [lib.VSCTL_PATH, "get", "interface",
+                               iface_uuid, "options:remote_ip"]
+
+        key_validation = lib.do_cmd(verify_interface_key)
+        ip_validation = lib.do_cmd(verify_interface_ip)
+
+        if not gre_key in key_validation or not remote_ip in ip_validation:
+            logging.debug("WARNING: Unexpected output while verifying " +
+                          "interface %s on bridge %s" % (name, bridge))
+            return "FAILURE:VERIFY_INTERFACE_FAILED"
+        logging.debug("Tunnel interface validated:%s" % verify_interface_ip)
+        cmd_tun_ofport = [lib.VSCTL_PATH, "get", "interface",
+                                          iface_uuid, "ofport"]
+        tun_ofport = lib.do_cmd(cmd_tun_ofport)
+        # Ensure no trailing LF
+        if tun_ofport.endswith('\n'):
+            tun_ofport = tun_ofport[:-1]
+        # add flow entryies for dropping broadcast coming in from gre tunnel
+        lib.add_flow(bridge, priority=1000, in_port=tun_ofport,
+                         dl_dst='ff:ff:ff:ff:ff:ff', actions='drop')
+        lib.add_flow(bridge, priority=1000, in_port=tun_ofport,
+                     nw_dst='224.0.0.0/24', actions='drop')
+        drop_flow_setup = True
+        logging.debug("Broadcast drop rules added")
+        return "SUCCESS:%s" % name
+    except:
+        logging.debug("An unexpected error occured. Rolling back")
+        if tunnel_setup:
+            logging.debug("Deleting GRE interface")
+            # Destroy GRE port and interface
+            lib.del_port(bridge, name)
+        if drop_flow_setup:
+            # Delete flows
+            logging.debug("Deleting flow entries from GRE interface")
+            lib.del_flows(bridge, in_port=tun_ofport)
+        # This will not cancel the original exception
+        raise
+
+def destroy_tunnel(bridge, iface_name):
+
+    logging.debug("Destroying tunnel at port %s for bridge %s"
+                            % (iface_name, bridge))
+    ofport = get_field_of_interface(iface_name, "ofport")
+    lib.del_flows(bridge, in_port=ofport)
+    lib.del_port(bridge, iface_name)
+    return "SUCCESS"
+
+def get_field_of_interface(iface_name, field):
+    get_iface_cmd = [lib.VSCTL_PATH, "get", "interface", iface_name, field]
+    res = lib.do_cmd(get_iface_cmd)
+    return res

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
index 3e3a25f..9d22b7f 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
@@ -47,4 +47,5 @@ public interface ConsoleProxyManager extends Manager, ConsoleProxyService {
     public boolean rebootProxy(long proxyVmId);
 
     public boolean destroyProxy(long proxyVmId);
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index 450a7e0..2a38ac1 100755
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -296,7 +296,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
                         ex.addProxyObject(ipAddrUuid, "networkId");
                         throw ex;
                     }
-                }
+               }
                 ipToServices.put(ip, services);
 
                 // if IP in allocating state then it will not have any rules attached so skip IPAssoc to network service
@@ -433,11 +433,15 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
         NetworkElement oldElement = getElementImplementingProvider(oldProvider.getName());
         NetworkElement newElement = getElementImplementingProvider(newProvider.getName());
         if (oldElement instanceof IpDeployingRequester && newElement instanceof IpDeployingRequester) {
-            IpDeployer oldIpDeployer = ((IpDeployingRequester)oldElement).getIpDeployer(network);
-            IpDeployer newIpDeployer = ((IpDeployingRequester)newElement).getIpDeployer(network);
-            if (!oldIpDeployer.getProvider().getName().equals(newIpDeployer.getProvider().getName())) {
-                throw new InvalidParameterException("There would be multiple providers for IP " + publicIp.getAddress() + "!");
-            }
+        	IpDeployer oldIpDeployer = ((IpDeployingRequester)oldElement).getIpDeployer(network);
+        	IpDeployer newIpDeployer = ((IpDeployingRequester)newElement).getIpDeployer(network);
+			// if
+			// (!oldIpDeployer.getProvider().getName().equals(newIpDeployer.getProvider().getName()))
+			// {
+			// throw new
+			// InvalidParameterException("There would be multiple providers for IP "
+			// + publicIp.getAddress() + "!");
+			// }
         } else {
             throw new InvalidParameterException("Ip cannot be applied for new provider!");
         }
@@ -517,7 +521,6 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
         SearchCriteria<IPAddressVO> sc = IpAddressSearch.create();
         sc.setParameters("accountId", accountId);
         sc.setParameters("associatedWithNetworkId", associatedNetworkId);
-
         if (sourceNat != null) {
             sc.addAnd("sourceNat", SearchCriteria.Op.EQ, sourceNat);
         }
@@ -1885,7 +1888,6 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
             new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate, isSecurityGroupSupportedInNetwork(network), getNetworkTag(
                 vm.getHypervisorType(), network));
 //        guru.updateNicProfile(profile, network);
-
         return profile;
     }
 
@@ -2010,7 +2012,6 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
                     return PublicIp.createFromAddrAndVlan(sourceNatIp, _vlanDao.findById(sourceNatIp.getVlanId()));
                 }
             }
-
         }
 
         return null;


[12/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
tuna add port forwarding support


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9c702ff3
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9c702ff3
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9c702ff3

Branch: refs/heads/master
Commit: 9c702ff388b859d5d212f0a932d80a2012ebf912
Parents: d935d38
Author: tuna <ng...@gmail.com>
Authored: Tue Aug 13 10:46:21 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 .../com/cloud/network/element/OvsElement.java   | 29 ++++++++++----------
 1 file changed, 15 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9c702ff3/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index 06965e8..9af708c 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -68,7 +68,7 @@ import com.cloud.vm.dao.DomainRouterDao;
 		PortForwardingServiceProvider.class, IpDeployer.class })
 public class OvsElement extends AdapterBase implements NetworkElement,
 		OvsElementService, ConnectivityProvider, ResourceStateAdapter,
-		SourceNatServiceProvider, PortForwardingServiceProvider,
+		PortForwardingServiceProvider,
 		StaticNatServiceProvider, IpDeployer {
 	@Inject
 	OvsTunnelManager _ovsTunnelMgr;
@@ -228,12 +228,6 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 			return false;
 		}
 
-		// if ((services.contains(Service.PortForwarding) || services
-		// .contains(Service.StaticNat))
-		// && !services.contains(Service.SourceNat)) {
-		// s_logger.warn("Unable to provide StaticNat and/or PortForwarding without the SourceNat service");
-		// return false;
-		// }
 		return true;
 	}
 
@@ -243,7 +237,6 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 		// L2 Support : SDN provisioning
 		capabilities.put(Service.Connectivity, null);
 
-		// TODO: we need L3 support for coding L3 services in next period
 		// L3 Support : Generic?
 		// capabilities.put(Service.Gateway, null);
 
@@ -256,7 +249,7 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 		// capabilities.put(Service.SourceNat, sourceNatCapabilities);
 
 		// L3 Support : Port Forwarding
-		// capabilities.put(Service.PortForwarding, null);
+		 capabilities.put(Service.PortForwarding, null);
 
 		// L3 support : StaticNat
 		capabilities.put(Service.StaticNat, null);
@@ -296,7 +289,6 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 		return new DeleteHostAnswer(true);
 	}
 
-	// TODO: Adding L3 services below
 	@Override
 	public IpDeployer getIpDeployer(Network network) {
 		return this;
@@ -331,8 +323,7 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 	}
 
 	@Override
-	public boolean applyStaticNats(Network network,
-			List<? extends StaticNat> rules)
+	public boolean applyStaticNats(Network network, List<? extends StaticNat> rules)
 			throws ResourceUnavailableException {
 		if (!canHandle(network, Service.StaticNat)) {
 			return false;
@@ -351,7 +342,17 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 	@Override
 	public boolean applyPFRules(Network network, List<PortForwardingRule> rules)
 			throws ResourceUnavailableException {
-		// TODO Auto-generated method stub
-		return false;
+		if (!canHandle(network, Service.PortForwarding)) {
+			return false;
+		}
+		List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
+				network.getId(), Role.VIRTUAL_ROUTER);
+		if (routers == null || routers.isEmpty()) {
+			s_logger.debug("Ovs element doesn't need to apply firewall rules on the backend; virtual "
+					+ "router doesn't exist in the network " + network.getId());
+			return true;
+		}
+
+		return _routerMgr.applyFirewallRules(network, rules, routers);
 	}
 }


[15/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
post-rebasing


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/267ff79b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/267ff79b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/267ff79b

Branch: refs/heads/master
Commit: 267ff79bfbfbfc6e4969ecdd95f3d8e9ad3253aa
Parents: 61e80f0
Author: tuna <ng...@gmail.com>
Authored: Mon Dec 9 23:02:41 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:15 2013 +0700

----------------------------------------------------------------------
 .../network/ovs/OvsCreateGreTunnelAnswer.java   | 79 -------------------
 .../network/ovs/OvsCreateTunnelAnswer.java      | 83 --------------------
 .../cloud/network/ovs/OvsTunnelManagerImpl.java | 67 ++--------------
 3 files changed, 6 insertions(+), 223 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/267ff79b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java
deleted file mode 100644
index 7eac7b0..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java
+++ /dev/null
@@ -1,79 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-
-public class OvsCreateGreTunnelAnswer extends Answer {
-    String hostIp;
-    String remoteIp;
-    String bridge;
-    String key;
-    long from;
-    long to;
-    int port;
-
-    public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details) {
-        super(cmd, success, details);
-    }
-
-    public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details, String hostIp, String bridge) {
-        super(cmd, success, details);
-        OvsCreateGreTunnelCommand c = (OvsCreateGreTunnelCommand)cmd;
-        this.hostIp = hostIp;
-        this.bridge = bridge;
-        this.remoteIp = c.getRemoteIp();
-        this.key = c.getKey();
-        this.port = -1;
-        this.from = c.getFrom();
-        this.to = c.getTo();
-    }
-
-    public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details, String hostIp, String bridge, int port) {
-        this(cmd, success, details, hostIp, bridge);
-        this.port = port;
-    }
-
-    public String getHostIp() {
-        return hostIp;
-    }
-
-    public String getRemoteIp() {
-        return remoteIp;
-    }
-
-    public String getBridge() {
-        return bridge;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public long getFrom() {
-        return from;
-    }
-
-    public long getTo() {
-        return to;
-    }
-
-    public int getPort() {
-        return port;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/267ff79b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateTunnelAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateTunnelAnswer.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateTunnelAnswer.java
deleted file mode 100644
index f90dc44..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateTunnelAnswer.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-
-public class OvsCreateTunnelAnswer extends Answer {
-    Long from;
-    Long to;
-    long networkId;
-    String inPortName;
-
-    //for debug info
-    String fromIp;
-    String toIp;
-    int key;
-    String bridge;
-
-    public OvsCreateTunnelAnswer(Command cmd, boolean success, String details, String bridge) {
-        super(cmd, success, details);
-        OvsCreateTunnelCommand c = (OvsCreateTunnelCommand)cmd;
-        from = c.getFrom();
-        to = c.getTo();
-        networkId = c.getNetworkId();
-        inPortName = "[]";
-        fromIp = c.getFromIp();
-        toIp = c.getRemoteIp();
-        key = c.getKey();
-        this.bridge = bridge;
-    }
-
-    public OvsCreateTunnelAnswer(Command cmd, boolean success, String details, String inPortName, String bridge) {
-        this(cmd, success, details, bridge);
-        this.inPortName = inPortName;
-    }
-
-    public Long getFrom() {
-        return from;
-    }
-
-    public Long getTo() {
-        return to;
-    }
-
-    public long getNetworkId() {
-        return networkId;
-    }
-
-    public String getInPortName() {
-        return inPortName;
-    }
-
-    public String getFromIp() {
-        return fromIp;
-    }
-
-    public String getToIp() {
-        return toIp;
-    }
-
-    public int getKey() {
-        return key;
-    }
-
-    public String getBridge() {
-        return bridge;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/267ff79b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
index bab96a8..553d645 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
@@ -19,6 +19,7 @@ package com.cloud.network.ovs;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 
 import javax.ejb.Local;
@@ -28,7 +29,6 @@ import javax.persistence.EntityExistsException;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 
 import com.cloud.agent.AgentManager;
@@ -60,6 +60,7 @@ import com.cloud.network.ovs.dao.OvsTunnelInterfaceVO;
 import com.cloud.network.ovs.dao.OvsTunnelNetworkDao;
 import com.cloud.network.ovs.dao.OvsTunnelNetworkVO;
 import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.DomainRouterVO;
@@ -103,28 +104,11 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 	@Override
 	public boolean configure(String name, Map<String, Object> params)
 			throws ConfigurationException {
-		return true;
-	}
+        _executorPool = Executors.newScheduledThreadPool(10, new NamedThreadFactory("OVS"));
+        _cleanupExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("OVS-Cleanup"));
 
-	@DB
-	protected OvsTunnelNetworkVO createTunnelRecord(long from, long to, long networkId, int key) {
-		OvsTunnelNetworkVO ta = null;
-		try {
-			ta = new OvsTunnelNetworkVO(from, to, key, networkId);
-			OvsTunnelNetworkVO lock = _tunnelNetworkDao.acquireInLockTable(Long
-					.valueOf(1));
-			if (lock == null) {
-				s_logger.warn("Cannot lock table ovs_tunnel_account");
-				return null;
-			}
-			_tunnelNetworkDao.persist(ta);
-			_tunnelNetworkDao.releaseFromLockTable(lock.getId());
-		} catch (EntityExistsException e) {
-			s_logger.debug("A record for the tunnel from " + from + " to " + to
-					+ " already exists");
-		}
-		return ta;
-	}
+        return true;
+    }
 
 	@DB
 	protected OvsTunnelInterfaceVO createInterfaceRecord(String ip,
@@ -163,14 +147,6 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 		return null;
 	}
 
-        if (_isEnabled) {
-            _executorPool = Executors.newScheduledThreadPool(10, new NamedThreadFactory("OVS"));
-            _cleanupExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("OVS-Cleanup"));
-        }
-
-        return true;
-    }
-
     @DB
     protected OvsTunnelNetworkVO createTunnelRecord(long from, long to, long networkId, int key) {
         OvsTunnelNetworkVO ta = null;
@@ -189,37 +165,6 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
         return ta;
     }
 
-    @DB
-    protected OvsTunnelInterfaceVO createInterfaceRecord(String ip, String netmask, String mac, long hostId, String label) {
-        OvsTunnelInterfaceVO ti = null;
-        try {
-            ti = new OvsTunnelInterfaceVO(ip, netmask, mac, hostId, label);
-            //TODO: Is locking really necessary here?
-            OvsTunnelInterfaceVO lock = _tunnelInterfaceDao.acquireInLockTable(Long.valueOf(1));
-            if (lock == null) {
-                s_logger.warn("Cannot lock table ovs_tunnel_account");
-                return null;
-            }
-            _tunnelInterfaceDao.persist(ti);
-            _tunnelInterfaceDao.releaseFromLockTable(lock.getId());
-        } catch (EntityExistsException e) {
-            s_logger.debug("A record for the interface for network " + label + " on host id " + hostId + " already exists");
-        }
-        return ti;
-    }
-
-    private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId) {
-        OvsFetchInterfaceAnswer ans = (OvsFetchInterfaceAnswer)answers[0];
-        if (ans.getResult()) {
-            if (ans.getIp() != null && !("".equals(ans.getIp()))) {
-                OvsTunnelInterfaceVO ti = createInterfaceRecord(ans.getIp(), ans.getNetmask(), ans.getMac(), hostId, ans.getLabel());
-                return ti.getIp();
-            }
-        }
-        // Fetch interface failed!
-        s_logger.warn("Unable to fetch the IP address for the GRE tunnel endpoint" + ans.getDetails());
-        return null;
-    }
 
     private void handleCreateTunnelAnswer(Answer[] answers) {
         OvsCreateTunnelAnswer r = (OvsCreateTunnelAnswer)answers[0];


[17/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
fix staticNat after rebase


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7efab203
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7efab203
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7efab203

Branch: refs/heads/master
Commit: 7efab20300eec38d391f1a3135c0c50dcd035dc8
Parents: 4d06021
Author: tuna <ng...@gmail.com>
Authored: Mon Nov 4 15:53:43 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:15 2013 +0700

----------------------------------------------------------------------
 engine/schema/src/com/cloud/network/dao/OvsProviderDaoImpl.java  | 2 +-
 .../ovs/src/com/cloud/network/element/OvsElement.java            | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7efab203/engine/schema/src/com/cloud/network/dao/OvsProviderDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/OvsProviderDaoImpl.java b/engine/schema/src/com/cloud/network/dao/OvsProviderDaoImpl.java
index b00d5c1..2026ccf 100644
--- a/engine/schema/src/com/cloud/network/dao/OvsProviderDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/OvsProviderDaoImpl.java
@@ -14,7 +14,7 @@ import com.cloud.utils.db.SearchCriteria;
 
 @Component
 @Local(value = OvsProviderDao.class)
-@DB(txn = false)
+@DB()
 public class OvsProviderDaoImpl extends GenericDaoBase<OvsProviderVO, Long>
 		implements OvsProviderDao {
 	final SearchBuilder<OvsProviderVO> AllFieldsSearch;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7efab203/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index 2b625a9..2641d54 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -407,8 +407,8 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 			throws ResourceUnavailableException {
 		boolean canHandle = true;
 		for (Service service : services) {
-			// check if Ovs can handle services except SourceNat
-			if (!canHandle(network, service) && service != Service.SourceNat) {
+			// check if Ovs can handle services except SourceNat & Firewall
+			if (!canHandle(network, service) && service != Service.SourceNat && service != Service.Firewall) {
 				canHandle = false;
 				break;
 			}


[10/21] add kvm support & LB service

Posted by tu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3df8b912/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index aa569fd..3444fa9 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -5892,7 +5892,566 @@
                                 }
                             }
                         }
-                    }
+                    },
+
+                    //ovs
+                    Ovs: {
+                        id: 'ovsProviders',
+                        label: 'label.ovs',
+                        isMaximized: true,
+                        type: 'detailView',
+                        fields: {
+                            name: {
+                                label: 'label.name'
+                            },
+                            ipaddress: {
+                                label: 'label.ip.address'
+                            },
+                            state: {
+                                label: 'label.status',
+                                indicator: {
+                                    'Enabled': 'on'
+                                }
+                            }
+                        },
+                        tabs: {
+                            network: {
+                                title: 'label.network',
+                                fields: [{
+                                    name: {
+                                        label: 'label.name'
+                                    }
+                                }, {
+                                    id: {
+                                        label: 'label.id'
+                                    },
+                                    state: {
+                                        label: 'label.state'
+                                    },
+                                    physicalnetworkid: {
+                                        label: 'label.physical.network.ID'
+                                    },
+                                    destinationphysicalnetworkid: {
+                                        label: 'label.destination.physical.network.id'
+                                    },
+                                    supportedServices: {
+                                        label: 'label.supported.services'
+                                    }
+                                }],
+                                dataProvider: function (args) {
+                                    refreshNspData("Ovs");
+                                    args.response.success({
+                                        actionFilter: virtualRouterProviderActionFilter,
+                                        data: $.extend(nspMap["Ovs"], {
+                                            supportedServices: nspMap["Ovs"].servicelist.join(', ')
+                                        })
+                                    });
+                                }
+                            },
+
+                            instances: {
+                                title: 'label.instances',
+                                listView: {
+                                    label: 'label.virtual.appliances',
+                                    id: 'routers',
+                                    fields: {
+                                        name: {
+                                            label: 'label.name'
+                                        },
+                                        zonename: {
+                                            label: 'label.zone'
+                                        },
+                                        routerType: {
+                                            label: 'label.type'
+                                        },
+                                        state: {
+                                            converter: function (str) {
+                                                // For localization
+                                                return str;
+                                            },
+                                            label: 'label.status',
+                                            indicator: {
+                                                'Running': 'on',
+                                                'Stopped': 'off',
+                                                'Error': 'off'
+                                            }
+                                        }
+                                    },
+                                    dataProvider: function (args) {
+                                        var array1 = [];
+                                        if (args.filterBy != null) {
+                                            if (args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) {
+                                                switch (args.filterBy.search.by) {
+                                                case "name":
+                                                    if (args.filterBy.search.value.length > 0)
+                                                        array1.push("&keyword=" + args.filterBy.search.value);
+                                                    break;
+                                                }
+                                            }
+                                        }
+
+                                        var data2 = {
+                                            forvpc: false
+                                        };
+                                        var routers = [];
+                                        $.ajax({
+                                            url: createURL("listRouters&zoneid=" + selectedZoneObj.id + "&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("")),
+                                            data: data2,
+                                            success: function (json) {
+                                                var items = json.listroutersresponse.router ?
+                                                    json.listroutersresponse.router : [];
+
+                                                $(items).map(function (index, item) {
+                                                    routers.push(item);
+                                                });
+
+                                                // Get project routers
+                                                $.ajax({
+                                                    url: createURL("listRouters&zoneid=" + selectedZoneObj.id + "&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("") + "&projectid=-1"),
+                                                    data: data2,
+                                                    success: function (json) {
+                                                        var items = json.listroutersresponse.router ?
+                                                            json.listroutersresponse.router : [];
+
+                                                        $(items).map(function (index, item) {
+                                                            routers.push(item);
+                                                        });
+                                                        args.response.success({
+                                                            actionFilter: routerActionfilter,
+                                                            data: $(routers).map(mapRouterType)
+                                                        });
+                                                    }
+                                                });
+                                            }
+                                        });
+                                    },
+                                    detailView: {
+                                        name: 'Virtual applicance details',
+                                        actions: {
+                                            start: {
+                                                label: 'label.action.start.router',
+                                                messages: {
+                                                    confirm: function (args) {
+                                                        return 'message.action.start.router';
+                                                    },
+                                                    notification: function (args) {
+                                                        return 'label.action.start.router';
+                                                    }
+                                                },
+                                                action: function (args) {
+                                                    $.ajax({
+                                                        url: createURL('startRouter&id=' + args.context.routers[0].id),
+                                                        dataType: 'json',
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jid = json.startrouterresponse.jobid;
+                                                            args.response.success({
+                                                                _custom: {
+                                                                    jobId: jid,
+                                                                    getUpdatedItem: function (json) {
+                                                                        return json.queryasyncjobresultresponse.jobresult.domainrouter;
+                                                                    },
+                                                                    getActionFilter: function () {
+                                                                        return routerActionfilter;
+                                                                    }
+                                                                }
+                                                            });
+                                                        }
+                                                    });
+                                                },
+                                                notification: {
+                                                    poll: pollAsyncJobResult
+                                                }
+                                            },
+
+                                            stop: {
+                                                label: 'label.action.stop.router',
+                                                createForm: {
+                                                    title: 'label.action.stop.router',
+                                                    desc: 'message.action.stop.router',
+                                                    fields: {
+                                                        forced: {
+                                                            label: 'force.stop',
+                                                            isBoolean: true,
+                                                            isChecked: false
+                                                        }
+                                                    }
+                                                },
+                                                messages: {
+                                                    notification: function (args) {
+                                                        return 'label.action.stop.router';
+                                                    }
+                                                },
+                                                action: function (args) {
+                                                    var array1 = [];
+                                                    array1.push("&forced=" + (args.data.forced == "on"));
+                                                    $.ajax({
+                                                        url: createURL('stopRouter&id=' + args.context.routers[0].id + array1.join("")),
+                                                        dataType: 'json',
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jid = json.stoprouterresponse.jobid;
+                                                            args.response.success({
+                                                                _custom: {
+                                                                    jobId: jid,
+                                                                    getUpdatedItem: function (json) {
+                                                                        return json.queryasyncjobresultresponse.jobresult.domainrouter;
+                                                                    },
+                                                                    getActionFilter: function () {
+                                                                        return routerActionfilter;
+                                                                    }
+                                                                }
+                                                            });
+                                                        }
+                                                    });
+                                                },
+                                                notification: {
+                                                    poll: pollAsyncJobResult
+                                                }
+                                            },
+
+                                            'remove': {
+                                                label: 'label.destroy.router',
+                                                messages: {
+                                                    confirm: function (args) {
+                                                        return 'message.confirm.destroy.router';
+                                                    },
+                                                    notification: function (args) {
+                                                        return 'label.destroy.router';
+                                                    }
+                                                },
+                                                action: function (args) {
+                                                    $.ajax({
+                                                        url: createURL("destroyRouter&id=" + args.context.routers[0].id),
+                                                        dataType: "json",
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jid = json.destroyrouterresponse.jobid;
+                                                            args.response.success({
+                                                                _custom: {
+                                                                    jobId: jid
+                                                                }
+                                                            });
+                                                        }
+                                                    });
+                                                },
+                                                notification: {
+                                                    poll: pollAsyncJobResult
+                                                }
+                                            },
+
+                                            migrate: {
+                                                label: 'label.action.migrate.router',
+                                                createForm: {
+                                                    title: 'label.action.migrate.router',
+                                                    desc: '',
+                                                    fields: {
+                                                        hostId: {
+                                                            label: 'label.host',
+                                                            validation: {
+                                                                required: true
+                                                            },
+                                                            select: function (args) {
+                                                                $.ajax({
+                                                                    url: createURL("findHostsForMigration&VirtualMachineId=" + args.context.routers[0].id),
+                                                                    dataType: "json",
+                                                                    async: true,
+                                                                    success: function (json) {
+                                                                        var hostObjs = json.findhostsformigrationresponse.host;
+                                                                        var items = [];
+                                                                        $(hostObjs).each(function () {
+                                                                            items.push({
+                                                                                id: this.id,
+                                                                                description: (this.name + " (" + (this.suitableformigration ? "Suitable" : "Not Suitable") + ")")
+                                                                            });
+                                                                        });
+                                                                        args.response.success({
+                                                                            data: items
+                                                                        });
+                                                                    }
+                                                                });
+                                                            },
+                                                            error: function (XMLHttpResponse) {
+                                                                var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                                args.response.error(errorMsg);
+                                                            }
+                                                        }
+                                                    }
+                                                },
+                                                messages: {
+                                                    notification: function (args) {
+                                                        return 'label.action.migrate.router';
+                                                    }
+                                                },
+                                                action: function (args) {
+                                                    $.ajax({
+                                                        url: createURL("migrateSystemVm&hostid=" + args.data.hostId + "&virtualmachineid=" + args.context.routers[0].id),
+                                                        dataType: "json",
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jid = json.migratesystemvmresponse.jobid;
+                                                            args.response.success({
+                                                                _custom: {
+                                                                    jobId: jid,
+                                                                    getUpdatedItem: function (json) {
+                                                                        //return json.queryasyncjobresultresponse.jobresult.systemvminstance;    //not all properties returned in systemvminstance
+                                                                        $.ajax({
+                                                                            url: createURL("listRouters&id=" + json.queryasyncjobresultresponse.jobresult.systemvminstance.id),
+                                                                            dataType: "json",
+                                                                            async: false,
+                                                                            success: function (json) {
+                                                                                var items = json.listroutersresponse.router;
+                                                                                if (items != null && items.length > 0) {
+                                                                                    return items[0];
+                                                                                }
+                                                                            }
+                                                                        });
+                                                                    },
+                                                                    getActionFilter: function () {
+                                                                        return routerActionfilter;
+                                                                    }
+                                                                }
+                                                            });
+                                                        }
+                                                    });
+                                                },
+                                                notification: {
+                                                    poll: pollAsyncJobResult
+                                                }
+                                            },
+
+                                            viewConsole: {
+                                                label: 'label.view.console',
+                                                action: {
+                                                    externalLink: {
+                                                        url: function (args) {
+                                                            return clientConsoleUrl + '?cmd=access&vm=' + args.context.routers[0].id;
+                                                        },
+                                                        title: function (args) {
+                                                            return args.context.routers[0].id.substr(0, 8); //title in window.open() can't have space nor longer than 8 characters. Otherwise, IE browser will have error.
+                                                        },
+                                                        width: 820,
+                                                        height: 640
+                                                    }
+                                                }
+                                            }
+                                        },
+                                        tabs: {
+                                            details: {
+                                                title: 'label.details',
+                                                preFilter: function (args) {
+                                                    var hiddenFields = [];
+                                                    if (!args.context.routers[0].project) {
+                                                        hiddenFields.push('project');
+                                                        hiddenFields.push('projectid');
+                                                    }
+                                                    if (selectedZoneObj.networktype == 'Basic') {
+                                                        hiddenFields.push('publicip'); //In Basic zone, guest IP is public IP. So, publicip is not returned by listRouters API. Only guestipaddress is returned by listRouters API.
+                                                    }
+                                                    return hiddenFields;
+                                                },
+                                                fields: [{
+                                                    name: {
+                                                        label: 'label.name'
+                                                    },
+                                                    project: {
+                                                        label: 'label.project'
+                                                    }
+                                                }, {
+                                                    id: {
+                                                        label: 'label.id'
+                                                    },
+                                                    projectid: {
+                                                        label: 'label.project.id'
+                                                    },
+                                                    state: {
+                                                        label: 'label.state'
+                                                    },
+                                                    guestnetworkid: {
+                                                        label: 'label.network.id'
+                                                    },
+                                                    publicip: {
+                                                        label: 'label.public.ip'
+                                                    },
+                                                    guestipaddress: {
+                                                        label: 'label.guest.ip'
+                                                    },
+                                                    linklocalip: {
+                                                        label: 'label.linklocal.ip'
+                                                    },
+                                                    hostname: {
+                                                        label: 'label.host'
+                                                    },
+                                                    serviceofferingname: {
+                                                        label: 'label.compute.offering'
+                                                    },
+                                                    networkdomain: {
+                                                        label: 'label.network.domain'
+                                                    },
+                                                    domain: {
+                                                        label: 'label.domain'
+                                                    },
+                                                    account: {
+                                                        label: 'label.account'
+                                                    },
+                                                    created: {
+                                                        label: 'label.created',
+                                                        converter: cloudStack.converters.toLocalDate
+                                                    },
+                                                    isredundantrouter: {
+                                                        label: 'label.redundant.router',
+                                                        converter: cloudStack.converters.toBooleanText
+                                                    },
+                                                    redundantRouterState: {
+                                                        label: 'label.redundant.state'
+                                                    }
+                                                }],
+                                                dataProvider: function (args) {
+                                                    $.ajax({
+                                                        url: createURL("listRouters&id=" + args.context.routers[0].id),
+                                                        dataType: 'json',
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jsonObj = json.listroutersresponse.router[0];
+                                                            addExtraPropertiesToRouterInstanceObject(jsonObj);
+                                                            args.response.success({
+                                                                actionFilter: routerActionfilter,
+                                                                data: jsonObj
+                                                            });
+                                                        }
+                                                    });
+                                                }
+                                            },
+                                            nics: {
+                                                title: 'label.nics',
+                                                multiple: true,
+                                                fields: [{
+                                                    name: {
+                                                        label: 'label.name',
+                                                        header: true
+                                                    },
+                                                    type: {
+                                                        label: 'label.type'
+                                                    },
+                                                    traffictype: {
+                                                        label: 'label.traffic.type'
+                                                    },
+                                                    networkname: {
+                                                        label: 'label.network.name'
+                                                    },
+                                                    netmask: {
+                                                        label: 'label.netmask'
+                                                    },
+                                                    ipaddress: {
+                                                        label: 'label.ip.address'
+                                                    },
+                                                    id: {
+                                                        label: 'label.id'
+                                                    },
+                                                    networkid: {
+                                                        label: 'label.network.id'
+                                                    },
+                                                    isolationuri: {
+                                                        label: 'label.isolation.uri'
+                                                    },
+                                                    broadcasturi: {
+                                                        label: 'label.broadcast.uri'
+                                                    }
+                                                }],
+                                                dataProvider: function (args) {
+                                                    $.ajax({
+                                                        url: createURL("listRouters&id=" + args.context.routers[0].id),
+                                                        dataType: 'json',
+                                                        async: true,
+                                                        success: function (json) {
+                                                            var jsonObj = json.listroutersresponse.router[0].nic;
+
+                                                            args.response.success({
+                                                                actionFilter: routerActionfilter,
+                                                                data: $.map(jsonObj, function (nic, index) {
+                                                                    var name = 'NIC ' + (index + 1);
+                                                                    if (nic.isdefault) {
+                                                                        name += ' (' + _l('label.default') + ')';
+                                                                    }
+                                                                    return $.extend(nic, {
+                                                                        name: name
+                                                                    });
+                                                                })
+                                                            });
+                                                        }
+                                                    });
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        },
+                        actions: {
+                            enable: {
+                                label: 'label.enable.provider',
+                                action: function (args) {
+                                    $.ajax({
+                                        url: createURL("updateNetworkServiceProvider&id=" + nspMap["Ovs"].id + "&state=Enabled"),
+                                        dataType: "json",
+                                        success: function (json) {
+                                            var jid = json.updatenetworkserviceproviderresponse.jobid;
+                                            args.response.success({
+                                                _custom: {
+                                                    jobId: jid,
+                                                    getUpdatedItem: function (json) {
+                                                        $(window).trigger('cloudStack.fullRefresh');
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    });
+                                },
+                                messages: {
+                                    confirm: function (args) {
+                                        return 'message.confirm.enable.provider';
+                                    },
+                                    notification: function () {
+                                        return 'label.enable.provider';
+                                    }
+                                },
+                                notification: {
+                                    poll: pollAsyncJobResult
+                                }
+                            },
+                            disable: {
+                                label: 'label.disable.provider',
+                                action: function (args) {
+                                    $.ajax({
+                                        url: createURL("updateNetworkServiceProvider&id=" + nspMap["Ovs"].id + "&state=Disabled"),
+                                        dataType: "json",
+                                        success: function (json) {
+                                            var jid = json.updatenetworkserviceproviderresponse.jobid;
+                                            args.response.success({
+                                                _custom: {
+                                                    jobId: jid,
+                                                    getUpdatedItem: function (json) {
+                                                        $(window).trigger('cloudStack.fullRefresh');
+                                                    }
+                                                }
+                                            });
+                                        }
+                                    });
+                                },
+                                messages: {
+                                    confirm: function (args) {
+                                        return 'message.confirm.disable.provider';
+                                    },
+                                    notification: function () {
+                                        return 'label.disable.provider';
+                                    }
+                                },
+                                notification: {
+                                    poll: pollAsyncJobResult
+                                }
+                            }
+                        }
+                    },
                 }
             }
         },
@@ -17916,55 +18475,35 @@
             jsonObj["redundantRouterState"] = "";
         }
     }
-  };
-
-	var addExtraPropertiesToClusterObject = function(jsonObj) {
-		if(jsonObj.managedstate == "Managed") {
-			jsonObj.state = jsonObj.allocationstate; //jsonObj.state == Enabled, Disabled
-		}
-		else {
-			jsonObj.state = jsonObj.managedstate; //jsonObj.state == Unmanaged, PrepareUnmanaged, PrepareUnmanagedError
-		}
-  }
-	
-	var addExtraPropertiesToRouterInstanceObject = function(jsonObj) {  		
-		if(jsonObj.isredundantrouter == true)
-			jsonObj["redundantRouterState"] = jsonObj.redundantstate;
-		else
-			jsonObj["redundantRouterState"] = "";				
-  }	
-	
-	var refreshNspData = function(nspName) {	  
-		var array1 = [];
-		if(nspName != null)
-		  array1.push("&name=" + nspName);
-		
-		$.ajax({
-			url: createURL("listNetworkServiceProviders&physicalnetworkid=" + selectedPhysicalNetworkObj.id + array1.join("")),
-			dataType: "json",
-			async: false,
-			success: function(json) {
-			  nspMap = {}; //reset 
-			
-				var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;	        
-        if(items != null) {				
-					for(var i = 0; i < items.length; i++) {
-						switch(items[i].name) {
-							case "VirtualRouter":
-								nspMap["virtualRouter"] = items[i];
-								break;
-              case "Ovs":
-                nspMap["Ovs"] = items[i];
-                break;
-							case "InternalLbVm":
-							  nspMap["InternalLbVm"] = items[i];
-							  break;
-							case "VpcVirtualRouter":
-							  nspMap["vpcVirtualRouter"] = items[i];
-							  break;
-							case "Netscaler":
-								nspMap["netscaler"] = items[i];
-								break;
+
+    var refreshNspData = function(nspName) {
+        var array1 = [];
+        if (nspName != null)
+            array1.push("&name=" + nspName);
+
+        $.ajax({
+            url: createURL("listNetworkServiceProviders&physicalnetworkid=" + selectedPhysicalNetworkObj.id + array1.join("")),
+            dataType: "json",
+            async: false,
+            success: function(json) {
+                nspMap = {}; //reset
+
+                var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;
+                if (items != null) {
+                    for (var i = 0; i < items.length; i++) {
+                        switch (items[i].name) {
+                            case "VirtualRouter":
+                                nspMap["virtualRouter"] = items[i];
+                                break;
+                            case "InternalLbVm":
+                                nspMap["InternalLbVm"] = items[i];
+                                break;
+                            case "VpcVirtualRouter":
+                                nspMap["vpcVirtualRouter"] = items[i];
+                                break;
+                            case "Netscaler":
+                                nspMap["netscaler"] = items[i];
+                                break;
                             case "MidoNet":
                                 nspMap["midoNet"] = items[i];
                                 break;
@@ -17989,52 +18528,66 @@
                             case "NiciraNvp":
                                 nspMap["niciraNvp"] = items[i];
                                 break;
-                                                        case "BigSwitchVns":
-                                                                nspMap["bigswitchVns"] = items[i];
-                                                                break;
-						}
-					}
-				}
-			}
-		});
-   
-		nspHardcodingArray = [
-			{
-				id: 'netscaler',
-				name: 'NetScaler',
-				state: nspMap.netscaler? nspMap.netscaler.state : 'Disabled'
-			},
-			{
-				id: 'virtualRouter',
-				name: 'Virtual Router',
-				state: nspMap.virtualRouter ? nspMap.virtualRouter.state : 'Disabled'
-			},
-      {
-        id: 'Ovs',
-        name: 'Ovs',
-        state: nspMap.Ovs ? nspMap.Ovs.state : 'Disabled'
-      },
-            {
-                id: 'niciraNvp',
-                name: 'Nicira Nvp',
-                state: nspMap.niciraNvp ? nspMap.niciraNvp.state : 'Disabled'
-            },
-                        {
-                                id: 'bigswitchVns',
-                                name: 'BigSwitch Vns',
-                                state: nspMap.bigswitchVns ? nspMap.bigswitchVns.state : 'Disabled'
-                        },
-      {
-        id: 'BaremetalDhcpProvider',
-        name: 'Baremetal DHCP',
-        state: nspMap.BaremetalDhcpProvider ? nspMap.BaremetalDhcpProvider.state : 'Disabled'
-      },
-      {
-        id: 'BaremetalPxeProvider',
-        name: 'Baremetal PXE',
-        state: nspMap.BaremetalPxeProvider ? nspMap.BaremetalPxeProvider.state : 'Disabled'
-      }
-		];
+                            case "BigSwitchVns":
+                                nspMap["bigswitchVns"] = items[i];
+                                break;
+                            case "Ovs":
+                                nspMap["Ovs"] = items[i];
+                                break;
+                        }
+                    }
+                }
+            }
+        });
+
+        nspHardcodingArray = [{
+            id: 'netscaler',
+            name: 'NetScaler',
+            state: nspMap.netscaler ? nspMap.netscaler.state : 'Disabled'
+        }, {
+            id: 'virtualRouter',
+            name: 'Virtual Router',
+            state: nspMap.virtualRouter ? nspMap.virtualRouter.state : 'Disabled'
+        }, {
+            id: 'niciraNvp',
+            name: 'Nicira Nvp',
+            state: nspMap.niciraNvp ? nspMap.niciraNvp.state : 'Disabled'
+        }, {
+            id: 'bigswitchVns',
+            name: 'BigSwitch Vns',
+            state: nspMap.bigswitchVns ? nspMap.bigswitchVns.state : 'Disabled'
+        }, {
+            id: 'BaremetalDhcpProvider',
+            name: 'Baremetal DHCP',
+            state: nspMap.BaremetalDhcpProvider ? nspMap.BaremetalDhcpProvider.state : 'Disabled'
+        }, {
+            id: 'BaremetalPxeProvider',
+            name: 'Baremetal PXE',
+            state: nspMap.BaremetalPxeProvider ? nspMap.BaremetalPxeProvider.state : 'Disabled'
+        }, {
+            id: 'Ovs',
+            name: 'Ovs',
+            state: nspMap.Ovs ? nspMap.Ovs.state : 'Disabled'
+        }];
+
+        $(window).trigger('cloudStack.system.serviceProviders.makeHarcodedArray', {
+            nspHardcodingArray: nspHardcodingArray,
+            selectedZoneObj: selectedZoneObj,
+            selectedPhysicalNetworkObj: selectedPhysicalNetworkObj
+        });
+
+        if (selectedZoneObj.networktype == "Basic") {
+            nspHardcodingArray.push({
+                id: 'securityGroups',
+                name: 'Security Groups',
+                state: nspMap.securityGroups ? nspMap.securityGroups.state : 'Disabled'
+            });
+        } else if (selectedZoneObj.networktype == "Advanced") {
+            nspHardcodingArray.push({
+                id: 'midoNet',
+                name: 'MidoNet',
+                state: nspMap.midoNet ? nspMap.midoNet.state : 'Disabled'
+            });
 
             nspHardcodingArray.push({
                 id: 'InternalLbVm',


[06/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
add two tables for gre controller


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/12a4d300
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/12a4d300
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/12a4d300

Branch: refs/heads/master
Commit: 12a4d300074e188ca3ec05a516c22803b17afd1f
Parents: 3a9c9bd
Author: tuna <ng...@gmail.com>
Authored: Wed Jul 17 15:37:38 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 .../com/cloud/network/ovs/dao/OvsDeviceDao.java | 26 ++++++
 .../cloud/network/ovs/dao/OvsDeviceDaoImpl.java | 49 +++++++++++
 .../com/cloud/network/ovs/dao/OvsDeviceVO.java  | 88 ++++++++++++++++++++
 .../cloud/network/ovs/dao/OvsNicMappingDao.java | 24 ++++++
 .../network/ovs/dao/OvsNicMappingDaoImpl.java   | 47 +++++++++++
 .../cloud/network/ovs/dao/OvsNicMappingVO.java  | 83 ++++++++++++++++++
 6 files changed, 317 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/12a4d300/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDao.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDao.java
new file mode 100644
index 0000000..794e45e
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDao.java
@@ -0,0 +1,26 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.ovs.dao;
+
+import java.util.List;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface OvsDeviceDao extends GenericDao<OvsDeviceVO, Long> {
+
+	List<OvsDeviceVO> listByPhysicalNetwork(long physicalNetworkId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/12a4d300/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDaoImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDaoImpl.java
new file mode 100644
index 0000000..11a4d48
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDaoImpl.java
@@ -0,0 +1,49 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.ovs.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+@Component
+@Local(value=OvsDeviceDao.class)
+public class OvsDeviceDaoImpl extends GenericDaoBase<OvsDeviceVO, Long> implements OvsDeviceDao {
+
+	protected final SearchBuilder<OvsDeviceVO> physicalNetworkIdSearch;
+
+	public OvsDeviceDaoImpl() {
+        physicalNetworkIdSearch = createSearchBuilder();
+        physicalNetworkIdSearch.and("physicalNetworkId", physicalNetworkIdSearch.entity().getPhysicalNetworkId(), Op.EQ);
+        physicalNetworkIdSearch.done();
+    }
+
+	@Override
+	public List<OvsDeviceVO> listByPhysicalNetwork(long physicalNetworkId) {
+		SearchCriteria<OvsDeviceVO> sc = physicalNetworkIdSearch.create();
+		sc.setParameters("physicalNetworkId", physicalNetworkId);
+		return search(sc, null);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/12a4d300/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceVO.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceVO.java
new file mode 100644
index 0000000..cab63f6
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceVO.java
@@ -0,0 +1,88 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.ovs.dao;
+
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="ovs_devices")
+public class OvsDeviceVO implements InternalIdentity {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="uuid")
+    private String uuid;
+
+    @Column(name="host_id")
+    private long hostId;
+
+    @Column(name="physical_network_id")
+    private long physicalNetworkId;
+
+    @Column(name="device_name")
+    private String deviceName;
+
+
+    public OvsDeviceVO() {
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+    public OvsDeviceVO(long hostId, long physicalNetworkId,
+            String deviceName) {
+        super();
+        this.hostId = hostId;
+        this.physicalNetworkId = physicalNetworkId;
+        this.deviceName = deviceName;
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public long getHostId() {
+        return hostId;
+    }
+
+    public String getDeviceName() {
+        return deviceName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/12a4d300/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDao.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDao.java
new file mode 100644
index 0000000..b2128eb
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDao.java
@@ -0,0 +1,24 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.ovs.dao;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface OvsNicMappingDao extends GenericDao<OvsNicMappingVO, Long> {
+
+	public OvsNicMappingVO findByNicUuid(String nicUuid);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/12a4d300/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDaoImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDaoImpl.java
new file mode 100644
index 0000000..87e41b7
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingDaoImpl.java
@@ -0,0 +1,47 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.ovs.dao;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+@Component
+@Local(value=OvsNicMappingDao.class)
+public class OvsNicMappingDaoImpl extends GenericDaoBase<OvsNicMappingVO, Long> implements OvsNicMappingDao{
+
+	protected final SearchBuilder<OvsNicMappingVO> nicSearch;
+
+	public OvsNicMappingDaoImpl() {
+        nicSearch = createSearchBuilder();
+        nicSearch.and("nicUuid", nicSearch.entity().getNicUuid(), Op.EQ);
+        nicSearch.done();
+    }
+
+	@Override
+	public OvsNicMappingVO findByNicUuid(String nicUuid) {
+		SearchCriteria<OvsNicMappingVO> sc = nicSearch.create();
+        sc.setParameters("nicUuid", nicUuid);
+        return findOneBy(sc);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/12a4d300/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingVO.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingVO.java
new file mode 100644
index 0000000..dc4a931
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsNicMappingVO.java
@@ -0,0 +1,83 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.ovs.dao;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="ovs_nic_map")
+public class OvsNicMappingVO implements InternalIdentity {
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	@Column(name="id")
+	private long id;
+
+	@Column(name="logicalswitch")
+	private String logicalSwitchUuid;
+
+	@Column(name="logicalswitchport")
+	private String logicalSwitchPortUuid;
+
+	@Column(name="nic")
+	private String nicUuid;
+
+	public OvsNicMappingVO() {
+
+	}
+
+	public OvsNicMappingVO (String logicalSwitchUuid, String logicalSwitchPortUuid, String nicUuid) {
+        this.logicalSwitchUuid = logicalSwitchUuid;
+        this.logicalSwitchPortUuid = logicalSwitchPortUuid;
+        this.nicUuid = nicUuid;
+    }
+
+	public String getLogicalSwitchUuid() {
+        return logicalSwitchUuid;
+    }
+
+	public void setLogicalSwitchUuid(String logicalSwitchUuid) {
+        this.logicalSwitchUuid = logicalSwitchUuid;
+    }
+
+    public String getLogicalSwitchPortUuid() {
+        return logicalSwitchPortUuid;
+    }
+
+    public void setLogicalSwitchPortUuid(String logicalSwitchPortUuid) {
+        this.logicalSwitchPortUuid = logicalSwitchPortUuid;
+    }
+
+    public String getNicUuid() {
+        return nicUuid;
+    }
+
+    public void setNicUuid(String nicUuid) {
+        this.nicUuid = nicUuid;
+    }
+
+    public long getId() {
+        return id;
+    }
+}


[07/21] re-factor gre controller

Posted by tu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDestroyTunnelCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDestroyTunnelCommand.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDestroyTunnelCommand.java
deleted file mode 100644
index 527dc7b..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsDestroyTunnelCommand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Command;
-
-public class OvsDestroyTunnelCommand extends Command {
-
-    Long networkId;
-    Integer key;
-    String inPortName;
-
-    public OvsDestroyTunnelCommand(Long networkId, Integer key, String inPortName) {
-        this.networkId = networkId;
-        this.inPortName = inPortName;
-        this.key = key;
-    }
-
-    public Long getNetworkId() {
-        return networkId;
-    }
-
-    public String getInPortName() {
-        return inPortName;
-    }
-
-    public Integer getKey() {
-        return key;
-    }
-
-    @Override
-    public boolean executeInSequence() {
-        return true;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsFetchInterfaceAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsFetchInterfaceAnswer.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsFetchInterfaceAnswer.java
deleted file mode 100644
index 1d09117..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsFetchInterfaceAnswer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-
-public class OvsFetchInterfaceAnswer extends Answer {
-    String ip;
-    String netmask;
-    String mac;
-    String label;
-
-    public OvsFetchInterfaceAnswer(Command cmd, boolean success, String details) {
-        super(cmd, success, details);
-        this.label = ((OvsFetchInterfaceCommand)cmd).getLabel();
-    }
-
-    public OvsFetchInterfaceAnswer(Command cmd, boolean success, String details, String ip, String netmask, String mac) {
-        super(cmd, success, details);
-        this.ip = ip;
-        this.netmask = netmask;
-        this.mac = mac;
-        this.label = ((OvsFetchInterfaceCommand)cmd).getLabel();
-    }
-
-    public String getIp() {
-        return ip;
-    }
-
-    public String getNetmask() {
-        return netmask;
-    }
-
-    public String getMac() {
-        return mac;
-    }
-
-    public String getLabel() {
-        return label;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsFetchInterfaceCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsFetchInterfaceCommand.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsFetchInterfaceCommand.java
deleted file mode 100644
index c27daf0..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsFetchInterfaceCommand.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Command;
-
-public class OvsFetchInterfaceCommand extends Command {
-    String label;
-
-    @Override
-    public boolean executeInSequence() {
-        return true;
-    }
-
-    public OvsFetchInterfaceCommand(String label) {
-        this.label = label;
-    }
-
-    public String getLabel() {
-        return label;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetTagAndFlowAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetTagAndFlowAnswer.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetTagAndFlowAnswer.java
deleted file mode 100644
index db40002..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetTagAndFlowAnswer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-
-public class OvsSetTagAndFlowAnswer extends Answer {
-    Long vmId;
-    Long seqno;
-
-    public OvsSetTagAndFlowAnswer(Command cmd, boolean success, String details) {
-        super(cmd, success, details);
-        OvsSetTagAndFlowCommand c = (OvsSetTagAndFlowCommand)cmd;
-        this.vmId = c.getVmId();
-        this.seqno = Long.parseLong(c.getSeqNo());
-    }
-
-    public Long getVmId() {
-        return vmId;
-    }
-
-    public Long getSeqNo() {
-        return seqno;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetTagAndFlowCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetTagAndFlowCommand.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetTagAndFlowCommand.java
deleted file mode 100644
index 17121a0..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetTagAndFlowCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Command;
-
-public class OvsSetTagAndFlowCommand extends Command {
-    String vlans;
-    String vmName;
-    String seqno;
-    String tag;
-    Long vmId;
-
-    @Override
-    public boolean executeInSequence() {
-        return true;
-    }
-
-    public String getSeqNo() {
-        return seqno;
-    }
-
-    public String getVlans() {
-        return vlans;
-    }
-
-    public String getVmName() {
-        return vmName;
-    }
-
-    public Long getVmId() {
-        return vmId;
-    }
-
-    public String getTag() {
-        return tag;
-    }
-
-    public OvsSetTagAndFlowCommand(String vmName, String tag, String vlans, String seqno, Long vmId) {
-        this.vmName = vmName;
-        this.tag = tag;
-        this.vlans = vlans;
-        this.seqno = seqno;
-        this.vmId = vmId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetupBridgeCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetupBridgeCommand.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetupBridgeCommand.java
deleted file mode 100644
index 9c9924d..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsSetupBridgeCommand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Command;
-
-public class OvsSetupBridgeCommand extends Command {
-    Integer key;
-    Long hostId;
-    Long networkId;
-
-    @Override
-    public boolean executeInSequence() {
-        return true;
-    }
-
-    public OvsSetupBridgeCommand(Integer key, Long hostId, Long networkId) {
-        this.key = key;
-        this.hostId = hostId;
-        this.networkId = networkId;
-    }
-
-    public Integer getKey() {
-        return key;
-    }
-
-    public Long getHostId() {
-        return hostId;
-    }
-
-    public Long getNetworkId() {
-        return networkId;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
index 10815a4..81518fb 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
@@ -35,6 +35,13 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
+import com.cloud.agent.api.OvsCreateTunnelAnswer;
+import com.cloud.agent.api.OvsCreateTunnelCommand;
+import com.cloud.agent.api.OvsDestroyBridgeCommand;
+import com.cloud.agent.api.OvsDestroyTunnelCommand;
+import com.cloud.agent.api.OvsFetchInterfaceAnswer;
+import com.cloud.agent.api.OvsFetchInterfaceCommand;
+import com.cloud.agent.api.OvsSetupBridgeCommand;
 import com.cloud.agent.manager.Commands;
 import com.cloud.configuration.Config;
 import com.cloud.deploy.DeployDestination;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/StartupOvsCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/StartupOvsCommand.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/StartupOvsCommand.java
deleted file mode 100644
index b85331e..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/StartupOvsCommand.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.host.Host;
-
-public class StartupOvsCommand extends StartupCommand {
-
-	public StartupOvsCommand() {
-		super(Host.Type.L2Networking);
-	}
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDao.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDao.java
deleted file mode 100644
index 794e45e..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDao.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs.dao;
-
-import java.util.List;
-
-import com.cloud.utils.db.GenericDao;
-
-public interface OvsDeviceDao extends GenericDao<OvsDeviceVO, Long> {
-
-	List<OvsDeviceVO> listByPhysicalNetwork(long physicalNetworkId);
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDaoImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDaoImpl.java
deleted file mode 100644
index 11a4d48..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceDaoImpl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs.dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Op;
-
-@Component
-@Local(value=OvsDeviceDao.class)
-public class OvsDeviceDaoImpl extends GenericDaoBase<OvsDeviceVO, Long> implements OvsDeviceDao {
-
-	protected final SearchBuilder<OvsDeviceVO> physicalNetworkIdSearch;
-
-	public OvsDeviceDaoImpl() {
-        physicalNetworkIdSearch = createSearchBuilder();
-        physicalNetworkIdSearch.and("physicalNetworkId", physicalNetworkIdSearch.entity().getPhysicalNetworkId(), Op.EQ);
-        physicalNetworkIdSearch.done();
-    }
-
-	@Override
-	public List<OvsDeviceVO> listByPhysicalNetwork(long physicalNetworkId) {
-		SearchCriteria<OvsDeviceVO> sc = physicalNetworkIdSearch.create();
-		sc.setParameters("physicalNetworkId", physicalNetworkId);
-		return search(sc, null);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceVO.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceVO.java
deleted file mode 100644
index cab63f6..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/dao/OvsDeviceVO.java
+++ /dev/null
@@ -1,88 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.network.ovs.dao;
-
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import org.apache.cloudstack.api.InternalIdentity;
-
-@Entity
-@Table(name="ovs_devices")
-public class OvsDeviceVO implements InternalIdentity {
-
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    @Column(name="id")
-    private long id;
-
-    @Column(name="uuid")
-    private String uuid;
-
-    @Column(name="host_id")
-    private long hostId;
-
-    @Column(name="physical_network_id")
-    private long physicalNetworkId;
-
-    @Column(name="device_name")
-    private String deviceName;
-
-
-    public OvsDeviceVO() {
-        this.uuid = UUID.randomUUID().toString();
-    }
-
-    public OvsDeviceVO(long hostId, long physicalNetworkId,
-            String deviceName) {
-        super();
-        this.hostId = hostId;
-        this.physicalNetworkId = physicalNetworkId;
-        this.deviceName = deviceName;
-        this.uuid = UUID.randomUUID().toString();
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public String getUuid() {
-        return uuid;
-    }
-
-    public void setUuid(String uuid) {
-        this.uuid = uuid;
-    }
-
-    public long getPhysicalNetworkId() {
-        return physicalNetworkId;
-    }
-
-    public long getHostId() {
-        return hostId;
-    }
-
-    public String getDeviceName() {
-        return deviceName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/network-elements/ovs/src/com/cloud/network/resource/OvsResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/resource/OvsResource.java b/plugins/network-elements/ovs/src/com/cloud/network/resource/OvsResource.java
deleted file mode 100644
index a94e4f8..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/resource/OvsResource.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package com.cloud.network.resource;
-
-import java.util.Map;
-
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.IAgentControl;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.MaintainAnswer;
-import com.cloud.agent.api.MaintainCommand;
-import com.cloud.agent.api.PingCommand;
-import com.cloud.agent.api.ReadyAnswer;
-import com.cloud.agent.api.ReadyCommand;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.network.ovs.OvsApi;
-import com.cloud.network.ovs.StartupOvsCommand;
-import com.cloud.resource.ServerResource;
-import com.cloud.utils.component.ManagerBase;
-
-public class OvsResource extends ManagerBase implements ServerResource {
-	private static final Logger s_logger = Logger.getLogger(OvsResource.class);
-
-	private String _name;
-	private String _guid;
-	private String _zoneId;
-	private int _numRetries;
-
-	private OvsApi _ovsApi;
-
-	protected OvsApi createOvsApi() {
-		return new OvsApi();
-	}
-
-	@Override
-	public boolean configure(String name, Map<String, Object> params)
-			throws ConfigurationException {
-		_name = (String) params.get("name");
-		if (_name == null) {
-			throw new ConfigurationException("Unable to find name");
-		}
-
-		_guid = (String) params.get("guid");
-		if (_guid == null) {
-			throw new ConfigurationException("Unable to find the guid");
-		}
-
-		_zoneId = (String) params.get("zoneId");
-		if (_zoneId == null) {
-			throw new ConfigurationException("Unable to find zone");
-		}
-
-		_numRetries = 2;
-
-		String ip = (String) params.get("ip");
-		if (ip == null) {
-			throw new ConfigurationException("Unable to find IP");
-		}
-
-		_ovsApi = createOvsApi();
-		_ovsApi.setControllerAddress(ip);
-
-		return true;
-	}
-
-	@Override
-	public boolean start() {
-		return true;
-	}
-
-	@Override
-	public boolean stop() {
-		return true;
-	}
-
-	@Override
-	public String getName() {
-		return _name;
-	}
-
-	@Override
-	public Type getType() {
-		return Host.Type.L2Networking;
-	}
-
-	@Override
-	public StartupCommand[] initialize() {
-		StartupOvsCommand sc = new StartupOvsCommand();
-		sc.setGuid(_guid);
-		sc.setName(_name);
-		sc.setDataCenter(_zoneId);
-		sc.setPod("");
-		sc.setPrivateIpAddress("");
-		sc.setStorageIpAddress("");
-		sc.setVersion("");
-		return new StartupCommand[] { sc };
-	}
-
-	@Override
-	public PingCommand getCurrentStatus(long id) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Answer executeRequest(Command cmd) {
-		return executeRequest(cmd, _numRetries);
-	}
-
-	private Answer executeRequest(ReadyCommand cmd) {
-		return new ReadyAnswer(cmd);
-	}
-
-	private Answer executeRequest(MaintainCommand cmd) {
-		return new MaintainAnswer(cmd);
-	}
-
-	public Answer executeRequest(Command cmd, int numRetries) {
-		if (cmd instanceof ReadyCommand) {
-			return executeRequest((ReadyCommand) cmd);
-		} else if (cmd instanceof MaintainCommand) {
-			return executeRequest((MaintainCommand) cmd);
-		}
-		// TODO: implement services request
-		// else if (cmd instanceof CreateOvsNetworkCommand) {
-		// return executeRequest((CreateOvsNetworkCommand)cmd, numRetries);
-		// }
-		// else if (cmd instanceof DeleteOvsNetworkCommand) {
-		// return executeRequest((DeleteOvsNetworkCommand) cmd, numRetries);
-		// }
-		// else if (cmd instanceof CreateOvsPortCommand) {
-		// return executeRequest((CreateOvsPortCommand) cmd, numRetries);
-		// }
-		// else if (cmd instanceof DeleteOvsPortCommand) {
-		// return executeRequest((DeleteOvsPortCommand) cmd, numRetries);
-		// }
-		// else if (cmd instanceof UpdateOvsPortCommand) {
-		// return executeRequest((UpdateOvsPortCommand) cmd, numRetries);
-		// }
-		s_logger.debug("Received unsupported command " + cmd.toString());
-		return Answer.createUnsupportedCommandAnswer(cmd);
-	}
-
-	@Override
-	public void disconnected() {
-	}
-
-	private Answer retry(Command cmd, int numRetries) {
-		s_logger.warn("Retrying " + cmd.getClass().getSimpleName()
-				+ ". Number of retries remaining: " + numRetries);
-		return executeRequest(cmd, numRetries);
-	}
-
-	private String truncate(String string, int length) {
-		if (string.length() <= length) {
-			return string;
-		} else {
-			return string.substring(0, length);
-		}
-	}
-
-	@Override
-	public IAgentControl getAgentControl() {
-		return null;
-	}
-
-	@Override
-	public void setAgentControl(IAgentControl agentControl) {
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index bf32b8d..8d3aa20 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -196,7 +196,6 @@ DROP TABLE IF EXISTS `cloud`.`vm_network_map`;
 DROP TABLE IF EXISTS `cloud`.`netapp_volume`;
 DROP TABLE IF EXISTS `cloud`.`netapp_pool`;
 DROP TABLE IF EXISTS `cloud`.`netapp_lun`;
-DROP TABLE IF EXISTS `cloud`.`ovs_devices`;
 DROP TABLE IF EXISTS `cloud`.`ovs_nic_map`;
 
 CREATE TABLE `cloud`.`version` (
@@ -2477,17 +2476,6 @@ CREATE TABLE `cloud`.`nicira_nvp_nic_map` (
   CONSTRAINT `fk_nicira_nvp_nic_map__nic` FOREIGN KEY(`nic`) REFERENCES `nics`(`uuid`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
-CREATE TABLE `cloud`.`ovs_devices` (
-  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
-  `uuid` varchar(255) UNIQUE,
-  `physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network in to which ovs device is added',
-  `device_name` varchar(255) NOT NULL COMMENT 'name of the ovs device',
-  `host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the ovs device',
-  PRIMARY KEY  (`id`),
-  CONSTRAINT `fk_ovs_devices__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
-  CONSTRAINT `fk_ovs_devices__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
 CREATE TABLE `cloud`.`ovs_nic_map` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
   `logicalswitch` varchar(255) NOT NULL COMMENT 'uuid of logical switch this port is provisioned on',


[04/21] re-factor gre controller prototype

Posted by tu...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/src/com/cloud/network/ovs/StartupOvsCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/StartupOvsCommand.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/StartupOvsCommand.java
new file mode 100644
index 0000000..b85331e
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/StartupOvsCommand.java
@@ -0,0 +1,27 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.ovs;
+
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.host.Host;
+
+public class StartupOvsCommand extends StartupCommand {
+
+	public StartupOvsCommand() {
+		super(Host.Type.L2Networking);
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/src/com/cloud/network/resource/OvsResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/resource/OvsResource.java b/plugins/network-elements/ovs/src/com/cloud/network/resource/OvsResource.java
new file mode 100644
index 0000000..a94e4f8
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/resource/OvsResource.java
@@ -0,0 +1,175 @@
+package com.cloud.network.resource;
+
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.IAgentControl;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.MaintainAnswer;
+import com.cloud.agent.api.MaintainCommand;
+import com.cloud.agent.api.PingCommand;
+import com.cloud.agent.api.ReadyAnswer;
+import com.cloud.agent.api.ReadyCommand;
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.host.Host;
+import com.cloud.host.Host.Type;
+import com.cloud.network.ovs.OvsApi;
+import com.cloud.network.ovs.StartupOvsCommand;
+import com.cloud.resource.ServerResource;
+import com.cloud.utils.component.ManagerBase;
+
+public class OvsResource extends ManagerBase implements ServerResource {
+	private static final Logger s_logger = Logger.getLogger(OvsResource.class);
+
+	private String _name;
+	private String _guid;
+	private String _zoneId;
+	private int _numRetries;
+
+	private OvsApi _ovsApi;
+
+	protected OvsApi createOvsApi() {
+		return new OvsApi();
+	}
+
+	@Override
+	public boolean configure(String name, Map<String, Object> params)
+			throws ConfigurationException {
+		_name = (String) params.get("name");
+		if (_name == null) {
+			throw new ConfigurationException("Unable to find name");
+		}
+
+		_guid = (String) params.get("guid");
+		if (_guid == null) {
+			throw new ConfigurationException("Unable to find the guid");
+		}
+
+		_zoneId = (String) params.get("zoneId");
+		if (_zoneId == null) {
+			throw new ConfigurationException("Unable to find zone");
+		}
+
+		_numRetries = 2;
+
+		String ip = (String) params.get("ip");
+		if (ip == null) {
+			throw new ConfigurationException("Unable to find IP");
+		}
+
+		_ovsApi = createOvsApi();
+		_ovsApi.setControllerAddress(ip);
+
+		return true;
+	}
+
+	@Override
+	public boolean start() {
+		return true;
+	}
+
+	@Override
+	public boolean stop() {
+		return true;
+	}
+
+	@Override
+	public String getName() {
+		return _name;
+	}
+
+	@Override
+	public Type getType() {
+		return Host.Type.L2Networking;
+	}
+
+	@Override
+	public StartupCommand[] initialize() {
+		StartupOvsCommand sc = new StartupOvsCommand();
+		sc.setGuid(_guid);
+		sc.setName(_name);
+		sc.setDataCenter(_zoneId);
+		sc.setPod("");
+		sc.setPrivateIpAddress("");
+		sc.setStorageIpAddress("");
+		sc.setVersion("");
+		return new StartupCommand[] { sc };
+	}
+
+	@Override
+	public PingCommand getCurrentStatus(long id) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Answer executeRequest(Command cmd) {
+		return executeRequest(cmd, _numRetries);
+	}
+
+	private Answer executeRequest(ReadyCommand cmd) {
+		return new ReadyAnswer(cmd);
+	}
+
+	private Answer executeRequest(MaintainCommand cmd) {
+		return new MaintainAnswer(cmd);
+	}
+
+	public Answer executeRequest(Command cmd, int numRetries) {
+		if (cmd instanceof ReadyCommand) {
+			return executeRequest((ReadyCommand) cmd);
+		} else if (cmd instanceof MaintainCommand) {
+			return executeRequest((MaintainCommand) cmd);
+		}
+		// TODO: implement services request
+		// else if (cmd instanceof CreateOvsNetworkCommand) {
+		// return executeRequest((CreateOvsNetworkCommand)cmd, numRetries);
+		// }
+		// else if (cmd instanceof DeleteOvsNetworkCommand) {
+		// return executeRequest((DeleteOvsNetworkCommand) cmd, numRetries);
+		// }
+		// else if (cmd instanceof CreateOvsPortCommand) {
+		// return executeRequest((CreateOvsPortCommand) cmd, numRetries);
+		// }
+		// else if (cmd instanceof DeleteOvsPortCommand) {
+		// return executeRequest((DeleteOvsPortCommand) cmd, numRetries);
+		// }
+		// else if (cmd instanceof UpdateOvsPortCommand) {
+		// return executeRequest((UpdateOvsPortCommand) cmd, numRetries);
+		// }
+		s_logger.debug("Received unsupported command " + cmd.toString());
+		return Answer.createUnsupportedCommandAnswer(cmd);
+	}
+
+	@Override
+	public void disconnected() {
+	}
+
+	private Answer retry(Command cmd, int numRetries) {
+		s_logger.warn("Retrying " + cmd.getClass().getSimpleName()
+				+ ". Number of retries remaining: " + numRetries);
+		return executeRequest(cmd, numRetries);
+	}
+
+	private String truncate(String string, int length) {
+		if (string.length() <= length) {
+			return string;
+		} else {
+			return string.substring(0, length);
+		}
+	}
+
+	@Override
+	public IAgentControl getAgentControl() {
+		return null;
+	}
+
+	@Override
+	public void setAgentControl(IAgentControl agentControl) {
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index 55cb4cc..bf32b8d 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -196,6 +196,8 @@ DROP TABLE IF EXISTS `cloud`.`vm_network_map`;
 DROP TABLE IF EXISTS `cloud`.`netapp_volume`;
 DROP TABLE IF EXISTS `cloud`.`netapp_pool`;
 DROP TABLE IF EXISTS `cloud`.`netapp_lun`;
+DROP TABLE IF EXISTS `cloud`.`ovs_devices`;
+DROP TABLE IF EXISTS `cloud`.`ovs_nic_map`;
 
 CREATE TABLE `cloud`.`version` (
   `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
@@ -2475,5 +2477,25 @@ CREATE TABLE `cloud`.`nicira_nvp_nic_map` (
   CONSTRAINT `fk_nicira_nvp_nic_map__nic` FOREIGN KEY(`nic`) REFERENCES `nics`(`uuid`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
+CREATE TABLE `cloud`.`ovs_devices` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `uuid` varchar(255) UNIQUE,
+  `physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network in to which ovs device is added',
+  `device_name` varchar(255) NOT NULL COMMENT 'name of the ovs device',
+  `host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the ovs device',
+  PRIMARY KEY  (`id`),
+  CONSTRAINT `fk_ovs_devices__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
+  CONSTRAINT `fk_ovs_devices__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`ovs_nic_map` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `logicalswitch` varchar(255) NOT NULL COMMENT 'uuid of logical switch this port is provisioned on',
+  `logicalswitchport` varchar(255) UNIQUE COMMENT 'uuid of this logical switch port',
+  `nic` varchar(255) UNIQUE COMMENT 'cloudstack uuid of the nic connected to this logical switch port',
+  PRIMARY KEY (`id`),
+  CONSTRAINT `fk_ovs_nic_map__nic` FOREIGN KEY(`nic`) REFERENCES `nics`(`uuid`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
 SET foreign_key_checks = 1;
 


[05/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
re-factor gre controller prototype


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/96188a37
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/96188a37
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/96188a37

Branch: refs/heads/master
Commit: 96188a3730b043338163ce6b2d50a748b5981447
Parents: 12a4d30
Author: tuna <ng...@gmail.com>
Authored: Wed Jul 17 21:06:46 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 api/src/com/cloud/event/EventTypes.java         |   2 +
 .../org/apache/cloudstack/api/ApiConstants.java |   4 +
 client/tomcatconf/applicationContext.xml.in     | 941 +++++++++++++++++++
 client/tomcatconf/commands.properties.in        |   6 +
 .../cloudstack/ovs/spring-ovs-context.xml       |   2 +
 .../cloud/api/response/OvsDeviceResponse.java   |  65 ++
 .../cloud/network/commands/AddOvsDeviceCmd.java | 116 +++
 .../network/commands/DeleteOvsDeviceCmd.java    | 110 +++
 .../network/commands/ListOvsDevicesCmd.java     | 114 +++
 .../com/cloud/network/element/OvsElement.java   |   7 +
 .../network/element/OvsElementService.java      |  22 +
 .../ovs/src/com/cloud/network/ovs/OvsApi.java   |  78 ++
 .../com/cloud/network/ovs/OvsApiException.java  |  35 +
 .../cloud/network/ovs/StartupOvsCommand.java    |  27 +
 .../com/cloud/network/resource/OvsResource.java | 175 ++++
 setup/db/create-schema.sql                      |  22 +
 16 files changed, 1726 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index c539066..d3c29e9 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -398,6 +398,8 @@ public class EventTypes {
     public static final String EVENT_EXTERNAL_NVP_CONTROLLER_ADD = "PHYSICAL.NVPCONTROLLER.ADD";
     public static final String EVENT_EXTERNAL_NVP_CONTROLLER_DELETE = "PHYSICAL.NVPCONTROLLER.DELETE";
     public static final String EVENT_EXTERNAL_NVP_CONTROLLER_CONFIGURE = "PHYSICAL.NVPCONTROLLER.CONFIGURE";
+    public static final String EVENT_EXTERNAL_OVS_CONTROLLER_ADD = "PHYSICAL.OVSCONTROLLER.ADD";
+    public static final String EVENT_EXTERNAL_OVS_CONTROLLER_DELETE = "PHYSICAL.OVSCONTROLLER.DELETE";
 
     // AutoScale
     public static final String EVENT_COUNTER_CREATE = "COUNTER.CREATE";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index efdff12..0cde5ba 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -409,6 +409,10 @@ public class ApiConstants {
     public static final String VSWITCH_TYPE_PUBLIC_TRAFFIC = "publicvswitchtype";
     public static final String VSWITCH_NAME_GUEST_TRAFFIC = "guestvswitchname";
     public static final String VSWITCH_NAME_PUBLIC_TRAFFIC = "publicvswitchname";
+    // Ovs controller
+    public static final String OVS_DEVICE_ID = "ovsdeviceid";
+    public static final String OVS_DEVICE_NAME = "ovsdevicename";
+
     public static final String EXTERNAL_SWITCH_MGMT_DEVICE_ID = "vsmdeviceid";
     public static final String EXTERNAL_SWITCH_MGMT_DEVICE_NAME = "vsmdevicename";
     public static final String EXTERNAL_SWITCH_MGMT_DEVICE_STATE = "vsmdevicestate";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
new file mode 100644
index 0000000..1f3571c
--- /dev/null
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -0,0 +1,941 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+
+
+
+
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">                     
+
+  <context:annotation-config />
+
+<!--=====================================================================================================-->
+<!--                                                                                                     -->
+<!--                           core OSS/non-OSS Common components                                        -->  
+<!--                                                                                                     -->
+<!--=====================================================================================================-->
+
+  <!--
+    @DB support
+  -->
+  <bean id="componentContext" class="com.cloud.utils.component.ComponentContext" />
+  <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
+  <bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
+
+  <bean id="instantiatePostProcessor" class="com.cloud.utils.component.ComponentInstantiationPostProcessor">
+    <property name="Interceptors">
+        <list>
+            <ref bean="transactionContextBuilder" />
+            <ref bean="actionEventInterceptor" />
+        </list>
+    </property>
+  </bean>
+
+  <!--
+    RPC/Async/EventBus
+  -->
+
+  <bean id="onwireRegistry" class="org.apache.cloudstack.framework.serializer.OnwireClassRegistry"
+    init-method="scan" >
+    <property name="packages">
+      <list>
+        <value>org.apache.cloudstack.framework</value>
+      </list>
+    </property>
+  </bean>
+  
+  <bean id="messageSerializer" class="org.apache.cloudstack.framework.serializer.JsonMessageSerializer">
+    <property name="onwireClassRegistry" ref="onwireRegistry" />
+  </bean>
+
+  <bean id="transportProvider" class="org.apache.cloudstack.framework.server.ServerTransportProvider"  init-method="initialize">
+    <property name="workerPoolSize" value="5" />
+    <property name="nodeId" value="Node1" />
+    <property name="messageSerializer" ref="messageSerializer" />
+  </bean>
+  
+  <bean id="rpcProvider" class="org.apache.cloudstack.framework.rpc.RpcProviderImpl" init-method="initialize">
+    <constructor-arg ref="transportProvider" />
+    <property name="messageSerializer" ref="messageSerializer" />
+  </bean>
+
+  <bean id="messageBus" class = "org.apache.cloudstack.framework.messagebus.MessageBusBase" />
+  <bean id="configDepot" class = "org.apache.cloudstack.framework.config.impl.ConfigDepotImpl" />
+
+  <!--
+    DAO with customized configuration
+  -->
+  <bean id="serviceOfferingDaoImpl" class="com.cloud.service.dao.ServiceOfferingDaoImpl">
+    <property name="configParams">
+      <map>
+        <entry key="cache.size" value="50" />
+        <entry key="cache.time.to.live" value="600" />
+      </map>
+    </property>  
+  </bean>
+
+  <bean id="diskOfferingDaoImpl" class="com.cloud.storage.dao.DiskOfferingDaoImpl">
+    <property name="configParams">
+      <map>
+        <entry key="cache.size" value="50" />
+        <entry key="cache.time.to.live" value="600" />
+      </map>
+    </property>  
+  </bean>
+
+  <bean id="dataCenterDaoImpl" class="com.cloud.dc.dao.DataCenterDaoImpl">
+    <property name="configParams">
+      <map>
+        <entry key="cache.size" value="50" />
+        <entry key="cache.time.to.live" value="600" />
+      </map>
+    </property>  
+  </bean>
+
+  <bean id="hostPodDaoImpl" class="com.cloud.dc.dao.HostPodDaoImpl">
+    <property name="configParams">
+      <map>
+        <entry key="cache.size" value="50" />
+        <entry key="cache.time.to.live" value="600" />
+      </map>
+    </property>  
+  </bean>
+
+  <bean id="vlanDaoImpl" class="com.cloud.dc.dao.VlanDaoImpl">
+    <property name="configParams">
+      <map>
+        <entry key="cache.size" value="30" />
+        <entry key="cache.time.to.live" value="3600" />
+      </map>
+    </property>  
+  </bean>
+
+  <bean id="userDaoImpl" class="com.cloud.user.dao.UserDaoImpl">
+    <property name="configParams">
+      <map>
+        <entry key="cache.size" value="5000" />
+        <entry key="cache.time.to.live" value="300" />
+      </map>
+    </property>  
+  </bean>
+
+  <bean id="VMTemplateDaoImpl" class="com.cloud.storage.dao.VMTemplateDaoImpl">
+    <property name="configParams">
+      <map>
+        <entry key="cache.size" value="100" />
+        <entry key="cache.time.to.live" value="600" />
+      </map>
+    </property>  
+  </bean>
+
+  <bean id="hypervisorCapabilitiesDaoImpl" class="com.cloud.hypervisor.dao.HypervisorCapabilitiesDaoImpl">
+    <property name="configParams">
+      <map>
+        <entry key="cache.size" value="100" />
+        <entry key="cache.time.to.live" value="600" />
+      </map>
+    </property>  
+  </bean>
+  <bean id="dedicatedResourceDaoImpl" class="com.cloud.dc.dao.DedicatedResourceDaoImpl">
+    <property name="configParams">
+      <map>
+        <entry key="cache.size" value="30" />
+        <entry key="cache.time.to.live" value="3600" />
+      </map>
+    </property>
+  </bean>
+  
+  <!--
+    DAOs with default configuration
+  -->
+  <bean id="accountDaoImpl" class="com.cloud.user.dao.AccountDaoImpl" />
+  <bean id="accountDetailsDaoImpl" class="com.cloud.user.AccountDetailsDaoImpl" />
+  <bean id="accountJoinDaoImpl" class="com.cloud.api.query.dao.AccountJoinDaoImpl" />
+  <bean id="accountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl" />
+  <bean id="accountVlanMapDaoImpl" class="com.cloud.dc.dao.AccountVlanMapDaoImpl" />
+  <bean id="alertDaoImpl" class="com.cloud.alert.dao.AlertDaoImpl" />
+  <bean id="asyncJobJoinDaoImpl" class="com.cloud.api.query.dao.AsyncJobJoinDaoImpl" />
+  <bean id="autoScalePolicyConditionMapDaoImpl" class="com.cloud.network.as.dao.AutoScalePolicyConditionMapDaoImpl" />
+  <bean id="autoScalePolicyDaoImpl" class="com.cloud.network.as.dao.AutoScalePolicyDaoImpl" />
+  <bean id="autoScaleVmGroupDaoImpl" class="com.cloud.network.as.dao.AutoScaleVmGroupDaoImpl" />
+  <bean id="autoScaleVmGroupPolicyMapDaoImpl" class="com.cloud.network.as.dao.AutoScaleVmGroupPolicyMapDaoImpl" />
+  <bean id="autoScaleVmProfileDaoImpl" class="com.cloud.network.as.dao.AutoScaleVmProfileDaoImpl" />
+  <bean id="capacityDaoImpl" class="com.cloud.capacity.dao.CapacityDaoImpl" />
+  <bean id="certificateDaoImpl" class="com.cloud.certificate.dao.CertificateDaoImpl" />
+  <bean id="clusterDaoImpl" class="com.cloud.dc.dao.ClusterDaoImpl" />
+  <bean id="clusterDetailsDaoImpl" class="com.cloud.dc.ClusterDetailsDaoImpl" />
+  <bean id="clusterVSMMapDaoImpl" class="com.cloud.dc.dao.ClusterVSMMapDaoImpl" />
+  <bean id="commandExecLogDaoImpl" class="com.cloud.secstorage.CommandExecLogDaoImpl" />
+  <bean id="conditionDaoImpl" class="com.cloud.network.as.dao.ConditionDaoImpl" />
+  <bean id="consoleProxyDaoImpl" class="com.cloud.vm.dao.ConsoleProxyDaoImpl" />
+  <bean id="counterDaoImpl" class="com.cloud.network.as.dao.CounterDaoImpl" />
+  <bean id="dataCenterIpAddressDaoImpl" class="com.cloud.dc.dao.DataCenterIpAddressDaoImpl" />
+  <bean id="dataCenterJoinDaoImpl" class="com.cloud.api.query.dao.DataCenterJoinDaoImpl" />
+  <bean id="dataCenterLinkLocalIpAddressDaoImpl" class="com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl" />
+  <bean id="dataCenterVnetDaoImpl" class="com.cloud.dc.dao.DataCenterVnetDaoImpl" />
+  <bean id="dcDetailsDaoImpl" class="com.cloud.dc.dao.DcDetailsDaoImpl" />
+  <bean id="engineDcDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.DcDetailsDaoImpl" />
+  <bean id="diskOfferingJoinDaoImpl" class="com.cloud.api.query.dao.DiskOfferingJoinDaoImpl" />
+  <bean id="domainDaoImpl" class="com.cloud.domain.dao.DomainDaoImpl" />
+  <bean id="domainRouterDaoImpl" class="com.cloud.vm.dao.DomainRouterDaoImpl" />
+  <bean id="domainRouterJoinDaoImpl" class="com.cloud.api.query.dao.DomainRouterJoinDaoImpl" />
+  <bean id="elasticLbVmMapDaoImpl" class="com.cloud.network.lb.dao.ElasticLbVmMapDaoImpl" />
+  <bean id="engineClusterDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDaoImpl" />
+  <bean id="engineDataCenterDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDaoImpl" />
+  <bean id="engineHostDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDaoImpl" />
+  <bean id="engineHostPodDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDaoImpl" />
+  <bean id="eventDaoImpl" class="com.cloud.event.dao.EventDaoImpl" />
+  <bean id="eventJoinDaoImpl" class="com.cloud.event.dao.EventJoinDaoImpl" />
+  <bean id="externalFirewallDeviceDaoImpl" class="com.cloud.network.dao.ExternalFirewallDeviceDaoImpl" />
+  <bean id="externalLoadBalancerDeviceDaoImpl" class="com.cloud.network.dao.ExternalLoadBalancerDeviceDaoImpl" />
+  <bean id="externalPublicIpStatisticsDaoImpl" class="com.cloud.usage.dao.ExternalPublicIpStatisticsDaoImpl" />
+  <bean id="firewallRulesCidrsDaoImpl" class="com.cloud.network.dao.FirewallRulesCidrsDaoImpl" />
+  <bean id="firewallRulesDaoImpl" class="com.cloud.network.dao.FirewallRulesDaoImpl" />
+  <bean id="globalLoadBalancerDaoImpl" class="org.apache.cloudstack.region.gslb.GlobalLoadBalancerDaoImpl" />
+  <bean id="globalLoadBalancerLbRuleMapDaoImpl" class="org.apache.cloudstack.region.gslb.GlobalLoadBalancerLbRuleMapDaoImpl" />
+  <bean id="guestOSCategoryDaoImpl" class="com.cloud.storage.dao.GuestOSCategoryDaoImpl" />
+  <bean id="guestOSDaoImpl" class="com.cloud.storage.dao.GuestOSDaoImpl" />
+  <bean id="guestOSHypervisorDaoImpl" class="com.cloud.storage.dao.GuestOSHypervisorDaoImpl" />
+  <bean id="highAvailabilityDaoImpl" class="com.cloud.ha.dao.HighAvailabilityDaoImpl" />
+  <bean id="hostDaoImpl" class="com.cloud.host.dao.HostDaoImpl" />
+  <bean id="engineHostDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostDetailsDaoImpl" />
+  <bean id="hostDetailsDaoImpl" class="com.cloud.host.dao.HostDetailsDaoImpl" />
+  <bean id="hostJoinDaoImpl" class="com.cloud.api.query.dao.HostJoinDaoImpl" />
+  <bean id="engineHostTagsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostTagsDaoImpl" />
+  <bean id="hostTagsDaoImpl" class="com.cloud.host.dao.HostTagsDaoImpl" />
+  <bean id="hostTransferMapDaoImpl" class="com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl" />
+  <bean id="iPAddressDaoImpl" class="com.cloud.network.dao.IPAddressDaoImpl" />
+  <bean id="identityDaoImpl" class="com.cloud.uuididentity.dao.IdentityDaoImpl" />
+  <bean id="imageStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDaoImpl" />
+  <bean id="imageStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.image.db.ImageStoreDetailsDaoImpl" /> 
+  <bean id="imageStoreJoinDaoImpl" class="com.cloud.api.query.dao.ImageStoreJoinDaoImpl" />   
+  <bean id="snapshotDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.SnapshotDataStoreDaoImpl" /> 
+  <bean id="templateDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.TemplateDataStoreDaoImpl" /> 
+  <bean id="templateJoinDaoImpl" class="com.cloud.api.query.dao.TemplateJoinDaoImpl" />
+  <bean id="volumeDataStoreDaoImpl" class="org.apache.cloudstack.storage.image.db.VolumeDataStoreDaoImpl" />   
+  <bean id="inlineLoadBalancerNicMapDaoImpl" class="com.cloud.network.dao.InlineLoadBalancerNicMapDaoImpl" />
+  <bean id="instanceGroupDaoImpl" class="com.cloud.vm.dao.InstanceGroupDaoImpl" />
+  <bean id="instanceGroupJoinDaoImpl" class="com.cloud.api.query.dao.InstanceGroupJoinDaoImpl" />
+  <bean id="instanceGroupVMMapDaoImpl" class="com.cloud.vm.dao.InstanceGroupVMMapDaoImpl" />
+  <bean id="itWorkDaoImpl" class="com.cloud.vm.ItWorkDaoImpl" />
+  <bean id="keystoreDaoImpl" class="com.cloud.keystore.KeystoreDaoImpl" />
+  <bean id="lBHealthCheckPolicyDaoImpl" class="com.cloud.network.dao.LBHealthCheckPolicyDaoImpl" />
+  <bean id="lBStickinessPolicyDaoImpl" class="com.cloud.network.dao.LBStickinessPolicyDaoImpl" />
+  <bean id="launchPermissionDaoImpl" class="com.cloud.storage.dao.LaunchPermissionDaoImpl" />
+  <bean id="loadBalancerDaoImpl" class="com.cloud.network.dao.LoadBalancerDaoImpl" />
+  <bean id="loadBalancerVMMapDaoImpl" class="com.cloud.network.dao.LoadBalancerVMMapDaoImpl" />
+  <bean id="managementServerHostDaoImpl" class="com.cloud.cluster.dao.ManagementServerHostDaoImpl" />
+  <bean id="managementServerHostPeerDaoImpl" class="com.cloud.cluster.dao.ManagementServerHostPeerDaoImpl" />
+  <bean id="networkAccountDaoImpl" class="com.cloud.network.dao.NetworkAccountDaoImpl" />
+  <bean id="networkACLDaoImpl" class="com.cloud.network.vpc.dao.NetworkACLDaoImpl" />
+  <bean id="networkACLItemDaoImpl" class="com.cloud.network.vpc.dao.NetworkACLItemDaoImpl" />
+  <bean id="networkDaoImpl" class="com.cloud.network.dao.NetworkDaoImpl" />
+  <bean id="networkDomainDaoImpl" class="com.cloud.network.dao.NetworkDomainDaoImpl" />
+  <bean id="networkExternalFirewallDaoImpl" class="com.cloud.network.dao.NetworkExternalFirewallDaoImpl" />
+  <bean id="networkExternalLoadBalancerDaoImpl" class="com.cloud.network.dao.NetworkExternalLoadBalancerDaoImpl" />
+  <bean id="networkOfferingDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingDaoImpl" />
+  <bean id="networkOfferingServiceMapDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingServiceMapDaoImpl" />
+  <bean id="networkOpDaoImpl" class="com.cloud.network.dao.NetworkOpDaoImpl" />
+  <bean id="networkRuleConfigDaoImpl" class="com.cloud.network.dao.NetworkRuleConfigDaoImpl" />
+  <bean id="networkServiceMapDaoImpl" class="com.cloud.network.dao.NetworkServiceMapDaoImpl" />
+  <bean id="nicDaoImpl" class="com.cloud.vm.dao.NicDaoImpl" />
+  <bean id="nicDetailDaoImpl" class="com.cloud.vm.dao.NicDetailDaoImpl" />
+  <bean id="nicSecondaryIpDaoImpl" class="com.cloud.vm.dao.NicSecondaryIpDaoImpl" />
+  <bean id="nicIpAliasDaoImpl" class="com.cloud.vm.dao.NicIpAliasDaoImpl" />
+  <bean id="objectInDataStoreDaoImpl" class="org.apache.cloudstack.storage.db.ObjectInDataStoreDaoImpl" />
+  <bean id="ovsTunnelInterfaceDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" />
+  <bean id="ovsTunnelNetworkDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" />
+  <bean id="ovsDeviceDaoImpl" class="com.cloud.network.ovs.dao.OvsDeviceDaoImpl" />
+  <bean id="ovsNicMappingDaoImpl" class="com.cloud.network.ovs.dao.OvsNicMappingDaoImpl" />
+  <bean id="physicalNetworkDaoImpl" class="com.cloud.network.dao.PhysicalNetworkDaoImpl" />
+  <bean id="physicalNetworkIsolationMethodDaoImpl" class="com.cloud.network.dao.PhysicalNetworkIsolationMethodDaoImpl" />
+  <bean id="physicalNetworkServiceProviderDaoImpl" class="com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl" />
+  <bean id="physicalNetworkTagDaoImpl" class="com.cloud.network.dao.PhysicalNetworkTagDaoImpl" />
+  <bean id="physicalNetworkTrafficTypeDaoImpl" class="com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl" />
+  <bean id="podVlanDaoImpl" class="com.cloud.dc.dao.PodVlanDaoImpl" />
+  <bean id="podVlanMapDaoImpl" class="com.cloud.dc.dao.PodVlanMapDaoImpl" />
+  <bean id="PortableIpDaoImpl" class="org.apache.cloudstack.region.PortableIpDaoImpl" />
+  <bean id="PortableIpRangeDaoImpl" class="org.apache.cloudstack.region.PortableIpRangeDaoImpl" />
+  <bean id="portForwardingRulesDaoImpl" class="com.cloud.network.rules.dao.PortForwardingRulesDaoImpl" />
+  <bean id="portProfileDaoImpl" class="com.cloud.network.dao.PortProfileDaoImpl" />
+  <bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" />
+  <bean id="primaryDataStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.volume.db.PrimaryDataStoreDetailsDaoImpl" />
+  <bean id="privateIpDaoImpl" class="com.cloud.network.vpc.dao.PrivateIpDaoImpl" />
+  <bean id="projectAccountDaoImpl" class="com.cloud.projects.dao.ProjectAccountDaoImpl" />
+  <bean id="projectAccountJoinDaoImpl" class="com.cloud.api.query.dao.ProjectAccountJoinDaoImpl" />
+  <bean id="projectDaoImpl" class="com.cloud.projects.dao.ProjectDaoImpl" />
+  <bean id="projectInvitationDaoImpl" class="com.cloud.projects.dao.ProjectInvitationDaoImpl" />
+  <bean id="projectInvitationJoinDaoImpl" class="com.cloud.api.query.dao.ProjectInvitationJoinDaoImpl" />
+  <bean id="projectJoinDaoImpl" class="com.cloud.api.query.dao.ProjectJoinDaoImpl" />
+  <bean id="regionDaoImpl" class="org.apache.cloudstack.region.dao.RegionDaoImpl" />
+  <bean id="remoteAccessVpnDaoImpl" class="com.cloud.network.dao.RemoteAccessVpnDaoImpl" />
+  <bean id="resourceCountDaoImpl" class="com.cloud.configuration.dao.ResourceCountDaoImpl" />
+  <bean id="resourceLimitDaoImpl" class="com.cloud.configuration.dao.ResourceLimitDaoImpl" />
+  <bean id="resourceTagJoinDaoImpl" class="com.cloud.api.query.dao.ResourceTagJoinDaoImpl" />
+  <bean id="resourceTagsDaoImpl" class="com.cloud.tags.dao.ResourceTagsDaoImpl" />
+  <bean id="routerNetworkDaoImpl" class="com.cloud.network.dao.RouterNetworkDaoImpl" />
+  <bean id="sSHKeyPairDaoImpl" class="com.cloud.user.dao.SSHKeyPairDaoImpl" />
+  <bean id="secondaryStorageVmDaoImpl" class="com.cloud.vm.dao.SecondaryStorageVmDaoImpl" />
+  <bean id="securityGroupDaoImpl" class="com.cloud.network.security.dao.SecurityGroupDaoImpl" />
+  <bean id="securityGroupJoinDaoImpl" class="com.cloud.api.query.dao.SecurityGroupJoinDaoImpl" />
+  <bean id="securityGroupRuleDaoImpl" class="com.cloud.network.security.dao.SecurityGroupRuleDaoImpl" />
+  <bean id="securityGroupRulesDaoImpl" class="com.cloud.network.security.dao.SecurityGroupRulesDaoImpl" />
+  <bean id="securityGroupVMMapDaoImpl" class="com.cloud.network.security.dao.SecurityGroupVMMapDaoImpl" />
+  <bean id="securityGroupWorkDaoImpl" class="com.cloud.network.security.dao.SecurityGroupWorkDaoImpl" />
+  <bean id="serviceOfferingJoinDaoImpl" class="com.cloud.api.query.dao.ServiceOfferingJoinDaoImpl" />
+  <bean id="site2SiteCustomerGatewayDaoImpl" class="com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl" />
+  <bean id="site2SiteVpnConnectionDaoImpl" class="com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl" />
+  <bean id="site2SiteVpnGatewayDaoImpl" class="com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl" />
+  <bean id="snapshotDaoImpl" class="com.cloud.storage.dao.SnapshotDaoImpl" />
+  <bean id="snapshotPolicyDaoImpl" class="com.cloud.storage.dao.SnapshotPolicyDaoImpl" />
+  <bean id="snapshotScheduleDaoImpl" class="com.cloud.storage.dao.SnapshotScheduleDaoImpl" />
+  <bean id="staticRouteDaoImpl" class="com.cloud.network.vpc.dao.StaticRouteDaoImpl" />
+  <bean id="storageNetworkIpAddressDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpAddressDaoImpl" />
+  <bean id="storageNetworkIpRangeDaoImpl" class="com.cloud.dc.dao.StorageNetworkIpRangeDaoImpl" />
+  <bean id="storagePoolDetailsDaoImpl" class="com.cloud.storage.dao.StoragePoolDetailsDaoImpl" />
+  <bean id="storagePoolHostDaoImpl" class="com.cloud.storage.dao.StoragePoolHostDaoImpl" />
+  <bean id="storagePoolJoinDaoImpl" class="com.cloud.api.query.dao.StoragePoolJoinDaoImpl" />
+  <bean id="storagePoolWorkDaoImpl" class="com.cloud.storage.dao.StoragePoolWorkDaoImpl" />
+  <bean id="templatePrimaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDaoImpl" />
+  <bean id="uploadDaoImpl" class="com.cloud.storage.dao.UploadDaoImpl" />
+  <bean id="usageDaoImpl" class="com.cloud.usage.dao.UsageDaoImpl" />
+  <bean id="usageEventDaoImpl" class="com.cloud.event.dao.UsageEventDaoImpl" />
+  <bean id="usageIPAddressDaoImpl" class="com.cloud.usage.dao.UsageIPAddressDaoImpl" />
+  <bean id="usageJobDaoImpl" class="com.cloud.usage.dao.UsageJobDaoImpl" />
+  <bean id="usageLoadBalancerPolicyDaoImpl" class="com.cloud.usage.dao.UsageLoadBalancerPolicyDaoImpl" />
+  <bean id="usageNetworkDaoImpl" class="com.cloud.usage.dao.UsageNetworkDaoImpl" />
+  <bean id="usageNetworkOfferingDaoImpl" class="com.cloud.usage.dao.UsageNetworkOfferingDaoImpl" />
+  <bean id="usagePortForwardingRuleDaoImpl" class="com.cloud.usage.dao.UsagePortForwardingRuleDaoImpl" />
+  <bean id="usageSecurityGroupDaoImpl" class="com.cloud.usage.dao.UsageSecurityGroupDaoImpl" />
+  <bean id="usageStorageDaoImpl" class="com.cloud.usage.dao.UsageStorageDaoImpl" />
+  <bean id="usageVMInstanceDaoImpl" class="com.cloud.usage.dao.UsageVMInstanceDaoImpl" />
+  <bean id="usageVPNUserDaoImpl" class="com.cloud.usage.dao.UsageVPNUserDaoImpl" />
+  <bean id="usageVolumeDaoImpl" class="com.cloud.usage.dao.UsageVolumeDaoImpl" />
+  <bean id="usageVmDiskDaoImpl" class="com.cloud.usage.dao.UsageVmDiskDaoImpl" />
+  <bean id="userAccountDaoImpl" class="com.cloud.user.dao.UserAccountDaoImpl" />
+  <bean id="userAccountJoinDaoImpl" class="com.cloud.api.query.dao.UserAccountJoinDaoImpl" />
+  <bean id="userIpv6AddressDaoImpl" class="com.cloud.network.dao.UserIpv6AddressDaoImpl" />
+  <bean id="userStatisticsDaoImpl" class="com.cloud.user.dao.UserStatisticsDaoImpl" />
+  <bean id="userStatsLogDaoImpl" class="com.cloud.user.dao.UserStatsLogDaoImpl" />
+  <bean id="userVmDiskStatsDaoImpl" class="com.cloud.user.dao.VmDiskStatisticsDaoImpl" />
+  <bean id="userVmCloneSettingDaoImpl" class="com.cloud.vm.dao.UserVmCloneSettingDaoImpl" />
+  <bean id="userVmDaoImpl" class="com.cloud.vm.dao.UserVmDaoImpl" />
+  <bean id="userVmDetailsDaoImpl" class="com.cloud.vm.dao.UserVmDetailsDaoImpl" />
+  <bean id="userVmJoinDaoImpl" class="com.cloud.api.query.dao.UserVmJoinDaoImpl" />
+  <bean id="vMComputeTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMComputeTagDaoImpl" />
+  <bean id="vMEntityDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDaoImpl" />
+  <bean id="vMInstanceDaoImpl" class="com.cloud.vm.dao.VMInstanceDaoImpl" />
+  <bean id="vMNetworkMapDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMNetworkMapDaoImpl" />
+  <bean id="vMReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDaoImpl" />
+  <bean id="vMRootDiskTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMRootDiskTagDaoImpl" />
+  <bean id="vMSnapshotDaoImpl" class="com.cloud.vm.snapshot.dao.VMSnapshotDaoImpl" />
+  <bean id="vMTemplateDetailsDaoImpl" class="com.cloud.storage.dao.VMTemplateDetailsDaoImpl" />
+  <bean id="vMTemplateHostDaoImpl" class="com.cloud.storage.dao.VMTemplateHostDaoImpl" />
+  <bean id="vMTemplatePoolDaoImpl" class="com.cloud.storage.dao.VMTemplatePoolDaoImpl" />
+  <bean id="vMTemplateZoneDaoImpl" class="com.cloud.storage.dao.VMTemplateZoneDaoImpl" />
+  <bean id="versionDaoImpl" class="com.cloud.upgrade.dao.VersionDaoImpl" />
+  <bean id="virtualRouterProviderDaoImpl" class="com.cloud.network.dao.VirtualRouterProviderDaoImpl" />
+  <bean id="vmRulesetLogDaoImpl" class="com.cloud.network.security.dao.VmRulesetLogDaoImpl" />
+  <bean id="volumeDaoImpl" class="com.cloud.storage.dao.VolumeDaoImpl" />
+  <bean id="volumeDetailsDaoImpl" class="com.cloud.storage.dao.VolumeDetailsDaoImpl" />
+  <bean id="volumeHostDaoImpl" class="com.cloud.storage.dao.VolumeHostDaoImpl" />
+  <bean id="volumeJoinDaoImpl" class="com.cloud.api.query.dao.VolumeJoinDaoImpl" />
+  <bean id="volumeReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VolumeReservationDaoImpl" />
+  <bean id="vpcDaoImpl" class="com.cloud.network.vpc.dao.VpcDaoImpl" />
+  <bean id="vpcGatewayDaoImpl" class="com.cloud.network.vpc.dao.VpcGatewayDaoImpl" />
+  <bean id="vpcOfferingDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingDaoImpl" />
+  <bean id="vpcOfferingServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingServiceMapDaoImpl" />
+  <bean id="vpcServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcServiceMapDaoImpl" />
+  <bean id="vpnUserDaoImpl" class="com.cloud.network.dao.VpnUserDaoImpl" />
+  <bean id="applicationLbRuleDaoImpl" class="org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDaoImpl" />
+  <bean id="networkOfferingDetailsDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingDetailsDaoImpl" />
+  <bean id="serviceOfferingDetailsDaoImpl" class="com.cloud.service.dao.ServiceOfferingDetailsDaoImpl"/>
+
+  <!--
+    Checkers
+  -->
+  <bean id="encryptionSecretKeyChecker" class="com.cloud.utils.crypt.EncryptionSecretKeyChecker" />
+  <bean id="StaticRoleBasedAPIAccessChecker" class="org.apache.cloudstack.acl.StaticRoleBasedAPIAccessChecker"/>
+  <bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
+  <bean id="domainChecker" class="com.cloud.acl.DomainChecker" />
+  <bean id="affinityGroupAccessChecker" class="com.cloud.acl.AffinityGroupAccessChecker" />
+  
+  <!--
+    Authenticators
+  --> 
+  <bean id="basicAgentAuthManager" class="com.cloud.agent.manager.authn.impl.BasicAgentAuthManager">
+    <property name="name" value="BASIC"/>
+  </bean>
+  <bean id="MD5UserAuthenticator" class="com.cloud.server.auth.MD5UserAuthenticator">
+    <property name="name" value="MD5"/>
+  </bean>
+  <bean id="LdapAuthenticator" class="org.apache.cloudstack.ldap.LdapAuthenticator">
+    <property name="name" value="LDAP"/>
+  </bean>
+  <bean id="SHA256SaltedUserAuthenticator" class="com.cloud.server.auth.SHA256SaltedUserAuthenticator">
+    <property name="name" value="SHA256SALT"/>
+  </bean>
+  <bean id="PlainTextUserAuthenticator" class="com.cloud.server.auth.PlainTextUserAuthenticator">
+    <property name="name" value="PLAINTEXT"/>
+  </bean>
+  <bean id="LdapManager" class="org.apache.cloudstack.ldap.LdapManagerImpl" />
+  <bean id="LdapUserManager" class="org.apache.cloudstack.ldap.LdapUserManager" />
+  <bean id="LdapContextFactory" class="org.apache.cloudstack.ldap.LdapContextFactory" />
+  <bean id="LdapConfigurationDao" class="org.apache.cloudstack.ldap.dao.LdapConfigurationDaoImpl" />
+  <bean id="LdapConfiguration" class="org.apache.cloudstack.ldap.LdapConfiguration" />
+
+  <!--
+      Network Elements
+  -->
+  <bean id="Ovs" class="com.cloud.network.element.OvsElement">
+    <property name="name" value="Ovs"/>
+  </bean>
+  <bean id="SecurityGroupProvider" class="com.cloud.network.element.SecurityGroupElement">
+    <property name="name" value="SecurityGroupProvider"/>
+  </bean>
+  <bean id="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement">
+    <property name="name" value="VirtualRouter"/>
+  </bean>
+  <bean id="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement">
+    <property name="name" value="VpcVirtualRouter"/>
+  </bean>
+  <bean id="elasticLoadBalancerElement" class="com.cloud.network.element.ElasticLoadBalancerElement">
+    <property name="name" value="ElasticLoadBalancerElement"/>
+  </bean>
+  <bean id="InternalLbVm" class="org.apache.cloudstack.network.element.InternalLoadBalancerElement">
+    <property name="name" value="InternalLbVm"/>
+  </bean>
+
+  <!-- 
+    General allocators
+  -->             
+  <bean id="firstFitAllocator" class="com.cloud.agent.manager.allocator.impl.FirstFitAllocator" />
+  <bean id="randomAllocator" class="com.cloud.agent.manager.allocator.impl.RandomAllocator" />
+
+  <!--
+     Host Allocators
+  -->
+  <bean id="FirstFitRouting" class="com.cloud.agent.manager.allocator.impl.FirstFitRoutingAllocator">
+    <property name="name" value="FirstFitRouting"/>
+  </bean>
+  
+  <!--
+    Storage pool allocators
+  -->
+  <bean id="LocalStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.LocalStoragePoolAllocator">
+    <property name="name" value="LocalStorage"/>
+  </bean>
+  <bean id="clusterScopeStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ClusterScopeStoragePoolAllocator" />
+  <bean id="zoneWideStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ZoneWideStoragePoolAllocator" />
+  <bean id="garbageCollectingStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.GarbageCollectingStoragePoolAllocator">
+    <property name="name" value="GCStorage"/>
+  </bean>
+
+  <bean id="UserConcentratedAllocator" class="com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator">
+    <property name="name" value="UserFirst"/>
+  </bean>
+  
+  
+  <bean id="recreatableFencer" class="com.cloud.ha.RecreatableFencer" />
+  <bean id="recreateHostAllocator" class="com.cloud.agent.manager.allocator.impl.RecreateHostAllocator" />
+  <bean id="secondaryStorageVmDefaultAllocator" class="com.cloud.storage.secondary.SecondaryStorageVmDefaultAllocator" />
+
+
+  <!--
+    Misc allocator & Adapters
+  -->
+  <bean id="ConsoleProxyAllocator" class="com.cloud.consoleproxy.ConsoleProxyBalanceAllocator">
+    <property name="name" value="Balance"/>
+  </bean>
+
+  <bean id="ExternalIpAddressAllocator" class="com.cloud.network.ExternalIpAddressAllocator">
+    <property name="name" value="Basic"/>
+  </bean>
+
+  <bean id="hypervisorTemplateAdapter" class="com.cloud.template.HypervisorTemplateAdapter" />
+  <bean id="clusterAlertAdapter" class="com.cloud.alert.ClusterAlertAdapter" />
+  <bean id="consoleProxyAlertAdapter" class="com.cloud.alert.ConsoleProxyAlertAdapter" />
+  <bean id="secondaryStorageVmAlertAdapter" class="com.cloud.alert.SecondaryStorageVmAlertAdapter" />
+  <bean id="clusterServiceServletAdapter" class="com.cloud.cluster.ClusterServiceServletAdapter" />
+
+  <!--
+    Investigators
+  -->
+  <bean id="CheckOnAgentInvestigator" class="com.cloud.ha.CheckOnAgentInvestigator">
+    <property name="name" value="SimpleInvestigator"/>
+  </bean>
+
+  <bean id="XenServerInvestigator" class="com.cloud.ha.XenServerInvestigator">
+    <property name="name" value="XenServerInvestigator"/>
+  </bean>
+  
+  <bean id="KVMInvestigator" class="com.cloud.ha.KVMInvestigator">
+    <property name="name" value="KVMInvestigator"/>
+  </bean>
+
+  <bean id="UserVmDomRInvestigator" class="com.cloud.ha.UserVmDomRInvestigator">
+    <property name="name" value="PingInvestigator"/>
+  </bean>
+
+  <bean id="ManagementIPSystemVMInvestigator" class="com.cloud.ha.ManagementIPSystemVMInvestigator">
+    <property name="name" value="ManagementIPSysVMInvestigator"/>
+  </bean>
+
+  <!--
+    Fencers
+  -->
+  <bean id="XenServerFencer" class="com.cloud.ha.XenServerFencer">
+    <property name="name" value="XenServerFenceBuilder"/>
+  </bean>
+  <bean id="KVMFencer" class="com.cloud.ha.KVMFencer">
+    <property name="name" value="KVMFenceBuilder"/>
+  </bean>
+  <bean id="OvmFencer" class="com.cloud.ovm.hypervisor.OvmFencer">
+    <property name="name" value="OvmFenceBuilder"/>
+  </bean>
+
+  <!--
+    Discovers
+  -->
+  <bean id="XcpServerDiscoverer" class="com.cloud.hypervisor.xen.discoverer.XcpServerDiscoverer">
+    <property name="name" value="XCP Agent"/>
+  </bean>
+
+  <bean id="SecondaryStorageDiscoverer" class="org.apache.cloudstack.storage.resource.SecondaryStorageDiscoverer">
+    <property name="name" value="SecondaryStorage"/>
+  </bean>
+
+  <bean id="KvmServerDiscoverer" class="com.cloud.hypervisor.kvm.discoverer.KvmServerDiscoverer">
+    <property name="name" value="KVM Agent"/>
+  </bean>
+
+  <bean id="LxcServerDiscoverer" class="com.cloud.hypervisor.kvm.discoverer.LxcServerDiscoverer">
+    <property name="name" value="Lxc Discover"/>
+  </bean>
+
+  <bean id="OvmDiscoverer" class="com.cloud.ovm.hypervisor.OvmDiscoverer">
+    <property name="name" value="Ovm Discover"/>
+  </bean>
+
+  <bean id="dummyHostDiscoverer" class="com.cloud.resource.DummyHostDiscoverer">
+    <property name="name" value="dummyHostDiscoverer" />
+  </bean>
+
+  <!--
+    Deployment planners
+  -->
+  <bean id="UserDispersingPlanner" class="com.cloud.deploy.UserDispersingPlanner">
+    <property name="name" value="UserDispersingPlanner"/>
+  </bean>
+  
+  <bean id="UserConcentratedPodPlanner" class="com.cloud.deploy.UserConcentratedPodPlanner">
+    <property name="name" value="UserConcentratedPodPlanner"/>
+  </bean>
+
+  <bean id="ImplicitDedicationPlanner" class="com.cloud.deploy.ImplicitDedicationPlanner">
+    <property name="name" value="ImplicitDedicationPlanner"/>
+  </bean>
+
+  <bean id="clusterBasedAgentLoadBalancerPlanner" class="com.cloud.cluster.agentlb.ClusterBasedAgentLoadBalancerPlanner">
+    <property name="name" value="ClusterBasedAgentLoadBalancerPlanner"/>
+  </bean>
+
+  <!--
+    Network Gurus
+  -->
+  <bean id="StorageNetworkGuru" class="com.cloud.network.guru.StorageNetworkGuru">
+    <property name="name" value="StorageNetworkGuru"/>
+  </bean>
+  <bean id="ExternalGuestNetworkGuru" class="com.cloud.network.guru.ExternalGuestNetworkGuru">
+    <property name="name" value="ExternalGuestNetworkGuru"/>
+  </bean>
+  <bean id="PublicNetworkGuru" class="com.cloud.network.guru.PublicNetworkGuru">
+    <property name="name" value="PublicNetworkGuru"/>
+  </bean>
+  <bean id="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru">
+    <property name="name" value="PodBasedNetworkGuru"/>
+  </bean>
+  <bean id="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru">
+    <property name="name" value="ControlNetworkGuru"/>
+  </bean>
+  <bean id="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru">
+    <property name="name" value="DirectNetworkGuru"/>
+  </bean>
+  <bean id="DirectPodBasedNetworkGuru" class="com.cloud.network.guru.DirectPodBasedNetworkGuru">
+    <property name="name" value="DirectPodBasedNetworkGuru"/>
+  </bean>
+  <bean id="OvsGuestNetworkGuru" class="com.cloud.network.guru.OvsGuestNetworkGuru">
+    <property name="name" value="OvsGuestNetworkGuru"/>
+  </bean>
+  <bean id="PrivateNetworkGuru" class="com.cloud.network.guru.PrivateNetworkGuru">
+    <property name="name" value="PrivateNetworkGuru"/>
+  </bean>
+ 
+  <!--
+   Hypervisor Gurus
+  -->
+  <bean id="XenServerGuru" class="com.cloud.hypervisor.XenServerGuru">
+    <property name="name" value="XenServerGuru"/>
+  </bean>
+  
+  <bean id="KVMGuru" class="com.cloud.hypervisor.KVMGuru">
+    <property name="name" value="KVMGuru"/>
+  </bean>
+
+  <bean id="LXCGuru" class="com.cloud.hypervisor.LXCGuru">
+    <property name="name" value="LXCGuru"/>
+  </bean>
+
+  <bean id="OvmGuru" class="com.cloud.ovm.hypervisor.OvmGuru">
+    <property name="name" value="OvmGuru"/>
+  </bean>
+
+  <!--=====================================================================================================-->
+  <!--                                                                                                     -->
+  <!--                           Storage Subsystem Components and Helpers                                  -->
+  <!--                                                                                                     -->
+  <!--=====================================================================================================-->
+
+  <!--Filesystem types-->
+  <bean id="iSCSI" class="org.apache.cloudstack.storage.datastore.type.ISCSI" />
+  <bean id="networkFileSystem" class="org.apache.cloudstack.storage.datastore.type.NetworkFileSystem" />
+
+  <!--Image formats-->
+  <bean id="ISO" class="org.apache.cloudstack.storage.image.format.ISO" />
+  <bean id="OVA" class="org.apache.cloudstack.storage.image.format.OVA" />
+  <bean id="QCOW2" class="org.apache.cloudstack.storage.image.format.QCOW2" />
+  <bean id="VHD" class="org.apache.cloudstack.storage.image.format.VHD" />
+  <bean id="VHDX" class="org.apache.cloudstack.storage.image.format.VHDX" />
+  <bean id="unknown" class="org.apache.cloudstack.storage.image.format.Unknown" />
+
+  <!--Data Store Services -->
+  <bean id="snapshotServiceImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotServiceImpl"
+        depends-on="snapshotStateMachineManagerImpl, snapshotDataFactoryImpl, dataStoreManagerImpl, dataMotionServiceImpl, objectInDataStoreManagerImpl"/>
+  <bean id="templateServiceImpl" class="org.apache.cloudstack.storage.image.TemplateServiceImpl"
+        depends-on="dataObjectManagerImpl, dataStoreManagerImpl, dataMotionServiceImpl, objectInDataStoreManagerImpl, defaultEndPointSelector, templateDataFactoryImpl"/>
+  <bean id="volumeServiceImpl" class="org.apache.cloudstack.storage.volume.VolumeServiceImpl"
+        depends-on="snapshotManagerImpl, dataMotionServiceImpl"/>
+
+  <bean id="xenserverSnapshotStrategy" class="org.apache.cloudstack.storage.snapshot.XenserverSnapshotStrategy" />
+
+  <!--Data Store Factory-->
+  <bean id="templateDataFactoryImpl" class="org.apache.cloudstack.storage.image.TemplateDataFactoryImpl" />
+  <bean id="snapshotDataFactoryImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotDataFactoryImpl"
+        depends-on="dataStoreManagerImpl, snapshotDataStoreDaoImpl, volumeDataFactoryImpl"/>
+  <bean id="volumeDataFactoryImpl" class="org.apache.cloudstack.storage.volume.VolumeDataFactoryImpl" />
+
+  <bean id="objectInDataStoreManagerImpl" class="org.apache.cloudstack.storage.datastore.ObjectInDataStoreManagerImpl" />
+  <bean id="dataObjectManagerImpl" class="org.apache.cloudstack.storage.datastore.DataObjectManagerImpl" />
+
+  <!--Data Store Helpers-->
+  <bean id="primaryDataStoreHelper" class="org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper" />
+  <bean id="imageStoreHelper" class="org.apache.cloudstack.storage.image.datastore.ImageStoreHelper" />
+  <bean id="imageFormatHelper" class="org.apache.cloudstack.storage.image.format.ImageFormatHelper" />
+
+  <bean id="storageCacheRandomAllocator" class="org.apache.cloudstack.storage.cache.allocator.StorageCacheRandomAllocator" />
+  <bean id="storageCacheManagerImpl" class="org.apache.cloudstack.storage.cache.manager.StorageCacheManagerImpl"  />
+  <bean id="StorageCacheReplacementAlgorithm" class="org.apache.cloudstack.storage.cache.manager.StorageCacheReplacementAlgorithmLRU" />
+
+  <bean id="snapshotStateMachineManagerImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotStateMachineManagerImpl" />
+  <bean id="defaultEndPointSelector" class="org.apache.cloudstack.storage.endpoint.DefaultEndPointSelector" />
+
+
+  <bean id="ancientDataMotionStrategy" class="org.apache.cloudstack.storage.motion.AncientDataMotionStrategy" />
+  <bean id="xenserverStorageMotionStrategy" class="org.apache.cloudstack.storage.motion.XenServerStorageMotionStrategy" />
+
+  <!--Data Motion Services-->
+  <bean id="dataMotionServiceImpl" class="org.apache.cloudstack.storage.motion.DataMotionServiceImpl">
+    <property name="strategies">
+      <list>
+        <ref local="ancientDataMotionStrategy"/>
+        <ref local="xenserverStorageMotionStrategy"/>
+      </list>
+    </property>
+  </bean>
+
+  <!--
+    Data Store Provider Manager
+  -->
+  <bean id="primaryDataStoreProviderMgr"
+        class="org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreProviderManagerImpl"/>
+  <bean id="imageStoreProviderMgr" class="org.apache.cloudstack.storage.image.manager.ImageStoreProviderManagerImpl"/>
+
+  <bean id="dataStoreManagerImpl" class="org.apache.cloudstack.storage.datastore.DataStoreManagerImpl"
+        depends-on="dataStoreProviderManager">
+    <property name="primaryStoreMgr" ref="primaryDataStoreProviderMgr"/>
+    <property name="imageDataStoreMgr" ref="imageStoreProviderMgr"/>
+  </bean>
+
+  <bean id="cloudStackPrimaryDataStoreProviderImpl"
+        class="org.apache.cloudstack.storage.datastore.provider.CloudStackPrimaryDataStoreProviderImpl"/>
+
+  <bean id="dataStoreProviderManager"
+        class="org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManagerImpl">
+    <property name="providers">
+      <list>
+        <!--Data Store Providers-->
+        <ref bean="cloudStackPrimaryDataStoreProviderImpl"/>
+      </list>
+    </property>
+  </bean>
+
+  <!--
+    Managers
+  -->
+  <bean id="accountManagerImpl" class="com.cloud.user.AccountManagerImpl" >
+    <property name="UserAuthenticators" value="#{userAuthenticators.Adapters}" />
+    <property name="UserPasswordEncoders" value="#{userPasswordEncoders.Adapters}" />
+    <property name="SecurityCheckers" value="#{securityCheckers.Adapters}" />
+  </bean>
+
+  <bean id="managementServerImpl" class ="com.cloud.server.ManagementServerImpl">
+    <property name="UserAuthenticators" value="#{userAuthenticators.Adapters}" />
+    <property name="UserPasswordEncoders" value="#{userPasswordEncoders.Adapters}" />
+    <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
+    <property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
+    <property name="Planners" value="#{deploymentPlanners.Adapters}" />
+  </bean>
+
+  <bean id="storageManagerImpl" class="com.cloud.storage.StorageManagerImpl"/>
+  
+  <bean id="volumeOrchestrator" class="org.apache.cloudstack.engine.orchestration.VolumeOrchestrator">
+    <property name="PodAllocators" value="#{podAllocators.Adapters}" />
+    <property name="StoragePoolAllocators" value="#{storagePoolAllocators.Adapters}" />
+  </bean>
+
+  <bean id="FirstFitPlanner" class="com.cloud.deploy.FirstFitPlanner">
+    <property name="name" value="FirstFitPlanner"/>
+  </bean>
+
+  <bean id="resourceManagerImpl" class="com.cloud.resource.ResourceManagerImpl" >
+    <property name="Discoverers" value="#{resourceDiscoverers.Adapters}" />
+  </bean>
+
+  <bean id="highAvailabilityManagerExtImpl" class="com.cloud.ha.HighAvailabilityManagerExtImpl" >
+    <property name="Investigators" value="#{haInvestigators.Adapters}" />
+    <property name="FenceBuilders" value="#{haFenceBuilders.Adapters}" />
+  </bean>
+
+  <bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl" >
+    <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
+  </bean>
+
+  <bean id="networkOrchestrator" class="org.apache.cloudstack.engine.orchestration.NetworkOrchestrator" >
+    <property name="NetworkGurus" value="#{networkGurus.Adapters}" />
+    <property name="NetworkElements" value="#{networkElements.Adapters}" />
+    <property name="IpDeployers" value="#{ipDeployers.Adapters}" />
+    <property name="DhcpProviders" value="#{dhcpProviders.Adapters}" />
+  </bean>
+
+  <bean id="ipAddressManagerImpl" class="com.cloud.network.IpAddressManagerImpl" >
+  </bean>
+  <bean id="networkModelImpl" class="com.cloud.network.NetworkModelImpl">
+    <property name="NetworkElements" value="#{networkElements.Adapters}" />
+  </bean>
+
+  <bean id="configurationServerImpl" class="com.cloud.server.ConfigurationServerImpl" />
+
+  <bean id="clusterManagerImpl" class="com.cloud.cluster.ClusterManagerImpl" />
+  <bean id="clusteredAgentManagerImpl" class="com.cloud.agent.manager.ClusteredAgentManagerImpl" />
+
+  <bean id="userVmManagerImpl" class="com.cloud.vm.UserVmManagerImpl" />
+  <bean id="consoleProxyManagerImpl" class="com.cloud.consoleproxy.ConsoleProxyManagerImpl" />
+  <bean id="securityGroupManagerImpl2" class="com.cloud.network.security.SecurityGroupManagerImpl2" />
+  <bean id="premiumSecondaryStorageManagerImpl" class="com.cloud.secstorage.PremiumSecondaryStorageManagerImpl" />
+
+  <bean id="ipv6AddressManagerImpl" class="com.cloud.network.Ipv6AddressManagerImpl" />
+
+  <bean id="apiRateLimitServiceImpl" class="org.apache.cloudstack.ratelimit.ApiRateLimitServiceImpl"/>
+  <bean id="alertManagerImpl" class="com.cloud.alert.AlertManagerImpl" />
+  <bean id="autoScaleManagerImpl" class="com.cloud.network.as.AutoScaleManagerImpl" />
+  <bean id="capacityManagerImpl" class="com.cloud.capacity.CapacityManagerImpl" />
+  <bean id="clusterFenceManagerImpl" class="com.cloud.cluster.ClusterFenceManagerImpl" />
+  <bean id="configurationManagerImpl" class="com.cloud.configuration.ConfigurationManagerImpl" />
+
+  <bean id="elasticLoadBalancerManagerImpl" class="com.cloud.network.lb.ElasticLoadBalancerManagerImpl" />
+  <bean id="entityManagerImpl" class="com.cloud.dao.EntityManagerImpl" />
+  <bean id="externalDeviceUsageManagerImpl" class="com.cloud.network.ExternalDeviceUsageManagerImpl" />
+  <bean id="externalNetworkDeviceManagerImpl" class="com.cloud.network.ExternalNetworkDeviceManagerImpl" />
+  <bean id="firewallManagerImpl" class="com.cloud.network.firewall.FirewallManagerImpl" />
+  <bean id="hypervisorGuruManagerImpl" class="com.cloud.hypervisor.HypervisorGuruManagerImpl" />
+  <bean id="identityServiceImpl" class="com.cloud.uuididentity.IdentityServiceImpl" />
+  <bean id="keystoreManagerImpl" class="com.cloud.keystore.KeystoreManagerImpl" />
+  <bean id="loadBalancingRulesManagerImpl" class="com.cloud.network.lb.LoadBalancingRulesManagerImpl" />
+  <bean id="networkACLManagerImpl" class="com.cloud.network.vpc.NetworkACLManagerImpl" />
+  <bean id="networkACLServiceImpl" class="com.cloud.network.vpc.NetworkACLServiceImpl" />
+  <bean id="networkServiceImpl" class="com.cloud.network.NetworkServiceImpl" />
+  <bean id="networkUsageManagerImpl" class="com.cloud.network.NetworkUsageManagerImpl" />
+  <bean id="oCFS2ManagerImpl" class="com.cloud.storage.OCFS2ManagerImpl" />
+  <bean id="ovsTunnelManagerImpl" class="com.cloud.network.ovs.OvsTunnelManagerImpl" />
+  <bean id="projectManagerImpl" class="com.cloud.projects.ProjectManagerImpl" />
+  <bean id="queryManagerImpl" class="com.cloud.api.query.QueryManagerImpl" />
+  <bean id="regionManagerImpl" class="org.apache.cloudstack.region.RegionManagerImpl" />
+  <bean id="regionServiceImpl" class="org.apache.cloudstack.region.RegionServiceImpl" />
+  <bean id="remoteAccessVpnManagerImpl" class="com.cloud.network.vpn.RemoteAccessVpnManagerImpl" />
+  <bean id="resourceLimitManagerImpl" class="com.cloud.resourcelimit.ResourceLimitManagerImpl" />
+  <bean id="rulesManagerImpl" class="com.cloud.network.rules.RulesManagerImpl" />
+    <bean id="site2SiteVpnManagerImpl" class="com.cloud.network.vpn.Site2SiteVpnManagerImpl" />
+  <bean id="snapshotManagerImpl" class="com.cloud.storage.snapshot.SnapshotManagerImpl" />
+  <bean id="snapshotSchedulerImpl" class="com.cloud.storage.snapshot.SnapshotSchedulerImpl" />
+  <bean id="storageNetworkManagerImpl" class="com.cloud.network.StorageNetworkManagerImpl" />
+  <bean id="taggedResourceManagerImpl" class="com.cloud.tags.TaggedResourceManagerImpl" />
+  <bean id="resourceMetaDataManagerImpl" class="com.cloud.metadata.ResourceMetaDataManagerImpl" />
+  <bean id="templateManagerImpl" class="com.cloud.template.TemplateManagerImpl" />
+  <bean id="uploadMonitorImpl" class="com.cloud.storage.upload.UploadMonitorImpl" />
+  <bean id="usageServiceImpl" class="com.cloud.usage.UsageServiceImpl" />
+  <bean id="virtualNetworkApplianceManagerImpl" class="com.cloud.network.router.VirtualNetworkApplianceManagerImpl" />
+  <bean id="vpcManagerImpl" class="com.cloud.network.vpc.VpcManagerImpl" />
+  <bean id="vpcVirtualNetworkApplianceManagerImpl" class="com.cloud.network.router.VpcVirtualNetworkApplianceManagerImpl" />
+
+  <!-- Async management -->
+  <bean id="asyncJobDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.AsyncJobDaoImpl" />
+  <bean id="asyncJobJournalDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.AsyncJobJournalDaoImpl" />
+  <bean id="asyncJobJoinMapDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDaoImpl" />
+  <bean id="asyncJobManagerImpl" class="org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl"/>
+  <bean id="asyncJobMonitor" class="org.apache.cloudstack.framework.jobs.impl.AsyncJobMonitor"/>
+  <bean id="syncQueueDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.SyncQueueDaoImpl" />
+  <bean id="syncQueueItemDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDaoImpl" />
+  <bean id="syncQueueManagerImpl" class="org.apache.cloudstack.framework.jobs.impl.SyncQueueManagerImpl" />
+
+  <bean id="ApiAsyncJobDispatcher" class="com.cloud.api.ApiAsyncJobDispatcher">
+    <property name="name" value="ApiAsyncJobDispatcher" />
+  </bean>
+
+
+  <!--
+    Misc components
+  -->
+  <bean id="actionEventUtils" class="com.cloud.event.ActionEventUtils" />
+  <bean id="alertGenerator" class="com.cloud.event.AlertGenerator" />
+  <bean id="apiDBUtils" class="com.cloud.api.ApiDBUtils" />
+  <bean id="apiDiscoveryServiceImpl" class="org.apache.cloudstack.discovery.ApiDiscoveryServiceImpl" />
+  <bean id="apiDispatcher" class="com.cloud.api.ApiDispatcher" />
+  <bean id="apiResponseHelper" class="com.cloud.api.ApiResponseHelper" />
+  <bean id="apiServer" class="com.cloud.api.ApiServer" />
+  <bean id="apiServlet" class="com.cloud.api.ApiServlet" />
+  <bean id="bAREMETAL" class="org.apache.cloudstack.storage.image.format.BAREMETAL" />
+  <bean id="cloudOrchestrator" class="org.apache.cloudstack.engine.orchestration.CloudOrchestrator" />
+  <bean id="clusterRestService" class="org.apache.cloudstack.engine.rest.service.api.ClusterRestService" />
+  <bean id="consoleProxyServlet" class="com.cloud.servlet.ConsoleProxyServlet" />
+  <bean id="dataCenterResourceManagerImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceManagerImpl" />
+  <bean id="dataDisk" class="org.apache.cloudstack.engine.subsystem.api.storage.type.DataDisk" />
+
+
+  <bean id="podRestService" class="org.apache.cloudstack.engine.rest.service.api.PodRestService" />
+  <bean id="iso" class="org.apache.cloudstack.engine.subsystem.api.storage.type.Iso" />
+  <bean id="networkRestService" class="org.apache.cloudstack.engine.rest.service.api.NetworkRestService" />
+  <bean id="provisioningServiceImpl" class="org.apache.cloudstack.engine.service.api.ProvisioningServiceImpl" />
+  <bean id="rootDisk" class="org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk" />
+  <bean id="registerCompleteServlet" class="com.cloud.servlet.RegisterCompleteServlet" />
+  <bean id="statsCollector" class="com.cloud.server.StatsCollector" />
+  <bean id="storagePoolAutomationImpl" class="com.cloud.storage.StoragePoolAutomationImpl" />
+  <bean id="usageEventUtils" class="com.cloud.event.UsageEventUtils" />
+  <bean id="vMEntityManagerImpl" class="org.apache.cloudstack.engine.cloud.entity.api.VMEntityManagerImpl" />
+  <bean id="virtualMachineEntityImpl" class="org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl" />
+  <bean id="virtualMachineRestService" class="org.apache.cloudstack.engine.rest.service.api.VirtualMachineRestService" />
+  <bean id="volumeRestService" class="org.apache.cloudstack.engine.rest.service.api.VolumeRestService" />
+  <bean id="volumeTypeHelper" class="org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper" />
+  <bean id="zoneRestService" class="org.apache.cloudstack.engine.rest.service.api.ZoneRestService" />
+  <bean id="cloudZonesStartupProcessor" class="com.cloud.hypervisor.CloudZonesStartupProcessor" />
+  <bean id="managementServerNode" class="org.apache.cloudstack.utils.identity.ManagementServerNode" />
+  <bean id="testingAllocator" class="com.cloud.agent.manager.allocator.impl.TestingAllocator" />
+  <bean id="domainManagerImpl" class="com.cloud.user.DomainManagerImpl" />
+  <bean id="downloadMonitorImpl" class="com.cloud.storage.download.DownloadMonitorImpl" />
+  <bean id="lBHealthCheckManagerImpl" class="com.cloud.network.lb.LBHealthCheckManagerImpl" />
+  <bean id="volumeApiServiceImpl" class="com.cloud.storage.VolumeApiServiceImpl"/>
+  <bean id="ApplicationLoadBalancerService" class="org.apache.cloudstack.network.lb.ApplicationLoadBalancerManagerImpl" />
+  <bean id="InternalLoadBalancerVMManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl" />
+
+  <bean id="vMSnapshotManagerImpl" class="com.cloud.vm.snapshot.VMSnapshotManagerImpl" />
+
+
+<!--=======================================================================================================-->
+<!--                                                                                                       -->
+<!--                           Module-basis OSS/non-OSS Common components                                  -->
+<!--                                                                                                       -->
+<!--=======================================================================================================-->
+
+  <!--
+    Baremetal components
+  -->
+  
+  <bean id="BareMetalDhcp" class="com.cloud.baremetal.networkservice.BaremetalDhcpElement">
+    <property name="name" value="BareMetalDhcp"/>
+  </bean>
+  <bean id="BareMetalPxe" class="com.cloud.baremetal.networkservice.BaremetalPxeElement">
+    <property name="name" value="BareMetalPxe"/>
+  </bean>
+  <bean id="BareMetalUserdata" class="com.cloud.baremetal.networkservice.BaremetalUserdataElement">
+      <property name="name" value="BareMetalUserdata"/>
+  </bean>
+
+  <bean id="BareMetalTemplateAdapter" class="com.cloud.baremetal.manager.BareMetalTemplateAdapter" />
+
+  <bean id="BareMetalDiscoverer" class="com.cloud.baremetal.manager.BareMetalDiscoverer">
+    <property name="name" value="Bare Metal Agent"/>
+  </bean>
+
+  <bean id="BareMetalPlanner" class="com.cloud.baremetal.manager.BareMetalPlanner">
+    <property name="name" value="BareMetalPlanner"/>
+  </bean>
+  
+  <bean id="BaremetalGuru" class="com.cloud.baremetal.manager.BareMetalGuru">
+    <property name="name" value="BaremetalGuru"/>
+  </bean>
+
+  <bean id="BaremetalManager" class="com.cloud.baremetal.manager.BaremetalManagerImpl"/>
+  <bean id="BaremetalDhcpManager" class="com.cloud.baremetal.networkservice.BaremetalDhcpManagerImpl"/>
+  <bean id="BaremetalKickStartPxeService" class="com.cloud.baremetal.networkservice.BaremetalKickStartServiceImpl"/>
+  <bean id="BaremetalPingPxeService" class="com.cloud.baremetal.networkservice.BareMetalPingServiceImpl" />
+  <bean id="BaremetalPxeManager" class="com.cloud.baremetal.networkservice.BaremetalPxeManagerImpl" /> 
+    
+  <bean id="BAREMETAL" class="org.apache.cloudstack.storage.image.format.BAREMETAL" />
+  <bean id="baremetalDhcpDaoImpl" class="com.cloud.baremetal.database.BaremetalDhcpDaoImpl" />
+  <bean id="baremetalPxeDaoImpl" class="com.cloud.baremetal.database.BaremetalPxeDaoImpl" />
+
+  <bean id="UcsManager" class="com.cloud.ucs.manager.UcsManagerImpl" />
+
+  <bean id="AffinityGroupServiceImpl" class="org.apache.cloudstack.affinity.AffinityGroupServiceImpl">
+  	<property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
+  </bean>
+  <bean id="DeploymentPlanningManager" class="com.cloud.deploy.DeploymentPlanningManagerImpl">
+    <property name="Planners" value="#{deploymentPlanners.Adapters}" />
+	<property name="AffinityGroupProcessors" value="#{affinityProcessors.Adapters}" />
+    <property name="StoragePoolAllocators" value="#{storagePoolAllocators.Adapters}" />
+    <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
+  </bean>
+  
+  <bean id="AffinityGroupJoinDaoImpl" class="com.cloud.api.query.dao.AffinityGroupJoinDaoImpl">
+  </bean>
+  <bean id="AffinityGroupDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupDaoImpl">
+  </bean>
+  <bean id="AffinityGroupVMMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDaoImpl">
+  </bean>
+  <bean id="AffinityGroupDomainMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDaoImpl">
+  </bean>
+  
+  <bean id="PlannerHostReservationDaoImpl" class="com.cloud.deploy.dao.PlannerHostReservationDaoImpl">
+  </bean>
+  
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 10afdcc..da4c03f 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -591,6 +591,12 @@ addBigSwitchVnsDevice=1
 deleteBigSwitchVnsDevice=1
 listBigSwitchVnsDevices=1
 
+#### ovs commands
+
+addOvsDevice=1
+deleteOvsDevice=1
+listOvsDevices=1
+
 #### host simulator commands
 
 configureSimulator=1

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml b/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
index 9180eeb..e60d93e 100644
--- a/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
+++ b/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
@@ -36,5 +36,7 @@
     </bean>
 
     <bean id="ovsTunnelManagerImpl" class="com.cloud.network.ovs.OvsTunnelManagerImpl" />
+    <bean id="ovsTunnelInterfaceDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" />
+    <bean id="ovsTunnelNetworkDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" />
     
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/src/com/cloud/api/response/OvsDeviceResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/api/response/OvsDeviceResponse.java b/plugins/network-elements/ovs/src/com/cloud/api/response/OvsDeviceResponse.java
new file mode 100644
index 0000000..c0901b2
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/api/response/OvsDeviceResponse.java
@@ -0,0 +1,65 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+
+import com.cloud.network.ovs.dao.OvsDeviceVO;
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+@EntityReference(value = OvsDeviceVO.class)
+public class OvsDeviceResponse extends BaseResponse {
+
+	@SerializedName(ApiConstants.OVS_DEVICE_ID)
+	@Param(description = "device id of the Ovs")
+	private String id;
+
+	@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
+	@Param(description = "the physical network to which this device belongs to")
+	private String physicalNetworkId;
+
+	@SerializedName(ApiConstants.OVS_DEVICE_NAME)
+	@Param(description = "device name")
+	private String deviceName;
+
+	@SerializedName(ApiConstants.HOST_NAME)
+	@Param(description = "the controller Ip address")
+	private String hostName;
+
+	public String getId() {
+		return this.id;
+	}
+
+	public void setId(String vnsDeviceId) {
+		this.id = vnsDeviceId;
+	}
+
+	public void setPhysicalNetworkId(String physicalNetworkId) {
+		this.physicalNetworkId = physicalNetworkId;
+	}
+
+	public void setDeviceName(String deviceName) {
+		this.deviceName = deviceName;
+	}
+
+	public void setHostName(String hostName) {
+		this.hostName = hostName;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/src/com/cloud/network/commands/AddOvsDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/commands/AddOvsDeviceCmd.java b/plugins/network-elements/ovs/src/com/cloud/network/commands/AddOvsDeviceCmd.java
new file mode 100644
index 0000000..1abc324
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/commands/AddOvsDeviceCmd.java
@@ -0,0 +1,116 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.commands;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
+
+import com.cloud.api.response.OvsDeviceResponse;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.element.OvsElementService;
+import com.cloud.network.ovs.dao.OvsDeviceVO;
+import com.cloud.user.UserContext;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "addDevice", responseObject = OvsDeviceResponse.class, description = "Adds a Ovs controller device")
+public class AddOvsDeviceCmd extends BaseAsyncCmd {
+	private static final String s_name = "adddeviceresponse";
+	@Inject
+	OvsElementService _ovsElementService;
+
+	// ///////////////////////////////////////////////////
+	// ////////////// API parameters /////////////////////
+	// ///////////////////////////////////////////////////
+
+	@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, required = true, description = "the Physical Network ID")
+	private Long physicalNetworkId;
+
+	@Parameter(name = ApiConstants.HOST_NAME, type = CommandType.STRING, required = true, description = "Hostname of ip address of the BigSwitch VNS Controller.")
+	private String host;
+
+	// ///////////////////////////////////////////////////
+	// ///////////////// Accessors ///////////////////////
+	// ///////////////////////////////////////////////////
+
+	public Long getPhysicalNetworkId() {
+		return physicalNetworkId;
+	}
+
+	public String getHost() {
+		return host;
+	}
+
+	// ///////////////////////////////////////////////////
+	// ///////////// API Implementation///////////////////
+	// ///////////////////////////////////////////////////
+	@Override
+	public void execute() throws ResourceUnavailableException,
+			InsufficientCapacityException, ServerApiException,
+			ConcurrentOperationException, ResourceAllocationException,
+			NetworkRuleConflictException {
+		try {
+			OvsDeviceVO ovsDeviceVO = _ovsElementService.addOvsDevice(this);
+			if (ovsDeviceVO != null) {
+				OvsDeviceResponse response = _ovsElementService
+						.createOvsDeviceResponse(ovsDeviceVO);
+				response.setObjectName("ovsdevice");
+				response.setResponseName(getCommandName());
+				this.setResponseObject(response);
+			}
+		} catch (InvalidParameterValueException invalidParamExcp) {
+			throw new ServerApiException(ApiErrorCode.PARAM_ERROR,
+					invalidParamExcp.getMessage());
+		} catch (CloudRuntimeException runtimeExcp) {
+			throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
+					runtimeExcp.getMessage());
+		}
+	}
+
+	@Override
+	public String getEventType() {
+		return EventTypes.EVENT_EXTERNAL_OVS_CONTROLLER_ADD;
+	}
+
+	@Override
+	public String getEventDescription() {
+		return "Adding an Ovs Controller";
+	}
+
+	@Override
+	public String getCommandName() {
+		return s_name;
+	}
+
+	@Override
+	public long getEntityOwnerId() {
+		return UserContext.current().getCaller().getId();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/src/com/cloud/network/commands/DeleteOvsDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/commands/DeleteOvsDeviceCmd.java b/plugins/network-elements/ovs/src/com/cloud/network/commands/DeleteOvsDeviceCmd.java
new file mode 100644
index 0000000..87eedfb
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/commands/DeleteOvsDeviceCmd.java
@@ -0,0 +1,110 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.commands;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.SuccessResponse;
+
+import com.cloud.api.response.OvsDeviceResponse;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.element.OvsElementService;
+import com.cloud.user.UserContext;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "deleteOvsDevice", responseObject = SuccessResponse.class, description = " delete a ovs device")
+public class DeleteOvsDeviceCmd extends BaseAsyncCmd {
+	private static final String s_name = "deleteovsdeviceresponse";
+	@Inject
+	OvsElementService _ovsElementService;
+
+	// ///////////////////////////////////////////////////
+	// ////////////// API parameters /////////////////////
+	// ///////////////////////////////////////////////////
+
+	@Parameter(name = ApiConstants.OVS_DEVICE_ID, type = CommandType.UUID, entityType = OvsDeviceResponse.class, required = true, description = "Ovs device ID")
+	private Long ovsDeviceId;
+
+	// ///////////////////////////////////////////////////
+	// ///////////////// Accessors ///////////////////////
+	// ///////////////////////////////////////////////////
+
+	public Long getOvsDeviceId() {
+		return ovsDeviceId;
+	}
+
+	// ///////////////////////////////////////////////////
+	// ///////////// API Implementation///////////////////
+	// ///////////////////////////////////////////////////
+	@Override
+	public void execute() throws ResourceUnavailableException,
+			InsufficientCapacityException, ServerApiException,
+			ConcurrentOperationException, ResourceAllocationException,
+			NetworkRuleConflictException {
+		try {
+			boolean result = _ovsElementService.deleteOvsDevice(this);
+			if (result) {
+				SuccessResponse response = new SuccessResponse(getCommandName());
+				response.setResponseName(getCommandName());
+				this.setResponseObject(response);
+			} else {
+				throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
+						"Failed to delete Ovs device.");
+			}
+
+		} catch (InvalidParameterValueException invalidParamExcp) {
+			throw new ServerApiException(ApiErrorCode.PARAM_ERROR,
+					invalidParamExcp.getMessage());
+		} catch (CloudRuntimeException runtimeExcp) {
+			throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
+					runtimeExcp.getMessage());
+		}
+	}
+
+	@Override
+	public String getEventType() {
+		return EventTypes.EVENT_EXTERNAL_OVS_CONTROLLER_DELETE;
+	}
+
+	@Override
+	public String getEventDescription() {
+		return "Deleting Ovs Controller";
+	}
+
+	@Override
+	public String getCommandName() {
+		return s_name;
+	}
+
+	@Override
+	public long getEntityOwnerId() {
+		return UserContext.current().getCaller().getId();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/src/com/cloud/network/commands/ListOvsDevicesCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/commands/ListOvsDevicesCmd.java b/plugins/network-elements/ovs/src/com/cloud/network/commands/ListOvsDevicesCmd.java
new file mode 100644
index 0000000..2adb33a
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/commands/ListOvsDevicesCmd.java
@@ -0,0 +1,114 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.api.response.OvsDeviceResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.element.OvsElementService;
+import com.cloud.network.ovs.dao.OvsDeviceVO;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "listOvsDevices", responseObject = OvsDeviceResponse.class, description = "Lists Ovs devices")
+public class ListOvsDevicesCmd extends BaseListCmd {
+	public static final Logger s_logger = Logger
+			.getLogger(ListOvsDevicesCmd.class.getName());
+	private static final String s_name = "listovsdeviceresponse";
+	@Inject
+	OvsElementService _ovsElementService;
+
+	// ///////////////////////////////////////////////////
+	// ////////////// API parameters /////////////////////
+	// ///////////////////////////////////////////////////
+
+	@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the Physical Network ID")
+	private Long physicalNetworkId;
+
+	@Parameter(name = ApiConstants.OVS_DEVICE_ID, type = CommandType.UUID, entityType = OvsDeviceResponse.class, description = "ovs device ID")
+	private Long ovsDeviceId;
+
+	// ///////////////////////////////////////////////////
+	// ///////////////// Accessors ///////////////////////
+	// ///////////////////////////////////////////////////
+
+	public Long getOvsDeviceId() {
+		return ovsDeviceId;
+	}
+
+	public Long getPhysicalNetworkId() {
+		return physicalNetworkId;
+	}
+
+	// ///////////////////////////////////////////////////
+	// ///////////// API Implementation///////////////////
+	// ///////////////////////////////////////////////////
+	@Override
+	public void execute() throws ResourceUnavailableException,
+			InsufficientCapacityException, ServerApiException,
+			ConcurrentOperationException, ResourceAllocationException,
+			NetworkRuleConflictException {
+		try {
+			List<OvsDeviceVO> ovsDevices = _ovsElementService
+					.listOvsDevices(this);
+			ListResponse<OvsDeviceResponse> response = new ListResponse<OvsDeviceResponse>();
+			List<OvsDeviceResponse> ovsDevicesResponse = new ArrayList<OvsDeviceResponse>();
+
+			if (ovsDevices != null && !ovsDevices.isEmpty()) {
+				for (OvsDeviceVO ovsDeviceVO : ovsDevices) {
+					OvsDeviceResponse ovsDeviceResponse = _ovsElementService
+							.createOvsDeviceResponse(ovsDeviceVO);
+					ovsDevicesResponse.add(ovsDeviceResponse);
+				}
+			}
+
+			response.setResponses(ovsDevicesResponse);
+			response.setResponseName(getCommandName());
+			this.setResponseObject(response);
+		} catch (InvalidParameterValueException invalidParamExcp) {
+			throw new ServerApiException(ApiErrorCode.PARAM_ERROR,
+					invalidParamExcp.getMessage());
+		} catch (CloudRuntimeException runtimeExcp) {
+			throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
+					runtimeExcp.getMessage());
+		}
+	}
+
+	@Override
+	public String getCommandName() {
+		return s_name;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index 18b7a90..0ec54e3 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -16,12 +16,14 @@
 // under the License.
 package com.cloud.network.element;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import com.cloud.api.response.OvsDeviceResponse;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
@@ -32,9 +34,14 @@ import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
 import com.cloud.network.Networks;
 import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.network.commands.AddOvsDeviceCmd;
+import com.cloud.network.commands.DeleteOvsDeviceCmd;
+import com.cloud.network.commands.ListOvsDevicesCmd;
 import com.cloud.network.ovs.OvsTunnelManager;
+import com.cloud.network.ovs.dao.OvsDeviceVO;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.db.DB;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachineProfile;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElementService.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElementService.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElementService.java
new file mode 100644
index 0000000..b55fe6b
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElementService.java
@@ -0,0 +1,22 @@
+package com.cloud.network.element;
+
+import java.util.List;
+
+import com.cloud.api.response.OvsDeviceResponse;
+import com.cloud.network.commands.AddOvsDeviceCmd;
+import com.cloud.network.commands.DeleteOvsDeviceCmd;
+import com.cloud.network.commands.ListOvsDevicesCmd;
+import com.cloud.network.ovs.dao.OvsDeviceVO;
+import com.cloud.utils.component.PluggableService;
+
+public interface OvsElementService extends PluggableService {
+
+	public OvsDeviceVO addOvsDevice(AddOvsDeviceCmd cmd);
+
+	public OvsDeviceResponse createOvsDeviceResponse(OvsDeviceVO ovsDeviceVO);
+
+	public boolean deleteOvsDevice(DeleteOvsDeviceCmd cmd);
+
+	public List<OvsDeviceVO> listOvsDevices(ListOvsDevicesCmd cmd);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApi.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApi.java
new file mode 100644
index 0000000..b533312
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApi.java
@@ -0,0 +1,78 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.ovs;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.cookie.CookiePolicy;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.log4j.Logger;
+
+public class OvsApi {
+	private static final Logger s_logger = Logger.getLogger(OvsApi.class);
+	private final static String _protocol = "http";
+	private final static MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
+
+	private String _host;
+
+	private final HttpClient _client;
+
+	protected HttpClient createHttpClient() {
+		return new HttpClient(s_httpClientManager);
+	}
+
+	protected HttpMethod createMethod(String type, String uri, int port)
+			throws OvsApiException {
+		String url;
+		try {
+			url = new URL(_protocol, _host, port, uri).toString();
+		} catch (MalformedURLException e) {
+			s_logger.error("Unable to build Ovs API URL", e);
+			throw new OvsApiException("Unable to Ovs API URL", e);
+		}
+
+		if ("post".equalsIgnoreCase(type)) {
+			return new PostMethod(url);
+		} else if ("get".equalsIgnoreCase(type)) {
+			return new GetMethod(url);
+		} else if ("delete".equalsIgnoreCase(type)) {
+			return new DeleteMethod(url);
+		} else if ("put".equalsIgnoreCase(type)) {
+			return new PutMethod(url);
+		} else {
+			throw new OvsApiException("Requesting unknown method type");
+		}
+	}
+
+	public OvsApi() {
+		_client = createHttpClient();
+		_client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
+	}
+
+	public void setControllerAddress(String address) {
+		this._host = address;
+	}
+
+	// TODO: implement requests
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96188a37/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApiException.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApiException.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApiException.java
new file mode 100644
index 0000000..20603e0
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsApiException.java
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.network.ovs;
+
+public class OvsApiException extends Exception {
+
+	public OvsApiException() {
+	}
+
+	public OvsApiException(String message) {
+		super(message);
+	}
+
+	public OvsApiException(Throwable cause) {
+		super(cause);
+	}
+
+	public OvsApiException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}


[20/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
refactor ovsProvider to new resource


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4d060217
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4d060217
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4d060217

Branch: refs/heads/master
Commit: 4d0602175cfca798dc0b0bcbfe482526ac7eee55
Parents: 0624fe5
Author: tuna <ng...@gmail.com>
Authored: Mon Nov 4 11:48:34 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:15 2013 +0700

----------------------------------------------------------------------
 .../cloudstack/core/spring-engine-schema-core-daos-context.xml    | 3 +--
 .../ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml  | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d060217/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
----------------------------------------------------------------------
diff --git a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
index dfab28c..4f7d7ea 100644
--- a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
+++ b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
@@ -209,8 +209,7 @@
   <bean id="nicSecondaryIpDaoImpl" class="com.cloud.vm.dao.NicSecondaryIpDaoImpl" />
   <bean id="nicIpAliasDaoImpl" class="com.cloud.vm.dao.NicIpAliasDaoImpl" />
   <bean id="objectInDataStoreDaoImpl" class="org.apache.cloudstack.storage.db.ObjectInDataStoreDaoImpl" />
-  <bean id="ovsTunnelInterfaceDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" />
-  <bean id="ovsTunnelNetworkDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" />
+  <bean id="ovsProviderDaoImpl" class="com.cloud.network.dao.OvsProviderDaoImpl" />
   <bean id="physicalNetworkDaoImpl" class="com.cloud.network.dao.PhysicalNetworkDaoImpl" />
   <bean id="physicalNetworkIsolationMethodDaoImpl" class="com.cloud.network.dao.PhysicalNetworkIsolationMethodDaoImpl" />
   <bean id="physicalNetworkServiceProviderDaoImpl" class="com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl" />

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4d060217/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml b/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
index c6012d9..e60d93e 100644
--- a/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
+++ b/plugins/network-elements/ovs/resources/META-INF/cloudstack/ovs/spring-ovs-context.xml
@@ -38,6 +38,5 @@
     <bean id="ovsTunnelManagerImpl" class="com.cloud.network.ovs.OvsTunnelManagerImpl" />
     <bean id="ovsTunnelInterfaceDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" />
     <bean id="ovsTunnelNetworkDaoImpl" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" />
-    <bean id="ovsProviderDaoImpl" class="com.cloud.network.dao.OvsProviderDaoImpl" />
     
 </beans>


[09/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
tuna


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9f82757e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9f82757e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9f82757e

Branch: refs/heads/master
Commit: 9f82757eb973378cc1a7dade7e1af24bc1ca4401
Parents: 3df8b91
Author: tuna <ng...@gmail.com>
Authored: Sat Sep 28 20:56:44 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:14 2013 +0700

----------------------------------------------------------------------
 .../com/cloud/network/element/OvsElement.java   |   8 -
 .../cloud/network/ovs/OvsTunnelManagerImpl.java | 162 +++++++++----------
 server/src/com/cloud/configuration/Config.java  |   8 -
 .../src/com/cloud/network/NetworkModelImpl.java |   8 +-
 .../network/element/VirtualRouterElement.java   |  12 --
 .../network/guru/ExternalGuestNetworkGuru.java  |  50 +++---
 6 files changed, 110 insertions(+), 138 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f82757e/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index 2622bdc..93b631f 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -247,14 +247,6 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 		// L2 Support : SDN provisioning
 		capabilities.put(Service.Connectivity, null);
 
-		// L3 Support : SourceNat
-		// Map<Capability, String> sourceNatCapabilities = new
-		// HashMap<Capability, String>();
-		// sourceNatCapabilities.put(Capability.SupportedSourceNatTypes,
-		// "peraccount");
-		// sourceNatCapabilities.put(Capability.RedundantRouter, "false");
-		// capabilities.put(Service.SourceNat, sourceNatCapabilities);
-
 		// L3 Support : Port Forwarding
 		 capabilities.put(Service.PortForwarding, null);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f82757e/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
index bfead90..505f57d 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
@@ -79,31 +79,30 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 
 	// boolean _isEnabled;
 	ScheduledExecutorService _executorPool;
-    ScheduledExecutorService _cleanupExecutor;
-
-	@Inject ConfigurationDao _configDao;
-	@Inject NicDao _nicDao;
-	@Inject HostDao _hostDao;
-	@Inject PhysicalNetworkTrafficTypeDao _physNetTTDao;
-	@Inject UserVmDao _userVmDao;
-	@Inject DomainRouterDao _routerDao;
-	@Inject OvsTunnelNetworkDao _tunnelNetworkDao;
-	@Inject OvsTunnelInterfaceDao _tunnelInterfaceDao;
-	@Inject AgentManager _agentMgr;
+	ScheduledExecutorService _cleanupExecutor;
+
+	@Inject
+	ConfigurationDao _configDao;
+	@Inject
+	NicDao _nicDao;
+	@Inject
+	HostDao _hostDao;
+	@Inject
+	PhysicalNetworkTrafficTypeDao _physNetTTDao;
+	@Inject
+	UserVmDao _userVmDao;
+	@Inject
+	DomainRouterDao _routerDao;
+	@Inject
+	OvsTunnelNetworkDao _tunnelNetworkDao;
+	@Inject
+	OvsTunnelInterfaceDao _tunnelInterfaceDao;
+	@Inject
+	AgentManager _agentMgr;
 
 	@Override
 	public boolean configure(String name, Map<String, Object> params)
 			throws ConfigurationException {
-		// _isEnabled =
-		// Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
-		//
-		// if (_isEnabled) {
-		// _executorPool = Executors.newScheduledThreadPool(10, new
-		// NamedThreadFactory("OVS"));
-		// _cleanupExecutor = Executors.newScheduledThreadPool(1, new
-		// NamedThreadFactory("OVS-Cleanup"));
-		// }
-
 		return true;
 	}
 
@@ -112,57 +111,55 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 		OvsTunnelNetworkVO ta = null;
 		try {
 			ta = new OvsTunnelNetworkVO(from, to, key, networkId);
-			OvsTunnelNetworkVO lock =
-					_tunnelNetworkDao.acquireInLockTable(Long.valueOf(1));
+			OvsTunnelNetworkVO lock = _tunnelNetworkDao.acquireInLockTable(Long
+					.valueOf(1));
 			if (lock == null) {
-			    s_logger.warn("Cannot lock table ovs_tunnel_account");
-			    return null;
+				s_logger.warn("Cannot lock table ovs_tunnel_account");
+				return null;
 			}
 			_tunnelNetworkDao.persist(ta);
 			_tunnelNetworkDao.releaseFromLockTable(lock.getId());
 		} catch (EntityExistsException e) {
-			s_logger.debug("A record for the tunnel from " + from +
-						   " to " + to + " already exists");
+			s_logger.debug("A record for the tunnel from " + from + " to " + to
+					+ " already exists");
 		}
 		return ta;
 	}
 
 	@DB
 	protected OvsTunnelInterfaceVO createInterfaceRecord(String ip,
-			String netmask,String mac,long hostId, String label) {
+			String netmask, String mac, long hostId, String label) {
 		OvsTunnelInterfaceVO ti = null;
 		try {
 			ti = new OvsTunnelInterfaceVO(ip, netmask, mac, hostId, label);
-			//TODO: Is locking really necessary here?
-			OvsTunnelInterfaceVO lock =
-					_tunnelInterfaceDao.acquireInLockTable(Long.valueOf(1));
+			// TODO: Is locking really necessary here?
+			OvsTunnelInterfaceVO lock = _tunnelInterfaceDao
+					.acquireInLockTable(Long.valueOf(1));
 			if (lock == null) {
-			    s_logger.warn("Cannot lock table ovs_tunnel_account");
-			    return null;
+				s_logger.warn("Cannot lock table ovs_tunnel_account");
+				return null;
 			}
 			_tunnelInterfaceDao.persist(ti);
 			_tunnelInterfaceDao.releaseFromLockTable(lock.getId());
 		} catch (EntityExistsException e) {
-			s_logger.debug("A record for the interface for network " + label +
-					       " on host id " + hostId + " already exists");
+			s_logger.debug("A record for the interface for network " + label
+					+ " on host id " + hostId + " already exists");
 		}
 		return ti;
 	}
 
-	private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId){
+	private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId) {
 		OvsFetchInterfaceAnswer ans = (OvsFetchInterfaceAnswer) answers[0];
 		if (ans.getResult()) {
-			if (ans.getIp() != null &&
-				!("".equals(ans.getIp()))) {
-				OvsTunnelInterfaceVO ti =
-						createInterfaceRecord(ans.getIp(), ans.getNetmask(),
-											  ans.getMac(), hostId, ans.getLabel());
+			if (ans.getIp() != null && !("".equals(ans.getIp()))) {
+				OvsTunnelInterfaceVO ti = createInterfaceRecord(ans.getIp(),
+						ans.getNetmask(), ans.getMac(), hostId, ans.getLabel());
 				return ti.getIp();
 			}
 		}
 		// Fetch interface failed!
-	    s_logger.warn("Unable to fetch the IP address for the GRE tunnel endpoint" +
-	    			  ans.getDetails());
+		s_logger.warn("Unable to fetch the IP address for the GRE tunnel endpoint"
+				+ ans.getDetails());
 		return null;
 	}
 
@@ -240,20 +237,19 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
             					  from, to, networkId));
 		}
 		if (!r.getResult()) {
-		    tunnel.setState("FAILED");
-			s_logger.warn("Create GRE tunnel failed due to " +
-					r.getDetails() + s);
+			tunnel.setState("FAILED");
+			s_logger.warn("Create GRE tunnel failed due to " + r.getDetails()
+					+ s);
 		} else {
-		    tunnel.setState("SUCCESS");
-		    tunnel.setPortName(r.getInPortName());
-		    s_logger.warn("Create GRE tunnel " +
-		    		r.getDetails() + s);
+			tunnel.setState("SUCCESS");
+			tunnel.setPortName(r.getInPortName());
+			s_logger.warn("Create GRE tunnel " + r.getDetails() + s);
 		}
 		_tunnelNetworkDao.update(tunnel.getId(), tunnel);
 	}
 
-	private String getGreEndpointIP(Host host, Network nw) throws
-		AgentUnavailableException, OperationTimedoutException {
+	private String getGreEndpointIP(Host host, Network nw)
+			throws AgentUnavailableException, OperationTimedoutException {
 		String endpointIp = null;
 		// Fetch fefault name for network label from configuration
 		String physNetLabel = _configDao.getValue(Config.OvsTunnelNetworkDefaultLabel.key());
@@ -317,12 +313,12 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
     		key = Integer.valueOf(keyStr);
     		return key;
 		} catch (NumberFormatException e) {
-			s_logger.debug("Well well, how did '" + key +
-					       "' end up in the broadcast URI for the network?");
-			throw new CloudRuntimeException(
-					String.format("Invalid GRE key parsed from" +
-							"network broadcast URI (%s)",
-							network.getBroadcastUri().toString()));
+			s_logger.debug("Well well, how did '" + key
+					+ "' end up in the broadcast URI for the network?");
+			throw new CloudRuntimeException(String.format(
+					"Invalid GRE key parsed from"
+							+ "network broadcast URI (%s)", network
+							.getBroadcastUri().toString()));
 		}
 	}
 
@@ -332,8 +328,8 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 		s_logger.debug("Creating tunnels with OVS tunnel manager");
 		if (instance.getType() != VirtualMachine.Type.User
 				&& instance.getType() != VirtualMachine.Type.DomainRouter) {
-			s_logger.debug("Will not work if you're not" +
-						   "an instance or a virtual router");
+			s_logger.debug("Will not work if you're not"
+					+ "an instance or a virtual router");
 			return;
 		}
 
@@ -341,11 +337,11 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 		int key = getGreKey(nw);
 		// Find active VMs with a NIC on the target network
 		List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(nw.getId(),
-							  State.Running, State.Starting,
-							  State.Stopping, State.Unknown, State.Migrating);
+				State.Running, State.Starting, State.Stopping, State.Unknown,
+				State.Migrating);
 		// Find routers for the network
 		List<DomainRouterVO> routers = _routerDao.findByNetwork(nw.getId());
-		List<VMInstanceVO>ins = new ArrayList<VMInstanceVO>();
+		List<VMInstanceVO> ins = new ArrayList<VMInstanceVO>();
 		if (vms != null) {
 			ins.addAll(vms);
 		}
@@ -395,45 +391,45 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
 			for (Long i : toHostIds) {
 				HostVO rHost = _hostDao.findById(i);
 				String otherIp = getGreEndpointIP(rHost, nw);
-	            if (otherIp == null)
-	            	throw new GreTunnelException("Unable to retrieve the remote " +
-	            								 "endpoint for the GRE tunnel." +
-	            								 "Failure is on host:" + rHost.getId());
+				if (otherIp == null)
+					throw new GreTunnelException(
+							"Unable to retrieve the remote "
+									+ "endpoint for the GRE tunnel."
+									+ "Failure is on host:" + rHost.getId());
 				Commands cmds = new Commands(
 						new OvsCreateTunnelCommand(otherIp, key,
 								Long.valueOf(hostId), i, nw.getId(), myIp));
-				s_logger.debug("Ask host " + hostId +
-						" to create gre tunnel to " + i);
+				s_logger.debug("Ask host " + hostId
+						+ " to create gre tunnel to " + i);
 				Answer[] answers = _agentMgr.send(hostId, cmds);
 				handleCreateTunnelAnswer(answers);
 				noHost = false;
 			}
 
 			for (Long i : fromHostIds) {
-			    HostVO rHost = _hostDao.findById(i);
-			    String otherIp = getGreEndpointIP(rHost, nw);
-				Commands cmds = new Commands(
-				        new OvsCreateTunnelCommand(myIp, key, i,
-				        						   Long.valueOf(hostId),
-				        		                   nw.getId(), otherIp));
-				s_logger.debug("Ask host " + i +
-						" to create gre tunnel to " + hostId);
+				HostVO rHost = _hostDao.findById(i);
+				String otherIp = getGreEndpointIP(rHost, nw);
+				Commands cmds = new Commands(new OvsCreateTunnelCommand(myIp,
+						key, i, Long.valueOf(hostId), nw.getId(), otherIp));
+				s_logger.debug("Ask host " + i + " to create gre tunnel to "
+						+ hostId);
 				Answer[] answers = _agentMgr.send(i, cmds);
 				handleCreateTunnelAnswer(answers);
 				noHost = false;
 			}
-			// If no tunnels have been configured, perform the bridge setup anyway
+			// If no tunnels have been configured, perform the bridge setup
+			// anyway
 			// This will ensure VIF rules will be triggered
 			if (noHost) {
-				Commands cmds = new Commands(
-						new OvsSetupBridgeCommand(key, hostId, nw.getId()));
-				s_logger.debug("Ask host " + hostId +
-						" to configure bridge for network:" + nw.getId());
+				Commands cmds = new Commands(new OvsSetupBridgeCommand(key,
+						hostId, nw.getId()));
+				s_logger.debug("Ask host " + hostId
+						+ " to configure bridge for network:" + nw.getId());
 				Answer[] answers = _agentMgr.send(hostId, cmds);
 				handleSetupBridgeAnswer(answers);
 			}
 		} catch (Exception e) {
-		    // I really thing we should do a better handling of these exceptions
+			// I really thing we should do a better handling of these exceptions
 			s_logger.warn("Ovs Tunnel network created tunnel failed", e);
 		}
 	}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f82757e/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 1490926..afc09d6 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -295,14 +295,6 @@ public enum Config {
             "false",
             "Direct Network Dhcp Server should not send a default route",
             "true/false"),
-    OvsTunnelNetwork(
-            "Network",
-            ManagementServer.class,
-            Boolean.class,
-            "sdn.ovs.controller",
-            "false",
-            "Enable/Disable Open vSwitch SDN controller for L2-in-L3 overlay networks",
-            null),
     OvsTunnelNetworkDefaultLabel(
             "Network",
             ManagementServer.class,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f82757e/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index 2a38ac1..7568da0 100755
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -435,13 +435,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel {
         if (oldElement instanceof IpDeployingRequester && newElement instanceof IpDeployingRequester) {
         	IpDeployer oldIpDeployer = ((IpDeployingRequester)oldElement).getIpDeployer(network);
         	IpDeployer newIpDeployer = ((IpDeployingRequester)newElement).getIpDeployer(network);
-			// if
-			// (!oldIpDeployer.getProvider().getName().equals(newIpDeployer.getProvider().getName()))
-			// {
-			// throw new
-			// InvalidParameterException("There would be multiple providers for IP "
-			// + publicIp.getAddress() + "!");
-			// }
+			// FIXME: I ignored this check
         } else {
             throw new InvalidParameterException("Ip cannot be applied for new provider!");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f82757e/server/src/com/cloud/network/element/VirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java
index 923094b..7ceb9a4 100755
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -993,18 +993,6 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
 
     @Override
     public boolean verifyServicesCombination(Set<Service> services) {
-//        if (!services.contains(Service.SourceNat)) {
-//            if (services.contains(Service.StaticNat) || services.contains(Service.Firewall) || services.contains(Service.Lb) ||
-//                    services.contains(Service.PortForwarding) || services.contains(Service.Vpn)) {
-//                String servicesList = "[";
-//                for (Service service : services) {
-//                    servicesList += service.getName() + " ";
-//                }
-//                servicesList += "]";
-//                s_logger.warn("Virtual router can't enable services " + servicesList + " without source NAT service");
-//                return false;
-//            }
-//        }
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f82757e/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
index cb7bbe1..207f159 100644
--- a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
@@ -99,9 +99,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
     @Override
     public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
 
-        if (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()))) {
-            return null;
-        }
+		// if
+		// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
+		// {
+		// return null;
+		// }
 
         NetworkVO config = (NetworkVO)super.design(offering, plan, userSpecified, owner);
         if (config == null) {
@@ -119,9 +121,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
         throws InsufficientVirtualNetworkCapcityException {
         assert (config.getState() == State.Implementing) : "Why are we implementing " + config;
 
-        if (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()))) {
-            return null;
-        }
+		// if
+		// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
+		// {
+		// return null;
+		// }
 
         if (!_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
             return super.implement(config, offering, dest, context);
@@ -225,10 +229,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
 
         NicProfile profile = super.allocate(config, nic, vm);
 
-        boolean _isEnabled = Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
-        if (_isEnabled) {
-            return null;
-        }
+		// boolean _isEnabled =
+		// Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
+		// if (_isEnabled) {
+		// return null;
+		// }
 
         if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
             profile.setStrategy(ReservationStrategy.Start);
@@ -246,9 +251,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
     public void deallocate(Network config, NicProfile nic, VirtualMachineProfile vm) {
         super.deallocate(config, nic, vm);
 
-        if (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()))) {
-            return;
-        }
+		// if
+		// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
+		// {
+		// return;
+		// }
 
         if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
             nic.setIp4Address(null);
@@ -263,10 +270,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
     public void reserve(NicProfile nic, Network config, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
         throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
         assert (nic.getReservationStrategy() == ReservationStrategy.Start) : "What can I do for nics that are not allocated at start? ";
-        boolean _isEnabled = Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
-        if (_isEnabled) {
-            return;
-        }
+		// boolean _isEnabled =
+		// Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()));
+		// if (_isEnabled) {
+		// return;
+		// }
 
         DataCenter dc = _dcDao.findById(config.getDataCenterId());
 
@@ -299,9 +307,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
     @Override
     public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) {
 
-        if (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key()))) {
-            return true;
-        }
+		// if
+		// (Boolean.parseBoolean(_configDao.getValue(Config.OvsTunnelNetwork.key())))
+		// {
+		// return true;
+		// }
 
         NetworkVO network = _networkDao.findById(nic.getNetworkId());
 


[18/21] git commit: updated refs/heads/master to 267ff79

Posted by tu...@apache.org.
move cloudstack_pluginlib


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c7dab82d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c7dab82d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c7dab82d

Branch: refs/heads/master
Commit: c7dab82dc48b1e33683122ae6663a7bda7fb7ac7
Parents: 32c55e6
Author: tuna <ng...@gmail.com>
Authored: Wed Oct 30 16:32:19 2013 +0700
Committer: tuna <ng...@gmail.com>
Committed: Mon Dec 9 23:33:15 2013 +0700

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java  |  29 +--
 .../vm/hypervisor/kvm/cloudstack_pluginlib.py   | 219 -------------------
 scripts/vm/network/vnet/cloudstack_pluginlib.py | 219 +++++++++++++++++++
 scripts/vm/network/vnet/ovstunnel.py            |  81 +++++--
 4 files changed, 290 insertions(+), 258 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7dab82d/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 9a680ac..cbe4de3 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1344,14 +1344,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 			cmd.add("destroy_ovs_bridge");
 			cmd.add("--bridge", bridge);
 			String result = cmd.execute();
-			String[] res = result.split(":");
-			if (res.length != 2 || !res[0].equalsIgnoreCase("SUCCESS")) {
+			if (result != null) {
 				// TODO: Should make this error not fatal?
 				// Can Concurrent VM shutdown/migration/reboot events can cause
 				// this method
 				// to be executed on a bridge which has already been removed?
-				throw new CloudRuntimeException("Unable to remove OVS bridge "
-						+ bridge + ":" + res);
+				throw new CloudRuntimeException("Unable to remove OVS bridge " + bridge);
 			}
 			return;
 		} catch (Exception e) {
@@ -1360,16 +1358,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 		}
 	}
 
-	private boolean networkExist(String nwName) {
-		Script.runSimpleBashScript("ifconfig " + nwName);
-		String result = Script.runSimpleBashScript("echo $?");
-		return result.equals("0");
-	}
-
 	private synchronized boolean findOrCreateTunnelNetwork(long key) {
 		try {
 			String nwName = "OVSTunnel" + key;
-			if (networkExist(nwName)) {
+			if (checkNetwork(nwName)) {
 				return true;
 			}
 			// if not found, create a new one
@@ -1377,7 +1369,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 			otherConfig.put("ovs-host-setup", "");
 			Script.runSimpleBashScript("ovs-vsctl -- --may-exist add-br "
 					+ nwName + " -- set bridge " + nwName
-					+ " other_config:ovs_host_setup=\" \"");
+					+ " other_config:ovs_host_setup='-1'");
 			s_logger.debug("### KVM network for tunnels created:" + nwName);
 		} catch (Exception e) {
 			s_logger.warn("createTunnelNetwork failed", e);
@@ -1410,12 +1402,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 				cmd.add("--cs_host_id", ((Long) hostId).toString());
 				cmd.add("--bridge", nwName);
 				String result = cmd.execute();
-				String[] res = result.split(":");
-				if (res.length != 2 || !res[0].equalsIgnoreCase("SUCCESS")) {
+				if (result != null) {
 					throw new CloudRuntimeException(
 							"Unable to pre-configure OVS bridge " + nwName
-									+ " for network ID:" + networkId + " - "
-									+ res);
+									+ " for network ID:" + networkId);
 				}
 			}
 		} catch (Exception e) {
@@ -1445,9 +1435,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 			command.add("--dst_host", cmd.getTo().toString());
 
 			String result = command.execute();
-			String[] res = result.split(":");
-			if (res.length == 2 && res[0].equalsIgnoreCase("SUCCESS")) {
-				return new OvsCreateTunnelAnswer(cmd, true, result, res[1],
+			if (result != null) {
+				return new OvsCreateTunnelAnswer(cmd, true, result, null,
 						bridge);
 			} else {
 				return new OvsCreateTunnelAnswer(cmd, false, result, bridge);
@@ -1473,7 +1462,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 			command.add("--bridge", bridge);
 			command.add("--iface_name", cmd.getInPortName());
 			String result = command.execute();
-			if (result.equalsIgnoreCase("SUCCESS")) {
+			if (result == null) {
 				return new Answer(cmd, true, result);
 			} else {
 				return new Answer(cmd, false, result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7dab82d/scripts/vm/hypervisor/kvm/cloudstack_pluginlib.py
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/kvm/cloudstack_pluginlib.py b/scripts/vm/hypervisor/kvm/cloudstack_pluginlib.py
deleted file mode 100755
index f886aa3..0000000
--- a/scripts/vm/hypervisor/kvm/cloudstack_pluginlib.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-# 
-#   http://www.apache.org/licenses/LICENSE-2.0
-# 
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# cloudstack_pluginlib for openvswitch on KVM hypervisor
-
-import ConfigParser
-import logging
-import os
-import subprocess
-
-from time import localtime, asctime
-
-DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
-DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
-DEFAULT_LOG_FILE = "/var/log/cloudstack_plugins.log"
-
-PLUGIN_CONFIG_PATH = "/usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/cloudstack_plugins.conf"
-OVSDB_PID_PATH = "/var/run/openvswitch/ovsdb-server.pid"
-OVSDB_DAEMON_PATH = "ovsdb-server"
-OVS_PID_PATH = "/var/run/openvswitch/ovs-vswitchd.pid"
-OVS_DAEMON_PATH = "ovs-vswitchd"
-VSCTL_PATH = "/usr/bin/ovs-vsctl"
-OFCTL_PATH = "/usr/bin/ovs-ofctl"
-
-class PluginError(Exception):
-    """Base Exception class for all plugin errors."""
-    def __init__(self, *args):
-        Exception.__init__(self, *args)
-
-
-def setup_logging(log_file=None):
-    debug = False
-    verbose = False
-    log_format = DEFAULT_LOG_FORMAT
-    log_date_format = DEFAULT_LOG_DATE_FORMAT
-    # try to read plugin configuration file
-    if os.path.exists(PLUGIN_CONFIG_PATH):
-        config = ConfigParser.ConfigParser()
-        config.read(PLUGIN_CONFIG_PATH)
-        try:
-            options = config.options('LOGGING')
-            if 'debug' in options:
-                debug = config.getboolean('LOGGING', 'debug')
-            if 'verbose' in options:
-                verbose = config.getboolean('LOGGING', 'verbose')
-            if 'format' in options:
-                log_format = config.get('LOGGING', 'format')
-            if 'date_format' in options:
-                log_date_format = config.get('LOGGING', 'date_format')
-            if 'file' in options:
-                log_file_2 = config.get('LOGGING', 'file')
-        except ValueError:
-            # configuration file contained invalid attributes
-            # ignore them
-            pass
-        except ConfigParser.NoSectionError:
-            # Missing 'Logging' section in configuration file
-            pass
-
-    root_logger = logging.root
-    if debug:
-        root_logger.setLevel(logging.DEBUG)
-    elif verbose:
-        root_logger.setLevel(logging.INFO)
-    else:
-        root_logger.setLevel(logging.WARNING)
-    formatter = logging.Formatter(log_format, log_date_format)
-
-    log_filename = log_file or log_file_2 or DEFAULT_LOG_FILE
-
-    logfile_handler = logging.FileHandler(log_filename)
-    logfile_handler.setFormatter(formatter)
-    root_logger.addHandler(logfile_handler)
-
-
-def do_cmd(cmd):
-    """Abstracts out the basics of issuing system commands. If the command
-    returns anything in stderr, a PluginError is raised with that information.
-    Otherwise, the output from stdout is returned.
-    """
-
-    pipe = subprocess.PIPE
-    logging.debug("Executing:%s", cmd)
-    proc = subprocess.Popen(cmd, shell=False, stdin=pipe, stdout=pipe,
-                            stderr=pipe, close_fds=True)
-    ret_code = proc.wait()
-    err = proc.stderr.read()
-    if ret_code:
-        logging.debug("The command exited with the error code: " +
-                      "%s (stderr output:%s)" % (ret_code, err))
-        raise PluginError(err)
-    output = proc.stdout.read()
-    if output.endswith('\n'):
-        output = output[:-1]
-    return output
-
-
-def _is_process_run(pidFile, name):
-    try:
-        fpid = open(pidFile, "r")
-        pid = fpid.readline()
-        fpid.close()
-    except IOError, e:
-        return -1
-
-    pid = pid[:-1]
-    ps = os.popen("ps -ae")
-    for l in ps:
-        if pid in l and name in l:
-            ps.close()
-            return 0
-
-    ps.close()
-    return -2
-
-
-def _is_tool_exist(name):
-    if os.path.exists(name):
-        return 0
-    return -1
-
-
-def check_switch():
-    global result
-
-    ret = _is_process_run(OVSDB_PID_PATH, OVSDB_DAEMON_PATH)
-    if ret < 0:
-        if ret == -1:
-            return "NO_DB_PID_FILE"
-        if ret == -2:
-            return "DB_NOT_RUN"
-
-    ret = _is_process_run(OVS_PID_PATH, OVS_DAEMON_PATH)
-    if ret < 0:
-        if ret == -1:
-            return "NO_SWITCH_PID_FILE"
-        if ret == -2:
-            return "SWITCH_NOT_RUN"
-
-    if _is_tool_exist(VSCTL_PATH) < 0:
-        return "NO_VSCTL"
-
-    if _is_tool_exist(OFCTL_PATH) < 0:
-        return "NO_OFCTL"
-
-    return "SUCCESS"
-
-
-def _build_flow_expr(**kwargs):
-    is_delete_expr = kwargs.get('delete', False)
-    flow = ""
-    if not is_delete_expr:
-        flow = "hard_timeout=%s,idle_timeout=%s,priority=%s"\
-                % (kwargs.get('hard_timeout', '0'),
-                   kwargs.get('idle_timeout', '0'),
-                   kwargs.get('priority', '1'))
-    in_port = 'in_port' in kwargs and ",in_port=%s" % kwargs['in_port'] or ''
-    dl_type = 'dl_type' in kwargs and ",dl_type=%s" % kwargs['dl_type'] or ''
-    dl_src = 'dl_src' in kwargs and ",dl_src=%s" % kwargs['dl_src'] or ''
-    dl_dst = 'dl_dst' in kwargs and ",dl_dst=%s" % kwargs['dl_dst'] or ''
-    nw_src = 'nw_src' in kwargs and ",nw_src=%s" % kwargs['nw_src'] or ''
-    nw_dst = 'nw_dst' in kwargs and ",nw_dst=%s" % kwargs['nw_dst'] or ''
-    proto = 'proto' in kwargs and ",%s" % kwargs['proto'] or ''
-    ip = ('nw_src' in kwargs or 'nw_dst' in kwargs) and ',ip' or ''
-    flow = (flow + in_port + dl_type + dl_src + dl_dst +
-            (ip or proto) + nw_src + nw_dst)
-    return flow
-
-
-def add_flow(bridge, **kwargs):
-    """
-    Builds a flow expression for **kwargs and adds the flow entry
-    to an Open vSwitch instance
-    """
-    flow = _build_flow_expr(**kwargs)
-    actions = 'actions' in kwargs and ",actions=%s" % kwargs['actions'] or ''
-    flow = flow + actions
-    addflow = [OFCTL_PATH, "add-flow", bridge, flow]
-    do_cmd(addflow)
-
-
-def del_flows(bridge, **kwargs):
-    """
-    Removes flows according to criteria passed as keyword.
-    """
-    flow = _build_flow_expr(delete=True, **kwargs)
-    # out_port condition does not exist for all flow commands
-    out_port = ("out_port" in kwargs and
-                ",out_port=%s" % kwargs['out_port'] or '')
-    flow = flow + out_port
-    delFlow = [OFCTL_PATH, 'del-flows', bridge, flow]
-    do_cmd(delFlow)
-
-
-def del_all_flows(bridge):
-    delFlow = [OFCTL_PATH, "del-flows", bridge]
-    do_cmd(delFlow)
-
-    normalFlow = "priority=0 idle_timeout=0 hard_timeout=0 actions=normal"
-    add_flow(bridge, normalFlow)
-
-
-def del_port(bridge, port):
-    delPort = [VSCTL_PATH, "del-port", bridge, port]
-    do_cmd(delPort)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7dab82d/scripts/vm/network/vnet/cloudstack_pluginlib.py
----------------------------------------------------------------------
diff --git a/scripts/vm/network/vnet/cloudstack_pluginlib.py b/scripts/vm/network/vnet/cloudstack_pluginlib.py
new file mode 100755
index 0000000..f886aa3
--- /dev/null
+++ b/scripts/vm/network/vnet/cloudstack_pluginlib.py
@@ -0,0 +1,219 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# cloudstack_pluginlib for openvswitch on KVM hypervisor
+
+import ConfigParser
+import logging
+import os
+import subprocess
+
+from time import localtime, asctime
+
+DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
+DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
+DEFAULT_LOG_FILE = "/var/log/cloudstack_plugins.log"
+
+PLUGIN_CONFIG_PATH = "/usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/cloudstack_plugins.conf"
+OVSDB_PID_PATH = "/var/run/openvswitch/ovsdb-server.pid"
+OVSDB_DAEMON_PATH = "ovsdb-server"
+OVS_PID_PATH = "/var/run/openvswitch/ovs-vswitchd.pid"
+OVS_DAEMON_PATH = "ovs-vswitchd"
+VSCTL_PATH = "/usr/bin/ovs-vsctl"
+OFCTL_PATH = "/usr/bin/ovs-ofctl"
+
+class PluginError(Exception):
+    """Base Exception class for all plugin errors."""
+    def __init__(self, *args):
+        Exception.__init__(self, *args)
+
+
+def setup_logging(log_file=None):
+    debug = False
+    verbose = False
+    log_format = DEFAULT_LOG_FORMAT
+    log_date_format = DEFAULT_LOG_DATE_FORMAT
+    # try to read plugin configuration file
+    if os.path.exists(PLUGIN_CONFIG_PATH):
+        config = ConfigParser.ConfigParser()
+        config.read(PLUGIN_CONFIG_PATH)
+        try:
+            options = config.options('LOGGING')
+            if 'debug' in options:
+                debug = config.getboolean('LOGGING', 'debug')
+            if 'verbose' in options:
+                verbose = config.getboolean('LOGGING', 'verbose')
+            if 'format' in options:
+                log_format = config.get('LOGGING', 'format')
+            if 'date_format' in options:
+                log_date_format = config.get('LOGGING', 'date_format')
+            if 'file' in options:
+                log_file_2 = config.get('LOGGING', 'file')
+        except ValueError:
+            # configuration file contained invalid attributes
+            # ignore them
+            pass
+        except ConfigParser.NoSectionError:
+            # Missing 'Logging' section in configuration file
+            pass
+
+    root_logger = logging.root
+    if debug:
+        root_logger.setLevel(logging.DEBUG)
+    elif verbose:
+        root_logger.setLevel(logging.INFO)
+    else:
+        root_logger.setLevel(logging.WARNING)
+    formatter = logging.Formatter(log_format, log_date_format)
+
+    log_filename = log_file or log_file_2 or DEFAULT_LOG_FILE
+
+    logfile_handler = logging.FileHandler(log_filename)
+    logfile_handler.setFormatter(formatter)
+    root_logger.addHandler(logfile_handler)
+
+
+def do_cmd(cmd):
+    """Abstracts out the basics of issuing system commands. If the command
+    returns anything in stderr, a PluginError is raised with that information.
+    Otherwise, the output from stdout is returned.
+    """
+
+    pipe = subprocess.PIPE
+    logging.debug("Executing:%s", cmd)
+    proc = subprocess.Popen(cmd, shell=False, stdin=pipe, stdout=pipe,
+                            stderr=pipe, close_fds=True)
+    ret_code = proc.wait()
+    err = proc.stderr.read()
+    if ret_code:
+        logging.debug("The command exited with the error code: " +
+                      "%s (stderr output:%s)" % (ret_code, err))
+        raise PluginError(err)
+    output = proc.stdout.read()
+    if output.endswith('\n'):
+        output = output[:-1]
+    return output
+
+
+def _is_process_run(pidFile, name):
+    try:
+        fpid = open(pidFile, "r")
+        pid = fpid.readline()
+        fpid.close()
+    except IOError, e:
+        return -1
+
+    pid = pid[:-1]
+    ps = os.popen("ps -ae")
+    for l in ps:
+        if pid in l and name in l:
+            ps.close()
+            return 0
+
+    ps.close()
+    return -2
+
+
+def _is_tool_exist(name):
+    if os.path.exists(name):
+        return 0
+    return -1
+
+
+def check_switch():
+    global result
+
+    ret = _is_process_run(OVSDB_PID_PATH, OVSDB_DAEMON_PATH)
+    if ret < 0:
+        if ret == -1:
+            return "NO_DB_PID_FILE"
+        if ret == -2:
+            return "DB_NOT_RUN"
+
+    ret = _is_process_run(OVS_PID_PATH, OVS_DAEMON_PATH)
+    if ret < 0:
+        if ret == -1:
+            return "NO_SWITCH_PID_FILE"
+        if ret == -2:
+            return "SWITCH_NOT_RUN"
+
+    if _is_tool_exist(VSCTL_PATH) < 0:
+        return "NO_VSCTL"
+
+    if _is_tool_exist(OFCTL_PATH) < 0:
+        return "NO_OFCTL"
+
+    return "SUCCESS"
+
+
+def _build_flow_expr(**kwargs):
+    is_delete_expr = kwargs.get('delete', False)
+    flow = ""
+    if not is_delete_expr:
+        flow = "hard_timeout=%s,idle_timeout=%s,priority=%s"\
+                % (kwargs.get('hard_timeout', '0'),
+                   kwargs.get('idle_timeout', '0'),
+                   kwargs.get('priority', '1'))
+    in_port = 'in_port' in kwargs and ",in_port=%s" % kwargs['in_port'] or ''
+    dl_type = 'dl_type' in kwargs and ",dl_type=%s" % kwargs['dl_type'] or ''
+    dl_src = 'dl_src' in kwargs and ",dl_src=%s" % kwargs['dl_src'] or ''
+    dl_dst = 'dl_dst' in kwargs and ",dl_dst=%s" % kwargs['dl_dst'] or ''
+    nw_src = 'nw_src' in kwargs and ",nw_src=%s" % kwargs['nw_src'] or ''
+    nw_dst = 'nw_dst' in kwargs and ",nw_dst=%s" % kwargs['nw_dst'] or ''
+    proto = 'proto' in kwargs and ",%s" % kwargs['proto'] or ''
+    ip = ('nw_src' in kwargs or 'nw_dst' in kwargs) and ',ip' or ''
+    flow = (flow + in_port + dl_type + dl_src + dl_dst +
+            (ip or proto) + nw_src + nw_dst)
+    return flow
+
+
+def add_flow(bridge, **kwargs):
+    """
+    Builds a flow expression for **kwargs and adds the flow entry
+    to an Open vSwitch instance
+    """
+    flow = _build_flow_expr(**kwargs)
+    actions = 'actions' in kwargs and ",actions=%s" % kwargs['actions'] or ''
+    flow = flow + actions
+    addflow = [OFCTL_PATH, "add-flow", bridge, flow]
+    do_cmd(addflow)
+
+
+def del_flows(bridge, **kwargs):
+    """
+    Removes flows according to criteria passed as keyword.
+    """
+    flow = _build_flow_expr(delete=True, **kwargs)
+    # out_port condition does not exist for all flow commands
+    out_port = ("out_port" in kwargs and
+                ",out_port=%s" % kwargs['out_port'] or '')
+    flow = flow + out_port
+    delFlow = [OFCTL_PATH, 'del-flows', bridge, flow]
+    do_cmd(delFlow)
+
+
+def del_all_flows(bridge):
+    delFlow = [OFCTL_PATH, "del-flows", bridge]
+    do_cmd(delFlow)
+
+    normalFlow = "priority=0 idle_timeout=0 hard_timeout=0 actions=normal"
+    add_flow(bridge, normalFlow)
+
+
+def del_port(bridge, port):
+    delPort = [VSCTL_PATH, "del-port", bridge, port]
+    do_cmd(delPort)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7dab82d/scripts/vm/network/vnet/ovstunnel.py
----------------------------------------------------------------------
diff --git a/scripts/vm/network/vnet/ovstunnel.py b/scripts/vm/network/vnet/ovstunnel.py
index 67ef89b..225876a 100755
--- a/scripts/vm/network/vnet/ovstunnel.py
+++ b/scripts/vm/network/vnet/ovstunnel.py
@@ -27,16 +27,16 @@ import os
 import sys
 import subprocess
 import time
+from optparse import OptionParser, OptionGroup, OptParseError, BadOptionError, OptionError, OptionConflictError, OptionValueError
 
 from time import localtime as _localtime, asctime as _asctime
 
-lib.setup_logging("/var/log/ovstunnel.log")
-
 def setup_ovs_bridge(bridge, key, cs_host_id):
 
     res = lib.check_switch()
     if res != "SUCCESS":
-        return "FAILURE:%s" % res
+        #return "FAILURE:%s" % res
+	return 'false'
 
     logging.debug("About to manually create the bridge:%s" % bridge)
     #set gre_key to bridge
@@ -44,15 +44,18 @@ def setup_ovs_bridge(bridge, key, cs_host_id):
                                      "other_config:gre_key=%s" % key])
     logging.debug("Bridge has been manually created:%s" % res)
     if res:
-        result = "FAILURE:%s" % res
+#        result = "FAILURE:%s" % res
+	result = 'false'
     else:
         # Verify the bridge actually exists, with the gre_key properly set
         res = lib.do_cmd([lib.VSCTL_PATH, "get", "bridge",
                                           bridge, "other_config:gre_key"])
         if key in res:
-            result = "SUCCESS:%s" % bridge
+#            result = "SUCCESS:%s" % bridge
+            result = 'true'
         else:
-            result = "FAILURE:%s" % res
+#            result = "FAILURE:%s" % res
+            result = 'false'
 
 	lib.do_cmd([lib.VSCTL_PATH, "set", "bridge", bridge, "other_config:is-ovs-tun-network=True"])
 	#get list of hosts using this bridge
@@ -69,29 +72,34 @@ def destroy_ovs_bridge(bridge):
 
     res = lib.check_switch()
     if res != "SUCCESS":
-        return res
+#        return res
+        return 'false'
+
     res = lib.do_cmd([lib.VSCTL_PATH, "del-br", bridge])
     logging.debug("Bridge has been manually removed:%s" % res)
     if res:
-        result = "FAILURE:%s" % res
+#        result = "FAILURE:%s" % res
+        result = 'false'
     else:
-        result = "SUCCESS:%s" % bridge
+#        result = "SUCCESS:%s" % bridge
+        result = 'true'
 
     logging.debug("Destroy_ovs_bridge completed with result:%s" % result)
     return result
 
-def create_tunnel(bridge, remote_ip, gre_key, src_host, dst_host):
+def create_tunnel(bridge, remote_ip, key, src_host, dst_host):
 
     logging.debug("Entering create_tunnel")
 
     res = lib.check_switch()
     if res != "SUCCESS":
         logging.debug("Openvswitch running: NO")
-        return "FAILURE:%s" % res
+#        return "FAILURE:%s" % res
+        return 'false'
 
     # We need to keep the name below 14 characters
     # src and target are enough - consider a fixed length hash
-    name = "t%s-%s-%s" % (gre_key, src_host, dst_host)
+    name = "t%s-%s-%s" % (key, src_host, dst_host)
 
     # Verify the bridge to be created
     # NOTE: Timeout should not be necessary anymore
@@ -101,7 +109,9 @@ def create_tunnel(bridge, remote_ip, gre_key, src_host, dst_host):
     if bridge not in res:
         logging.debug("WARNING:Can't find bridge %s for creating " +
                                   "tunnel!" % bridge)
-        return "FAILURE:NO_BRIDGE"
+#        return "FAILURE:NO_BRIDGE"
+        return 'false'
+
     logging.debug("bridge %s for creating tunnel - VERIFIED" % bridge)
     tunnel_setup = False
     drop_flow_setup = False
@@ -109,7 +119,7 @@ def create_tunnel(bridge, remote_ip, gre_key, src_host, dst_host):
         # Create a port and configure the tunnel interface for it
         add_tunnel = [lib.VSCTL_PATH, "add-port", bridge,
                                   name, "--", "set", "interface",
-                                  name, "type=gre", "options:key=%s" % gre_key,
+                                  name, "type=gre", "options:key=%s" % key,
                                   "options:remote_ip=%s" % remote_ip]
         lib.do_cmd(add_tunnel)
         tunnel_setup = True
@@ -123,7 +133,8 @@ def create_tunnel(bridge, remote_ip, gre_key, src_host, dst_host):
         if len(iface_list) != 1:
             logging.debug("WARNING: Unexpected output while verifying " +
                                       "port %s on bridge %s" % (name, bridge))
-            return "FAILURE:VERIFY_PORT_FAILED"
+#            return "FAILURE:VERIFY_PORT_FAILED"
+            return 'false'
 
         # verify interface
         iface_uuid = iface_list[0]
@@ -135,10 +146,12 @@ def create_tunnel(bridge, remote_ip, gre_key, src_host, dst_host):
         key_validation = lib.do_cmd(verify_interface_key)
         ip_validation = lib.do_cmd(verify_interface_ip)
 
-        if not gre_key in key_validation or not remote_ip in ip_validation:
+        if not key in key_validation or not remote_ip in ip_validation:
             logging.debug("WARNING: Unexpected output while verifying " +
                           "interface %s on bridge %s" % (name, bridge))
-            return "FAILURE:VERIFY_INTERFACE_FAILED"
+#            return "FAILURE:VERIFY_INTERFACE_FAILED"
+            return 'false'
+
         logging.debug("Tunnel interface validated:%s" % verify_interface_ip)
         cmd_tun_ofport = [lib.VSCTL_PATH, "get", "interface",
                                           iface_uuid, "ofport"]
@@ -153,7 +166,8 @@ def create_tunnel(bridge, remote_ip, gre_key, src_host, dst_host):
                      nw_dst='224.0.0.0/24', actions='drop')
         drop_flow_setup = True
         logging.debug("Broadcast drop rules added")
-        return "SUCCESS:%s" % name
+#        return "SUCCESS:%s" % name
+        return 'true'
     except:
         logging.debug("An unexpected error occured. Rolling back")
         if tunnel_setup:
@@ -174,9 +188,38 @@ def destroy_tunnel(bridge, iface_name):
     ofport = get_field_of_interface(iface_name, "ofport")
     lib.del_flows(bridge, in_port=ofport)
     lib.del_port(bridge, iface_name)
-    return "SUCCESS"
+#    return "SUCCESS"
+    return 'true'
 
 def get_field_of_interface(iface_name, field):
     get_iface_cmd = [lib.VSCTL_PATH, "get", "interface", iface_name, field]
     res = lib.do_cmd(get_iface_cmd)
     return res
+
+if __name__ == '__main__':
+    logging.basicConfig(filename="/var/log/cloudstack/agent/ovstunnel.log", format="%(asctime)s - %(message)s", level=logging.DEBUG)
+    parser = OptionParser()
+    parser.add_option("--key", dest="key")
+    parser.add_option("--cs_host_id", dest="cs_host_id")
+    parser.add_option("--bridge", dest="bridge")
+    parser.add_option("--remote_ip", dest="remote_ip")
+    parser.add_option("--src_host", dest="src_host")
+    parser.add_option("--dst_host", dest="dst_host")
+    parser.add_option("--iface_name", dest="iface_name")
+    (option, args) = parser.parse_args()
+    if len(args) == 0:
+        logging.debug("No command to execute")
+        sys.exit(1)
+    cmd = args[0]
+    if cmd == "setup_ovs_bridge":
+        setup_ovs_bridge(option.bridge, option.key, option.cs_host_id)
+    elif cmd == "destroy_ovs_bridge":
+        destroy_ovs_bridge(option.bridge)
+    elif cmd == "create_tunnel":
+        create_tunnel(option.bridge, option.remote_ip, option.key, option.src_host, option.dst_host)
+    elif cmd == "destroy_tunnel":
+        destroy_tunnel(option.bridge, option.iface_name)
+    else:
+        logging.debug("Unknown command: " + cmd)
+        sys.exit(1)
+