Skip to content

Commit ee3fd18

Browse files
kjiangMurali Reddy
authored andcommitted
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
1 parent 690c312 commit ee3fd18

20 files changed

Lines changed: 656 additions & 216 deletions

client/WEB-INF/classes/resources/messages.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,10 @@ label.nicira.controller.address=Controller Address
15821582
label.nicira.transportzoneuuid=Transport Zone Uuid
15831583
label.nicira.l3gatewayserviceuuid=L3 Gateway Service Uuid
15841584

1585+
label.add.BigSwitchVns.device=Add BigSwitch Vns Controller
1586+
label.delete.BigSwitchVns=Remove BigSwitch Vns Controller
1587+
label.bigswitch.controller.address=BigSwitch Vns Controller Address
1588+
15851589
#resizeVolumes
15861590
label.resize.new.size=New Size(GB)
15871591
label.action.resize.volume=Resize Volume

client/tomcatconf/componentContext.xml.in

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,6 @@
107107
<property name="name" value="NiciraNvp"/>
108108
</bean>
109109
-->
110-
111-
<!--
112-
<bean id="BigSwitchVnsElementService" class="com.cloud.network.element.BigSwitchVnsElement">
113-
<property name="name" value="BigSwitchVnsElementService"/>
114-
</bean>
115-
-->
116110

117111
<!--
118112
Adapters
@@ -296,12 +290,9 @@
296290
<bean id="NiciraNvpGuestNetworkGuru" class="com.cloud.network.guru.NiciraNvpGuestNetworkGuru">
297291
<property name="name" value="NiciraNvpGuestNetworkGuru"/>
298292
</bean>
299-
300-
<!--
301-
<bean id="BigSwitchVnsGuestNetworkGuru" class=".BigSwitchVnsGuestNetworkGuru">
302-
<property name="name" value="com.cloud.network.guru.BigSwitchVnsGuestNetworkGuru"/>
293+
<bean id="BigSwitchVnsGuestNetworkGuru" class="com.cloud.network.guru.BigSwitchVnsGuestNetworkGuru">
294+
<property name="name" value="BigSwitchVnsGuestNetworkGuru"/>
303295
</bean>
304-
-->
305296

306297
<!--
307298
Hypervisor Gurus

client/tomcatconf/nonossComponentContext.xml.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
<bean id="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement">
112112
<property name="name" value="NiciraNvp"/>
113113
</bean>
114+
<bean id="BigSwitchVns" class="com.cloud.network.element.BigSwitchVnsElement">
115+
<property name="name" value="BigSwitchVns"/>
116+
</bean>
114117

115118
<bean id="JuniperSRX" class="com.cloud.network.element.JuniperSRXExternalFirewallElement">
116119
<property name="name" value="JuniperSRX"/>
@@ -299,6 +302,9 @@
299302
<bean id="NiciraNvpGuestNetworkGuru" class="com.cloud.network.guru.NiciraNvpGuestNetworkGuru">
300303
<property name="name" value="NiciraNvpGuestNetworkGuru"/>
301304
</bean>
305+
<bean id="BigSwitchVnsGuestNetworkGuru" class="com.cloud.network.guru.BigSwitchVnsGuestNetworkGuru">
306+
<property name="name" value="BigSwitchVnsGuestNetworkGuru"/>
307+
</bean>
302308

303309
<!--
304310
Hypervisor Gurus

plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/DeleteBigSwitchVnsDeviceCmd.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.cloudstack.api.ServerApiException;
2727
import org.apache.cloudstack.api.response.SuccessResponse;
2828

29+
import com.cloud.api.response.BigSwitchVnsDeviceResponse;
2930
import com.cloud.exception.ConcurrentOperationException;
3031
import com.cloud.exception.InsufficientCapacityException;
3132
import com.cloud.exception.InvalidParameterValueException;
@@ -44,7 +45,8 @@ public class DeleteBigSwitchVnsDeviceCmd extends BaseAsyncCmd {
4445
//////////////// API parameters /////////////////////
4546
/////////////////////////////////////////////////////
4647

47-
@Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID, type=CommandType.LONG, required=true, description="BigSwitch device ID")
48+
@Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID, type=CommandType.UUID, entityType = BigSwitchVnsDeviceResponse.class,
49+
required=true, description="BigSwitch device ID")
4850
private Long bigswitchVnsDeviceId;
4951

5052
/////////////////////////////////////////////////////

plugins/network-elements/bigswitch-vns/src/com/cloud/api/commands/ListBigSwitchVnsDevicesCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ public class ListBigSwitchVnsDevicesCmd extends BaseListCmd {
5252
/////////////////////////////////////////////////////
5353

5454
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID,
55-
entityType = PhysicalNetworkResponse.class,
55+
entityType = PhysicalNetworkResponse.class,
5656
description="the Physical Network ID")
5757
private Long physicalNetworkId;
5858

