Merge "Added required docker file to deploy as container"
authorDan Timoney <dtimoney@att.com>
Tue, 9 Apr 2019 17:09:05 +0000 (17:09 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 9 Apr 2019 17:09:05 +0000 (17:09 +0000)
cds-ui/client/angular.json
cds-ui/client/src/app/common/shared/components/search-dialog/search-dialog.html
cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html
cds-ui/server/src/controllers/blueprint-rest.controller.ts
ms/blueprintsprocessor/application/src/main/resources/application-dev.properties
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfSessionListener.kt
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicator.kt
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt [new file with mode: 0644]

index 96b4df0..c5800f0 100644 (file)
@@ -30,7 +30,8 @@
                             "src/styles.scss",
                             "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
                             "./node_modules/material-design-icons/iconfont/material-icons.css",
-                            "./node_modules/font-awesome/css/font-awesome.css"
+                            "./node_modules/font-awesome/css/font-awesome.css",                            
+                            "./node_modules/bootstrap/dist/css/bootstrap.min.css"
                         ],
                         "scripts": [
                             "./node_modules/ace-builds/src-min/ace.js",
index c6c41bf..9d2141c 100644 (file)
@@ -1,7 +1,7 @@
 <!--
 ============LICENSE_START==========================================
 ===================================================================
-Copyright (C) 2018 IBM Intellectual Property. All rights reserved.
+Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved.
 ===================================================================
 
 Unless otherwise specified, all software contained herein is licensed
index ea4c298..5a3973a 100644 (file)
@@ -17,7 +17,6 @@ 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============================================ -->
-
 <div class="containerDiv">
     <div class="fileViewContainer">
         <!-- <div style="width:inherit; height: inherit; position: fixed;z-index: 1; background-color: rgb(0,0,0);background-color: rgba(0,0,0,0.4);"></div> -->
@@ -46,7 +45,7 @@ limitations under the License.
             </mat-tree-node>
         </mat-tree>
     </div>
-    <div class="editorConatiner">
+    <div class="editorConatiner" [ngClass] = "{ 'apply-scrol-to-editor-container' : viewTemplateMode}">
         <!-- <i class="fa fa-save save-icon" style="font-size:24px" (click)="updateBlueprint()"></i>
         <ace-editor [(text)]="text" [(mode)]="mode" #editor class="aceEditor"></ace-editor> -->
         <div class="normal-editor-mode" [ngClass]="{ 'resource-mapping-mode': viewTemplateMode}">
index c630ce0..c1f7f96 100644 (file)
@@ -135,14 +135,15 @@ export class BlueprintRestController {
     });
   }
 
