You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2013/10/07 13:58:46 UTC

[1/2] git commit: updated refs/heads/sdnextensions to 3056b1a

Updated Branches:
  refs/heads/sdnextensions 0d6125f36 -> 3056b1a9f


Review 13499 - [GSoC] Add staticNat support to GRE controller

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


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

Branch: refs/heads/sdnextensions
Commit: a0a818317ff8742d84eff15f9fb15e7028590534
Parents: 0d6125f
Author: Nguyen Anh Tu <ng...@gmail.com>
Authored: Mon Oct 7 13:46:44 2013 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Mon Oct 7 13:46:44 2013 +0200

----------------------------------------------------------------------
 .../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   |  81 ++++++---
 .../ovs/src/com/cloud/network/ovs/OvsApi.java   |  78 ---------
 .../com/cloud/network/ovs/OvsApiException.java  |  35 ----
 .../network/ovs/OvsCreateGreTunnelAnswer.java   |  81 ---------
 .../network/ovs/OvsCreateGreTunnelCommand.java  |  54 ------
 .../network/ovs/OvsCreateTunnelAnswer.java      |  86 ---------
 .../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    |  59 -------
 .../network/ovs/OvsFetchInterfaceCommand.java   |  38 ----
 .../network/ovs/OvsSetTagAndFlowAnswer.java     |  40 -----
 .../network/ovs/OvsSetTagAndFlowCommand.java    |  60 -------
 .../network/ovs/OvsSetupBridgeCommand.java      |  50 ------
 .../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 -------------------
 .../network/element/VirtualRouterElement.java   |  53 ++----
 25 files changed, 77 insertions(+), 1608 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0a81831/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/a0a81831/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/a0a81831/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/a0a81831/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/a0a81831/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 3824669..c7c6484 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
@@ -47,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;
@@ -55,10 +57,12 @@ 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.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.DomainRouterDao;
 
 @Local(value = { NetworkElement.class, ConnectivityProvider.class,
 		SourceNatServiceProvider.class, StaticNatServiceProvider.class,
@@ -75,6 +79,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();
@@ -132,8 +140,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;
 	}
 
@@ -223,12 +229,12 @@ 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;
 	}
 
@@ -239,22 +245,22 @@ public class OvsElement extends AdapterBase implements NetworkElement,
 		capabilities.put(Service.Connectivity, null);
 
 		// TODO: we need L3 support for coding L3 services in next period
-		// // L3 Support : Generic?
+		// L3 Support : Generic?
 		// capabilities.put(Service.Gateway, null);
-		//
-		// // L3 Support : SourceNat
+
+		// 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
+
+		// L3 Support : Port Forwarding
 		// capabilities.put(Service.PortForwarding, null);
-		//
-		// // L3 support : StaticNat
-		// capabilities.put(Service.StaticNat, null);
+
+		// L3 support : StaticNat
+		capabilities.put(Service.StaticNat, null);
 
 		return capabilities;
 	}
@@ -294,24 +300,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/a0a81831/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/a0a81831/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/a0a81831/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 5f0f8c1..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java
+++ /dev/null
@@ -1,81 +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/a0a81831/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/a0a81831/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 fc2eb8a..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsCreateTunnelAnswer.java
+++ /dev/null
@@ -1,86 +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/a0a81831/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/a0a81831/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/a0a81831/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 8be5586..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;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0a81831/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 4594d99..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/a0a81831/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 1ee6606..0000000
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsFetchInterfaceAnswer.java
+++ /dev/null
@@ -1,59 +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/a0a81831/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/a0a81831/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 ba16839..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/a0a81831/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/a0a81831/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 29cce15..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/a0a81831/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/a0a81831/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/a0a81831/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/a0a81831/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/a0a81831/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/a0a81831/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 ecf6473..fa0d05f 100755
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -32,7 +32,6 @@ import org.apache.cloudstack.api.command.admin.router.ListOvsElementsCmd;
 import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
 import org.apache.log4j.Logger;
 
-import com.cloud.agent.api.PvlanSetupCommand;
 import com.cloud.agent.api.to.LoadBalancerTO;
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.dao.ConfigurationDao;
@@ -52,7 +51,6 @@ import com.cloud.network.Network.Service;
 import com.cloud.network.NetworkMigrationResponder;
 import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks;
-import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.OvsProvider;
 import com.cloud.network.PhysicalNetworkServiceProvider;
@@ -91,7 +89,6 @@ import com.cloud.utils.db.SearchCriteriaService;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicProfile;
-import com.cloud.vm.NicVO;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.UserVmManager;
 import com.cloud.vm.UserVmVO;
@@ -102,25 +99,13 @@ import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.google.gson.Gson;
-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.ListVirtualRouterElementsCmd;
-import org.apache.log4j.Logger;
 
-import javax.ejb.Local;
-import javax.inject.Inject;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-@Local(value = {NetworkElement.class, FirewallServiceProvider.class, 
-		        DhcpServiceProvider.class, UserDataServiceProvider.class, 
+@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, 
+public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider,
     UserDataServiceProvider, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider,
         LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer,
         NetworkMigrationResponder {
@@ -185,7 +170,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
             }
         } else {
             if (!_networkMgr.isProviderSupportServiceInNetwork(network.getId(), service, getProvider())) {
-                s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName() 
+                s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName()
                         + " in the network " + network);
                 return false;
             }
@@ -206,8 +191,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1);
         params.put(VirtualMachineProfile.Param.ReProgramGuestNetworks, true);
 
-        List<DomainRouterVO> routers = _routerMgr.deployVirtualRouterInGuestNetwork(network, dest, 
-                _accountMgr.getAccount(network.getAccountId()), params, 
+        List<DomainRouterVO> routers = _routerMgr.deployVirtualRouterInGuestNetwork(network, dest,
+                _accountMgr.getAccount(network.getAccountId()), params,
                 offering.getRedundantRouter());
         if ((routers == null) || (routers.size() == 0)) {
             throw new ResourceUnavailableException("Can't find at least one running router!",
@@ -218,7 +203,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     }
 
     @Override
-    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, 
+    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm,
             DeployDestination dest, ReservationContext context)
             throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
         if (vm.getType() != VirtualMachine.Type.User || vm.getHypervisorType() == HypervisorType.BareMetal) {
@@ -1047,18 +1032,18 @@ 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;
-            }
-        }
+//        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;
     }
 


[2/2] git commit: updated refs/heads/sdnextensions to 3056b1a

Posted by hu...@apache.org.
adding KVM support for GRE controller

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


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

Branch: refs/heads/sdnextensions
Commit: 3056b1a9f8be155d0a66117d8335d6c3a23dcad0
Parents: a0a8183
Author: tuna <ng...@gmail.com>
Authored: Tue Sep 17 10:27:49 2013 +0700
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Mon Oct 7 13:55:18 2013 +0200

----------------------------------------------------------------------
 plugins/hypervisors/kvm/pom.xml                 |   5 +
 .../kvm/resource/LibvirtComputingResource.java  | 265 ++++++++++++++++++-
 .../vm/hypervisor/kvm/cloudstack_pluginlib.py   | 219 +++++++++++++++
 scripts/vm/network/vnet/ovstunnel.py            | 182 +++++++++++++
 4 files changed, 658 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3056b1a9/plugins/hypervisors/kvm/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/pom.xml b/plugins/hypervisors/kvm/pom.xml
index 1babe7c..9d055f1 100644
--- a/plugins/hypervisors/kvm/pom.xml
+++ b/plugins/hypervisors/kvm/pom.xml
@@ -41,6 +41,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/3056b1a9/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 914017c..c9e34c5 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
@@ -63,8 +63,8 @@ import org.apache.cloudstack.utils.qemu.QemuImg;
 import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
 import org.apache.cloudstack.utils.qemu.QemuImgException;
 import org.apache.cloudstack.utils.qemu.QemuImgFile;
-import org.apache.log4j.Logger;
 import org.apache.commons.io.FileUtils;
+import org.apache.log4j.Logger;
 import org.libvirt.Connect;
 import org.libvirt.Domain;
 import org.libvirt.DomainBlockStats;
@@ -121,6 +121,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;
@@ -266,7 +273,7 @@ import com.cloud.vm.VirtualMachineName;
  **/
 @Local(value = { ServerResource.class })
 public class LibvirtComputingResource extends ServerResourceBase implements
