summaryrefslogtreecommitdiffstats
path: root/pomba/network-discovery-api
diff options
context:
space:
mode:
authorBrad Benesch <brad.benesch@amdocs.com>2018-07-12 14:26:26 -0400
committerBrad Benesch <brad.benesch@amdocs.com>2018-07-23 15:02:36 -0400
commit92c73de0f57aee2ada5f5c85b960c4c8ce7adf85 (patch)
tree66038237e070b13a82b1ceb7e7b0d98ba15fe576 /pomba/network-discovery-api
parent17ac3b089df1cc33ced623ab4150edcacd4381c6 (diff)
Initial code for network discovery microservice
Issue-ID: SDNC-317 Change-Id: I09d44de02283079471de0084da07793cb3d7820c Signed-off-by: Brad Benesch <brad.benesch@amdocs.com>
Diffstat (limited to 'pomba/network-discovery-api')
-rw-r--r--pomba/network-discovery-api/pom.xml51
-rw-r--r--pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/Attribute.java53
-rw-r--r--pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/DataQuality.java65
-rw-r--r--pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/NetworkDiscoveryNotification.java41
-rw-r--r--pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/NetworkDiscoveryResponse.java74
-rw-r--r--pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/Resource.java74
-rw-r--r--pomba/network-discovery-api/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/test/PojoTest.java82
-rw-r--r--pomba/network-discovery-api/src/test/resources/notification.json87
-rw-r--r--pomba/network-discovery-api/version.properties13
9 files changed, 540 insertions, 0 deletions
diff --git a/pomba/network-discovery-api/pom.xml b/pomba/network-discovery-api/pom.xml
new file mode 100644
index 0000000..a24dcd6
--- /dev/null
+++ b/pomba/network-discovery-api/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+============LICENSE_START===================================================
+Copyright (c) 2018 Amdocs
+============================================================================
+Licensed 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.
+============LICENSE_END=====================================================
+-->
+<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>
+
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>1.1.1</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.onap.sdnc.apps.pomba</groupId>
+ <artifactId>network-discovery-api</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ <name>Network Discovery API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.9.6</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project> \ No newline at end of file
diff --git a/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/Attribute.java b/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/Attribute.java
new file mode 100644
index 0000000..131b708
--- /dev/null
+++ b/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/Attribute.java
@@ -0,0 +1,53 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * Licensed 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.sdnc.apps.pomba.networkdiscovery.datamodel;
+
+public class Attribute {
+ private String name;
+ private String value;
+ private DataQuality dataQuality;
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public DataQuality getDataQuality() {
+ return this.dataQuality;
+ }
+
+ public void setDataQuality(DataQuality dataQuality) {
+ this.dataQuality = dataQuality;
+ }
+
+ @Override
+ public String toString() {
+ return "Attribute [name=" + this.name + ", value=" + this.value + ", dataQuality=" + this.dataQuality + "]";
+ }
+}
diff --git a/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/DataQuality.java b/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/DataQuality.java
new file mode 100644
index 0000000..3e7836a
--- /dev/null
+++ b/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/DataQuality.java
@@ -0,0 +1,65 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * Licensed 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.sdnc.apps.pomba.networkdiscovery.datamodel;
+
+public class DataQuality {
+ public static enum Status {
+ ok, error
+ }
+
+ private Status status;
+ private String errorText;
+
+
+ public Status getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ public String getErrorText() {
+ return this.errorText;
+ }
+
+ public void setErrorText(String errorText) {
+ this.errorText = errorText;
+ }
+
+
+ public static DataQuality ok() {
+ // as a non-mutable class, it is not safe to define a constant for this
+ DataQuality result = new DataQuality();
+ result.setStatus(Status.ok);
+ return result;
+ }
+
+ public static DataQuality error(String text) {
+ // as a non-mutable class, it is not safe to define a constant for this
+ DataQuality result = new DataQuality();
+ result.setStatus(Status.error);
+ result.setErrorText(text);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "DataQuality [status=" + this.status + ", errorText=" + this.errorText + "]";
+ }
+}
diff --git a/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/NetworkDiscoveryNotification.java b/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/NetworkDiscoveryNotification.java
new file mode 100644
index 0000000..0508628
--- /dev/null
+++ b/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/NetworkDiscoveryNotification.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * Licensed 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.sdnc.apps.pomba.networkdiscovery.datamodel;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class NetworkDiscoveryNotification extends NetworkDiscoveryResponse {
+ private List<Resource> resources;
+
+ public List<Resource> getResources() {
+ return this.resources;
+ }
+
+ public void setResources(List<Resource> resources) {
+ this.resources = resources;
+ }
+
+ @Override
+ public String toString() {
+ return "NetworkDiscoveryResponse [requestId=" + getRequestId() + ", code=" + getCode() + ", message="
+ + getMessage() + ", ackFinalIndicator=" + getAckFinalIndicator() + ", resources=" + this.resources
+ + "]";
+ }
+}
diff --git a/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/NetworkDiscoveryResponse.java b/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/NetworkDiscoveryResponse.java
new file mode 100644
index 0000000..136688a
--- /dev/null
+++ b/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/NetworkDiscoveryResponse.java
@@ -0,0 +1,74 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * Licensed 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.sdnc.apps.pomba.networkdiscovery.datamodel;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class NetworkDiscoveryResponse {
+ /** The originating request identifier */
+ private String requestId;
+ /** Result code - 200 indicates success */
+ private Integer code;
+ private String message;
+
+ /**
+ * @return false if further asynchronous notifications will follow.
+ */
+ private Boolean ackFinalIndicator;
+
+ public String getRequestId() {
+ return this.requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public Integer getCode() {
+ return this.code;
+ }
+
+ public void setCode(Integer responseCode) {
+ this.code = responseCode;
+ }
+
+ public String getMessage() {
+ return this.message;
+ }
+
+ public void setMessage(String responseMessage) {
+ this.message = responseMessage;
+ }
+
+ public Boolean getAckFinalIndicator() {
+ return this.ackFinalIndicator;
+ }
+
+ public void setAckFinalIndicator(Boolean ackFinalIndicator) {
+ this.ackFinalIndicator = ackFinalIndicator;
+ }
+
+ @Override
+ public String toString() {
+ return "NetworkDiscoveryResponse [requestId=" + this.requestId + ", code=" + this.code + ", message="
+ + this.message + ", ackFinalIndicator=" + this.ackFinalIndicator
+ + "]";
+ }
+}
diff --git a/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/Resource.java b/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/Resource.java
new file mode 100644
index 0000000..a98d457
--- /dev/null
+++ b/pomba/network-discovery-api/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/Resource.java
@@ -0,0 +1,74 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * Licensed 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.sdnc.apps.pomba.networkdiscovery.datamodel;
+
+import java.util.List;
+
+public class Resource {
+ private String id;
+ private String name;
+ private String type;
+ private DataQuality dataQuality;
+ private List<Attribute> attributeList;
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public List<Attribute> getAttributeList() {
+ return this.attributeList;
+ }
+
+ public void setAttributeList(List<Attribute> attributeList) {
+ this.attributeList = attributeList;
+ }
+
+ public DataQuality getDataQuality() {
+ return this.dataQuality;
+ }
+
+ public void setDataQuality(DataQuality dataQuality) {
+ this.dataQuality = dataQuality;
+ }
+
+ @Override
+ public String toString() {
+ return "Resource [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", dataQuality="
+ + this.dataQuality + ", attributeList=" + this.attributeList + "]";
+ }
+}
diff --git a/pomba/network-discovery-api/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/test/PojoTest.java b/pomba/network-discovery-api/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/test/PojoTest.java
new file mode 100644
index 0000000..0aa0809
--- /dev/null
+++ b/pomba/network-discovery-api/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/datamodel/test/PojoTest.java
@@ -0,0 +1,82 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * Licensed 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.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Attribute;
+import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.DataQuality;
+import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.NetworkDiscoveryNotification;
+import org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Resource;
+
+public class PojoTest {
+
+ @Test
+ public void fromJson() throws Exception {
+ ObjectMapper objectMapper = new ObjectMapper();
+ NetworkDiscoveryNotification notification = objectMapper.readValue(
+ ClassLoader.getSystemResourceAsStream("notification.json"),
+ NetworkDiscoveryNotification.class);
+
+ System.out.println(notification);
+
+ assertEquals("1", notification.getRequestId());
+ assertEquals(200, notification.getCode().intValue());
+ assertEquals(true, notification.getAckFinalIndicator());
+ assertEquals(1, notification.getResources().size());
+ Resource vserver = notification.getResources().get(0);
+ assertEquals("25fb07ab-0478-465e-a021-6384ac299671", vserver.getId());
+ assertEquals("vserver", vserver.getType());
+ assertEquals(DataQuality.Status.ok, vserver.getDataQuality().getStatus());
+ assertNull(vserver.getDataQuality().getErrorText());
+
+ Map<String, String> expectedValues = new HashMap<>();
+ expectedValues.put("vserver-id", "25fb07ab-0478-465e-a021-6384ac299671");
+ expectedValues.put("power-state", "1");
+ expectedValues.put("vm-state", "active");
+ expectedValues.put("status", "ACTIVE");
+ expectedValues.put("host-status", "UNKNOWN");
+ expectedValues.put("updated", "2017-11-20T04:26:13Z");
+ expectedValues.put("disk-allocation-gb", ".010");
+ expectedValues.put("memory-usage-mb", "null");
+ expectedValues.put("cpu-util-percent", ".043");
+ expectedValues.put("retrieval-timestamp", "2018-06-25 18:02:55 +0000");
+
+ for (Attribute attribute : vserver.getAttributeList()) {
+ assertEquals(expectedValues.remove(attribute.getName()), attribute.getValue());
+ assertEquals(DataQuality.Status.ok, attribute.getDataQuality().getStatus());
+ }
+ assertEquals(0, expectedValues.size());
+ }
+
+ @Test
+ public void dataQualityHelpers() {
+ DataQuality value = DataQuality.ok();
+ assertEquals(DataQuality.Status.ok, value.getStatus());
+ assertNull(value.getErrorText());
+
+ value = DataQuality.error("test");
+ assertEquals(DataQuality.Status.error, value.getStatus());
+ assertEquals("test", value.getErrorText());
+ }
+}
diff --git a/pomba/network-discovery-api/src/test/resources/notification.json b/pomba/network-discovery-api/src/test/resources/notification.json
new file mode 100644
index 0000000..6a3bd4b
--- /dev/null
+++ b/pomba/network-discovery-api/src/test/resources/notification.json
@@ -0,0 +1,87 @@
+{
+ "requestId": "1",
+ "code": 200,
+ "message": "OK",
+ "ackFinalIndicator": true,
+ "resources": [
+ {
+ "id": "25fb07ab-0478-465e-a021-6384ac299671",
+ "type": "vserver",
+ "dataQuality": {
+ "status": "ok"
+ },
+ "attributeList": [
+ {
+ "name": "vserver-id",
+ "value": "25fb07ab-0478-465e-a021-6384ac299671",
+ "dataQuality": {
+ "status": "ok"
+ }
+ },
+ {
+ "name": "power-state",
+ "value": "1",
+ "dataQuality": {
+ "status": "ok"
+ }
+ },
+ {
+ "name": "vm-state",
+ "value": "active",
+ "dataQuality": {
+ "status": "ok"
+ }
+ },
+ {
+ "name": "status",
+ "value": "ACTIVE",
+ "dataQuality": {
+ "status": "ok"
+ }
+ },
+ {
+ "name": "host-status",
+ "value": "UNKNOWN",
+ "dataQuality": {
+ "status": "ok"
+ }
+ },
+ {
+ "name": "updated",
+ "value": "2017-11-20T04:26:13Z",
+ "dataQuality": {
+ "status": "ok"
+ }
+ },
+ {
+ "name": "disk-allocation-gb",
+ "value": ".010",
+ "dataQuality": {
+ "status": "ok"
+ }
+ },
+ {
+ "name": "memory-usage-mb",
+ "value": "null",
+ "dataQuality": {
+ "status": "ok"
+ }
+ },
+ {
+ "name": "cpu-util-percent",
+ "value": ".043",
+ "dataQuality": {
+ "status": "ok"
+ }
+ },
+ {
+ "name": "retrieval-timestamp",
+ "value": "2018-06-25 18:02:55 +0000",
+ "dataQuality": {
+ "status": "ok"
+ }
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/pomba/network-discovery-api/version.properties b/pomba/network-discovery-api/version.properties
new file mode 100644
index 0000000..a254b21
--- /dev/null
+++ b/pomba/network-discovery-api/version.properties
@@ -0,0 +1,13 @@
+# Versioning variables
+# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )
+# because they are used in Jenkins, whose plug-in doesn't support
+
+major=1
+minor=3
+patch=0
+
+base_version=${major}.${minor}.${patch}
+
+# Release must be completed with git revision # in Jenkins
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT