cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [3/3] git commit: updated refs/heads/sdnextensions to 0d6125f
Date Mon, 12 Aug 2013 11:29:06 GMT
Review 12941 refactor gre controller

Signed-off-by: Hugo Trippaers <htrippaers@schubergphilis.com>


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

Branch: refs/heads/sdnextensions
Commit: 0d6125f36449b1fcbbc5d296496c4a01f2208fc4
Parents: de99eef
Author: Nguyen Anh Tu <ng.tuna@gmail.com>
Authored: Mon Aug 12 13:25:30 2013 +0200
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Mon Aug 12 13:27:20 2013 +0200

----------------------------------------------------------------------
 api/src/com/cloud/network/Network.java          |    2 +
 api/src/com/cloud/network/OvsProvider.java      |   10 +
 .../element/VirtualRouterElementService.java    |    7 +
 .../cloudstack/api/ResponseGenerator.java       |    4 +
 .../admin/router/ConfigureOvsElementCmd.java    |  116 +
 .../admin/router/ListOvsElementsCmd.java        |   91 +
 .../api/response/OvsProviderResponse.java       |   77 +
 client/tomcatconf/applicationContext.xml.in     |    2 +-
 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        |   24 +-
 .../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      |   45 +
 .../agent/api/OvsDestroyTunnelCommand.java      |   51 +
 .../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  |   50 +
 .../com/cloud/agent/api/StartupOvsCommand.java  |   27 +
 .../com/cloud/network/element/OvsElement.java   |  209 +-
 .../network/element/OvsElementService.java      |   15 -
 .../cloud/network/guru/OvsGuestNetworkGuru.java |  252 +-
 .../cloud/network/ovs/OvsTunnelManagerImpl.java |  133 +-
 scripts/vm/hypervisor/xenserver/ovstunnel       |   24 +-
 server/src/com/cloud/api/ApiResponseHelper.java |   18 +
 .../com/cloud/network/NetworkServiceImpl.java   |   24 +
 .../network/element/VirtualRouterElement.java   |   45 +-
 .../com/cloud/server/ManagementServerImpl.java  |    4 +
 setup/db/create-schema.sql                      |   22 -
 setup/db/db/schema-410to420.sql                 |   22 +
 tools/apidoc/gen_toc.py                         |    3 +-
 ui/scripts/zoneWizard.js                        | 7777 +++++++++---------
 39 files changed, 5794 insertions(+), 3943 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d6125f3/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 a06208b..aea496d 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -127,6 +127,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);
+        // add new Ovs provider
+        public static final Provider Ovs = new Provider("Ovs", false);
 
         private String name;
         private boolean isExternal;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d6125f3/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/0d6125f3/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 ea971b8..4f47e10 100644