-ServerResource {
+		ServerResource {
     private static final Logger s_logger = Logger
             .getLogger(LibvirtComputingResource.class);
 
@@ -282,6 +289,7 @@ ServerResource {
     private String _ovsPvlanDhcpHostPath;
     private String _ovsPvlanVmPath;
     private String _routerProxyPath;
+	private String _ovsTunnelPath;
     private String _host;
     private String _dcId;
     private String _pod;
@@ -289,6 +297,7 @@ ServerResource {
     private int _migrateSpeed;
 
     private long _hvVersion;
+	private long _kernelVersion;
     private KVMHAMonitor _monitor;
     private final String _SSHKEYSPATH = "/root/.ssh";
     private final String _SSHPRVKEYPATH = _SSHKEYSPATH + File.separator
@@ -597,6 +606,11 @@ ServerResource {
                     "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) {
@@ -846,6 +860,11 @@ ServerResource {
         storageProcessor.configure(name, params);
         storageHandler = new StorageSubsystemCommandHandlerBase(storageProcessor);
 
+		String unameKernelVersion = Script.runSimpleBashScript("uname -r");
+		String[] kernelVersions = unameKernelVersion.split("[\\.\\-]");
+		_kernelVersion = Integer.parseInt(kernelVersions[0]) * 1000 * 1000
+				+ Integer.parseInt(kernelVersions[1]) * 1000
+				+ Integer.parseInt(kernelVersions[2]);
         return true;
     }
 
@@ -1069,7 +1088,7 @@ ServerResource {
         return vnetId;
     }
 
-    private void passCmdLine(String vmName, String cmdLine)
+	private boolean passCmdLine(String vmName, String cmdLine)
             throws InternalErrorException {
         final Script command = new Script(_patchViaSocketPath, _timeout, s_logger);
         String result;
@@ -1077,8 +1096,10 @@ ServerResource {
         command.add("-p", cmdLine.replaceAll(" ", "%"));
         result = command.execute();
         if (result != null) {
-            throw new InternalErrorException(result);
+			s_logger.debug("passcmd failed:" + result);
+			return false;
         }
+		return true;
     }
 
     boolean isDirectAttachedNetwork(String type) {
@@ -1256,7 +1277,17 @@ ServerResource {
                 return this.storageHandler.handleStorageCommands((StorageSubSystemCommand)cmd);
             } else if (cmd instanceof PvlanSetupCommand) {
                 return execute((PvlanSetupCommand) 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);
             }
@@ -1265,6 +1296,188 @@ ServerResource {
         }
     }
 
+	// 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();
@@ -2930,7 +3143,8 @@ ServerResource {
         }
     }
 
-    private Answer execute(RebootCommand cmd) {
+
+	private Answer execute(RebootCommand cmd) {
 
         synchronized (_vms) {
             _vms.put(cmd.getVmName(), State.Starting);
@@ -3011,7 +3225,8 @@ ServerResource {
         }
     }
 
-    protected Answer execute(StopCommand cmd) {
+
+	protected Answer execute(StopCommand cmd) {
         final String vmName = cmd.getVmName();
 
         State state = null;
@@ -3178,8 +3393,8 @@ ServerResource {
 
         if (vmTO.getMinRam() != vmTO.getMaxRam()){
             grd.setMemBalloning(true);
-            grd.setCurrentMem((long)vmTO.getMinRam()/1024);
-            grd.setMemorySize((long)vmTO.getMaxRam()/1024);
+            grd.setCurrentMem(vmTO.getMinRam()/1024);
+            grd.setMemorySize(vmTO.getMaxRam()/1024);
         }
         else{
             grd.setMemorySize(vmTO.getMaxRam() / 1024);
@@ -3268,7 +3483,8 @@ ServerResource {
         }
     }
 
-    protected synchronized StartAnswer execute(StartCommand cmd) {
+
+	protected synchronized StartAnswer execute(StartCommand cmd) {
         VirtualMachineTO vmSpec = cmd.getVirtualMachine();
         vmSpec.setVncAddr(cmd.getHostIp());
         String vmName = vmSpec.getName();
@@ -3317,8 +3533,31 @@ ServerResource {
             }
 
             // 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) {
-                passCmdLine(vmName, vmSpec.getBootArgs() );
+				if ((_kernelVersion < 2006034) && (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
+					for (int count = 0; count < 30; count++) {
+						boolean succeed = passCmdLine(vmName, vmSpec.getBootArgs());
+						if (succeed) {
+							break;
+						}
+						try {
+							Thread.sleep(5000);
+						} catch (InterruptedException e) {
+							s_logger.trace("Ignoring InterruptedException.", e);
+						}
+					}
+				} else {
+					passCmdLine(vmName, vmSpec.getBootArgs());
+				}
             }
 
             state = State.Running;
@@ -4589,7 +4828,7 @@ ServerResource {
                 bytes_rd += blockStats.rd_bytes;
                 bytes_wr += blockStats.wr_bytes;
             }
-            
+
             if (oldStats != null) {
                 long deltaiord = io_rd - oldStats._io_rd;
                 if (deltaiord > 0)
@@ -4604,7 +4843,7 @@ ServerResource {
                 if (deltabyteswr > 0)
                     stats.setDiskWriteKBs(deltabyteswr / 1024);
             }
-            
+
             /* save to Hashmap */
             vmStats newStat = new vmStats();
             newStat._usedTime = info.cpuTime;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3056b1a9/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 100644
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/3056b1a9/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 100644
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