You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mu...@apache.org on 2013/02/07 08:43:58 UTC
[27/50] [abbrv] git commit: refs/heads/gslb - bigswitch controller
support
bigswitch controller support
Reviewed-by: Chiradeep Vittal <ch...@gmail.com>
Signed-off-by: Murali Reddy <mu...@citrix.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/736b236e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/736b236e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/736b236e
Branch: refs/heads/gslb
Commit: 736b236eaffc8a0252396e7ad2a5ba0ad6a909b0
Parents: 2491ff1
Author: Kanzhe Jiang <ka...@bigswitch.com>
Authored: Fri Feb 1 12:38:17 2013 +0530
Committer: Murali Reddy <mu...@citrix.com>
Committed: Fri Feb 1 12:42:04 2013 +0530
----------------------------------------------------------------------
api/src/com/cloud/network/PhysicalNetwork.java | 3 +-
client/pom.xml | 5 +
client/tomcatconf/commands.properties.in | 6 +
client/tomcatconf/components.xml.in | 5 +
cloud.spec | 1 +
debian/cloud-server.install | 1 +
docs/en-US/Release_Notes.xml | 9 +
plugins/network-elements/bigswitch-vns/pom.xml | 29 +
.../cloud/agent/api/CreateVnsNetworkAnswer.java | 28 +
.../cloud/agent/api/CreateVnsNetworkCommand.java | 52 ++
.../com/cloud/agent/api/CreateVnsPortAnswer.java | 30 +
.../com/cloud/agent/api/CreateVnsPortCommand.java | 65 ++
.../cloud/agent/api/DeleteVnsNetworkAnswer.java | 30 +
.../cloud/agent/api/DeleteVnsNetworkCommand.java | 41 ++
.../com/cloud/agent/api/DeleteVnsPortAnswer.java | 30 +
.../com/cloud/agent/api/DeleteVnsPortCommand.java | 48 ++
.../agent/api/StartupBigSwitchVnsCommand.java | 27 +
.../com/cloud/agent/api/UpdateVnsPortAnswer.java | 30 +
.../com/cloud/agent/api/UpdateVnsPortCommand.java | 58 ++
.../api/commands/AddBigSwitchVnsDeviceCmd.java | 110 +++
.../api/commands/DeleteBigSwitchVnsDeviceCmd.java | 99 +++
.../api/commands/ListBigSwitchVnsDevicesCmd.java | 109 +++
.../src/com/cloud/api/commands/VnsConstants.java | 19 +
.../api/response/BigSwitchVnsDeviceResponse.java | 63 ++
.../com/cloud/network/BigSwitchVnsDeviceVO.java | 94 +++
.../com/cloud/network/bigswitch/Attachment.java | 38 +
.../cloud/network/bigswitch/BigSwitchVnsApi.java | 330 +++++++++
.../bigswitch/BigSwitchVnsApiException.java | 39 +
.../network/bigswitch/ControlClusterStatus.java | 25 +
.../src/com/cloud/network/bigswitch/Network.java | 74 ++
.../src/com/cloud/network/bigswitch/Port.java | 56 ++
.../src/com/cloud/network/dao/BigSwitchVnsDao.java | 32 +
.../com/cloud/network/dao/BigSwitchVnsDaoImpl.java | 48 ++
.../cloud/network/element/BigSwitchVnsElement.java | 543 +++++++++++++++
.../element/BigSwitchVnsElementService.java | 39 +
.../network/guru/BigSwitchVnsGuestNetworkGuru.java | 261 +++++++
.../network/resource/BigSwitchVnsResource.java | 322 +++++++++
.../cloud/network/bigswitch/BigSwitchApiTest.java | 228 ++++++
.../network/resource/BigSwitchVnsResourceTest.java | 254 +++++++
plugins/pom.xml | 1 +
setup/db/create-schema.sql | 13 +
tools/apidoc/gen_toc.py | 1 +
ui/scripts/ui-custom/zoneWizard.js | 5 +-
wscript_configure | 2 +-
44 files changed, 3300 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/api/src/com/cloud/network/PhysicalNetwork.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/PhysicalNetwork.java b/api/src/com/cloud/network/PhysicalNetwork.java
index a495092..383b1b6 100644
--- a/api/src/com/cloud/network/PhysicalNetwork.java
+++ b/api/src/com/cloud/network/PhysicalNetwork.java
@@ -35,7 +35,8 @@ public interface PhysicalNetwork extends Identity, InternalIdentity {
VLAN,
L3,
GRE,
- STT;
+ STT,
+ VNS;
}
public enum BroadcastDomainRange {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 63ec2ef..df82402 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -77,6 +77,11 @@
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-plugin-network-vns</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-hypervisor-xen</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 4b0506f..d70649b 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -513,6 +513,12 @@ listNiciraNvpDeviceNetworks=1
# Not implemented (yet)
#configureNiciraNvpDevice=1
+#### bigswitch vns commands
+
+addBigSwitchVnsDevice=1
+deleteBigSwitchVnsDevice=1
+listBigSwitchVnsDevices=1
+
#### host simulator commands
configureSimulator=1
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/client/tomcatconf/components.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in
index e84be04..c62abe8 100755
--- a/client/tomcatconf/components.xml.in
+++ b/client/tomcatconf/components.xml.in
@@ -106,6 +106,7 @@ under the License.
<adapter name="OvsGuestNetworkGuru" class="com.cloud.network.guru.OvsGuestNetworkGuru"/>
<adapter name="PrivateNetworkGuru" class="com.cloud.network.guru.PrivateNetworkGuru"/>
<adapter name="NiciraNvpGuestNetworkGuru" class="com.cloud.network.guru.NiciraNvpGuestNetworkGuru"/>
+ <adapter name="BigSwitchVnsGuestNetworkGuru" class="com.cloud.network.guru.BigSwitchVnsGuestNetworkGuru"/>
</adapters>
<adapters key="com.cloud.cluster.ClusterServiceAdapter">
<adapter name="ClusterService" class="com.cloud.cluster.ClusterServiceServletAdapter"/>
@@ -166,6 +167,7 @@ under the License.
<adapter name="SecurityGroupProvider" class="com.cloud.network.element.SecurityGroupElement"/>
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
<adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
+ <adapter name="BigSwitchVns" class="com.cloud.network.element.BigSwitchVnsElement"/>
</adapters>
<adapters key="com.cloud.network.element.FirewallServiceProvider">
<adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
@@ -212,6 +214,7 @@ under the License.
</adapters>
<adapters key="com.cloud.network.element.ConnectivityProvider">
<adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
+ <adapter name="BigSwitchVns" class="com.cloud.network.element.BigSwitchVnsElement"/>
</adapters>
<adapters key="com.cloud.network.element.NetworkACLServiceProvider">
<adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
@@ -239,12 +242,14 @@ under the License.
<pluggableservice name="VirtualRouterElementService" key="com.cloud.network.element.VirtualRouterElementService" class="com.cloud.network.element.VirtualRouterElement"/>
<pluggableservice name="NiciraNvpElementService" key="com.cloud.network.element.NiciraNvpElementService" class="com.cloud.network.element.NiciraNvpElement"/>
<pluggableservice name="ApiRateLimitService" key="org.apache.cloudstack.ratelimit.ApiRateLimitService" class="org.apache.cloudstack.ratelimit.ApiRateLimitServiceImpl"/>
+ <pluggableservice name="BigSwitchVnsElementService" key="com.cloud.network.element.BigSwitchVnsElementService" class="com.cloud.network.element.BigSwitchVnsElement"/>
<dao name="OvsTunnelInterfaceDao" class="com.cloud.network.ovs.dao.OvsTunnelInterfaceDaoImpl" singleton="false"/>
<dao name="OvsTunnelAccountDao" class="com.cloud.network.ovs.dao.OvsTunnelNetworkDaoImpl" singleton="false"/>
<dao name="NiciraNvpDao" class="com.cloud.network.dao.NiciraNvpDaoImpl" singleton="false"/>
<dao name="NiciraNvpNicMappingDao" class="com.cloud.network.dao.NiciraNvpNicMappingDaoImpl" singleton="false"/>
<dao name="NiciraNvpRouterMappingDao" class="com.cloud.network.dao.NiciraNvpRouterMappingDaoImpl" singleton="false"/>
<dao name="ElasticLbVmMapDao" class="com.cloud.network.lb.dao.ElasticLbVmMapDaoImpl" singleton="false"/>
+ <dao name="BigSwitchVnsDao" class="com.cloud.network.dao.BigSwitchVnsDaoImpl" singleton="false"/>
</management-server>
<configuration-server class="com.cloud.server.ConfigurationServerImpl">
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/cloud.spec
----------------------------------------------------------------------
diff --git a/cloud.spec b/cloud.spec
index 9f46dd6..bde3958 100644
--- a/cloud.spec
+++ b/cloud.spec
@@ -448,6 +448,7 @@ fi
%{_javadir}/%{name}-plugin-hypervisor-xen.jar
%{_javadir}/%{name}-plugin-elb.jar
%{_javadir}/%{name}-plugin-nicira-nvp.jar
+%{_javadir}/%{name}-plugin-bigswitch-vns.jar
%config(noreplace) %{_sysconfdir}/%{name}/server/*
%doc LICENSE
%doc NOTICE
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/debian/cloud-server.install
----------------------------------------------------------------------
diff --git a/debian/cloud-server.install b/debian/cloud-server.install
index 9cd1eeb..f792cc2 100644
--- a/debian/cloud-server.install
+++ b/debian/cloud-server.install
@@ -24,6 +24,7 @@
/usr/share/java/cloud-plugin-elb.jar
/usr/share/java/cloud-plugin-ovs.jar
/usr/share/java/cloud-plugin-nicira-nvp.jar
+/usr/share/java/cloud-plugin-bigswitch-vns.jar
/usr/share/java/cloud-storage-allocator-random.jar
/usr/share/java/cloud-user-authenticator-ldap.jar
/usr/share/java/cloud-user-authenticator-md5.jar
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/docs/en-US/Release_Notes.xml
----------------------------------------------------------------------
diff --git a/docs/en-US/Release_Notes.xml b/docs/en-US/Release_Notes.xml
index c8cc686..4d1f62f 100644
--- a/docs/en-US/Release_Notes.xml
+++ b/docs/en-US/Release_Notes.xml
@@ -1291,6 +1291,15 @@ Done restarting router(s).
appropriate calls to the Nicira NVP Controller. The plug-in has been tested with Nicira
NVP versions 2.1.0, 2.2.0 and 2.2.1.</para>
</section>
+ <section id="bigswitch-vns-plugin">
+ <title>The BigSwitch Controller Plugin</title>
+ <para>The BigSwitch Controller plug-in adds OpenFlow based solution for network virtualization
+ to CloudStack. The plugin supports both BigSwitch commercial controller and the opensource
+ Floodlight controller. The plugin functions as a provider for CloudStack networks and Connectivity
+ service. This service is responsible for creating Layer 2 networks supporting the networks
+ created by guests. When a tenant creates a new network, a virutal network segment will be
+ created by sending the appropriate calls to the BigSwitch Controller.</para>
+ </section>
<section id="castor-support">
<title>Support for CAStor Cluster</title>
<para>CloudStack 4.0.0-incubating supports using a CAStor cluster as the back-end storage
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/pom.xml b/plugins/network-elements/bigswitch-vns/pom.xml
new file mode 100644
index 0000000..32650f3
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/pom.xml
@@ -0,0 +1,29 @@
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cloud-plugin-network-vns</artifactId>
+ <name>Apache CloudStack Plugin - BigSwitch Virtual Network Segment</name>
+ <parent>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloudstack-plugins</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsNetworkAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsNetworkAnswer.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsNetworkAnswer.java
new file mode 100644
index 0000000..e950abe
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsNetworkAnswer.java
@@ -0,0 +1,28 @@
+// 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;
+
+public class CreateVnsNetworkAnswer extends Answer {
+
+ public CreateVnsNetworkAnswer(Command command, boolean success, String details) {
+ super(command, success, details);
+ }
+
+ public CreateVnsNetworkAnswer(Command command, Exception e) {
+ super(command, e);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsNetworkCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsNetworkCommand.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsNetworkCommand.java
new file mode 100644
index 0000000..df98328
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsNetworkCommand.java
@@ -0,0 +1,52 @@
+// 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;
+
+public class CreateVnsNetworkCommand extends Command {
+ private String _networkUuid;
+ private String _name;
+ private String _tenantUuid;
+ private int _vlan;
+
+ public CreateVnsNetworkCommand(String networkUuid, String name, String tenantUuid, int vlan) {
+ this._networkUuid = networkUuid;
+ this._name = name;
+ this._tenantUuid = tenantUuid;
+ this._vlan = vlan;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+ public String getNetworkUuid() {
+ return _networkUuid;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getTenantUuid() {
+ return _tenantUuid;
+ }
+
+ public int getVlan() {
+ return _vlan;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsPortAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsPortAnswer.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsPortAnswer.java
new file mode 100644
index 0000000..e88c7b5
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsPortAnswer.java
@@ -0,0 +1,30 @@
+// 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;
+
+public class CreateVnsPortAnswer extends Answer {
+
+ public CreateVnsPortAnswer(Command command, boolean success,
+ String details) {
+ super(command, success, details);
+ }
+
+ public CreateVnsPortAnswer(Command command, Exception e) {
+ super(command, e);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsPortCommand.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsPortCommand.java
new file mode 100644
index 0000000..a4a3a04
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/CreateVnsPortCommand.java
@@ -0,0 +1,65 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.agent.api;
+
+public class CreateVnsPortCommand extends Command {
+ private String _networkUuid;
+ private String _portUuid;
+ private String _tenantUuid;
+ private String _portName;
+ private String _mac;
+
+ public CreateVnsPortCommand(String networkUuid, String portUuid,
+ String tenantUuid, String portName, String mac) {
+ this._networkUuid = networkUuid;
+ this._portUuid = portUuid;
+ this._tenantUuid = tenantUuid;
+ this._portName = portName;
+ this._mac = mac;
+ }
+
+
+ public String getNetworkUuid() {
+ return _networkUuid;
+ }
+
+
+ public String getPortUuid() {
+ return _portUuid;
+ }
+
+
+ public String getTenantUuid() {
+ return _tenantUuid;
+ }
+
+
+ public String getPortName() {
+ return _portName;
+ }
+
+
+ public String getMac() {
+ return _mac;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsNetworkAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsNetworkAnswer.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsNetworkAnswer.java
new file mode 100644
index 0000000..498180c
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsNetworkAnswer.java
@@ -0,0 +1,30 @@
+// 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;
+
+public class DeleteVnsNetworkAnswer extends Answer {
+
+ public DeleteVnsNetworkAnswer(Command command, boolean success,
+ String details) {
+ super(command, success, details);
+ }
+
+ public DeleteVnsNetworkAnswer(Command command, Exception e) {
+ super(command, e);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsNetworkCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsNetworkCommand.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsNetworkCommand.java
new file mode 100644
index 0000000..6cf169b
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsNetworkCommand.java
@@ -0,0 +1,41 @@
+// 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;
+
+public class DeleteVnsNetworkCommand extends Command {
+
+ private String _tenantUuid;
+ private String _networkUuid;
+
+ public DeleteVnsNetworkCommand(String tenantUuid, String networkUuid) {
+ this._tenantUuid = tenantUuid;
+ this._networkUuid = networkUuid;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+ public String get_tenantUuid() {
+ return _tenantUuid;
+ }
+
+ public String getNetworkUuid() {
+ return _networkUuid;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsPortAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsPortAnswer.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsPortAnswer.java
new file mode 100644
index 0000000..00c6abc
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsPortAnswer.java
@@ -0,0 +1,30 @@
+// 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;
+
+public class DeleteVnsPortAnswer extends Answer {
+
+ public DeleteVnsPortAnswer(Command command, boolean success,
+ String details) {
+ super(command, success, details);
+ }
+
+ public DeleteVnsPortAnswer(Command command, Exception e) {
+ super(command, e);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsPortCommand.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsPortCommand.java
new file mode 100644
index 0000000..0cae01d
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/DeleteVnsPortCommand.java
@@ -0,0 +1,48 @@
+// 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;
+
+public class DeleteVnsPortCommand extends Command {
+
+ private String _networkUuid;
+ private String _portUuid;
+ private String _tenantUuid;
+
+ public DeleteVnsPortCommand(String networkUuid, String portUuid, String tenantUuid) {
+ this._networkUuid = networkUuid;
+ this._portUuid = portUuid;
+ this._tenantUuid = tenantUuid;
+ }
+
+ public String getNetworkUuid() {
+ return _networkUuid;
+ }
+
+ public String getPortUuid() {
+ return _portUuid;
+ }
+
+ public String getTenantUuid() {
+ return _tenantUuid;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/StartupBigSwitchVnsCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/StartupBigSwitchVnsCommand.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/StartupBigSwitchVnsCommand.java
new file mode 100644
index 0000000..8310b07
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/StartupBigSwitchVnsCommand.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.host.Host;
+
+public class StartupBigSwitchVnsCommand extends StartupCommand {
+
+ public StartupBigSwitchVnsCommand() {
+ super(Host.Type.L2Networking);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/UpdateVnsPortAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/UpdateVnsPortAnswer.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/UpdateVnsPortAnswer.java
new file mode 100644
index 0000000..6313d14
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/UpdateVnsPortAnswer.java
@@ -0,0 +1,30 @@
+// 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;
+
+public class UpdateVnsPortAnswer extends Answer {
+
+ public UpdateVnsPortAnswer(Command command, boolean success,
+ String details) {
+ super(command, success, details);
+ }
+
+ public UpdateVnsPortAnswer(Command command, Exception e) {
+ super(command, e);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/UpdateVnsPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/UpdateVnsPortCommand.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/UpdateVnsPortCommand.java
new file mode 100644
index 0000000..3492b99
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/agent/api/UpdateVnsPortCommand.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;
+
+public class UpdateVnsPortCommand extends Command {
+ private String _networkUuid;
+ private String _portUuid;
+ private String _tenantUuid;
+ private String _portName;
+
+ public UpdateVnsPortCommand(String networkUuid, String portUuid, String tenantUuid, String portName) {
+ this._networkUuid = networkUuid;
+ this._portUuid = portUuid;
+ this._tenantUuid = tenantUuid;
+ this._portName = portName;
+ }
+
+
+ public String getNetworkUuid() {
+ return _networkUuid;
+ }
+
+
+ public String getPortUuid() {
+ return _portUuid;
+ }
+
+
+ public String getTenantUuid() {
+ return _tenantUuid;
+ }
+
+
+ public String getPortName() {
+ return _portName;
+ }
+
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
new file mode 100644
index 0000000..3662a2e
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/AddBigSwitchVnsDeviceCmd.java
@@ -0,0 +1,110 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.api.commands;
+
+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.PlugService;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
+
+import com.cloud.api.response.BigSwitchVnsDeviceResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.BigSwitchVnsDeviceVO;
+import com.cloud.network.element.BigSwitchVnsElementService;
+import com.cloud.user.UserContext;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "addBigSwitchVnsDevice", responseObject=BigSwitchVnsDeviceResponse.class, description="Adds a BigSwitch VNS device")
+public class AddBigSwitchVnsDeviceCmd extends BaseAsyncCmd {
+ private static final String s_name = "addbigswitchvnsdeviceresponse";
+ @PlugService BigSwitchVnsElementService _bigswitchVnsElementService;
+
+ /////////////////////////////////////////////////////
+ //////////////// 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 {
+ try {
+ BigSwitchVnsDeviceVO bigswitchVnsDeviceVO = _bigswitchVnsElementService.addBigSwitchVnsDevice(this);
+ if (bigswitchVnsDeviceVO != null) {
+ BigSwitchVnsDeviceResponse response = _bigswitchVnsElementService.createBigSwitchVnsDeviceResponse(bigswitchVnsDeviceVO);
+ response.setObjectName("bigswitchvnsdevice");
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add BigSwitch VNS device due to internal error.");
+ }
+ } 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;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return UserContext.current().getCaller().getId();
+ }
+
+ @Override
+ public String getEventType() {
+ return VnsConstants.EVENT_EXTERNAL_VNS_CONTROLLER_ADD;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Adding a BigSwitch VNS Controller";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
new file mode 100644
index 0000000..83adb22
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java
@@ -0,0 +1,99 @@
+// 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.commands;
+
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.PlugService;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.SuccessResponse;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.element.BigSwitchVnsElementService;
+import com.cloud.user.UserContext;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "deleteBigSwitchVnsDevice", responseObject=SuccessResponse.class, description=" delete a bigswitch vns device")
+public class DeleteBigSwitchVnsDeviceCmd extends BaseAsyncCmd {
+ private static final String s_name = "deletebigswitchvnsdeviceresponse";
+ @PlugService BigSwitchVnsElementService _bigswitchVnsElementService;
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID, type=CommandType.LONG, required=true, description="BigSwitch device ID")
+ private Long bigswitchVnsDeviceId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getBigSwitchVnsDeviceId() {
+ return bigswitchVnsDeviceId;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
+ try {
+ boolean result = _bigswitchVnsElementService.deleteBigSwitchVnsDevice(this);
+ if (result) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete BigSwitch 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 getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return UserContext.current().getCaller().getId();
+ }
+
+ @Override
+ public String getEventType() {
+ return VnsConstants.EVENT_EXTERNAL_VNS_CONTROLLER_DELETE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Deleting BigSwitch Vns Controller";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/ListBigSwitchVnsDevicesCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/ListBigSwitchVnsDevicesCmd.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/ListBigSwitchVnsDevicesCmd.java
new file mode 100644
index 0000000..d9a209e
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/ListBigSwitchVnsDevicesCmd.java
@@ -0,0 +1,109 @@
+// 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.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.PlugService;
+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.BigSwitchVnsDeviceResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.BigSwitchVnsDeviceVO;
+import com.cloud.network.element.BigSwitchVnsElementService;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "listBigSwitchVnsDevices", responseObject=BigSwitchVnsDeviceResponse.class, description="Lists BigSwitch Vns devices")
+public class ListBigSwitchVnsDevicesCmd extends BaseListCmd {
+ public static final Logger s_logger = Logger.getLogger(ListBigSwitchVnsDevicesCmd.class.getName());
+ private static final String s_name = "listbigswitchvnsdeviceresponse";
+ @PlugService BigSwitchVnsElementService _bigswitchVnsElementService;
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID,
+ entityType = PhysicalNetworkResponse.class,
+ description="the Physical Network ID")
+ private Long physicalNetworkId;
+
+ @Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID,
+ type=CommandType.LONG,
+ description="bigswitch vns device ID")
+ private Long bigswitchVnsDeviceId;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getBigSwitchVnsDeviceId() {
+ return bigswitchVnsDeviceId;
+ }
+
+ public Long getPhysicalNetworkId() {
+ return physicalNetworkId;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException,
+ ConcurrentOperationException, ResourceAllocationException {
+ try {
+ List<BigSwitchVnsDeviceVO> bigswitchDevices = _bigswitchVnsElementService.listBigSwitchVnsDevices(this);
+ ListResponse<BigSwitchVnsDeviceResponse> response = new ListResponse<BigSwitchVnsDeviceResponse>();
+ List<BigSwitchVnsDeviceResponse> bigswitchDevicesResponse = new ArrayList<BigSwitchVnsDeviceResponse>();
+
+ if (bigswitchDevices != null && !bigswitchDevices.isEmpty()) {
+ for (BigSwitchVnsDeviceVO bigswitchDeviceVO : bigswitchDevices) {
+ BigSwitchVnsDeviceResponse bigswitchDeviceResponse =
+ _bigswitchVnsElementService.createBigSwitchVnsDeviceResponse(bigswitchDeviceVO);
+ bigswitchDevicesResponse.add(bigswitchDeviceResponse);
+ }
+ }
+
+ response.setResponses(bigswitchDevicesResponse);
+ 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/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/VnsConstants.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/VnsConstants.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/VnsConstants.java
new file mode 100644
index 0000000..5a81ec6
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/VnsConstants.java
@@ -0,0 +1,19 @@
+package com.cloud.api.commands;
+
+
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
+
+import com.cloud.network.Network.Provider;
+
+public class VnsConstants {
+ public static final String BIGSWITCH_VNS_DEVICE_ID = "vnsdeviceid";
+ public static final String BIGSWITCH_VNS_DEVICE_NAME = "bigswitchdevicename";
+
+ public static final String EVENT_EXTERNAL_VNS_CONTROLLER_ADD = "PHYSICAL.VNSCONTROLLER.ADD";
+ public static final String EVENT_EXTERNAL_VNS_CONTROLLER_DELETE = "PHYSICAL.VNSCONTROLLER.DELETE";
+
+ public static final Provider BigSwitchVns = new Provider("BigSwitchVns", true);
+
+ public static final NetworkDevice BigSwitchVnsDevice = new NetworkDevice("BigSwitchVns", BigSwitchVns.getName());
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/api/response/BigSwitchVnsDeviceResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/api/response/BigSwitchVnsDeviceResponse.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/response/BigSwitchVnsDeviceResponse.java
new file mode 100644
index 0000000..ede5adf
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/api/response/BigSwitchVnsDeviceResponse.java
@@ -0,0 +1,63 @@
+// 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.api.commands.VnsConstants;
+import com.cloud.network.BigSwitchVnsDeviceVO;
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+@EntityReference(value=BigSwitchVnsDeviceVO.class)
+public class BigSwitchVnsDeviceResponse extends BaseResponse {
+ @SerializedName(VnsConstants.BIGSWITCH_VNS_DEVICE_ID) @Param(description="device id of the BigSwitch Vns")
+ private String id;
+
+ @SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network to which this BigSwitch Vns belongs to")
+ private String physicalNetworkId;
+
+ @SerializedName(ApiConstants.PROVIDER) @Param(description="name of the provider")
+ private String providerName;
+
+ @SerializedName(VnsConstants.BIGSWITCH_VNS_DEVICE_NAME) @Param(description="device name")
+ private String deviceName;
+
+ @SerializedName(ApiConstants.HOST_NAME) @Param(description="the controller Ip address")
+ private String hostName;
+
+ public void setId(String vnsDeviceId) {
+ this.id = vnsDeviceId;
+ }
+
+ public void setPhysicalNetworkId(String physicalNetworkId) {
+ this.physicalNetworkId = physicalNetworkId;
+ }
+
+ public void setProviderName(String providerName) {
+ this.providerName = providerName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/network/BigSwitchVnsDeviceVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/BigSwitchVnsDeviceVO.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/BigSwitchVnsDeviceVO.java
new file mode 100644
index 0000000..7e64833
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/BigSwitchVnsDeviceVO.java
@@ -0,0 +1,94 @@
+// 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;
+
+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;
+
+@Entity
+@Table(name="external_bigswitch_vns_devices")
+public class BigSwitchVnsDeviceVO {
+
+ @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="provider_name")
+ private String providerName;
+
+ @Column(name="device_name")
+ private String deviceName;
+
+ public BigSwitchVnsDeviceVO() {
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ public BigSwitchVnsDeviceVO(long hostId, long physicalNetworkId,
+ String providerName, String deviceName) {
+ super();
+ this.hostId = hostId;
+ this.physicalNetworkId = physicalNetworkId;
+ this.providerName = providerName;
+ 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 getProviderName() {
+ return providerName;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Attachment.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Attachment.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Attachment.java
new file mode 100644
index 0000000..9a13467
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Attachment.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.network.bigswitch;
+
+public class Attachment {
+ private String id;
+ private String mac;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getMac() {
+ return mac;
+ }
+
+ public void setMac(String mac) {
+ this.mac = mac;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/BigSwitchVnsApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/BigSwitchVnsApi.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/BigSwitchVnsApi.java
new file mode 100644
index 0000000..c409dce
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/BigSwitchVnsApi.java
@@ -0,0 +1,330 @@
+// 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.bigswitch;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Type;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.NameValuePair;
+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.commons.httpclient.methods.StringRequestEntity;
+import org.apache.log4j.Logger;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+public class BigSwitchVnsApi {
+ private static final Logger s_logger = Logger.getLogger(BigSwitchVnsApi.class);
+ private final static String _protocol = "http";
+ private final static String _nsBaseUri = "/networkService/v1.1";
+ private final static String _controllerBaseUri = "/wm/core";
+ private final static String CONTENT_TYPE = "Content-Type";
+ private final static String CONTENT_JSON = "application/json";
+ private final static String HTTP_HEADER_INSTANCE_ID = "HTTP_INSTANCE_ID";
+ private final static String CLOUDSTACK_INSTANCE_ID = "org.apache.cloudstack";
+ private final static MultiThreadedHttpConnectionManager s_httpClientManager =
+ new MultiThreadedHttpConnectionManager();
+
+ private String _host;
+
+ private HttpClient _client;
+
+ /* This factory method is protected so we can extend this
+ * in the unittests.
+ */
+ protected HttpClient createHttpClient() {
+ return new HttpClient(s_httpClientManager);
+ }
+
+ protected HttpMethod createMethod(String type, String uri, int port) throws BigSwitchVnsApiException {
+ String url;
+ try {
+ url = new URL(_protocol, _host, port, uri).toString();
+ } catch (MalformedURLException e) {
+ s_logger.error("Unable to build BigSwitch API URL", e);
+ throw new BigSwitchVnsApiException("Unable to build v 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 BigSwitchVnsApiException("Requesting unknown method type");
+ }
+ }
+
+ public BigSwitchVnsApi() {
+ _client = createHttpClient();
+ _client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
+ }
+
+ public void setControllerAddress(String address) {
+ this._host = address;
+ }
+
+
+ /**
+ * Logs into the BigSwitch API. The cookie is stored in the <code>_authcookie<code> variable.
+ * <p>
+ * The method returns false if the login failed or the connection could not be made.
+ *
+ */
+ protected void login() throws BigSwitchVnsApiException {
+ return;
+ }
+
+ public void createNetwork(Network network)
+ throws BigSwitchVnsApiException {
+ String uri = _nsBaseUri + "/tenant/" + network.getTenant_id() + "/network";
+ executeCreateObject(network, new TypeToken<Network>(){}.getType(),
+ uri, Collections.<String,String>emptyMap());
+ }
+
+ public void deleteNetwork(String tenantId, String networkId) throws BigSwitchVnsApiException {
+ String uri = _nsBaseUri + "/tenant/" + tenantId + "/networks/" + networkId;
+ executeDeleteObject(uri);
+ }
+
+ public void createPort(String networkUuid, Port port)
+ throws BigSwitchVnsApiException {
+ String uri = _nsBaseUri + "/tenant/" + port.getTenant_id() + "/networks/" + networkUuid + "/ports";
+ executeCreateObject(port, new TypeToken<Port>(){}.getType(),
+ uri, Collections.<String,String>emptyMap());
+ }
+
+ public void modifyPort(String networkId, Port port)
+ throws BigSwitchVnsApiException {
+ String uri = _nsBaseUri + "/tenant/" + port.getTenant_id() + "/networks/" + networkId + "/ports";
+ executeUpdateObject(port, uri, Collections.<String,String>emptyMap());
+ }
+
+ public void deletePort(String tenantId, String networkId, String portId)
+ throws BigSwitchVnsApiException {
+ String uri = _nsBaseUri + "/tenant/" + tenantId + "/networks/" + networkId + "/ports/" + portId;
+ executeDeleteObject(uri);
+ }
+
+ public void modifyPortAttachment(String tenantId,
+ String networkId,
+ String portId,
+ Attachment attachment) throws BigSwitchVnsApiException {
+ String uri = _nsBaseUri + "/tenant/" + tenantId + "/networks/" + networkId + "/ports/" + portId + "/attachment";
+ executeUpdateObject(attachment, uri, Collections.<String,String>emptyMap());
+ }
+
+ public void deletePortAttachment(String tenantId, String networkId, String portId)
+ throws BigSwitchVnsApiException {
+ String uri = _nsBaseUri + "/tenant/" + tenantId + "/networks/" + networkId + "/ports/" + portId + "/attachment";
+ executeDeleteObject(uri);
+ }
+
+ public ControlClusterStatus getControlClusterStatus() throws BigSwitchVnsApiException {
+ String uri = _controllerBaseUri + "/health/json";
+ ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>(){}.getType(),
+ uri, 80, null);
+
+ return ccs;
+ }
+
+ protected <T> void executeUpdateObject(T newObject, String uri, Map<String,String> parameters)
+ throws BigSwitchVnsApiException {
+ if (_host == null || _host.isEmpty()) {
+ throw new BigSwitchVnsApiException("Hostname is null or empty");
+ }
+
+ Gson gson = new Gson();
+
+ PutMethod pm = (PutMethod) createMethod("put", uri, 80);
+ pm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
+ pm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
+ try {
+ pm.setRequestEntity(new StringRequestEntity(
+ gson.toJson(newObject), CONTENT_JSON, null));
+ } catch (UnsupportedEncodingException e) {
+ throw new BigSwitchVnsApiException("Failed to encode json request body", e);
+ }
+
+ executeMethod(pm);
+
+ if (pm.getStatusCode() != HttpStatus.SC_OK) {
+ String errorMessage = responseToErrorMessage(pm);
+ pm.releaseConnection();
+ s_logger.error("Failed to update object : " + errorMessage);
+ throw new BigSwitchVnsApiException("Failed to update object : " + errorMessage);
+ }
+ pm.releaseConnection();
+ }
+
+ protected <T> void executeCreateObject(T newObject, Type returnObjectType, String uri,
+ Map<String,String> parameters)
+ throws BigSwitchVnsApiException {
+ if (_host == null || _host.isEmpty()) {
+ throw new BigSwitchVnsApiException("Hostname is null or empty");
+ }
+
+ Gson gson = new Gson();
+
+ PostMethod pm = (PostMethod) createMethod("post", uri, 80);
+ pm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
+ pm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
+ try {
+ pm.setRequestEntity(new StringRequestEntity(
+ gson.toJson(newObject), CONTENT_JSON, null));
+ } catch (UnsupportedEncodingException e) {
+ throw new BigSwitchVnsApiException("Failed to encode json request body", e);
+ }
+
+ executeMethod(pm);
+
+ if (pm.getStatusCode() != HttpStatus.SC_OK) {
+ String errorMessage = responseToErrorMessage(pm);
+ pm.releaseConnection();
+ s_logger.error("Failed to create object : " + errorMessage);
+ throw new BigSwitchVnsApiException("Failed to create object : " + errorMessage);
+ }
+ pm.releaseConnection();
+
+ return;
+ }
+
+ protected void executeDeleteObject(String uri) throws BigSwitchVnsApiException {
+ if (_host == null || _host.isEmpty()) {
+ throw new BigSwitchVnsApiException("Hostname is null or empty");
+ }
+
+ DeleteMethod dm = (DeleteMethod) createMethod("delete", uri, 80);
+ dm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
+ dm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
+
+ executeMethod(dm);
+
+ if (dm.getStatusCode() != HttpStatus.SC_OK) {
+ String errorMessage = responseToErrorMessage(dm);
+ dm.releaseConnection();
+ s_logger.error("Failed to delete object : " + errorMessage);
+ throw new BigSwitchVnsApiException("Failed to delete object : " + errorMessage);
+ }
+ dm.releaseConnection();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> T executeRetrieveObject(Type returnObjectType, String uri, int port, Map<String,String> parameters)
+ throws BigSwitchVnsApiException {
+ if (_host == null || _host.isEmpty()) {
+ throw new BigSwitchVnsApiException("Hostname is null or empty");
+ }
+
+ GetMethod gm = (GetMethod) createMethod("get", uri, port);
+ gm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
+ gm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
+
+ if (parameters != null && !parameters.isEmpty()) {
+ List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
+ for (Entry<String,String> e : parameters.entrySet()) {
+ nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
+ }
+ gm.setQueryString(nameValuePairs.toArray(new NameValuePair[0]));
+ }
+
+ executeMethod(gm);
+
+ if (gm.getStatusCode() != HttpStatus.SC_OK) {
+ String errorMessage = responseToErrorMessage(gm);
+ gm.releaseConnection();
+ s_logger.error("Failed to retrieve object : " + errorMessage);
+ throw new BigSwitchVnsApiException("Failed to retrieve object : " + errorMessage);
+ }
+
+ Gson gson = new Gson();
+ T returnValue;
+ try {
+ returnValue = (T)gson.fromJson(gm.getResponseBodyAsString(), returnObjectType);
+ } catch (IOException e) {
+ s_logger.error("IOException while retrieving response body",e);
+ throw new BigSwitchVnsApiException(e);
+ } finally {
+ gm.releaseConnection();
+ }
+ return returnValue;
+ }
+
+ protected void executeMethod(HttpMethodBase method) throws BigSwitchVnsApiException {
+ try {
+ _client.executeMethod(method);
+ if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
+ method.releaseConnection();
+ // login and try again
+ login();
+ _client.executeMethod(method);
+ }
+ } catch (HttpException e) {
+ s_logger.error("HttpException caught while trying to connect to the BigSwitch Controller", e);
+ method.releaseConnection();
+ throw new BigSwitchVnsApiException("API call to BigSwitch Controller Failed", e);
+ } catch (IOException e) {
+ s_logger.error("IOException caught while trying to connect to the BigSwitch Controller", e);
+ method.releaseConnection();
+ throw new BigSwitchVnsApiException("API call to BigSwitch Controller Failed", e);
+ }
+ }
+
+ private String responseToErrorMessage(HttpMethodBase method) {
+ assert method.isRequestSent() : "no use getting an error message unless the request is sent";
+
+ if ("text/html".equals(method.getResponseHeader(CONTENT_TYPE).getValue())) {
+ // The error message is the response content
+ // Safety margin of 1024 characters, anything longer is probably useless
+ // and will clutter the logs
+ try {
+ return method.getResponseBodyAsString(1024);
+ } catch (IOException e) {
+ s_logger.debug("Error while loading response body", e);
+ }
+ }
+
+ // The default
+ return method.getStatusText();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/BigSwitchVnsApiException.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/BigSwitchVnsApiException.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/BigSwitchVnsApiException.java
new file mode 100644
index 0000000..49c3238
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/BigSwitchVnsApiException.java
@@ -0,0 +1,39 @@
+// 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.bigswitch;
+
+public class BigSwitchVnsApiException extends Exception {
+
+
+ private static final long serialVersionUID = -5864952230870945604L;
+
+ public BigSwitchVnsApiException() {
+ }
+
+ public BigSwitchVnsApiException(String message) {
+ super(message);
+ }
+
+ public BigSwitchVnsApiException(Throwable cause) {
+ super(cause);
+ }
+
+ public BigSwitchVnsApiException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/ControlClusterStatus.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/ControlClusterStatus.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/ControlClusterStatus.java
new file mode 100644
index 0000000..9181afd
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/ControlClusterStatus.java
@@ -0,0 +1,25 @@
+// 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.bigswitch;
+
+public class ControlClusterStatus {
+ private boolean healthy;
+
+ public boolean getStatus() {
+ return healthy;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Network.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Network.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Network.java
new file mode 100644
index 0000000..c89c693
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Network.java
@@ -0,0 +1,74 @@
+// 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.bigswitch;
+
+public class Network {
+ private String id;
+ private String name;
+ private String tenant_id;
+ private int vlan;
+ private String gateway;
+ private String state;
+
+ public String getUuid() {
+ return id;
+ }
+
+ public void setUuid(String id) {
+ this.id = id;
+ }
+
+ public String getDisplay_name() {
+ return name;
+ }
+
+ public void setDisplay_name(String display_name) {
+ this.name = display_name;
+ }
+
+ public String getTenant_id() {
+ return tenant_id;
+ }
+
+ public void setTenant_id(String tenant_id) {
+ this.tenant_id = tenant_id;
+ }
+
+ public int getVlan() {
+ return vlan;
+ }
+
+ public void setVlan(int vlan) {
+ this.vlan = vlan;
+ }
+
+ public String getGateway() {
+ return gateway;
+ }
+
+ public void setGateway(String gateway) {
+ this.gateway = gateway;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Port.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Port.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Port.java
new file mode 100644
index 0000000..bf749d0
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Port.java
@@ -0,0 +1,56 @@
+// 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.bigswitch;
+
+public class Port {
+ private String id;
+ private String name;
+ private String tenant_id;
+ private String state;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getTenant_id() {
+ return tenant_id;
+ }
+
+ public void setTenant_id(String tenant_id) {
+ this.tenant_id = tenant_id;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDao.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDao.java
new file mode 100644
index 0000000..d9bbf9d
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDao.java
@@ -0,0 +1,32 @@
+// 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.dao;
+
+import java.util.List;
+
+import com.cloud.network.BigSwitchVnsDeviceVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface BigSwitchVnsDao extends GenericDao<BigSwitchVnsDeviceVO, Long>{
+ /**
+ * list all the bigswitch Vns devices added in to this physical network
+ * @param physicalNetworkId physical Network Id
+ * @return list of BigSwitchVnsDeviceVO for this physical network.
+ */
+ List<BigSwitchVnsDeviceVO> listByPhysicalNetwork(long physicalNetworkId);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/736b236e/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDaoImpl.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDaoImpl.java
new file mode 100644
index 0000000..955bdda
--- /dev/null
+++ b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/dao/BigSwitchVnsDaoImpl.java
@@ -0,0 +1,48 @@
+// 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.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import com.cloud.network.BigSwitchVnsDeviceVO;
+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;
+
+@Local(value=BigSwitchVnsDao.class)
+public class BigSwitchVnsDaoImpl extends GenericDaoBase<BigSwitchVnsDeviceVO, Long>
+ implements BigSwitchVnsDao {
+
+ protected final SearchBuilder<BigSwitchVnsDeviceVO> physicalNetworkIdSearch;
+
+ public BigSwitchVnsDaoImpl() {
+ physicalNetworkIdSearch = createSearchBuilder();
+ physicalNetworkIdSearch.and("physicalNetworkId", physicalNetworkIdSearch.entity().getPhysicalNetworkId(), Op.EQ);
+ physicalNetworkIdSearch.done();
+ }
+
+ @Override
+ public List<BigSwitchVnsDeviceVO> listByPhysicalNetwork(long physicalNetworkId) {
+ SearchCriteria<BigSwitchVnsDeviceVO> sc = physicalNetworkIdSearch.create();
+ sc.setParameters("physicalNetworkId", physicalNetworkId);
+ return search(sc, null);
+ }
+
+}