BigSwitch networking plugin update

Update BigSwitch Plugin:

. UI support for adding BigSwitch controller as a network service provider
. Correct the message format between the plugin and the controller
. Add Health check API

Test to add a BigSwitch controller as a network service provider and view.
Test to implementation of guest network on the controller
Test to associate VM to its guest network
This commit is contained in:
Kanzhe Jiang 2013-03-29 18:48:50 +05:30 committed by Murali Reddy
parent 690c31290b
commit ee3fd18435
20 changed files with 648 additions and 208 deletions

View File

@ -1582,6 +1582,10 @@ label.nicira.controller.address=Controller Address
label.nicira.transportzoneuuid=Transport Zone Uuid
label.nicira.l3gatewayserviceuuid=L3 Gateway Service Uuid
label.add.BigSwitchVns.device=Add BigSwitch Vns Controller
label.delete.BigSwitchVns=Remove BigSwitch Vns Controller
label.bigswitch.controller.address=BigSwitch Vns Controller Address
#resizeVolumes
label.resize.new.size=New Size(GB)
label.action.resize.volume=Resize Volume

View File

@ -107,12 +107,6 @@
<property name="name" value="NiciraNvp"/>
</bean>
-->
<!--
<bean id="BigSwitchVnsElementService" class="com.cloud.network.element.BigSwitchVnsElement">
<property name="name" value="BigSwitchVnsElementService"/>
</bean>
-->
<!--
Adapters
@ -296,12 +290,9 @@
<bean id="NiciraNvpGuestNetworkGuru" class="com.cloud.network.guru.NiciraNvpGuestNetworkGuru">
<property name="name" value="NiciraNvpGuestNetworkGuru"/>
</bean>
<!--
<bean id="BigSwitchVnsGuestNetworkGuru" class=".BigSwitchVnsGuestNetworkGuru">
<property name="name" value="com.cloud.network.guru.BigSwitchVnsGuestNetworkGuru"/>
<bean id="BigSwitchVnsGuestNetworkGuru" class="com.cloud.network.guru.BigSwitchVnsGuestNetworkGuru">
<property name="name" value="BigSwitchVnsGuestNetworkGuru"/>
</bean>
-->
<!--
Hypervisor Gurus

View File

@ -111,6 +111,9 @@
<bean id="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement">
<property name="name" value="NiciraNvp"/>
</bean>
<bean id="BigSwitchVns" class="com.cloud.network.element.BigSwitchVnsElement">
<property name="name" value="BigSwitchVns"/>
</bean>
<bean id="JuniperSRX" class="com.cloud.network.element.JuniperSRXExternalFirewallElement">
<property name="name" value="JuniperSRX"/>
@ -299,6 +302,9 @@
<bean id="NiciraNvpGuestNetworkGuru" class="com.cloud.network.guru.NiciraNvpGuestNetworkGuru">
<property name="name" value="NiciraNvpGuestNetworkGuru"/>
</bean>
<bean id="BigSwitchVnsGuestNetworkGuru" class="com.cloud.network.guru.BigSwitchVnsGuestNetworkGuru">
<property name="name" value="BigSwitchVnsGuestNetworkGuru"/>
</bean>
<!--
Hypervisor Gurus

View File

@ -26,6 +26,7 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.SuccessResponse;
import com.cloud.api.response.BigSwitchVnsDeviceResponse;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
@ -44,7 +45,8 @@ public class DeleteBigSwitchVnsDeviceCmd extends BaseAsyncCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID, type=CommandType.LONG, required=true, description="BigSwitch device ID")
@Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID, type=CommandType.UUID, entityType = BigSwitchVnsDeviceResponse.class,
required=true, description="BigSwitch device ID")
private Long bigswitchVnsDeviceId;
/////////////////////////////////////////////////////

View File

@ -52,13 +52,13 @@ public class ListBigSwitchVnsDevicesCmd extends BaseListCmd {
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID,
entityType = PhysicalNetworkResponse.class,
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")
@Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID, type=CommandType.UUID,
entityType = BigSwitchVnsDeviceResponse.class,
description="bigswitch vns device ID")
private Long bigswitchVnsDeviceId;
/////////////////////////////////////////////////////

View File

@ -41,6 +41,10 @@ public class BigSwitchVnsDeviceResponse extends BaseResponse {
@SerializedName(ApiConstants.HOST_NAME) @Param(description="the controller Ip address")
private String hostName;
public String getId() {
return this.id;
}
public void setId(String vnsDeviceId) {
this.id = vnsDeviceId;
}

View File

@ -25,9 +25,11 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name="external_bigswitch_vns_devices")
public class BigSwitchVnsDeviceVO {
public class BigSwitchVnsDeviceVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)

