Merge "Add multicloud sim"
authorShankaranarayanan Puzhavakath Narayanan <snarayanan@research.att.com>
Fri, 6 Apr 2018 14:37:34 +0000 (14:37 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 6 Apr 2018 14:37:34 +0000 (14:37 +0000)
13 files changed:
conductor/conductor/tests/functional/simulators/aaisim/Dockerfile
conductor/conductor/tests/functional/simulators/aaisim/aaisim.py
conductor/conductor/tests/functional/simulators/build_aaisim.sh
conductor/conductor/tests/functional/simulators/build_multicloudsim.sh [new file with mode: 0755]
conductor/conductor/tests/functional/simulators/destroy_aaisim.sh
conductor/conductor/tests/functional/simulators/destroy_multicloudsim.sh [new file with mode: 0755]
conductor/conductor/tests/functional/simulators/multicloudsim/Dockerfile [new file with mode: 0755]
conductor/conductor/tests/functional/simulators/multicloudsim/multicloudsim.py [new file with mode: 0755]
conductor/conductor/tests/functional/simulators/multicloudsim/requirements.txt [new file with mode: 0755]
conductor/conductor/tests/functional/simulators/multicloudsim/responses/healthcheck.json [new file with mode: 0644]
conductor/conductor/tests/functional/simulators/multicloudsim/responses/post_check_vim_capacity.json [new file with mode: 0644]
conductor/conductor/tests/functional/simulators/run_aaisim.sh
conductor/conductor/tests/functional/simulators/run_multicloudsim.sh [new file with mode: 0755]

index 3f241b0..9ab4213 100755 (executable)
@@ -1,3 +1,21 @@
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   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.
+#
+# -------------------------------------------------------------------------
+#
 # Use an official Python runtime as a parent image
 FROM python:2.7
 
index 2e60bd3..2a96e97 100755 (executable)
@@ -1,3 +1,21 @@
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   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.
+#
+# -------------------------------------------------------------------------
+#
 import web
 import web.webapi
 import json
index 0fcd129..441b6b9 100755 (executable)
@@ -1,3 +1,22 @@
+#!/bin/bash
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   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.
+#
+# -------------------------------------------------------------------------
+#
 cd ./aaisim
 docker build -t aaisim .  
 
diff --git a/conductor/conductor/tests/functional/simulators/build_multicloudsim.sh b/conductor/conductor/tests/functional/simulators/build_multicloudsim.sh
new file mode 100755 (executable)
index 0000000..054a41f
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   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.
+#
+# -------------------------------------------------------------------------
+#
+cd ./multicloudsim
+docker build -t multicloudsim .  
+
index ddc3798..0bf2ac0 100755 (executable)
@@ -1,4 +1,23 @@
+#!/bin/bash
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   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.
+#
+# -------------------------------------------------------------------------
+#
 docker stop aaisim
-docker rm aasim
+docker rm aaisim
 docker rmi aaisim
 
diff --git a/conductor/conductor/tests/functional/simulators/destroy_multicloudsim.sh b/conductor/conductor/tests/functional/simulators/destroy_multicloudsim.sh
new file mode 100755 (executable)
index 0000000..48a9c9e
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   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.
+#
+# -------------------------------------------------------------------------
+#
+docker stop multicloudsim
+docker rm multicloudsim
+docker rmi multicloudsim
+
diff --git a/conductor/conductor/tests/functional/simulators/multicloudsim/Dockerfile b/conductor/conductor/tests/functional/simulators/multicloudsim/Dockerfile
new file mode 100755 (executable)
index 0000000..aeaf2b9
--- /dev/null
@@ -0,0 +1,39 @@
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   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.
+#
+# -------------------------------------------------------------------------
+#
+# Use an official Python runtime as a parent image
+FROM python:2.7
+
+# Set the working directory to /su/python/webpy-rest-dockerized
+WORKDIR /opt/multicloudsim
+
+# Copy the current directory contents into the container at /app
+ADD ./  /opt/multicloudsim
+
+# Install any needed packages specified in requirements.txt
+RUN pip install web.py
+
+# Make port 80 available to the world outside this container
+EXPOSE 8082
+
+# Define environment variable
+ENV NAME multicloudsim
+
+# Run multicloudsim.py when the container launches
+CMD ["/bin/sh", "-c", "python -u multicloudsim.py 8082 > /tmp/multicloudsim.log 2>&1"]
+
diff --git a/conductor/conductor/tests/functional/simulators/multicloudsim/multicloudsim.py b/conductor/conductor/tests/functional/simulators/multicloudsim/multicloudsim.py
new file mode 100755 (executable)
index 0000000..d3d2228
--- /dev/null
@@ -0,0 +1,90 @@
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   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.
+#
+# -------------------------------------------------------------------------
+#
+import web
+import web.webapi
+import json
+
+from subprocess import Popen, PIPE
+from xml.dom import minidom
+
+
+urls = (
+  '/healthcheck','healthcheck',
+  '/api/multicloud/v0/check_vim_capacity','post_check_vim_capacity',
+)
+
+
+myok = {"ok":"ok"}
+json_data={}
+
+replydir = "./responses/"
+
+def replyToAaiGet(web, replydir, replyfile):
+        print ("------------------------------------------------------")
+        fullreply = replydir + replyfile
+        trid=web.ctx.env.get('X_TRANSACTIONID','111111')
+        #print ("X-TransactionId : {}".format(trid))
+        print ("this is the context : {}".format(web.ctx.fullpath))
+        with open(fullreply) as json_file:
+            json_data = json.load(json_file)
+            print(json_data)
+   
+        web.header('Content-Type', 'application/json')
+        web.header('X-TransactionId', trid)
+        return json.dumps(json_data)
+
+class healthcheck:
+    def GET(self):
+        print ("------------------------------------------------------")
+        replyfile = "healthcheck.json"
+        #replyToAaiGet (web, replydir, replyfile)
+        fullreply = replydir + replyfile
+        trid=web.ctx.env.get('X_TRANSACTIONID','111111')
+        #print ("X-TransactionId : {}".format(trid))
+        print ("this is the context : {}".format(web.ctx.fullpath))
+        with open(fullreply) as json_file:
+            json_data = json.load(json_file)
+            print(json_data)
+   
+        web.header('Content-Type', 'application/json')
+        web.header('X-TransactionId', trid)
+        return json.dumps(json_data)
+
+class post_check_vim_capacity:
+    def POST(self):
+        print ("------------------------------------------------------")
+        replyfile = "post_check_vim_capacity.json"
+        #replyToAaiGet (web, replydir, replyfile)
+        fullreply = replydir + replyfile
+        trid=web.ctx.env.get('X_TRANSACTIONID','111111')
+        #print ("X-TransactionId : {}".format(trid))
+        print ("this is the context : {}".format(web.ctx.fullpath))
+        with open(fullreply) as json_file:
+            json_data = json.load(json_file)
+            print(json_data)
+   
+        web.header('Content-Type', 'application/json')
+        web.header('X-TransactionId', trid)
+        return json.dumps(json_data)
+
+
+
+if __name__ == "__main__": 
+    app = web.application(urls, globals())
+    app.run()
diff --git a/conductor/conductor/tests/functional/simulators/multicloudsim/requirements.txt b/conductor/conductor/tests/functional/simulators/multicloudsim/requirements.txt
new file mode 100755 (executable)
index 0000000..c077218
--- /dev/null
@@ -0,0 +1 @@
+web
diff --git a/conductor/conductor/tests/functional/simulators/multicloudsim/responses/healthcheck.json b/conductor/conductor/tests/functional/simulators/multicloudsim/responses/healthcheck.json
new file mode 100644 (file)
index 0000000..b0bd6da
--- /dev/null
@@ -0,0 +1 @@
+{"status":"success"}
diff --git a/conductor/conductor/tests/functional/simulators/multicloudsim/responses/post_check_vim_capacity.json b/conductor/conductor/tests/functional/simulators/multicloudsim/responses/post_check_vim_capacity.json
new file mode 100644 (file)
index 0000000..aef2ee9
--- /dev/null
@@ -0,0 +1 @@
+{"VIMs": ["HPA-cloud_cloud-region-1"]}
index 21c7bb3..203de16 100755 (executable)
@@ -1,2 +1,21 @@
+#!/bin/bash
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   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.
+#
+# -------------------------------------------------------------------------
+#
 docker run -d --name aaisim -p 8081:8081  aaisim
 
diff --git a/conductor/conductor/tests/functional/simulators/run_multicloudsim.sh b/conductor/conductor/tests/functional/simulators/run_multicloudsim.sh
new file mode 100755 (executable)
index 0000000..50f4c8f
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   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.
+#
+# -------------------------------------------------------------------------
+#
+docker run -d --name multicloudsim -p 8082:8082  multicloudsim
+