Fix to support vlan interface setup in OpenstackNodeWebResource class
Change-Id: I1e6ed8021fc4ec7e62507355495895953c75a7bd
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
index cce5134..f4c5f5c 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
@@ -53,6 +53,21 @@
private static final String MESSAGE_NODE = "Received node %s request";
private static final String NODES = "nodes";
+ private static final String CREATE = "CREATE";
+ private static final String UPDATE = "UPDATE";
+ private static final String NODE_ID = "NODE_ID";
+ private static final String DELETE = "DELETE";
+
+ private static final String HOST_NAME = "hostname";
+ private static final String TYPE = "type";
+ private static final String MANAGEMENT_IP = "managementIp";
+ private static final String DATA_IP = "dataIp";
+ private static final String INTEGRATION_BRIDGE = "integrationBridge";
+ private static final String VLAN_INTF_NAME = "vlanPort";
+
+ // GATEWAY node specific fields
+ private static final String ROUTER_BRIDGE = "routerBridge";
+
private final OpenstackNodeAdminService osNodeAdminService =
DefaultServiceDirectory.getService(OpenstackNodeAdminService.class);
@@ -66,7 +81,7 @@
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createNodes(InputStream input) {
- log.trace(String.format(MESSAGE_NODE, "CREATE"));
+ log.trace(String.format(MESSAGE_NODE, CREATE));
readNodeConfiguration(input).forEach(osNode -> {
OpenstackNode existing = osNodeService.node(osNode.hostname());
@@ -77,7 +92,7 @@
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
.path(NODES)
- .path("NODE_ID");
+ .path(NODE_ID);
return created(locationBuilder.build()).build();
}
@@ -86,7 +101,7 @@
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateNodes(InputStream input) {
- log.trace(String.format(MESSAGE_NODE, "UPDATE"));
+ log.trace(String.format(MESSAGE_NODE, UPDATE));
Set<OpenstackNode> nodes = readNodeConfiguration(input);
for (OpenstackNode osNode: nodes) {
@@ -106,7 +121,7 @@
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteNodes(InputStream input) {
- log.trace(String.format(MESSAGE_NODE, "DELETE"));
+ log.trace(String.format(MESSAGE_NODE, DELETE));
Set<OpenstackNode> nodes = readNodeConfiguration(input);
for (OpenstackNode osNode: nodes) {
@@ -126,28 +141,34 @@
Set<OpenstackNode> nodeSet = Sets.newHashSet();
try {
JsonNode jsonTree = mapper().enable(INDENT_OUTPUT).readTree(input);
- ArrayNode nodes = (ArrayNode) jsonTree.path("nodes");
+ ArrayNode nodes = (ArrayNode) jsonTree.path(NODES);
nodes.forEach(node -> {
try {
- String hostname = node.get("hostname").asText();
- String type = node.get("type").asText();
- String mIp = node.get("managementIp").asText();
- String dIp = node.get("dataIp").asText();
- String iBridge = node.get("integrationBridge").asText();
+ String hostname = node.get(HOST_NAME).asText();
+ String type = node.get(TYPE).asText();
+ String mIp = node.get(MANAGEMENT_IP).asText();
+ String iBridge = node.get(INTEGRATION_BRIDGE).asText();
String rBridge = null;
- if (node.get("routerBridge") != null) {
- rBridge = node.get("routerBridge").asText();
+ if (node.get(ROUTER_BRIDGE) != null) {
+ rBridge = node.get(ROUTER_BRIDGE).asText();
}
DefaultOpenstackNode.Builder nodeBuilder = DefaultOpenstackNode.builder()
.hostname(hostname)
.type(OpenstackNode.NodeType.valueOf(type))
.managementIp(IpAddress.valueOf(mIp))
- .dataIp(IpAddress.valueOf(dIp))
.intgBridge(DeviceId.deviceId(iBridge))
.state(NodeState.INIT);
+
+ if (node.get(VLAN_INTF_NAME) != null) {
+ nodeBuilder.vlanIntf(node.get(VLAN_INTF_NAME).asText());
+ }
+ if (node.get(DATA_IP) != null) {
+ nodeBuilder.dataIp(IpAddress.valueOf(node.get(DATA_IP).asText()));
+ }
if (rBridge != null) {
nodeBuilder.routerBridge(DeviceId.deviceId(rBridge));
}
+
log.trace("node is {}", nodeBuilder.build().toString());
nodeSet.add(nodeBuilder.build());
} catch (Exception e) {