59-
@Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID,
60-
type=CommandType.LONG,
61-
description="bigswitch vns device ID")
59+
@Parameter(name=VnsConstants.BIGSWITCH_VNS_DEVICE_ID, type=CommandType.UUID,
60+
entityType = BigSwitchVnsDeviceResponse.class,
61+
description="bigswitch vns device ID")
6262
private Long bigswitchVnsDeviceId;
6363

6464
/////////////////////////////////////////////////////

plugins/network-elements/bigswitch-vns/src/com/cloud/api/response/BigSwitchVnsDeviceResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public class BigSwitchVnsDeviceResponse extends BaseResponse {
4141
@SerializedName(ApiConstants.HOST_NAME) @Param(description="the controller Ip address")
4242
private String hostName;
4343

44+
public String getId() {
45+
return this.id;
46+
}
47+
4448
public void setId(String vnsDeviceId) {
4549
this.id = vnsDeviceId;
4650
}

plugins/network-elements/bigswitch-vns/src/com/cloud/network/BigSwitchVnsDeviceVO.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
import javax.persistence.Id;
2626
import javax.persistence.Table;
2727

28+
import org.apache.cloudstack.api.InternalIdentity;
29+
2830
@Entity
2931
@Table(name="external_bigswitch_vns_devices")
30-
public class BigSwitchVnsDeviceVO {
32+
public class BigSwitchVnsDeviceVO implements InternalIdentity {
3133

3234
@Id
3335
@GeneratedValue(strategy = GenerationType.IDENTITY)

plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/Attachment.java renamed to plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/AttachmentData.java

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,35 @@
1616
// under the License.
1717
package com.cloud.network.bigswitch;
1818

19-
public class Attachment {
20-
private String id;
21-
private String mac;
19+
public class AttachmentData {
20+
private Attachment attachment;
2221

23-
public String getId() {
24-
return id;
25-
}
22+
public Attachment getAttachment() {
23+
return attachment;
24+
}
2625

27-
public void setId(String id) {
28-
this.id = id;
29-
}
26+
public AttachmentData() {
27+
this.attachment = new Attachment();
28+
}
3029

31-
public String getMac() {
32-
return mac;
33-
}
30+
public class Attachment {
31+
private String id;
32+
private String mac;
3433

35-
public void setMac(String mac) {
36-
this.mac = mac;
37-
}
34+
public String getId() {
35+
return id;
36+
}
37+
38+
public void setId(String id) {
39+
this.id = id;
40+
}
41+
42+
public String getMac() {
43+
return mac;
44+
}
45+
46+
public void setMac(String mac) {
47+
this.mac = mac;
48+
}
49+
}
3850
}

plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/BigSwitchVnsApi.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public class BigSwitchVnsApi {
4949
private static final Logger s_logger = Logger.getLogger(BigSwitchVnsApi.class);
5050
private final static String _protocol = "http";
5151
private final static String _nsBaseUri = "/networkService/v1.1";
52-
private final static String _controllerBaseUri = "/wm/core";
5352
private final static String CONTENT_TYPE = "Content-Type";
53+
private final static String ACCEPT = "Accept";
5454
private final static String CONTENT_JSON = "application/json";
55-
private final static String HTTP_HEADER_INSTANCE_ID = "HTTP_INSTANCE_ID";
55+
private final static String HTTP_HEADER_INSTANCE_ID = "INSTANCE_ID";
5656
private final static String CLOUDSTACK_INSTANCE_ID = "org.apache.cloudstack";
5757
private final static MultiThreadedHttpConnectionManager s_httpClientManager =
5858
new MultiThreadedHttpConnectionManager();
@@ -114,55 +114,56 @@ protected void login() throws BigSwitchVnsApiException {
114114
return;
115115
}
116116

117-
public void createNetwork(Network network)
117+
public void createNetwork(NetworkData network)
118118
throws BigSwitchVnsApiException {
119-
String uri = _nsBaseUri + "/tenant/" + network.getTenant_id() + "/network";
120-
executeCreateObject(network, new TypeToken<Network>(){}.getType(),
119+
String uri = _nsBaseUri + "/tenants/" + network.getNetwork().getTenant_id() + "/networks";
120+
executeCreateObject(network, new TypeToken<NetworkData>(){}.getType(),
121121
uri, Collections.<String,String>emptyMap());
122122
}
123123

124124
public void deleteNetwork(String tenantId, String networkId) throws BigSwitchVnsApiException {
125-
String uri = _nsBaseUri + "/tenant/" + tenantId + "/networks/" + networkId;
125+
String uri = _nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId;
126126
executeDeleteObject(uri);
127127
}
128128

129-
public void createPort(String networkUuid, Port port)
129+
public void createPort(String networkUuid, PortData port)
130130
throws BigSwitchVnsApiException {
131-
String uri = _nsBaseUri + "/tenant/" + port.getTenant_id() + "/networks/" + networkUuid + "/ports";
132-
executeCreateObject(port, new TypeToken<Port>(){}.getType(),
131+
String uri = _nsBaseUri + "/tenants/" + port.getPort().getTenant_id() + "/networks/" + networkUuid + "/ports";
132+
executeCreateObject(port, new TypeToken<PortData>(){}.getType(),
133133
uri, Collections.<String,String>emptyMap());
134134
}
135135

136-
public void modifyPort(String networkId, Port port)
136+
public void modifyPort(String networkId, PortData port)
137137
throws BigSwitchVnsApiException {
138-
String uri = _nsBaseUri + "/tenant/" + port.getTenant_id() + "/networks/" + networkId + "/ports";
138+
String uri = _nsBaseUri + "/tenants/" + port.getPort().getTenant_id() + "/networks/" + networkId + "/ports";
139139
executeUpdateObject(port, uri, Collections.<String,String>emptyMap());
140140
}
141141

142142
public void deletePort(String tenantId, String networkId, String portId)
143143
throws BigSwitchVnsApiException {
144-
String uri = _nsBaseUri + "/tenant/" + tenantId + "/networks/" + networkId + "/ports/" + portId;
144+
String uri = _nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + portId;
145145
executeDeleteObject(uri);
146146
}
147147

148148
public void modifyPortAttachment(String tenantId,
149149
String networkId,
150150
String portId,
151-
Attachment attachment) throws BigSwitchVnsApiException {
152-
String uri = _nsBaseUri + "/tenant/" + tenantId + "/networks/" + networkId + "/ports/" + portId + "/attachment";
151+
AttachmentData attachment) throws BigSwitchVnsApiException {
152+
String uri = _nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + portId + "/attachment";
153153
executeUpdateObject(attachment, uri, Collections.<String,String>emptyMap());
154154
}
155155

156156
public void deletePortAttachment(String tenantId, String networkId, String portId)
157157
throws BigSwitchVnsApiException {
158-
String uri = _nsBaseUri + "/tenant/" + tenantId + "/networks/" + networkId + "/ports/" + portId + "/attachment";
158+
String uri = _nsBaseUri + "/tenants/" + tenantId + "/networks/" + networkId + "/ports/" + portId + "/attachment";
159159
executeDeleteObject(uri);
160160
}
161161

162162
public ControlClusterStatus getControlClusterStatus() throws BigSwitchVnsApiException {
163-
String uri = _controllerBaseUri + "/health/json";
163+
String uri = _nsBaseUri + "/health";
164164
ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>(){}.getType(),
165165
uri, 80, null);
166+
ccs.setStatus(true);
166167

167168
return ccs;
168169
}
@@ -177,6 +178,7 @@ protected <T> void executeUpdateObject(T newObject, String uri, Map<String,Strin
177178

178179
PutMethod pm = (PutMethod) createMethod("put", uri, 80);
179180
pm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
181+
pm.setRequestHeader(ACCEPT, CONTENT_JSON);
180182
pm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
181183
try {
182184
pm.setRequestEntity(new StringRequestEntity(
@@ -207,6 +209,7 @@ protected <T> void executeCreateObject(T newObject, Type returnObjectType, Strin
207209

208210
PostMethod pm = (PostMethod) createMethod("post", uri, 80);
209211
pm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
212+
pm.setRequestHeader(ACCEPT, CONTENT_JSON);
210213
pm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
211214
try {
212215
pm.setRequestEntity(new StringRequestEntity(
@@ -235,6 +238,7 @@ protected void executeDeleteObject(String uri) throws BigSwitchVnsApiException {
235238

236239
DeleteMethod dm = (DeleteMethod) createMethod("delete", uri, 80);
237240
dm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
241+
dm.setRequestHeader(ACCEPT, CONTENT_JSON);
238242
dm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
239243

240244
executeMethod(dm);
@@ -257,6 +261,7 @@ protected <T> T executeRetrieveObject(Type returnObjectType, String uri, int por
257261

258262
GetMethod gm = (GetMethod) createMethod("get", uri, port);
259263
gm.setRequestHeader(CONTENT_TYPE, CONTENT_JSON);
264+
gm.setRequestHeader(ACCEPT, CONTENT_JSON);
260265
gm.setRequestHeader(HTTP_HEADER_INSTANCE_ID, CLOUDSTACK_INSTANCE_ID);
261266

262267
if (parameters != null && !parameters.isEmpty()) {
@@ -327,4 +332,4 @@ private String responseToErrorMessage(HttpMethodBase method) {
327332
return method.getStatusText();
328333
}
329334

330-
}
335+
}

plugins/network-elements/bigswitch-vns/src/com/cloud/network/bigswitch/ControlClusterStatus.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ public class ControlClusterStatus {
2222
public boolean getStatus() {
2323
return healthy;
2424
}
25+
26+
public void setStatus(boolean status) {
27+
this.healthy = status;
28+
}
2529
}

0 commit comments

Comments
 (0)