View File

@ -16,23 +16,35 @@
// under the License.
package com.cloud.network.bigswitch;
public class Attachment {
private String id;
private String mac;
public class AttachmentData {
private Attachment attachment;
public String getId() {
return id;
}
public Attachment getAttachment() {
return attachment;
}
public void setId(String id) {
this.id = id;
}
public AttachmentData() {
this.attachment = new Attachment();
}
public String getMac() {
return mac;
}
public class Attachment {
private String id;
private String mac;
public void setMac(String mac) {
this.mac = 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;
}
}
}

View File

@ -49,10 +49,10 @@ 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 ACCEPT = "Accept";
private final static String CONTENT_JSON = "application/json";
private final static String HTTP_HEADER_INSTANCE_ID = "HTTP_INSTANCE_ID";
private final static String HTTP_HEADER_INSTANCE_ID = "INSTANCE_ID";
private final static String CLOUDSTACK_INSTANCE_ID = "org.apache.cloudstack";
private final static MultiThreadedHttpConnectionManager s_httpClientManager =
new MultiThreadedHttpConnectionManager();
@ -114,55 +114,56 @@ public class BigSwitchVnsApi {
return;
}
public void createNetwork(Network network)
public void createNetwork(NetworkData network)
throws BigSwitchVnsApiException {
String uri = _nsBaseUri + "/tenant/" + network.getTenant_id() + "/network";
executeCreateObject(network, new TypeToken<Network>(){}.getType(),
String uri = _nsBaseUri + "/tenants/" + network.getNetwork().getTenant_id() + "/networks";
executeCreateObject(network, new TypeToken<NetworkData>(){}.getType(),
uri, Collections.<String,String>emptyMap());
}
public void deleteNetwork(String tenantId, String networkId) throws BigSwitchVnsApiException {
String uri = _nsBaseUri + "/tenant/" + tenantId + "/networks/" + networkId;
String uri = _nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId;
executeDeleteObject(uri);
}
public void createPort(String networkUuid, Port port)
public void createPort(String networkUuid, PortData port)
throws BigSwitchVnsApiException {
String uri = _nsBaseUri + "/tenant/" + port.getTenant_id() + "/networks/" + networkUuid + "/ports";
executeCreateObject(port, new TypeToken<Port>(){}.getType(),
String uri = _nsBaseUri + "/tenants/" + port.getPort().getTenant_id() + "/networks/" + networkUuid + "/ports";
executeCreateObject(port, new TypeToken<PortData>(){}.getType(),
uri, Collections.<String,String>emptyMap());
}
public void modifyPort(String networkId, Port port)
public void modifyPort(String networkId, PortData port)
throws BigSwitchVnsApiException {
String uri = _nsBaseUri + "/tenant/" + port.getTenant_id() + "/networks/" + networkId + "/ports";
String uri = _nsBaseUri + "/tenants/" + port.getPort().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;
String uri = _nsBaseUri + "/tenants/" + 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";
AttachmentData attachment) throws BigSwitchVnsApiException {
String uri = _nsBaseUri + "/tenants/" + 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";
String uri = _nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + portId + "/attachment";
executeDeleteObject(uri);
}
public ControlClusterStatus getControlClusterStatus() throws BigSwitchVnsApiException {
String uri = _controllerBaseUri + "/health/json";
String uri = _nsBaseUri + "/health";
ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>(){}.getType(),
uri, 80, null);
ccs.setStatus(true);
return ccs;
}
@ -177,6 +178,7 @@ public class BigSwitchVnsApi {
PutMethod pm = (PutMethod) createMethod("put", uri, 80);
pm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
pm.setRequestHeader(ACCEPT, CONTENT_JSON);
pm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
try {
pm.setRequestEntity(new StringRequestEntity(
@ -207,6 +209,7 @@ public class BigSwitchVnsApi {
PostMethod pm = (PostMethod) createMethod("post", uri, 80);
pm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
pm.setRequestHeader(ACCEPT, CONTENT_JSON);
pm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
try {
pm.setRequestEntity(new StringRequestEntity(
@ -235,6 +238,7 @@ public class BigSwitchVnsApi {
DeleteMethod dm = (DeleteMethod) createMethod("delete", uri, 80);
dm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
dm.setRequestHeader(ACCEPT, CONTENT_JSON);
dm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
executeMethod(dm);
@ -257,6 +261,7 @@ public class BigSwitchVnsApi {
GetMethod gm = (GetMethod) createMethod("get", uri, port);
gm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
gm.setRequestHeader(ACCEPT, CONTENT_JSON);
gm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
if (parameters != null && !parameters.isEmpty()) {
@ -327,4 +332,4 @@ public class BigSwitchVnsApi {
return method.getStatusText();
}
}
}

View File

@ -22,4 +22,8 @@ public class ControlClusterStatus {
public boolean getStatus() {
return healthy;
}
public void setStatus(boolean status) {
this.healthy = status;
}
}

View File

@ -1,74 +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;
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;
}
}

View File

@ -0,0 +1,86 @@
// 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 NetworkData {
private Network network;
public Network getNetwork() {
return this.network;
}
public NetworkData() {
this.network = new Network();
}
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;
}
}
}

View File

@ -16,41 +16,53 @@
// 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 class PortData {
private Port port;
public String getId() {
return id;
}
public Port getPort() {
return this.port;
}
public void setId(String id) {
this.id = id;
}
public PortData() {
this.port = new Port();
}
public String getName() {
return name;
}
public class Port {
private String id;
private String name;
private String tenant_id;
private String state;
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public String getTenant_id() {
return tenant_id;
}
public void setId(String id) {
this.id = id;
}
public void setTenant_id(String tenant_id) {
this.tenant_id = tenant_id;
}
public String getName() {
return name;
}
public String getState() {
return state;
}
public void setName(String name) {
this.name = name;
}
public void setState(String state) {
this.state = state;
}
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;
}
}
}

View File

@ -76,7 +76,6 @@ import com.cloud.network.dao.PhysicalNetworkVO;
import com.cloud.network.resource.BigSwitchVnsResource;
import com.cloud.offering.NetworkOffering;
import com.cloud.resource.ResourceManager;
import com.cloud.resource.ResourceState;
import com.cloud.resource.ResourceStateAdapter;
import com.cloud.resource.ServerResource;
import com.cloud.resource.UnableDeleteHostException;
@ -139,7 +138,7 @@ public class BigSwitchVnsElement extends AdapterBase implements
if (network.getBroadcastDomainType() != BroadcastDomainType.Lswitch) {
return false;
}
/*
if (!_networkModel.isProviderForNetwork(getProvider(),
network.getId())) {
s_logger.debug("BigSwitchVnsElement is not a provider for network "
@ -154,7 +153,7 @@ public class BigSwitchVnsElement extends AdapterBase implements
+ network.getDisplayText());
return false;
}
*/
return true;
}
@ -198,7 +197,7 @@ public class BigSwitchVnsElement extends AdapterBase implements
}
String mac = nic.getMacAddress();
String tenantId = context.getDomain().getName() + "-" + context.getAccount().getAccountId();
String tenantId = context.getDomain().getName();
List<BigSwitchVnsDeviceVO> devices = _bigswitchVnsDao
.listByPhysicalNetwork(network.getPhysicalNetworkId());
@ -242,7 +241,7 @@ public class BigSwitchVnsElement extends AdapterBase implements
return false;
}
String tenantId = context.getDomain().getName() + "-" + context.getAccount().getAccountId();
String tenantId = context.getDomain().getName();
List<BigSwitchVnsDeviceVO> devices = _bigswitchVnsDao
.listByPhysicalNetwork(network.getPhysicalNetworkId());
@ -462,8 +461,9 @@ public class BigSwitchVnsElement extends AdapterBase implements
HostVO bigswitchHost = _hostDao.findById(bigswitchVnsDevice.getHostId());
Long hostId = bigswitchHost.getId();
bigswitchHost.setResourceState(ResourceState.Maintenance);
_hostDao.update(hostId, bigswitchHost);
//bigswitchHost.setResourceState(ResourceState.Maintenance);
//_hostDao.update(hostId, bigswitchHost);
_hostDao.remove(hostId);
_resourceMgr.deleteHost(hostId, false, false);
_bigswitchVnsDao.remove(bigswitchVnsDeviceId);

View File

@ -179,7 +179,7 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
name = name.substring(0, 63); // max length 64
}
String tenantId = context.getDomain().getName() + "-" + context.getAccount().getAccountId();
String tenantId = context.getDomain().getName();
List<BigSwitchVnsDeviceVO> devices = _bigswitchVnsDao.listByPhysicalNetwork(physicalNetworkId);
if (devices.isEmpty()) {
s_logger.error("No BigSwitch Controller on physical network " + physicalNetworkId);
@ -244,7 +244,7 @@ public class BigSwitchVnsGuestNetworkGuru extends GuestNetworkGuru {
BigSwitchVnsDeviceVO bigswitchVnsDevice = devices.get(0);
HostVO bigswitchVnsHost = _hostDao.findById(bigswitchVnsDevice.getHostId());
String tenantId = profile.getNetworkDomain() + "-" + profile.getAccountId();
String tenantId = profile.getNetworkDomain();
DeleteVnsNetworkCommand cmd = new DeleteVnsNetworkCommand(tenantId,
networkObject.getBroadcastUri().getSchemeSpecificPart());

View File

@ -47,9 +47,9 @@ import com.cloud.host.Host.Type;
import com.cloud.network.bigswitch.BigSwitchVnsApi;
import com.cloud.network.bigswitch.BigSwitchVnsApiException;
import com.cloud.network.bigswitch.ControlClusterStatus;
import com.cloud.network.bigswitch.Attachment;
import com.cloud.network.bigswitch.Network;
import com.cloud.network.bigswitch.Port;
import com.cloud.network.bigswitch.AttachmentData;
import com.cloud.network.bigswitch.NetworkData;
import com.cloud.network.bigswitch.PortData;
import com.cloud.resource.ServerResource;
import com.cloud.utils.component.ManagerBase;
@ -193,15 +193,15 @@ public class BigSwitchVnsResource extends ManagerBase implements ServerResource
}
private Answer executeRequest(CreateVnsNetworkCommand cmd, int numRetries) {
Network network = new Network();
network.setTenant_id(cmd.getTenantUuid());
network.setUuid(cmd.getNetworkUuid());
network.setDisplay_name(truncate("vns-cloudstack-" + cmd.getName(), 64));
network.setVlan(cmd.getVlan());
NetworkData network = new NetworkData();
network.getNetwork().setTenant_id(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.getUuid() + " created");
return new CreateVnsNetworkAnswer(cmd, true, "VNS " + network.getNetwork().getUuid() + " created");
} catch (BigSwitchVnsApiException e) {
if (numRetries > 0) {
return retry(cmd, --numRetries);
@ -228,17 +228,17 @@ public class BigSwitchVnsResource extends ManagerBase implements ServerResource
}
private Answer executeRequest(CreateVnsPortCommand cmd, int numRetries) {
Port port = new Port();
port.setId(cmd.getPortUuid());
port.setName(cmd.getPortName());
port.setTenant_id(cmd.getTenantUuid());
PortData port = new PortData();
port.getPort().setId(cmd.getPortUuid());
port.getPort().setName(cmd.getPortName());
port.getPort().setTenant_id(cmd.getTenantUuid());
try {
_bigswitchVnsApi.createPort(cmd.getNetworkUuid(), port);
try {
Attachment attachment = new Attachment();
attachment.setId(cmd.getPortUuid());
attachment.setMac(cmd.getMac());
AttachmentData attachment = new AttachmentData();
attachment.getAttachment().setId(cmd.getPortUuid());
attachment.getAttachment().setMac(cmd.getMac());
_bigswitchVnsApi.modifyPortAttachment(cmd.getTenantUuid(),
cmd.getNetworkUuid(), cmd.getPortUuid(), attachment);
@ -279,10 +279,10 @@ public class BigSwitchVnsResource extends ManagerBase implements ServerResource
}
private Answer executeRequest(UpdateVnsPortCommand cmd, int numRetries) {
Port port = new Port();
port.setId(cmd.getPortUuid());
port.setName(cmd.getPortName());
port.setTenant_id(cmd.getTenantUuid());
PortData port = new PortData();
port.getPort().setId(cmd.getPortUuid());
port.getPort().setName(cmd.getPortName());
port.getPort().setTenant_id(cmd.getTenantUuid());
try {
_bigswitchVnsApi.modifyPort(cmd.getNetworkUuid(), port);

View File

@ -98,10 +98,10 @@ public class BigSwitchApiTest {
@Test
public void testExecuteCreateObject() throws BigSwitchVnsApiException, IOException {
_api.setControllerAddress("10.10.0.10");
Network network = new Network();
NetworkData network = new NetworkData();
_method = mock(PostMethod.class);
when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
_api.executeCreateObject(network, Network.class, "/", Collections.<String, String> emptyMap());
_api.executeCreateObject(network, NetworkData.class, "/", Collections.<String, String> emptyMap());
verify(_method, times(1)).releaseConnection();
}
@ -109,7 +109,7 @@ public class BigSwitchApiTest {
@Test (expected=BigSwitchVnsApiException.class)
public void testExecuteCreateObjectFailure() throws BigSwitchVnsApiException, IOException {
_api.setControllerAddress("10.10.0.10");
Network network = new Network();
NetworkData network = new NetworkData();
_method = mock(PostMethod.class);
when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
Header header = mock(Header.class);
@ -118,7 +118,7 @@ public class BigSwitchApiTest {
when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
when(_method.isRequestSent()).thenReturn(true);
try {
_api.executeCreateObject(network, Network.class, "/", Collections.<String, String> emptyMap());
_api.executeCreateObject(network, NetworkData.class, "/", Collections.<String, String> emptyMap());
} finally {
verify(_method, times(1)).releaseConnection();
}
@ -127,7 +127,7 @@ public class BigSwitchApiTest {
@Test (expected=BigSwitchVnsApiException.class)
public void testExecuteCreateObjectException() throws BigSwitchVnsApiException, IOException {
_api.setControllerAddress("10.10.0.10");
Network network = new Network();
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);
@ -136,7 +136,7 @@ public class BigSwitchApiTest {
when(_method.getResponseHeader("Content-Type")).thenReturn(header);
when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
try {
_api.executeCreateObject(network, Network.class, "/", Collections.<String, String> emptyMap());
_api.executeCreateObject(network, NetworkData.class, "/", Collections.<String, String> emptyMap());
} finally {
verify(_method, times(1)).releaseConnection();
}
@ -145,7 +145,7 @@ public class BigSwitchApiTest {
@Test
public void testExecuteUpdateObject() throws BigSwitchVnsApiException, IOException {
_api.setControllerAddress("10.10.0.10");
Network network = new Network();
NetworkData network = new NetworkData();
_method = mock(PutMethod.class);
when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
_api.executeUpdateObject(network, "/", Collections.<String, String> emptyMap());
@ -156,7 +156,7 @@ public class BigSwitchApiTest {
@Test (expected=BigSwitchVnsApiException.class)
public void testExecuteUpdateObjectFailure() throws BigSwitchVnsApiException, IOException {
_api.setControllerAddress("10.10.0.10");
Network network = new Network();
NetworkData network = new NetworkData();
_method = mock(PutMethod.class);
when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
Header header = mock(Header.class);
@ -174,7 +174,7 @@ public class BigSwitchApiTest {
@Test (expected=BigSwitchVnsApiException.class)
public void testExecuteUpdateObjectException() throws BigSwitchVnsApiException, IOException {
_api.setControllerAddress("10.10.0.10");
Network network = new Network();
NetworkData network = new NetworkData();
_method = mock(PutMethod.class);
when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
when(_client.executeMethod((HttpMethod) any())).thenThrow(new IOException());

View File

@ -41,10 +41,10 @@ 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.Attachment;
import com.cloud.network.bigswitch.AttachmentData;
import com.cloud.network.bigswitch.ControlClusterStatus;
import com.cloud.network.bigswitch.Network;
import com.cloud.network.bigswitch.Port;
import com.cloud.network.bigswitch.NetworkData;
import com.cloud.network.bigswitch.PortData;
import com.cloud.network.bigswitch.BigSwitchVnsApi;
import com.cloud.network.bigswitch.BigSwitchVnsApiException;
@ -140,7 +140,9 @@ public class BigSwitchVnsResourceTest {
public void testRetries() throws ConfigurationException, BigSwitchVnsApiException {
_resource.configure("BigSwitchVnsResource", _parameters);
Network network = mock(Network.class);
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);
@ -152,7 +154,9 @@ public class BigSwitchVnsResourceTest {
public void testCreateNetwork() throws ConfigurationException, BigSwitchVnsApiException {
_resource.configure("BigSwitchVnsResource", _parameters);
Network network = mock(Network.class);
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);
@ -164,9 +168,11 @@ public class BigSwitchVnsResourceTest {
public void testCreateNetworkApiException() throws ConfigurationException, BigSwitchVnsApiException {
_resource.configure("BigSwitchVnsResource", _parameters);
Network network = mock(Network.class);
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((Network)any());
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);
@ -197,8 +203,10 @@ public class BigSwitchVnsResourceTest {
public void testCreatePort() throws ConfigurationException, BigSwitchVnsApiException {
_resource.configure("BigSwitchVnsResource", _parameters);
Port networkp = mock(Port.class);
when(networkp.getId()).thenReturn("eeee");
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);
@ -209,9 +217,11 @@ public class BigSwitchVnsResourceTest {
public void testCreatePortApiExceptionInCreate() throws ConfigurationException, BigSwitchVnsApiException {
_resource.configure("BigSwitchVnsResource", _parameters);
Port networkp = mock(Port.class);
when(networkp.getId()).thenReturn("eeee");
doThrow(new BigSwitchVnsApiException()).when(_bigswitchVnsApi).createPort((String)any(), (Port)any());
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);
@ -222,9 +232,11 @@ public class BigSwitchVnsResourceTest {
public void testCreatePortApiExceptionInModify() throws ConfigurationException, BigSwitchVnsApiException {
_resource.configure("BigSwitchVnsResource", _parameters);
Port networkp = mock(Port.class);
when(networkp.getId()).thenReturn("eeee");
doThrow(new BigSwitchVnsApiException()).when(_bigswitchVnsApi).modifyPortAttachment((String)any(), (String)any(), (String)any(), (Attachment)any());
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);
@ -246,7 +258,7 @@ public class BigSwitchVnsResourceTest {
public void testUpdatePortException() throws ConfigurationException, BigSwitchVnsApiException {
_resource.configure("BigSwitchVnsResource", _parameters);
doThrow(new BigSwitchVnsApiException()).when(_bigswitchVnsApi).modifyPort((String) any(), (Port)any());
doThrow(new BigSwitchVnsApiException()).when(_bigswitchVnsApi).modifyPort((String) any(), (PortData)any());
UpdateVnsPortAnswer dntkpa = (UpdateVnsPortAnswer) _resource.executeRequest(
new UpdateVnsPortCommand("networkId","portId","tenantId","portname"));
assertFalse(dntkpa.getResult());

View File

@ -1470,6 +1470,9 @@ dictionary = {
'label.action.vmsnapshot.delete': '<fmt:message key="label.action.vmsnapshot.delete" />',
'label.action.vmsnapshot.revert': '<fmt:message key="label.action.vmsnapshot.revert" />',
'message.action.vmsnapshot.delete': '<fmt:message key="message.action.vmsnapshot.delete" />',
'message.action.vmsnapshot.revert': '<fmt:message key="message.action.vmsnapshot.revert" />'
'message.action.vmsnapshot.revert': '<fmt:message key="message.action.vmsnapshot.revert" />',
'label.add.BigSwitchVns.device': '<fmt:message key="label.add.BigSwitchVns.device" />',
'label.delete.BigSwitchVns': '<fmt:message key="label.delete.BigSwitchVns" />',
'label.bigswitch.controller.address': '<fmt:message key="label.bigswitch.controller.address" />'
};
</script>

View File

@ -4109,6 +4109,199 @@
notification: { poll: pollAsyncJobResult }
}
}
},
// BigSwitch Vns provider detail view
bigswitchVns: {
type: 'detailView',
id: 'bigswitchVnsProvider',
label: 'label.bigswitchVns',
viewAll: { label: 'label.devices', path: '_zone.bigswitchVnsDevices' },
tabs: {
details: {
title: 'label.details',
fields: [
{
name: { label: 'label.name' }
},
{
state: { label: 'label.state' }
}
],
dataProvider: function(args) {
refreshNspData("BigSwitchVns");
var providerObj;
$(nspHardcodingArray).each(function(){
if(this.id == "bigswitchVns") {
providerObj = this;
return false;
}
});
args.response.success({
data: providerObj,
actionFilter: networkProviderActionFilter('bigswitchVns')
});
}
}
},
actions: {
add: {
label: 'label.add.BigSwitchVns.device',
createForm: {
title: 'label.add.BigSwitchVns.device',
preFilter: function(args) { },
fields: {
host: {
label: 'label.ip.address'
},
numretries: {
label: 'label.numretries',
defaultValue: '2'
},
}
},
action: function(args) {
if(nspMap["bigswitchVns"] == null) {
$.ajax({
url: createURL("addNetworkServiceProvider&name=BigSwitchVns&physicalnetworkid=" + selectedPhysicalNetworkObj.id),
dataType: "json",
async: true,
success: function(json) {
var jobId = json.addnetworkserviceproviderresponse.jobid;
var addBigSwitchVnsProviderIntervalID = setInterval(function() {
$.ajax({
url: createURL("queryAsyncJobResult&jobId="+jobId),
dataType: "json",
success: function(json) {
var result = json.queryasyncjobresultresponse;
if (result.jobstatus == 0) {
return; //Job has not completed
}
else {
clearInterval(addBigSwitchVnsProviderIntervalID);
if (result.jobstatus == 1) {
nspMap["bigswitchVns"] = json.queryasyncjobresultresponse.jobresult.networkserviceprovider;
addBigSwitchVnsDevice(args, selectedPhysicalNetworkObj, "addBigSwitchVnsDevice", "addbigswitchvnsdeviceresponse", "bigswitchvnsdevice")
}
else if (result.jobstatus == 2) {
alert("addNetworkServiceProvider&name=BigSwitchVns failed. Error: " + _s(result.jobresult.errortext));
}
}
},
error: function(XMLHttpResponse) {
var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
alert("addNetworkServiceProvider&name=BigSwitchVns failed. Error: " + errorMsg);
}
});
}, 3000);
}
});
}
else {
addBigSwitchVnsDevice(args, selectedPhysicalNetworkObj, "addBigSwitchVnsDevice", "addbigswitchvnsdeviceresponse", "bigswitchvnsdevice")
}
},
messages: {
notification: function(args) {
return 'label.add.BigSwitchVns.device';
}
},
notification: {
poll: pollAsyncJobResult
}
},
enable: {
label: 'label.enable.provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["bigswitchVns"].id + "&state=Enabled"),
dataType: "json",
success: function(json) {
var jid = json.updatenetworkserviceproviderresponse.jobid;
args.response.success(
{_custom:
{
jobId: jid,
getUpdatedItem: function(json) {
$(window).trigger('cloudStack.fullRefresh');
}
}
}
);
}
});
},
messages: {
confirm: function(args) {
return 'message.confirm.enable.provider';
},
notification: function() {
return 'label.enable.provider';
}
},
notification: { poll: pollAsyncJobResult }
},
disable: {
label: 'label.disable.provider',
action: function(args) {
$.ajax({
url: createURL("updateNetworkServiceProvider&id=" + nspMap["bigswitchVns"].id + "&state=Disabled"),
dataType: "json",
success: function(json) {
var jid = json.updatenetworkserviceproviderresponse.jobid;
args.response.success(
{_custom:
{
jobId: jid,
getUpdatedItem: function(json) {
$(window).trigger('cloudStack.fullRefresh');
}
}
}
);
}
});
},
messages: {
confirm: function(args) {
return 'message.confirm.disable.provider';
},
notification: function() {
return 'label.disable.provider';
}
},
notification: { poll: pollAsyncJobResult }
},
destroy: {
label: 'label.shutdown.provider',
action: function(args) {
$.ajax({
url: createURL("deleteNetworkServiceProvider&id=" + nspMap["bigswitchVns"].id),
dataType: "json",
success: function(json) {
var jid = json.deletenetworkserviceproviderresponse.jobid;
args.response.success(
{_custom:
{
jobId: jid
}
}
);
$(window).trigger('cloudStack.fullRefresh');
}
});
},
messages: {
confirm: function(args) {
return 'message.confirm.shutdown.provider';
},
notification: function(args) {
return 'label.shutdown.provider';
}
},
notification: { poll: pollAsyncJobResult }
}
}
}
}
}
@ -6914,6 +7107,152 @@
}
}
},
bigswitchVnsDevices: {
id: 'bigswitchVnsDevices',
title: 'label.devices',
listView: {
id: 'bigswitchVnsDevices',
fields: {
hostname: { label: 'label.bigswitch.controller.address' },
},
actions: {
add: {
label: 'label.add.BigSwitchVns.device',
createForm: {
title: 'label.add.BigSwitchVns.device',
preFilter: function(args) { },
fields: {
host: {
label: 'label.ip.address'
},
numretries: {
label: 'label.numretries',
defaultValue: '2'
},
}
},
action: function(args) {
if(nspMap["bigswitchVns"] == null) {
$.ajax({
url: createURL("addNetworkServiceProvider&name=BigSwitchVns&physicalnetworkid=" + selectedPhysicalNetworkObj.id),
dataType: "json",
async: true,
success: function(json) {
var jobId = json.addnetworkserviceproviderresponse.jobid;
var addBigSwitchVnsProviderIntervalID = setInterval(function() {
$.ajax({
url: createURL("queryAsyncJobResult&jobId="+jobId),
dataType: "json",
success: function(json) {
var result = json.queryasyncjobresultresponse;
if (result.jobstatus == 0) {
return;
}
else {
clearInterval(addBigSwitchVnsProviderIntervalID);
if (result.jobstatus == 1) {
nspMap["bigswitchVns"] = json.queryasyncjobresultresponse.jobresult.networkserviceprovider;
addBigSwitchVnsDevice(args, selectedPhysicalNetworkObj, "addBigSwitchVnsDevice", "addbigswitchvnsdeviceresponse", "bigswitchvnsdevice")
}
else if (result.jobstatus == 2) {
alert("addNetworkServiceProvider&name=BigSwitchVns failed. Error: " + _s(result.jobresult.errortext));
}
}
},
error: function(XMLHttpResponse) {
var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
alert("addNetworkServiceProvider&name=BigSwitchVns failed. Error: " + errorMsg);
}
});
}, 3000);
}
});
}
else {
addBigSwitchVnsDevice(args, selectedPhysicalNetworkObj, "addBigSwitchVnsDevice", "addbigswitchvnsdeviceresponse", "bigswitchvnsdevice")
}
},
messages: {
notification: function(args) {
return 'Added new BigSwitch Vns Controller';
}
},
notification: {
poll: pollAsyncJobResult
}
}
},
dataProvider: function(args) {
$.ajax({
url: createURL("listBigSwitchVnsDevices&physicalnetworkid=" + selectedPhysicalNetworkObj.id),
data: { page: args.page, pageSize: pageSize },
dataType: "json",
async: false,
success: function(json) {
var items = json.listbigswitchvnsdeviceresponse.bigswitchvnsdevice;
args.response.success({data: items});
}
});
},
detailView: {
name: 'BigSwitch Vns details',
actions: {
'remove': {
label: 'label.delete.BigSwitchVns',
messages: {
confirm: function(args) {
return 'message.confirm.delete.BigSwitchVns';
},
notification: function(args) {
return 'label.delete.BigSwitchVns';
}
},
action: function(args) {
$.ajax({
url: createURL("deleteBigSwitchVnsDevice&vnsdeviceid=" + args.context.bigswitchvnsDevices[0].vnsdeviceid),
dataType: "json",
async: true,
success: function(json) {
var jid = json.deletebigswitchvnsdeviceresponse.jobid;
args.response.success(
{_custom:
{jobId: jid}
}
);
}
});
},
notification: {
poll: pollAsyncJobResult
}
}
},
tabs: {
details: {
title: 'label.details',
fields: [
{
vnsdeviceid: { label: 'label.id' },
hostname: { label: 'label.ip.address' },
}
],
dataProvider: function(args) {
$.ajax({
url: createURL("listBigSwitchVnsDevices&vnsdeviceid=" + args.context.bigswitchVnsDevices[0].vnsdeviceid),
dataType: "json",
async: true,
success: function(json) {
var item = json.listbigswitchvnsdeviceresponse.bigswitchvnsdevice[0];
args.response.success({data: item});
}
});
}
}
}
}
}
},
pods: {
title: 'label.pods',
listView: {
@ -10397,6 +10736,30 @@
});
}
function addBigSwitchVnsDevice(args, physicalNetworkObj, apiCmd, apiCmdRes, apiCmdObj) {
var array1 = [];
array1.push("&physicalnetworkid=" + physicalNetworkObj.id);
array1.push("&hostname=" + todb(args.data.host));
$.ajax({
url: createURL(apiCmd + array1.join("")),
dataType: "json",
success: function(json) {
var jid = json[apiCmdRes].jobid;
args.response.success(
{_custom:
{jobId: jid,
getUpdatedItem: function(json) {
var item = json.queryasyncjobresultresponse.jobresult[apiCmdObj];
return item;
}
}
}
);
}
});
}
var afterCreateZonePhysicalNetworkTrafficTypes = function(args, newZoneObj, newPhysicalnetwork) {
$.ajax({
@ -10982,6 +11345,9 @@
case "NiciraNvp":
nspMap["niciraNvp"] = items[i];
break;
case "BigSwitchVns":
nspMap["bigswitchVns"] = items[i];
break;
}
}
}
@ -11003,7 +11369,12 @@
id: 'niciraNvp',
name: 'Nicira Nvp',
state: nspMap.niciraNvp ? nspMap.niciraNvp.state : 'Disabled'
}
},
{
id: 'bigswitchVns',
name: 'BigSwitch Vns',
state: nspMap.bigswitchVns ? nspMap.bigswitchVns.state : 'Disabled'
}
];
if(selectedZoneObj.networktype == "Basic") {