diff options
author | Norm Traxler <normant@amdocs.com> | 2019-02-11 17:00:46 +0000 |
---|---|---|
committer | Norm Traxler <normant@amdocs.com> | 2019-02-11 17:01:03 +0000 |
commit | d8850d592f42d16a7d3d8d0c4ae1c64badf0b439 (patch) | |
tree | 8cbf50caeda36a39becef612fc3ed02809b777c5 /pomba | |
parent | c727082e6809f7a3076809dceb218e80ce4456bf (diff) |
Add support for Openstack Port object
Issue-ID: SDNC-475
Change-Id: Id17404ed05b2ca251e46dc739657900953f76cc4
Signed-off-by: Norm Traxler <normant@amdocs.com>
Diffstat (limited to 'pomba')
7 files changed, 114 insertions, 3 deletions
diff --git a/pomba/network-discovery/config/application.properties b/pomba/network-discovery/config/application.properties index b7d41b7..9e822bf 100644 --- a/pomba/network-discovery/config/application.properties +++ b/pomba/network-discovery/config/application.properties @@ -19,9 +19,10 @@ openstack.identity.url = http://10.69.100.11:5000/v3/auth/tokens openstack.identity.user = jbalasub openstack.identity.password = OBF:1thj1vn01v1p1toq1to41v2p1vo21th3 -openstack.types = vserver, l3-network +openstack.types = vserver, l3-network, port openstack.type.vserver.url = http://10.69.100.11:8774/v2.1/servers/{0} openstack.type.l3-network.url = http://10.69.100.11:9696/v2.0/networks/{0} +openstack.type.port.url = http://10.69.100.11:9696/v2.0/ports/{0} openstack.api.microversion = 2.42 diff --git a/pomba/network-discovery/config/jolt/l3-network.json b/pomba/network-discovery/config/jolt/l3-network.json index 77fa4aa..bf4f637 100644 --- a/pomba/network-discovery/config/jolt/l3-network.json +++ b/pomba/network-discovery/config/jolt/l3-network.json @@ -5,7 +5,7 @@ "network": { "id": "id", "name": "name", - "admin_state_up": "tempList[].adminState", + "admin_state_up": "tempList[].adminStateUp", "shared": "tempList[].sharedNetwork", "status": "tempList[].status", "subnets" : { diff --git a/pomba/network-discovery/config/jolt/port.json b/pomba/network-discovery/config/jolt/port.json new file mode 100644 index 0000000..99597b5 --- /dev/null +++ b/pomba/network-discovery/config/jolt/port.json @@ -0,0 +1,33 @@ +[ + { + "operation": "shift", + "spec": { + "port": { + "id": "id", + "name": "name", + "admin_state_up": "tempList[].adminStateUp", + "mac_address" : "tempList[].macAddress" + } + } + }, + { + "operation": "shift", + "spec": { + "tempList": { + "*": { + "*" : { + "$": "attributeList[#3].name", + "@": "attributeList[#3].value" + }, + "#ok": "attributeList[#2].dataQuality.status" + } + }, + "*": { + "@" : "&" + }, + "#port": "type", + "#ok": "dataQuality.status" + } + } + +]
\ No newline at end of file diff --git a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/util/TransformationUtilTest.java b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/util/TransformationUtilTest.java index f43fa60..cd076c0 100644 --- a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/util/TransformationUtilTest.java +++ b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/util/TransformationUtilTest.java @@ -72,6 +72,24 @@ public class TransformationUtilTest { JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(resourceInstJson)));
}
+
+ @Test
+ public void testTransformPort() {
+
+ Object sourceObject = JsonUtils.filepathToObject(TEST_RESOURCES + "port-input.json");
+ String resultJson = TransformationUtil.transform(JsonUtils.toJsonString(sourceObject), "port");
+
+ Gson gson = new Gson();
+ Resource resourceInst = gson.fromJson(resultJson, Resource.class);
+ String resourceInstJson = gson.toJson(resourceInst);
+
+ Object expectedObject = JsonUtils.filepathToObject(TEST_RESOURCES + "port-expected.json");
+
+ Assert.assertEquals("Json transformation result does not match expected content",
+ JsonUtils.toPrettyJsonString(expectedObject),
+ JsonUtils.toPrettyJsonString(JsonUtils.jsonToObject(resourceInstJson)));
+
+ }
@Test
public void testTransformFailureFileNotFound() {
diff --git a/pomba/network-discovery/src/test/resources/jolt/l3network-expected.json b/pomba/network-discovery/src/test/resources/jolt/l3network-expected.json index e9e37dd..2cf8f90 100644 --- a/pomba/network-discovery/src/test/resources/jolt/l3network-expected.json +++ b/pomba/network-discovery/src/test/resources/jolt/l3network-expected.json @@ -6,7 +6,7 @@ "status" : "ok"
},
"attributeList" : [ {
- "name" : "adminState",
+ "name" : "adminStateUp",
"value" : "true",
"dataQuality" : {
"status" : "ok"
diff --git a/pomba/network-discovery/src/test/resources/jolt/port-expected.json b/pomba/network-discovery/src/test/resources/jolt/port-expected.json new file mode 100644 index 0000000..33f6dc1 --- /dev/null +++ b/pomba/network-discovery/src/test/resources/jolt/port-expected.json @@ -0,0 +1,21 @@ +{
+ "id" : "bcd87883-c92f-4f2b-b5bf-1288948facdd",
+ "name" : "bcd8",
+ "type" : "port",
+ "dataQuality" : {
+ "status" : "ok"
+ },
+ "attributeList" : [ {
+ "name" : "adminStateUp",
+ "value" : "true",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ }, {
+ "name" : "macAddress",
+ "value" : "fa:16:3e:ff:f7:af",
+ "dataQuality" : {
+ "status" : "ok"
+ }
+ } ]
+}
\ No newline at end of file diff --git a/pomba/network-discovery/src/test/resources/jolt/port-input.json b/pomba/network-discovery/src/test/resources/jolt/port-input.json new file mode 100644 index 0000000..7e3e59b --- /dev/null +++ b/pomba/network-discovery/src/test/resources/jolt/port-input.json @@ -0,0 +1,38 @@ +{ + "port": { + "status": "ACTIVE", + "binding:host_id": "Setup-D2-OTT-A-Master", + "description": "", + "allowed_address_pairs": [], + "tags": [], + "extra_dhcp_opts": [], + "updated_at": "2019-02-07T21:11:17Z", + "device_owner": "compute:nova", + "revision_number": 9, + "binding:profile": {}, + "fixed_ips": [ + { + "subnet_id": "b3684cd7-43ee-4aa3-9266-8c66f87d10a3", + "ip_address": "10.69.102.6" + } + ], + "id": "bcd87883-c92f-4f2b-b5bf-1288948facdd", + "security_groups": [ + "6e0243dc-5040-491a-b54e-55b88cd01855" + ], + "device_id": "645a12dc-09b5-45cb-8ab1-a0ce41b7200a", + "name": "bcd8", + "admin_state_up": true, + "network_id": "2ea02809-7279-4b5e-931a-62b231615497", + "tenant_id": "1130b349e19c4827bf91a29d51256af1", + "binding:vif_details": { + "port_filter": true, + "ovs_hybrid_plug": true + }, + "binding:vnic_type": "normal", + "binding:vif_type": "ovs", + "mac_address": "fa:16:3e:ff:f7:af", + "project_id": "1130b349e19c4827bf91a29d51256af1", + "created_at": "2018-12-04T20:40:58Z" + } +}
\ No newline at end of file |