-  @get('/download-blueprint/{id}')
+  @get('/download-blueprint/{name}/{version}')
   async download(
-    @param.path.string('id') id: string,
-    @inject(RestBindings.Http.REQUEST) request: Request,
+    @param.path.string('name') name: string,
+    @param.path.string('version') version:string,
+    // @inject(RestBindings.Http.REQUEST) request: Request,
     @inject(RestBindings.Http.RESPONSE) response: Response,
   ): Promise<any> {
     return new Promise((resolve, reject) => { 
-      this.downloadFileFromBlueprintController("/blueprint-model/download/" + id).then(resp=>{
+      this.downloadFileFromBlueprintController("/blueprint-model/download/by-name/"+name+"/version/"+version).then(resp=>{
         response.setHeader("X-ONAP-RequestID", resp.headers['x-onap-requestid']);
         response.setHeader("Content-Disposition", resp.headers['content-disposition']);
         resolve(resp.body);
index fc148bf..0e2cdf9 100755 (executable)
 #logging.level.web=DEBUG\r
 \r
 # Web server config\r
-server.port=8080\r
+server.port=8081\r
 \r
 blueprintsprocessor.grpcEnable=false\r
-blueprintsprocessor.httpPort=8080\r
+blueprintsprocessor.httpPort=8081\r
 blueprintsprocessor.grpcPort=9111\r
 \r
 # Blueprint Processor File Execution and Handling Properties\r
index 4199998..12e3b83 100644 (file)
@@ -57,11 +57,7 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
                 val cInt = bufferReader.read()
                 if (cInt == -1) {
                     log.error("$deviceInfo: Received cInt = -1")
-//                    bufferReader.close()
                     socketClosed = true
-//                    sessionListener.notify(NetconfReceivedEvent(
-//                        NetconfReceivedEvent.Type.SESSION_CLOSED,
-//                        deviceInfo = deviceInfo))
                 }
                 val c = cInt.toChar()
                 state = state.evaluateChar(c)
@@ -71,7 +67,7 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
                     if (deviceReply == RpcMessageUtils.END_PATTERN) {
                         socketClosed = true
                         bufferReader.close()
-                        sessionListener.notify(NetconfReceivedEvent(
+                        sessionListener.accept(NetconfReceivedEvent(
                             NetconfReceivedEvent.Type.DEVICE_UNREGISTERED,
                             deviceInfo = deviceInfo))
                     } else {
@@ -84,7 +80,7 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
                     if (!NetconfMessageUtils.validateChunkedFraming(deviceReply)) {
                         log.debug("$deviceInfo: Received badly framed message $deviceReply")
                         socketClosed = true
-                        sessionListener.notify(NetconfReceivedEvent(
+                        sessionListener.accept(NetconfReceivedEvent(
                             NetconfReceivedEvent.Type.DEVICE_ERROR,
                             deviceInfo = deviceInfo))
                     } else {
@@ -98,98 +94,89 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
 
         } catch (e: IOException) {
             log.warn("$deviceInfo: Fail while reading from channel", e)
-            sessionListener.notify(NetconfReceivedEvent(
+            sessionListener.accept(NetconfReceivedEvent(
                 NetconfReceivedEvent.Type.DEVICE_ERROR,
                 deviceInfo = deviceInfo))
         }
 
     }
 
-    private enum class NetconfMessageState {
+    /**
+     * State machine for the Netconf message parser
+     */
+    internal enum class NetconfMessageState {
         NO_MATCHING_PATTERN {
             override fun evaluateChar(c: Char): NetconfMessageState {
-                return if (c == ']') {
-                    FIRST_BRACKET
-                } else if (c == '\n') {
-                    FIRST_LF
-                } else {
-                    this
+                return when (c) {
+                    ']' -> FIRST_BRACKET
+                    '\n' -> FIRST_LF
+                    else -> this
                 }
             }
         },
         FIRST_BRACKET {
             override fun evaluateChar(c: Char): NetconfMessageState {
-                return if (c == ']') {
-                    SECOND_BRACKET
-                } else {
-                    NO_MATCHING_PATTERN
+                return when (c) {
+                    ']' -> SECOND_BRACKET
+                    else -> NO_MATCHING_PATTERN
                 }
             }
         },
         SECOND_BRACKET {
             override fun evaluateChar(c: Char): NetconfMessageState {
-                return if (c == '>') {
-                    FIRST_BIGGER
-                } else {
-                    NO_MATCHING_PATTERN
+                return when (c) {
+                    '>' -> FIRST_BIGGER
+                    else -> NO_MATCHING_PATTERN
                 }
             }
         },
         FIRST_BIGGER {
             override fun evaluateChar(c: Char): NetconfMessageState {
-                return if (c == ']') {
-                    THIRD_BRACKET
-                } else {
-                    NO_MATCHING_PATTERN
+                return when (c) {
+                    ']' -> THIRD_BRACKET
+                    else -> NO_MATCHING_PATTERN
                 }
             }
         },
         THIRD_BRACKET {
             override fun evaluateChar(c: Char): NetconfMessageState {
-                return if (c == ']') {
-                    ENDING_BIGGER
-                } else {
-                    NO_MATCHING_PATTERN
+                return when (c) {
+                    ']' -> ENDING_BIGGER
+                    else -> NO_MATCHING_PATTERN
                 }
             }
         },
         ENDING_BIGGER {
             override fun evaluateChar(c: Char): NetconfMessageState {
-                return if (c == '>') {
-                    END_PATTERN
-                } else {
-                    NO_MATCHING_PATTERN
+                return when (c) {
+                    '>' -> END_PATTERN
+                    else -> NO_MATCHING_PATTERN
                 }
             }
         },
         FIRST_LF {
             override fun evaluateChar(c: Char): NetconfMessageState {
-                return if (c == '#') {
-                    FIRST_HASH
-                } else if (c == ']') {
-                    FIRST_BRACKET
-                } else if (c == '\n') {
-                    this
-                } else {
-                    NO_MATCHING_PATTERN
+                return when (c) {
+                    '#' -> FIRST_HASH
+                    ']' -> FIRST_BRACKET
+                    '\n' -> this
+                    else -> NO_MATCHING_PATTERN
                 }
             }
         },
         FIRST_HASH {
             override fun evaluateChar(c: Char): NetconfMessageState {
-                return if (c == '#') {
-                    SECOND_HASH
-                } else {
-                    NO_MATCHING_PATTERN
+                return when (c) {
+                    '#' -> SECOND_HASH
+                    else -> NO_MATCHING_PATTERN
                 }
             }
         },
         SECOND_HASH {
             override fun evaluateChar(c: Char): NetconfMessageState {
-                return if (c == '\n') {
-                    END_CHUNKED_PATTERN
-                } else {
-                    NO_MATCHING_PATTERN
+                return when (c) {
+                    '\n' -> END_CHUNKED_PATTERN
+                    else -> NO_MATCHING_PATTERN
                 }
             }
         },
@@ -204,6 +191,11 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
             }
         };
 
+        /**
+         * Evaluate next transition state based on current state and the character read
+         * @param c character read in
+         * @return result of lookup of transition to the next {@link NetconfMessageState}
+         */
         internal abstract fun evaluateChar(c: Char): NetconfMessageState
     }
 
@@ -234,7 +226,7 @@ class NetconfDeviceCommunicator(private var inputStream: InputStream,
         } else {
             log.error("$deviceInfo: Invalid message received: \n $deviceReply")
         }
-        sessionListener.notify(NetconfReceivedEvent(
+        sessionListener.accept(NetconfReceivedEvent(
             NetconfReceivedEvent.Type.DEVICE_REPLY,
             deviceReply,
             NetconfMessageUtils.getMsgId(deviceReply),
index ae4d844..d0f4a1d 100644 (file)
@@ -263,7 +263,7 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
     }
 
     inner class NetconfSessionListenerImpl : NetconfSessionListener {
-        override fun notify(event: NetconfReceivedEvent) {
+        override fun accept(event: NetconfReceivedEvent) {
             val messageId = event.messageId
 
             when (event.type) {
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt
new file mode 100644 (file)
index 0000000..d46ee78
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2019 Bell Canada
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api
+
+
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
+import org.junit.Test
+import kotlin.test.assertEquals
+
+class DeviceInfoTest {
+    @Test
+    fun testToString() {
+
+       val di: DeviceInfo = DeviceInfo().apply {
+           username = "username"
+           password = "password"
+           ipAddress = "localhost"
+           port = 2224
+           connectTimeout = 10
+       }
+        assertEquals("localhost:2224", di.toString())
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt
new file mode 100644 (file)
index 0000000..70bf015
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright © 2019 Bell Canada
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api
+
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertTrue
+import org.junit.Test
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.RpcStatus
+
+class NetconfMessageTest {
+    @Test
+    fun testSuccessfulDeviceResponse() {
+        val dr: DeviceResponse = genSuccessfulEmptyDeviceResponse()
+        assertTrue(dr.isSuccess())
+
+        val dr2: DeviceResponse = genSuccessfulEmptyDeviceResponse()
+        dr2.errorMessage = "some error msg"
+        assertFalse(dr2.isSuccess())
+    }
+
+    @Test
+    fun testUnsuccessfulDeviceResponse() {
+        val dr: DeviceResponse = genUnsuccessfulEmptyDeviceResponse()
+        assertFalse(dr.isSuccess())
+
+        //case 2: Success, but with error message
+        val dr2: DeviceResponse = genUnsuccessfulEmptyDeviceResponse()
+        dr2.errorMessage = "Some error message."
+        assertFalse(dr2.isSuccess())
+    }
+
+    //helper function to generate a device response
+    private fun genSuccessfulEmptyDeviceResponse(): DeviceResponse {
+        return DeviceResponse().apply {
+            status = RpcStatus.SUCCESS
+            errorMessage = ""
+            responseMessage = ""
+            requestMessage = ""
+        }
+    }
+
+    private fun genUnsuccessfulEmptyDeviceResponse(): DeviceResponse {
+        return DeviceResponse().apply {
+            status = RpcStatus.FAILURE
+            errorMessage = ""
+            responseMessage = ""
+            requestMessage = ""
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt
new file mode 100644 (file)
index 0000000..95148dd
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Copyright © 2019 Bell Canada
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core
+
+import org.junit.Test
+import kotlin.test.assertEquals
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core.NetconfDeviceCommunicator.NetconfMessageState
+class NetconfMessageStateTest {
+
+    private val charList: List<Char> = Char.MIN_VALUE.toInt().rangeTo(Char.MAX_VALUE.toInt())
+        .map { it -> it.toChar() }
+
+    @Test
+    fun `NO_MATCHING_PATTERN transitions`() {
+        assertEquals(NetconfMessageState.FIRST_BRACKET,
+            NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar(']'))
+        assertEquals(NetconfMessageState.FIRST_LF,
+            NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar('\n'))
+
+        charList.minus(listOf(']','\n')).forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar(it))
+        }
+    }
+
+    @Test
+    fun `FIRST_BRACKET transitions`() {
+        assertEquals(NetconfMessageState.SECOND_BRACKET,
+            NetconfMessageState.FIRST_BRACKET.evaluateChar(']'))
+
+        charList.minus( ']').forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.FIRST_BRACKET.evaluateChar(it))
+        }
+    }
+
+    @Test
+    fun `SECOND_BRACKET transitions`() {
+        assertEquals(NetconfMessageState.FIRST_BIGGER,
+            NetconfMessageState.SECOND_BRACKET.evaluateChar('>'))
+
+        charList.minus('>').forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.SECOND_BRACKET.evaluateChar(it))
+        }
+    }
+
+    @Test
+    fun `FIRST_BIGGER transitions`() {
+        assertEquals(NetconfMessageState.THIRD_BRACKET,
+            NetconfMessageState.FIRST_BIGGER.evaluateChar(']'))
+
+        charList.minus(']').forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.FIRST_BIGGER.evaluateChar(it))
+        }
+    }
+
+    @Test
+    fun `THIRD_BRACKET transitions`() {
+        assertEquals(NetconfMessageState.ENDING_BIGGER,
+            NetconfMessageState.THIRD_BRACKET.evaluateChar(']'))
+
+        charList.minus(']').forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.THIRD_BRACKET.evaluateChar(it))
+        }
+    }
+
+    @Test
+    fun `ENDING_BIGGER transitions`() {
+        assertEquals(NetconfMessageState.END_PATTERN,
+            NetconfMessageState.ENDING_BIGGER.evaluateChar('>'))
+
+        charList.minus('>').forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.ENDING_BIGGER.evaluateChar(it))
+        }
+    }
+
+    @Test
+    fun `FIRST_LF transitions`() {
+        assertEquals(NetconfMessageState.FIRST_HASH,
+            NetconfMessageState.FIRST_LF.evaluateChar('#'))
+        assertEquals(NetconfMessageState.FIRST_BRACKET,
+            NetconfMessageState.FIRST_LF.evaluateChar(']'))
+        assertEquals(NetconfMessageState.FIRST_LF,
+            NetconfMessageState.FIRST_LF.evaluateChar('\n'))
+        charList.minus(listOf('#', ']', '\n')).forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.FIRST_LF.evaluateChar(it))
+        }
+    }
+
+    @Test
+    fun `FIRST_HASH transitions`() {
+        assertEquals(NetconfMessageState.SECOND_HASH,
+            NetconfMessageState.FIRST_HASH.evaluateChar('#'))
+        charList.minus('#').forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.FIRST_HASH.evaluateChar(it))
+        }
+    }
+
+    @Test
+    fun `SECOND_HASH transitions`() {
+        assertEquals(NetconfMessageState.END_CHUNKED_PATTERN,
+            NetconfMessageState.SECOND_HASH.evaluateChar('\n'))
+
+        charList.minus( '\n').forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.SECOND_HASH.evaluateChar(it))
+        }
+    }
+
+    @Test
+    fun `END_CHUNKED_PATTERN transitions`() {
+        charList.forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.END_CHUNKED_PATTERN.evaluateChar(it))
+        }
+    }
+
+    @Test
+    fun `END_PATTERN transitions`() {
+        charList.forEach {
+            assertEquals(NetconfMessageState.NO_MATCHING_PATTERN,
+                NetconfMessageState.END_PATTERN.evaluateChar(it))
+        }
+    }
+
+}
\ No newline at end of file