You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by wi...@apache.org on 2015/04/15 10:05:05 UTC
[05/53] [abbrv] git commit: updated refs/heads/reporter to 5c99784
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch-vns/src/com/cloud/network/resource/BigSwitchVnsResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/resource/BigSwitchVnsResource.java b/plugins/network-elements/bigswitch-vns/src/com/cloud/network/resource/BigSwitchVnsResource.java
deleted file mode 100644
index 223972e..0000000
--- a/plugins/network-elements/bigswitch-vns/src/com/cloud/network/resource/BigSwitchVnsResource.java
+++ /dev/null
@@ -1,309 +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.resource;
-
-import java.util.Map;
-
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.IAgentControl;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.CreateVnsNetworkAnswer;
-import com.cloud.agent.api.CreateVnsNetworkCommand;
-import com.cloud.agent.api.CreateVnsPortAnswer;
-import com.cloud.agent.api.CreateVnsPortCommand;
-import com.cloud.agent.api.DeleteVnsNetworkAnswer;
-import com.cloud.agent.api.DeleteVnsNetworkCommand;
-import com.cloud.agent.api.DeleteVnsPortAnswer;
-import com.cloud.agent.api.DeleteVnsPortCommand;
-import com.cloud.agent.api.MaintainAnswer;
-import com.cloud.agent.api.MaintainCommand;
-import com.cloud.agent.api.PingCommand;
-import com.cloud.agent.api.ReadyAnswer;
-import com.cloud.agent.api.ReadyCommand;
-import com.cloud.agent.api.StartupBigSwitchVnsCommand;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.UpdateVnsPortAnswer;
-import com.cloud.agent.api.UpdateVnsPortCommand;
-import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
-import com.cloud.network.bigswitch.AttachmentData;
-import com.cloud.network.bigswitch.BigSwitchVnsApi;
-import com.cloud.network.bigswitch.BigSwitchVnsApiException;
-import com.cloud.network.bigswitch.ControlClusterStatus;
-import com.cloud.network.bigswitch.NetworkData;
-import com.cloud.network.bigswitch.PortData;
-import com.cloud.resource.ServerResource;
-import com.cloud.utils.component.ManagerBase;
-
-public class BigSwitchVnsResource extends ManagerBase implements ServerResource {
- private static final Logger s_logger = Logger.getLogger(BigSwitchVnsResource.class);
-
- private String _name;
- private String _guid;
- private String _zoneId;
- private int _numRetries;
-
- private BigSwitchVnsApi _bigswitchVnsApi;
-
- protected BigSwitchVnsApi createBigSwitchVnsApi() {
- return new BigSwitchVnsApi();
- }
-
- @Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
-
- _name = (String)params.get("name");
- if (_name == null) {
- throw new ConfigurationException("Unable to find name");
- }
-
- _guid = (String)params.get("guid");
- if (_guid == null) {
- throw new ConfigurationException("Unable to find the guid");
- }
-
- _zoneId = (String)params.get("zoneId");
- if (_zoneId == null) {
- throw new ConfigurationException("Unable to find zone");
- }
-
- _numRetries = 2;
-
- String ip = (String)params.get("ip");
- if (ip == null) {
- throw new ConfigurationException("Unable to find IP");
- }
-
- _bigswitchVnsApi = createBigSwitchVnsApi();
- _bigswitchVnsApi.setControllerAddress(ip);
-
- return true;
- }
-
- @Override
- public boolean start() {
- return true;
- }
-
- @Override
- public boolean stop() {
- return true;
- }
-
- @Override
- public String getName() {
- return _name;
- }
-
- @Override
- public Type getType() {
- // Think up a better name for this Type?
- return Host.Type.L2Networking;
- }
-
- @Override
- public StartupCommand[] initialize() {
- StartupBigSwitchVnsCommand sc = new StartupBigSwitchVnsCommand();
- sc.setGuid(_guid);
- sc.setName(_name);
- sc.setDataCenter(_zoneId);
- sc.setPod("");
- sc.setPrivateIpAddress("");
- sc.setStorageIpAddress("");
- sc.setVersion("");
- return new StartupCommand[] {sc};
- }
-
- @Override
- public PingCommand getCurrentStatus(long id) {
- try {
- ControlClusterStatus ccs = _bigswitchVnsApi.getControlClusterStatus();
- if (!ccs.getStatus()) {
- s_logger.error("ControlCluster state is not ready: " + ccs.getStatus());
- return null;
- }
- } catch (BigSwitchVnsApiException e) {
- s_logger.error("getControlClusterStatus failed", e);
- return null;
- }
- return new PingCommand(Host.Type.L2Networking, id);
- }
-
- @Override
- public Answer executeRequest(Command cmd) {
- return executeRequest(cmd, _numRetries);
- }
-
- public Answer executeRequest(Command cmd, int numRetries) {
- if (cmd instanceof ReadyCommand) {
- return executeRequest((ReadyCommand)cmd);
- } else if (cmd instanceof MaintainCommand) {
- return executeRequest((MaintainCommand)cmd);
- } else if (cmd instanceof CreateVnsNetworkCommand) {
- return executeRequest((CreateVnsNetworkCommand)cmd, numRetries);
- } else if (cmd instanceof DeleteVnsNetworkCommand) {
- return executeRequest((DeleteVnsNetworkCommand)cmd, numRetries);
- } else if (cmd instanceof CreateVnsPortCommand) {
- return executeRequest((CreateVnsPortCommand)cmd, numRetries);
- } else if (cmd instanceof DeleteVnsPortCommand) {
- return executeRequest((DeleteVnsPortCommand)cmd, numRetries);
- } else if (cmd instanceof UpdateVnsPortCommand) {
- return executeRequest((UpdateVnsPortCommand)cmd, numRetries);
- }
- s_logger.debug("Received unsupported command " + cmd.toString());
- return Answer.createUnsupportedCommandAnswer(cmd);
- }
-
- @Override
- public void disconnected() {
- }
-
- @Override
- public IAgentControl getAgentControl() {
- return null;
- }
-
- @Override
- public void setAgentControl(IAgentControl agentControl) {
- }
-
- private Answer executeRequest(CreateVnsNetworkCommand cmd, int numRetries) {
- NetworkData network = new NetworkData();
- network.getNetwork().setTenantId(cmd.getTenantUuid());
- network.getNetwork().setUuid(cmd.getNetworkUuid());
- network.getNetwork().setDisplay_name(truncate("vns-cloudstack-" + cmd.getName(), 64));
- network.getNetwork().setVlan(cmd.getVlan());
-
- try {
- _bigswitchVnsApi.createNetwork(network);
- return new CreateVnsNetworkAnswer(cmd, true, "VNS " + network.getNetwork().getUuid() + " created");
- } catch (BigSwitchVnsApiException e) {
- if (numRetries > 0) {
- return retry(cmd, --numRetries);
- } else {
- return new CreateVnsNetworkAnswer(cmd, e);
- }
- }
-
- }
-
- private Answer executeRequest(DeleteVnsNetworkCommand cmd, int numRetries) {
- try {
- _bigswitchVnsApi.deleteNetwork(cmd.get_tenantUuid(), cmd.getNetworkUuid());
- return new DeleteVnsNetworkAnswer(cmd, true, "VNS " + cmd.getNetworkUuid() + " deleted");
- } catch (BigSwitchVnsApiException e) {
- if (numRetries > 0) {
- return retry(cmd, --numRetries);
- } else {
- return new DeleteVnsNetworkAnswer(cmd, e);
- }
- }
- }
-
- private Answer executeRequest(CreateVnsPortCommand cmd, int numRetries) {
- PortData port = new PortData();
- port.getPort().setId(cmd.getPortUuid());
- port.getPort().setName(cmd.getPortName());
- port.getPort().setTenantId(cmd.getTenantUuid());
-
- try {
- _bigswitchVnsApi.createPort(cmd.getNetworkUuid(), port);
- try {
- AttachmentData attachment = new AttachmentData();
- attachment.getAttachment().setId(cmd.getPortUuid());
- attachment.getAttachment().setMac(cmd.getMac());
- _bigswitchVnsApi.modifyPortAttachment(cmd.getTenantUuid(), cmd.getNetworkUuid(), cmd.getPortUuid(), attachment);
-
- } catch (BigSwitchVnsApiException ex) {
- s_logger.warn("modifyPortAttachment failed after switchport was created, removing switchport");
- _bigswitchVnsApi.deletePort(cmd.getTenantUuid(), cmd.getNetworkUuid(), cmd.getPortUuid());
- throw (ex); // Rethrow the original exception
- }
- return new CreateVnsPortAnswer(cmd, true, "network port " + cmd.getPortUuid() + " created");
- } catch (BigSwitchVnsApiException e) {
- if (numRetries > 0) {
- return retry(cmd, --numRetries);
- } else {
- return new CreateVnsPortAnswer(cmd, e);
- }
- }
- }
-
- private Answer executeRequest(DeleteVnsPortCommand cmd, int numRetries) {
- try {
- _bigswitchVnsApi.deletePortAttachment(cmd.getTenantUuid(), cmd.getNetworkUuid(), cmd.getPortUuid());
- try {
- _bigswitchVnsApi.deletePort(cmd.getTenantUuid(), cmd.getNetworkUuid(), cmd.getPortUuid());
- } catch (BigSwitchVnsApiException ex) {
- s_logger.warn("deletePort failed after portAttachment was removed");
- throw (ex); // Rethrow the original exception
- }
- return new DeleteVnsPortAnswer(cmd, true, "network port " + cmd.getPortUuid() + " deleted");
- } catch (BigSwitchVnsApiException e) {
- if (numRetries > 0) {
- return retry(cmd, --numRetries);
- } else {
- return new DeleteVnsPortAnswer(cmd, e);
- }
- }
- }
-
- private Answer executeRequest(UpdateVnsPortCommand cmd, int numRetries) {
- PortData port = new PortData();
- port.getPort().setId(cmd.getPortUuid());
- port.getPort().setName(cmd.getPortName());
- port.getPort().setTenantId(cmd.getTenantUuid());
-
- try {
- _bigswitchVnsApi.modifyPort(cmd.getNetworkUuid(), port);
- return new UpdateVnsPortAnswer(cmd, true, "Network Port " + cmd.getPortUuid() + " updated");
- } catch (BigSwitchVnsApiException e) {
- if (numRetries > 0) {
- return retry(cmd, --numRetries);
- } else {
- return new UpdateVnsPortAnswer(cmd, e);
- }
- }
-
- }
-
- private Answer executeRequest(ReadyCommand cmd) {
- return new ReadyAnswer(cmd);
- }
-
- private Answer executeRequest(MaintainCommand cmd) {
- return new MaintainAnswer(cmd);
- }
-
- private Answer retry(Command cmd, int numRetries) {
- s_logger.warn("Retrying " + cmd.getClass().getSimpleName() + ". Number of retries remaining: " + numRetries);
- return executeRequest(cmd, numRetries);
- }
-
- private String truncate(String string, int length) {
- if (string.length() <= length) {
- return string;
- } else {
- return string.substring(0, length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch-vns/test/com/cloud/network/bigswitch/BigSwitchApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/test/com/cloud/network/bigswitch/BigSwitchApiTest.java b/plugins/network-elements/bigswitch-vns/test/com/cloud/network/bigswitch/BigSwitchApiTest.java
deleted file mode 100644
index 4d8021c..0000000
--- a/plugins/network-elements/bigswitch-vns/test/com/cloud/network/bigswitch/BigSwitchApiTest.java
+++ /dev/null
@@ -1,232 +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.bigswitch;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.Collections;
-
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-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.params.HttpClientParams;
-import org.apache.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Test;
-
-public class BigSwitchApiTest {
- BigSwitchVnsApi _api;
- HttpClient _client = mock(HttpClient.class);
- HttpMethod _method;
-
- @Before
- public void setUp() {
- HttpClientParams hmp = mock(HttpClientParams.class);
- when(_client.getParams()).thenReturn(hmp);
- _api = new BigSwitchVnsApi() {
- @Override
- protected HttpClient createHttpClient() {
- return _client;
- }
-
- @Override
- protected HttpMethod createMethod(String type, String uri, int port) {
- return _method;
- }
- };
- }
-
- @Test(expected = BigSwitchVnsApiException.class)
- public void testExecuteUpdateObjectWithoutHostname() throws BigSwitchVnsApiException {
- _api.setControllerAddress(null);
- _api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
- }
-
- @Test(expected = BigSwitchVnsApiException.class)
- public void testExecuteCreateObjectWithoutHostname() throws BigSwitchVnsApiException {
- _api.setControllerAddress(null);
- _api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
- }
-
- @Test(expected = BigSwitchVnsApiException.class)
- public void testExecuteDeleteObjectWithoutHostname() throws BigSwitchVnsApiException {
- _api.setControllerAddress(null);
- _api.executeDeleteObject("/");
- }
-
- @Test
- public void executeMethodTest() throws BigSwitchVnsApiException {
- GetMethod gm = mock(GetMethod.class);
-
- when(gm.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- _api.executeMethod(gm);
- verify(gm, times(1)).getStatusCode();
- }
-
- /* Bit of a roundabout way to ensure that login is called after an un authorized result
- * It not possible to properly mock login()
- */
- @Test(expected = BigSwitchVnsApiException.class)
- public void executeMethodTestWithLogin() throws BigSwitchVnsApiException, HttpException, IOException {
- GetMethod gm = mock(GetMethod.class);
- when(_client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
- when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
- _api.executeMethod(gm);
- verify(gm, times(1)).getStatusCode();
- }
-
- @Test
- public void testExecuteCreateObject() throws BigSwitchVnsApiException, IOException {
- _api.setControllerAddress("10.10.0.10");
- NetworkData network = new NetworkData();
- _method = mock(PostMethod.class);
- when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- _api.executeCreateObject(network, NetworkData.class, "/", Collections.<String, String> emptyMap());
- verify(_method, times(1)).releaseConnection();
-
- }
-
- @Test(expected = BigSwitchVnsApiException.class)
- public void testExecuteCreateObjectFailure() throws BigSwitchVnsApiException, IOException {
- _api.setControllerAddress("10.10.0.10");
- NetworkData network = new NetworkData();
- _method = mock(PostMethod.class);
- when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- Header header = mock(Header.class);
- when(header.getValue()).thenReturn("text/html");
- when(_method.getResponseHeader("Content-Type")).thenReturn(header);
- when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
- when(_method.isRequestSent()).thenReturn(true);
- try {
- _api.executeCreateObject(network, NetworkData.class, "/", Collections.<String, String> emptyMap());
- } finally {
- verify(_method, times(1)).releaseConnection();
- }
- }
-
- @Test(expected = BigSwitchVnsApiException.class)
- public void testExecuteCreateObjectException() throws BigSwitchVnsApiException, IOException {
- _api.setControllerAddress("10.10.0.10");
- NetworkData network = new NetworkData();
- when(_client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
- _method = mock(PostMethod.class);
- when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- Header header = mock(Header.class);
- when(header.getValue()).thenReturn("text/html");
- when(_method.getResponseHeader("Content-Type")).thenReturn(header);
- when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
- try {
- _api.executeCreateObject(network, NetworkData.class, "/", Collections.<String, String> emptyMap());
- } finally {
- verify(_method, times(1)).releaseConnection();
- }
- }
-
- @Test
- public void testExecuteUpdateObject() throws BigSwitchVnsApiException, IOException {
- _api.setControllerAddress("10.10.0.10");
- NetworkData network = new NetworkData();
- _method = mock(PutMethod.class);
- when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- _api.executeUpdateObject(network, "/", Collections.<String, String> emptyMap());
- verify(_method, times(1)).releaseConnection();
- verify(_client, times(1)).executeMethod(_method);
- }
-
- @Test(expected = BigSwitchVnsApiException.class)
- public void testExecuteUpdateObjectFailure() throws BigSwitchVnsApiException, IOException {
- _api.setControllerAddress("10.10.0.10");
- NetworkData network = new NetworkData();
- _method = mock(PutMethod.class);
- when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- Header header = mock(Header.class);
- when(header.getValue()).thenReturn("text/html");
- when(_method.getResponseHeader("Content-Type")).thenReturn(header);
- when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
- when(_method.isRequestSent()).thenReturn(true);
- try {
- _api.executeUpdateObject(network, "/", Collections.<String, String> emptyMap());
- } finally {
- verify(_method, times(1)).releaseConnection();
- }
- }
-
- @Test(expected = BigSwitchVnsApiException.class)
- public void testExecuteUpdateObjectException() throws BigSwitchVnsApiException, IOException {
- _api.setControllerAddress("10.10.0.10");
- NetworkData network = new NetworkData();
- _method = mock(PutMethod.class);
- when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- when(_client.executeMethod((HttpMethod)any())).thenThrow(new IOException());
- try {
- _api.executeUpdateObject(network, "/", Collections.<String, String> emptyMap());
- } finally {
- verify(_method, times(1)).releaseConnection();
- }
- }
-
- @Test
- public void testExecuteDeleteObject() throws BigSwitchVnsApiException, IOException {
- _api.setControllerAddress("10.10.0.10");
- _method = mock(DeleteMethod.class);
- when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- _api.executeDeleteObject("/");
- verify(_method, times(1)).releaseConnection();
- verify(_client, times(1)).executeMethod(_method);
- }
-
- @Test(expected = BigSwitchVnsApiException.class)
- public void testExecuteDeleteObjectFailure() throws BigSwitchVnsApiException, IOException {
- _api.setControllerAddress("10.10.0.10");
- _method = mock(DeleteMethod.class);
- when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- Header header = mock(Header.class);
- when(header.getValue()).thenReturn("text/html");
- when(_method.getResponseHeader("Content-Type")).thenReturn(header);
- when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
- when(_method.isRequestSent()).thenReturn(true);
- try {
- _api.executeDeleteObject("/");
- } finally {
- verify(_method, times(1)).releaseConnection();
- }
- }
-
- @Test(expected = BigSwitchVnsApiException.class)
- public void testExecuteDeleteObjectException() throws BigSwitchVnsApiException, IOException {
- _api.setControllerAddress("10.10.0.10");
- _method = mock(DeleteMethod.class);
- when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- when(_client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
- try {
- _api.executeDeleteObject("/");
- } finally {
- verify(_method, times(1)).releaseConnection();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch-vns/test/com/cloud/network/resource/BigSwitchVnsResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch-vns/test/com/cloud/network/resource/BigSwitchVnsResourceTest.java b/plugins/network-elements/bigswitch-vns/test/com/cloud/network/resource/BigSwitchVnsResourceTest.java
deleted file mode 100644
index 8cf322a..0000000
--- a/plugins/network-elements/bigswitch-vns/test/com/cloud/network/resource/BigSwitchVnsResourceTest.java
+++ /dev/null
@@ -1,271 +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.resource;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.naming.ConfigurationException;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.cloud.agent.api.CreateVnsNetworkAnswer;
-import com.cloud.agent.api.CreateVnsNetworkCommand;
-import com.cloud.agent.api.CreateVnsPortAnswer;
-import com.cloud.agent.api.CreateVnsPortCommand;
-import com.cloud.agent.api.DeleteVnsNetworkAnswer;
-import com.cloud.agent.api.DeleteVnsNetworkCommand;
-import com.cloud.agent.api.DeleteVnsPortAnswer;
-import com.cloud.agent.api.DeleteVnsPortCommand;
-import com.cloud.agent.api.PingCommand;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.UpdateVnsPortAnswer;
-import com.cloud.agent.api.UpdateVnsPortCommand;
-import com.cloud.host.Host;
-import com.cloud.network.bigswitch.AttachmentData;
-import com.cloud.network.bigswitch.BigSwitchVnsApi;
-import com.cloud.network.bigswitch.BigSwitchVnsApiException;
-import com.cloud.network.bigswitch.ControlClusterStatus;
-import com.cloud.network.bigswitch.NetworkData;
-import com.cloud.network.bigswitch.PortData;
-
-public class BigSwitchVnsResourceTest {
- BigSwitchVnsApi _bigswitchVnsApi = mock(BigSwitchVnsApi.class);
- BigSwitchVnsResource _resource;
- Map<String, Object> _parameters;
-
- @Before
- public void setUp() throws ConfigurationException {
- _resource = new BigSwitchVnsResource() {
- @Override
- protected BigSwitchVnsApi createBigSwitchVnsApi() {
- return _bigswitchVnsApi;
- }
- };
-
- _parameters = new HashMap<String, Object>();
- _parameters.put("name", "bigswitchvnstestdevice");
- _parameters.put("ip", "127.0.0.1");
- _parameters.put("guid", "aaaaa-bbbbb-ccccc");
- _parameters.put("zoneId", "blublub");
- }
-
- @Test(expected = ConfigurationException.class)
- public void resourceConfigureFailure() throws ConfigurationException {
- _resource.configure("BigSwitchVnsResource", Collections.<String, Object> emptyMap());
- }
-
- @Test
- public void resourceConfigure() throws ConfigurationException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- verify(_bigswitchVnsApi).setControllerAddress("127.0.0.1");
-
- assertTrue("bigswitchvnstestdevice".equals(_resource.getName()));
-
- /* Pretty lame test, but here to assure this plugin fails
- * if the type name ever changes from L2Networking
- */
- assertTrue(_resource.getType() == Host.Type.L2Networking);
- }
-
- @Test
- public void testInitialization() throws ConfigurationException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- StartupCommand[] sc = _resource.initialize();
- assertTrue(sc.length == 1);
- assertTrue("aaaaa-bbbbb-ccccc".equals(sc[0].getGuid()));
- assertTrue("bigswitchvnstestdevice".equals(sc[0].getName()));
- assertTrue("blublub".equals(sc[0].getDataCenter()));
- }
-
- @Test
- public void testPingCommandStatusOk() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- ControlClusterStatus ccs = mock(ControlClusterStatus.class);
- when(ccs.getStatus()).thenReturn(true);
- when(_bigswitchVnsApi.getControlClusterStatus()).thenReturn(ccs);
-
- PingCommand ping = _resource.getCurrentStatus(42);
- assertTrue(ping != null);
- assertTrue(ping.getHostId() == 42);
- assertTrue(ping.getHostType() == Host.Type.L2Networking);
- }
-
- @Test
- public void testPingCommandStatusFail() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- ControlClusterStatus ccs = mock(ControlClusterStatus.class);
- when(ccs.getStatus()).thenReturn(false);
- when(_bigswitchVnsApi.getControlClusterStatus()).thenReturn(ccs);
-
- PingCommand ping = _resource.getCurrentStatus(42);
- assertTrue(ping == null);
- }
-
- @Test
- public void testPingCommandStatusApiException() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- ControlClusterStatus ccs = mock(ControlClusterStatus.class);
- when(ccs.getStatus()).thenReturn(false);
- when(_bigswitchVnsApi.getControlClusterStatus()).thenThrow(new BigSwitchVnsApiException());
-
- PingCommand ping = _resource.getCurrentStatus(42);
- assertTrue(ping == null);
- }
-
- @Test
- public void testRetries() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- NetworkData networkdata = mock(NetworkData.class);
- NetworkData.Network network = mock(NetworkData.Network.class);
- when(networkdata.getNetwork()).thenReturn(network);
- when(network.getUuid()).thenReturn("cccc").thenReturn("cccc");
-
- CreateVnsNetworkCommand cntkc = new CreateVnsNetworkCommand((String)_parameters.get("guid"), "networkName", "tenantid", 1);
- CreateVnsNetworkAnswer cntka = (CreateVnsNetworkAnswer)_resource.executeRequest(cntkc);
- assertTrue(cntka.getResult());
- }
-
- @Test
- public void testCreateNetwork() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- NetworkData networkdata = mock(NetworkData.class);
- NetworkData.Network network = mock(NetworkData.Network.class);
- when(networkdata.getNetwork()).thenReturn(network);
- when(network.getUuid()).thenReturn("cccc").thenReturn("cccc");
-
- CreateVnsNetworkCommand cntkc = new CreateVnsNetworkCommand((String)_parameters.get("guid"), "networkName", "tenantid", 1);
- CreateVnsNetworkAnswer cntka = (CreateVnsNetworkAnswer)_resource.executeRequest(cntkc);
- assertTrue(cntka.getResult());
- }
-
- @Test
- public void testCreateNetworkApiException() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- NetworkData networkdata = mock(NetworkData.class);
- NetworkData.Network network = mock(NetworkData.Network.class);
- when(networkdata.getNetwork()).thenReturn(network);
- when(network.getUuid()).thenReturn("cccc").thenReturn("cccc");
- doThrow(new BigSwitchVnsApiException()).when(_bigswitchVnsApi).createNetwork((NetworkData)any());
-
- CreateVnsNetworkCommand cntkc = new CreateVnsNetworkCommand((String)_parameters.get("guid"), "networkName", "tenantid", 1);
- CreateVnsNetworkAnswer cntka = (CreateVnsNetworkAnswer)_resource.executeRequest(cntkc);
- assertFalse(cntka.getResult());
- }
-
- @Test
- public void testDeleteNetwork() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- DeleteVnsNetworkCommand dntkc = new DeleteVnsNetworkCommand("tenantid", "networkid");
- DeleteVnsNetworkAnswer dntka = (DeleteVnsNetworkAnswer)_resource.executeRequest(dntkc);
- assertTrue(dntka.getResult());
- }
-
- @Test
- public void testDeleteNetworkApiException() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- doThrow(new BigSwitchVnsApiException()).when(_bigswitchVnsApi).deleteNetwork((String)any(), (String)any());
-
- DeleteVnsNetworkCommand dntkc = new DeleteVnsNetworkCommand("tenantid", "networkid");
- DeleteVnsNetworkAnswer dntka = (DeleteVnsNetworkAnswer)_resource.executeRequest(dntkc);
- assertFalse(dntka.getResult());
- }
-
- @Test
- public void testCreatePort() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- PortData portdata = mock(PortData.class);
- PortData.Port port = mock(PortData.Port.class);
- when(portdata.getPort()).thenReturn(port);
- when(port.getId()).thenReturn("eeee");
-
- CreateVnsPortCommand cntkc = new CreateVnsPortCommand("networkid", "portid", "tenantid", "portname", "aa:bb:cc:dd:ee:ff");
- CreateVnsPortAnswer cntka = (CreateVnsPortAnswer)_resource.executeRequest(cntkc);
- assertTrue(cntka.getResult());
- }
-
- @Test
- public void testCreatePortApiExceptionInCreate() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- PortData portdata = mock(PortData.class);
- PortData.Port port = mock(PortData.Port.class);
- when(portdata.getPort()).thenReturn(port);
- when(port.getId()).thenReturn("eeee");
- doThrow(new BigSwitchVnsApiException()).when(_bigswitchVnsApi).createPort((String)any(), (PortData)any());
-
- CreateVnsPortCommand cntkc = new CreateVnsPortCommand("networkid", "portid", "tenantid", "portname", "aa:bb:cc:dd:ee:ff");
- CreateVnsPortAnswer cntka = (CreateVnsPortAnswer)_resource.executeRequest(cntkc);
- assertFalse(cntka.getResult());
- }
-
- @Test
- public void testCreatePortApiExceptionInModify() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- PortData portdata = mock(PortData.class);
- PortData.Port port = mock(PortData.Port.class);
- when(portdata.getPort()).thenReturn(port);
- when(port.getId()).thenReturn("eeee");
- doThrow(new BigSwitchVnsApiException()).when(_bigswitchVnsApi).modifyPortAttachment((String)any(), (String)any(), (String)any(), (AttachmentData)any());
-
- CreateVnsPortCommand cntkc = new CreateVnsPortCommand("networkid", "portid", "tenantid", "portname", "aa:bb:cc:dd:ee:ff");
- CreateVnsPortAnswer cntka = (CreateVnsPortAnswer)_resource.executeRequest(cntkc);
- assertFalse(cntka.getResult());
- verify(_bigswitchVnsApi, atLeastOnce()).deletePort((String)any(), (String)any(), (String)any());
- }
-
- @Test
- public void testDeletePortException() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- doThrow(new BigSwitchVnsApiException()).when(_bigswitchVnsApi).deletePort((String)any(), (String)any(), (String)any());
- DeleteVnsPortAnswer dntkpa = (DeleteVnsPortAnswer)_resource.executeRequest(new DeleteVnsPortCommand("networkId", "portid", "tenantid"));
- assertFalse(dntkpa.getResult());
- }
-
- @Test
- public void testUpdatePortException() throws ConfigurationException, BigSwitchVnsApiException {
- _resource.configure("BigSwitchVnsResource", _parameters);
-
- doThrow(new BigSwitchVnsApiException()).when(_bigswitchVnsApi).modifyPort((String)any(), (PortData)any());
- UpdateVnsPortAnswer dntkpa = (UpdateVnsPortAnswer)_resource.executeRequest(new UpdateVnsPortCommand("networkId", "portId", "tenantId", "portname"));
- assertFalse(dntkpa.getResult());
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/findbugsExcludeFilter.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/findbugsExcludeFilter.xml b/plugins/network-elements/bigswitch/findbugsExcludeFilter.xml
new file mode 100644
index 0000000..d372850
--- /dev/null
+++ b/plugins/network-elements/bigswitch/findbugsExcludeFilter.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<FindBugsFilter>
+
+
+</FindBugsFilter>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/pom.xml b/plugins/network-elements/bigswitch/pom.xml
new file mode 100644
index 0000000..d530088
--- /dev/null
+++ b/plugins/network-elements/bigswitch/pom.xml
@@ -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.
+
+-->
+<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-bigswitch</artifactId>
+ <name>Apache CloudStack Plugin - BigSwitch Virtual Network Segment</name>
+ <parent>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloudstack-plugins</artifactId>
+ <version>4.6.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.mycila</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>cloudstack-checklicence</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/resources/META-INF/cloudstack/bigswitch/module.properties
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/resources/META-INF/cloudstack/bigswitch/module.properties b/plugins/network-elements/bigswitch/resources/META-INF/cloudstack/bigswitch/module.properties
new file mode 100644
index 0000000..22bc7d8
--- /dev/null
+++ b/plugins/network-elements/bigswitch/resources/META-INF/cloudstack/bigswitch/module.properties
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+
+name=bigswitch
+parent=network
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/resources/META-INF/cloudstack/bigswitch/spring-bigswitch-context.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/resources/META-INF/cloudstack/bigswitch/spring-bigswitch-context.xml b/plugins/network-elements/bigswitch/resources/META-INF/cloudstack/bigswitch/spring-bigswitch-context.xml
new file mode 100644
index 0000000..ea3d3aa
--- /dev/null
+++ b/plugins/network-elements/bigswitch/resources/META-INF/cloudstack/bigswitch/spring-bigswitch-context.xml
@@ -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.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ >
+
+ <bean id="bigSwitchBcfDaoImpl" class="com.cloud.network.dao.BigSwitchBcfDaoImpl" />
+ <bean id="BigSwitchBcfGuestNetworkGuru" class="com.cloud.network.guru.BigSwitchBcfGuestNetworkGuru">
+ <property name="name" value="BigSwitchBcfGuestNetworkGuru" />
+ </bean>
+ <bean id="BigSwitchBcf" class="com.cloud.network.element.BigSwitchBcfElement">
+ <property name="name" value="BigSwitchBcf" />
+ </bean>
+
+
+</beans>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfAnswer.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfAnswer.java
new file mode 100644
index 0000000..d144386
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfAnswer.java
@@ -0,0 +1,43 @@
+//
+// 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 BcfAnswer extends Answer{
+ private final String hash;
+
+ public BcfAnswer(Command command, boolean success, String details) {
+ super(command, success, details);
+ this.hash = "";
+ }
+
+ public BcfAnswer(Command command, boolean success, String details, String hash) {
+ super(command, success, details);
+ this.hash = hash;
+ }
+
+ public BcfAnswer(Command command, Exception e) {
+ super(command, e);
+ this.hash = "";
+ }
+
+ public String getHash() {
+ return hash;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfCommand.java
new file mode 100644
index 0000000..b245945
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/BcfCommand.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;
+
+import com.cloud.network.bigswitch.TopologyData;
+
+public class BcfCommand extends Command {
+ private TopologyData topology = null;
+ private boolean _topologySyncRequested = false;
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+ public TopologyData getTopology() {
+ return topology;
+ }
+
+ public void setTopology(TopologyData topology) {
+ this.topology = topology;
+ }
+
+ public boolean is_topologySyncRequested() {
+ return _topologySyncRequested;
+ }
+
+ public void set_topologySyncRequested(boolean requested) {
+ this._topologySyncRequested = requested;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CacheBcfTopologyCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CacheBcfTopologyCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CacheBcfTopologyCommand.java
new file mode 100644
index 0000000..39e7b66
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CacheBcfTopologyCommand.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.agent.api;
+
+import com.cloud.network.bigswitch.TopologyData;
+
+public class CacheBcfTopologyCommand extends Command{
+ private final TopologyData topology;
+
+ public CacheBcfTopologyCommand(TopologyData topology){
+ this.topology = topology;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+ public TopologyData getTopology() {
+ return topology;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfAttachmentCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfAttachmentCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfAttachmentCommand.java
new file mode 100644
index 0000000..97d56a5
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfAttachmentCommand.java
@@ -0,0 +1,75 @@
+//
+// 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 CreateBcfAttachmentCommand extends BcfCommand {
+ private String _tenantId;
+ private String _tenantName;
+ private String _networkId;
+ private String _portId;
+ private String _nicId;
+ private Integer _vlan;
+ private String _ipv4;
+ private String _mac;
+
+ public CreateBcfAttachmentCommand(String tenantId, String tenantName,
+ String networkId, String portId, String nicId,
+ Integer vlan, String ipv4, String mac) {
+ this._tenantId = tenantId;
+ this._tenantName = tenantName;
+ this._networkId = networkId;
+ this._portId = portId;
+ this._nicId = nicId;
+ this._vlan = vlan;
+ this._ipv4 = ipv4;
+ this._mac = mac;
+ }
+
+ public String getTenantId() {
+ return _tenantId;
+ }
+
+ public String getTenantName() {
+ return _tenantName;
+ }
+ public String getNetworkId() {
+ return _networkId;
+ }
+
+ public String getPortId() {
+ return _portId;
+ }
+
+ public String getNicId() {
+ return _nicId;
+ }
+
+ public Integer getVlan() {
+ return _vlan;
+ }
+
+ public String getIpv4() {
+ return _ipv4;
+ }
+
+ public String getMac() {
+ return _mac;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterCommand.java
new file mode 100644
index 0000000..4379ed4
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterCommand.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.agent.api;
+
+public class CreateBcfRouterCommand extends BcfCommand {
+ private final String _tenantId;
+
+ public CreateBcfRouterCommand(String tenantId){
+ this._tenantId = tenantId;
+ }
+
+ public String get_tenantId() {
+ return _tenantId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterInterfaceCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterInterfaceCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterInterfaceCommand.java
new file mode 100644
index 0000000..4b8d227
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfRouterInterfaceCommand.java
@@ -0,0 +1,57 @@
+//
+// 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 CreateBcfRouterInterfaceCommand extends BcfCommand{
+ private final String _tenantId;
+ private final String _networkId;
+ private final String _cidr;
+ private final String _gateway;
+ private final String _networkName;
+
+ public CreateBcfRouterInterfaceCommand(String tenantId, String networkId, String cidr,
+ String gateway, String networkName){
+ this._tenantId = tenantId;
+ this._networkId = networkId;
+ this._networkName = networkName;
+ this._cidr = cidr;
+ this._gateway = gateway;
+ }
+
+ public String get_tenantId() {
+ return _tenantId;
+ }
+
+ public String get_networkId() {
+ return _networkId;
+ }
+
+ public String get_networkName() {
+ return _networkName;
+ }
+
+ public String get_cidr() {
+ return _cidr;
+ }
+
+ public String get_gateway() {
+ return _gateway;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfSegmentCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfSegmentCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfSegmentCommand.java
new file mode 100644
index 0000000..d54dac6
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfSegmentCommand.java
@@ -0,0 +1,57 @@
+//
+// 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 CreateBcfSegmentCommand extends BcfCommand {
+ private String _tenantId;
+ private String _tenantName;
+ private String _networkId;
+ private String _networkName;
+ private Integer _vlan;
+
+ public CreateBcfSegmentCommand(String tenantId, String tenantName,
+ String networkId, String networkName, Integer vlan) {
+ this._tenantId = tenantId;
+ this._tenantName = tenantName;
+ this._networkId = networkId;
+ this._networkName = networkName;
+ this._vlan = vlan;
+ }
+
+ public String getNetworkId() {
+ return _networkId;
+ }
+
+ public String getNetworkName() {
+ return _networkName;
+ }
+
+ public String getTenantId() {
+ return _tenantId;
+ }
+
+ public String getTenantName() {
+ return _tenantName;
+ }
+
+ public Integer getVlan() {
+ return _vlan;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfStaticNatCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfStaticNatCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfStaticNatCommand.java
new file mode 100644
index 0000000..917f480
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/CreateBcfStaticNatCommand.java
@@ -0,0 +1,57 @@
+//
+// 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 CreateBcfStaticNatCommand extends BcfCommand {
+ private final String _tenantId;
+ private final String _networkId;
+ private final String _privateIp;
+ private final String _publicIp;
+ private final String _mac;
+
+ public CreateBcfStaticNatCommand(String tenantId, String networkId,
+ String privateIp, String publicIp, String mac){
+ this._tenantId = tenantId;
+ this._networkId = networkId;
+ this._privateIp = privateIp;
+ this._publicIp = publicIp;
+ this._mac = mac;
+ }
+
+ public String get_tenantId() {
+ return _tenantId;
+ }
+
+ public String get_networkId() {
+ return _networkId;
+ }
+
+ public String get_privateIp() {
+ return _privateIp;
+ }
+
+ public String get_publicIp() {
+ return _publicIp;
+ }
+
+ public String get_mac() {
+ return _mac;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfAttachmentCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfAttachmentCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfAttachmentCommand.java
new file mode 100644
index 0000000..d5cf13f
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfAttachmentCommand.java
@@ -0,0 +1,45 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.agent.api;
+
+public class DeleteBcfAttachmentCommand extends BcfCommand {
+ private String _tenantId;
+ private String _networkId;
+ private String _attachmentId;
+
+ public DeleteBcfAttachmentCommand(String tenantId,
+ String networkId, String attachmentId) {
+ this._tenantId = tenantId;
+ this._networkId = networkId;
+ this._attachmentId = attachmentId;
+ }
+
+ public String getTenantId() {
+ return _tenantId;
+ }
+
+ public String getNetworkId() {
+ return _networkId;
+ }
+
+ public String getAttachmentId() {
+ return _attachmentId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfSegmentCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfSegmentCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfSegmentCommand.java
new file mode 100644
index 0000000..a6987a5
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfSegmentCommand.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.agent.api;
+
+public class DeleteBcfSegmentCommand extends BcfCommand {
+
+ private String _tenantUuid;
+ private String _networkUuid;
+
+ public DeleteBcfSegmentCommand(String tenantUuid, String networkUuid) {
+ this._tenantUuid = tenantUuid;
+ this._networkUuid = networkUuid;
+ }
+
+ public String get_tenantUuid() {
+ return _tenantUuid;
+ }
+
+ public String getNetworkUuid() {
+ return _networkUuid;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfStaticNatCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfStaticNatCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfStaticNatCommand.java
new file mode 100644
index 0000000..7861bfb
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/DeleteBcfStaticNatCommand.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;
+
+public class DeleteBcfStaticNatCommand extends BcfCommand {
+ private final String _tenantId;
+ private final String _publicIp;
+ private final String _floatingIpId;
+
+ public DeleteBcfStaticNatCommand(String tenantId, String publicIp){
+ this._tenantId = tenantId;
+ this._publicIp = publicIp;
+ this._floatingIpId = publicIp.replace(".", "-");
+ }
+
+ public String get_tenantId() {
+ return _tenantId;
+ }
+
+ public String get_publicIp() {
+ return _publicIp;
+ }
+
+ public String get_floatingIpId() {
+ return _floatingIpId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataAnswer.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataAnswer.java
new file mode 100644
index 0000000..e32bfb0
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataAnswer.java
@@ -0,0 +1,45 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.agent.api;
+
+public class GetControllerDataAnswer extends Answer {
+ private final String ipAddress;
+ private final boolean isMaster;
+
+ public GetControllerDataAnswer(GetControllerDataCommand cmd,
+ String ipAddress, boolean isMaster){
+ this.ipAddress = ipAddress;
+ this.isMaster = isMaster;
+ }
+
+ public GetControllerDataAnswer(Command command, Exception e) {
+ super(command, e);
+ this.ipAddress = null;
+ this.isMaster = false;
+ }
+
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ public boolean isMaster() {
+ return isMaster;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataCommand.java
new file mode 100644
index 0000000..661ad16
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerDataCommand.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.agent.api;
+
+public class GetControllerDataCommand extends BcfCommand {
+ public GetControllerDataCommand() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsAnswer.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsAnswer.java
new file mode 100644
index 0000000..413e83e
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsAnswer.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.host.HostVO;
+
+public class GetControllerHostsAnswer {
+ private HostVO master;
+ private HostVO slave;
+
+ public HostVO getMaster() {
+ return master;
+ }
+ public void setMaster(HostVO master) {
+ this.master = master;
+ }
+ public HostVO getSlave() {
+ return slave;
+ }
+ public void setSlave(HostVO slave) {
+ this.slave = slave;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsCommand.java
new file mode 100644
index 0000000..253c8e2
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/GetControllerHostsCommand.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.agent.api;
+
+public class GetControllerHostsCommand extends BcfCommand {
+ public GetControllerHostsCommand() {
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/StartupBigSwitchBcfCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/StartupBigSwitchBcfCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/StartupBigSwitchBcfCommand.java
new file mode 100644
index 0000000..6acb43d
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/StartupBigSwitchBcfCommand.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;
+
+import com.cloud.host.Host;
+
+public class StartupBigSwitchBcfCommand extends StartupCommand {
+
+ public StartupBigSwitchBcfCommand() {
+ super(Host.Type.L2Networking);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/SyncBcfTopologyCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/SyncBcfTopologyCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/SyncBcfTopologyCommand.java
new file mode 100644
index 0000000..660151c
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/SyncBcfTopologyCommand.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;
+
+public class SyncBcfTopologyCommand extends BcfCommand {
+ private final boolean networkIncluded;
+ private final boolean routerIncluded;
+
+ public SyncBcfTopologyCommand(boolean networkIncluded, boolean routerIncluded) {
+ this.networkIncluded = networkIncluded;
+ this.routerIncluded = routerIncluded;
+ }
+
+ public boolean isNetworkIncluded() {
+ return networkIncluded;
+ }
+
+ public boolean isRouterIncluded() {
+ return routerIncluded;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfAttachmentCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfAttachmentCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfAttachmentCommand.java
new file mode 100644
index 0000000..412ee21
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfAttachmentCommand.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;
+
+public class UpdateBcfAttachmentCommand extends BcfCommand {
+ private String _networkId;
+ private String _attachmentId;
+ private String _tenantId;
+ private String _attachmentName;
+
+ public UpdateBcfAttachmentCommand(String networkId, String attachmentId, String tenantId, String attachmentName) {
+ this._networkId = networkId;
+ this._attachmentId = attachmentId;
+ this._tenantId = tenantId;
+ this._attachmentName = attachmentName;
+ }
+
+ public String getNetworkId() {
+ return _networkId;
+ }
+
+ public String getAttachmentId() {
+ return _attachmentId;
+ }
+
+ public String getTenantId() {
+ return _tenantId;
+ }
+
+ public String getPortName() {
+ return _attachmentName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfRouterCommand.java b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfRouterCommand.java
new file mode 100644
index 0000000..675a1ee
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/agent/api/UpdateBcfRouterCommand.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 java.util.ArrayList;
+import java.util.List;
+
+import com.cloud.network.bigswitch.AclData;
+
+public class UpdateBcfRouterCommand extends BcfCommand {
+ private String tenantId;
+ private String publicIp;
+ private List<AclData> acls;
+
+ public UpdateBcfRouterCommand(String tenantId){
+ this.tenantId = tenantId;
+ this.publicIp = null;
+ this.acls = new ArrayList<AclData>();
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getPublicIp() {
+ return publicIp;
+ }
+
+ public void setPublicIp(String publicIp) {
+ this.publicIp = publicIp;
+ }
+
+ public List<AclData> getAcls() {
+ return acls;
+ }
+
+ public void addAcl(AclData acl){
+ this.acls.add(acl);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01864ef7/plugins/network-elements/bigswitch/src/com/cloud/api/commands/AddBigSwitchBcfDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/api/commands/AddBigSwitchBcfDeviceCmd.java b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/AddBigSwitchBcfDeviceCmd.java
new file mode 100644
index 0000000..24334ea
--- /dev/null
+++ b/plugins/network-elements/bigswitch/src/com/cloud/api/commands/AddBigSwitchBcfDeviceCmd.java
@@ -0,0 +1,143 @@
+//
+// 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 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 org.apache.cloudstack.context.CallContext;
+
+import com.cloud.api.response.BigSwitchBcfDeviceResponse;
+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.BigSwitchBcfDeviceVO;
+import com.cloud.network.element.BigSwitchBcfElementService;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@APICommand(name = "addBigSwitchBcfDevice", responseObject = BigSwitchBcfDeviceResponse.class, description = "Adds a BigSwitch BCF Controller device", since = "4.6.0",
+ requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
+public class AddBigSwitchBcfDeviceCmd extends BaseAsyncCmd {
+ private static final String s_name = "addbigswitchbcfdeviceresponse";
+ @Inject
+ BigSwitchBcfElementService _bigswitchBcfElementService;
+
+ /////////////////////////////////////////////////////
+ //////////////// 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 BCF Controller.")
+ private String host;
+
+ @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true,
+ description="Username of the BigSwitch BCF Controller.")
+ private String username;
+
+ @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true,
+ description="Password of the BigSwitch BCF Controller.")
+ private String password;
+
+ @Parameter(name=BcfConstants.BIGSWITCH_BCF_DEVICE_NAT, type=CommandType.BOOLEAN, required=true,
+ description="NAT support of the BigSwitch BCF Controller.")
+ private Boolean nat;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getPhysicalNetworkId() {
+ return physicalNetworkId;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public Boolean getNat() {
+ return nat;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+ ResourceAllocationException {
+ try {
+ BigSwitchBcfDeviceVO bigswitchBcfDeviceVO = _bigswitchBcfElementService.addBigSwitchBcfDevice(this);
+ if (bigswitchBcfDeviceVO != null) {
+ BigSwitchBcfDeviceResponse response = _bigswitchBcfElementService.createBigSwitchBcfDeviceResponse(bigswitchBcfDeviceVO);
+ response.setObjectName("bigswitchbcfdevice");
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add BigSwitch BCF Controller 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 CallContext.current().getCallingAccount().getId();
+ }
+
+ @Override
+ public String getEventType() {
+ return BcfConstants.EVENT_EXTERNAL_BCF_CONTROLLER_ADD;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Adding a BigSwitch BCF Controller";
+ }
+}