cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [08/21] git commit: updated refs/heads/master to 267ff79
Date Mon, 09 Dec 2013 16:52:34 GMT
re-factor gre controller

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


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

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

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


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

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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e914b70/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index d10791c..25f30f4 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -264,18 +264,6 @@ import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.IsolationType;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.PhysicalNetworkSetupInfo;
-import com.cloud.network.ovs.OvsCreateGreTunnelAnswer;
-import com.cloud.network.ovs.OvsCreateGreTunnelCommand;
-import com.cloud.network.ovs.OvsCreateTunnelAnswer;
-import com.cloud.network.ovs.OvsCreateTunnelCommand;
-import com.cloud.network.ovs.OvsDeleteFlowCommand;
-import com.cloud.network.ovs.OvsDestroyBridgeCommand;
-import com.cloud.network.ovs.OvsDestroyTunnelCommand;
-import com.cloud.network.ovs.OvsFetchInterfaceAnswer;
-import com.cloud.network.ovs.OvsFetchInterfaceCommand;
-import com.cloud.network.ovs.OvsSetTagAndFlowAnswer;
-import com.cloud.network.ovs.OvsSetTagAndFlowCommand;
-import com.cloud.network.ovs.OvsSetupBridgeCommand;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.resource.ServerResource;
 import com.cloud.resource.hypervisor.HypervisorResource;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


Mime
View raw message