--- a/api/src/com/cloud/network/element/VirtualRouterElementService.java
+++ b/api/src/com/cloud/network/element/VirtualRouterElementService.java
@@ -18,16 +18,23 @@ 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.VirtualRouterProviderType;
 import com.cloud.utils.component.PluggableService;
 
 public interface VirtualRouterElementService extends PluggableService{
     VirtualRouterProvider configure(ConfigureVirtualRouterElementCmd cmd);
+
+	OvsProvider configure(ConfigureOvsElementCmd cmd);
     VirtualRouterProvider addElement(Long nspId, VirtualRouterProviderType 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/0d6125f3/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 d8d07cb..b8ecef3 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -35,6 +35,7 @@ import com.cloud.network.Network;
 import com.cloud.network.Network.Service;
 import com.cloud.network.Networks.IsolationType;
 import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.OvsProvider;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PhysicalNetworkTrafficType;
 import com.cloud.network.RemoteAccessVpn;
@@ -137,6 +138,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;
@@ -363,6 +365,8 @@ 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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d6125f3/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/0d6125f3/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/0d6125f3/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/0d6125f3/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 60f1e30..8d67de5 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" />
@@ -362,6 +361,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/0d6125f3/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 6ec4d92..a52ebaf 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -490,6 +490,11 @@ createVirtualRouterElement=7
 configureVirtualRouterElement=7
 listVirtualRouterElements=7
 
+#### ovs commands
+createOvsElement=7
+configureOvsElement=7
+listOvsElements=7
+
 #### usage commands
 generateUsageRecords=1
 listUsageRecords=1

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d6125f3/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/0d6125f3/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/0d6125f3/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/0d6125f3/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 30b0521..9741763 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
@@ -157,6 +157,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;
@@ -265,18 +277,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/0d6125f3/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/0d6125f3/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/0d6125f3/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/0d6125f3/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/0d6125f3/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/0d6125f3/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..e5593d8
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDestroyBridgeCommand.java
@@ -0,0 +1,45 @@
+// 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/0d6125f3/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..b00adba
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsDestroyTunnelCommand.java
@@ -0,0 +1,51 @@
+// 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/0d6125f3/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/0d6125f3/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/0d6125f3/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/0d6125f3/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/0d6125f3/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..7fc0c35
--- /dev/null
+++ b/plugins/network-elements/ovs/src/com/cloud/agent/api/OvsSetupBridgeCommand.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 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/0d6125f3/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/0d6125f3/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 0ea6b52..3824669 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,57 +16,108 @@
 // under the License.
 package com.cloud.network.element;
 
+import java.util.ArrayList;
+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.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
-@Local(value = { NetworkElement.class })
+@Local(value = { NetworkElement.class, ConnectivityProvider.class,
+		SourceNatServiceProvider.class, StaticNatServiceProvider.class,
+		PortForwardingServiceProvider.class, IpDeployer.class })
 public class OvsElement extends AdapterBase implements NetworkElement,
-		OvsElementService {
+		OvsElementService, ConnectivityProvider, ResourceStateAdapter,
+		SourceNatServiceProvider, PortForwardingServiceProvider,
+		StaticNatServiceProvider, IpDeployer {
 	@Inject
 	OvsTunnelManager _ovsTunnelMgr;
+	@Inject
+	NetworkModel _networkModel;
+	@Inject
+	NetworkServiceMapDao _ntwkSrvcDao;
+	@Inject
+	ResourceManager _resourceMgr;
 
-	@Override
-	public boolean destroy(Network network, ReservationContext context)
-			throws ConcurrentOperationException, ResourceUnavailableException {
-		return true;
-	}
+	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 null;
+		return capabilities;
 	}
 
 	@Override
 	public Provider getProvider() {
-		return null;
+		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
@@ -74,7 +125,15 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 			DeployDestination dest, ReservationContext context)
 			throws ConcurrentOperationException, ResourceUnavailableException,
 			InsufficientCapacityException {
-		// Consider actually implementing the network here
+		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;
 	}
 
@@ -84,16 +143,19 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 			DeployDestination dest, ReservationContext context)
 			throws ConcurrentOperationException, ResourceUnavailableException,
 			InsufficientCapacityException {
+		if (!canHandle(network, Service.Connectivity)) {
+			return false;
+		}
+
 		if (nic.getBroadcastType() != Networks.BroadcastDomainType.Vswitch) {
-			return true;
+			return false;
 		}
 
 		if (nic.getTrafficType() != Networks.TrafficType.Guest) {
-			return true;
+			return false;
 		}
 
 		_ovsTunnelMgr.VmCheckAndCreateTunnel(vm, network, dest);
-		// _ovsTunnelMgr.applyDefaultFlow(vm.getVirtualMachine(), dest);
 
 		return true;
 	}
@@ -103,12 +165,15 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 			VirtualMachineProfile<? extends VirtualMachine> vm,
 			ReservationContext context) throws ConcurrentOperationException,
 			ResourceUnavailableException {
+		if (!canHandle(network, Service.Connectivity)) {
+			return false;
+		}
 		if (nic.getBroadcastType() != Networks.BroadcastDomainType.Vswitch) {
-			return true;
+			return false;
 		}
 
 		if (nic.getTrafficType() != Networks.TrafficType.Guest) {
-			return true;
+			return false;
 		}
 
 		_ovsTunnelMgr.CheckAndDestroyTunnel(vm.getVirtualMachine(), network);
@@ -119,6 +184,18 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 	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;
 	}
 
@@ -136,42 +213,112 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 
 	@Override
 	public boolean canEnableIndividualServices() {
-		return false;
+		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>>();
+
+		// 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);
+		//
+		// // 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() {
-		// TODO Auto-generated method stub
-		return null;
+		List<Class<?>> cmdList = new ArrayList<Class<?>>();
+		return cmdList;
 	}
 
 	@Override
-	@DB
-	public OvsDeviceVO addOvsDevice(AddOvsDeviceCmd cmd) {
-		// TODO
+	public HostVO createHostVOForConnectedAgent(HostVO host,
+			StartupCommand[] cmd) {
 		return null;
 	}
 
 	@Override
-	public OvsDeviceResponse createOvsDeviceResponse(OvsDeviceVO ovsDeviceVO) {
+	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 deleteOvsDevice(DeleteOvsDeviceCmd cmd) {
+	public boolean applyIps(Network network,
+			List<? extends PublicIpAddress> ipAddress, Set<Service> services)
+			throws ResourceUnavailableException {
 		// TODO Auto-generated method stub
 		return false;
 	}
 
 	@Override
-	public List<OvsDeviceVO> listOvsDevices(ListOvsDevicesCmd cmd) {
+	public boolean applyStaticNats(Network config,
+			List<? extends StaticNat> rules)
+			throws ResourceUnavailableException {
 		// TODO Auto-generated method stub
-		return null;
+		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/0d6125f3/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/0d6125f3/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 bbdf110..7ddf26a 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
@@ -19,7 +19,6 @@ package com.cloud.network.guru;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import com.cloud.event.ActionEventUtils;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -27,93 +26,204 @@ import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.deploy.DeployDestination;
 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.user.UserContext;
+import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
 
 @Component
-@Local(value=NetworkGuru.class)
+@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,
-                    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());
-        }
-    }
-
-    @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();
+		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
+		// locate the physical network
+		if (physicalNetworkId == null) {
+			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);
+
+		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());
+		}
+	}
 
 }


Mime
View raw message