--- /dev/null
+FROM python:2
+
+ENV MSB_ADDR "127.0.0.1"
+ENV MSB_PORT "80"
+ENV AAI_ADDR "aai.api.simpledemo.openecomp.org"
+ENV AAI_PORT "8443"
+ENV AAI_SCHEMA_VERSION "v11"
+ENV AAI_USERNAME "AAI"
+ENV AAI_PASSWORD "AAI"
+
+EXPOSE 9001
+
+# COPY ./ /opt/multivimbroker/
+RUN apt-get update && \
+ apt-get install -y unzip && \
+ cd /opt/ && \
+ wget -O multicloud-framework.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.multicloud.framework&a=multicloud-framework&e=zip&v=LATEST" && \
+ unzip -q -o -B multicloud-framework.zip && \
+ rm -f multicloud-framework.zip && \
+ pip install -r /opt/multivimbroker/requirements.txt
+
+WORKDIR /opt/multivimbroker
+CMD /bin/sh -c /opt/multivimbroker/run.sh
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+IMAGE="multicloud-framework"
+VERSION="latest"
+
+docker build -t ${IMAGE}:${VERSION} .
\ No newline at end of file
MSB_SERVICE_IP = '127.0.0.1'
MSB_SERVICE_PORT = '10080'
+
# [ESR]
-ESR_GET_VIM_URI = "/api/extsys/v1/vims"
+# ESR_GET_VIM_URI = "/api/extsys/v1/vims"
+
+# [A&AI]
+AAI_ADDR = "aai.api.simpledemo.openecomp.org"
+AAI_PORT = "8443"
+AAI_SERVICE_URL = 'https://%s:%s/aai' % (AAI_ADDR, AAI_PORT)
+AAI_SCHEMA_VERSION = "v11"
+AAI_USERNAME = 'AAI'
+AAI_PASSWORD = 'AAI'
# [IMAGE LOCAL PATH]
ROOT_PATH = os.path.dirname(
REDIS_PORT = '6379'
REDIS_PASSWD = ''
-# [mysql]
-DB_IP = "127.0.0.1"
-DB_PORT = 3306
-DB_NAME = "multivimbroker"
-DB_USER = "root"
-DB_PASSWD = "password"
-
# [register]
-REG_TO_MSB_WHEN_START = True
+REG_TO_MSB_WHEN_START = False
REG_TO_MSB_REG_URL = "/api/microservices/v1/services"
REG_TO_MSB_REG_PARAM = {
"serviceName": "multivim",
import logging
from multivimbroker.pub.exceptions import VimBrokerException
-from multivimbroker.pub.utils.restcall import req_by_msb
-from multivimbroker.pub.config.config import ESR_GET_VIM_URI
+from multivimbroker.pub.utils.restcall import get_res_from_aai
logger = logging.getLogger(__name__)
-def get_vims():
- ret = req_by_msb(ESR_GET_VIM_URI, "GET")
- if ret[0] != 0:
- logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
- raise VimBrokerException(
- status_code=404, content="Failed to query VIMs from extsys.")
- return json.JSONDecoder().decode(ret[1])
+def split_vim_to_owner_region(vim_id):
+ split_vim = vim_id.split('_')
+ cloud_owner = split_vim[0]
+ cloud_region = "".join(split_vim[1:])
+ return cloud_owner, cloud_region
def get_vim_by_id(vim_id):
- ret = req_by_msb("%s/%s" % (ESR_GET_VIM_URI, vim_id), "GET")
+ cloud_owner, cloud_region = split_vim_to_owner_region(vim_id)
+ ret = get_res_from_aai("/cloud-infrastructure/cloud-regions/cloud-region"
+ "/%s/%s" % (cloud_owner, cloud_region))
if ret[0] != 0:
- logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ logger.error("Status code is %s, detail is %s." % (ret[2], ret[1]))
raise VimBrokerException(
status_code=404,
content="Failed to query VIM with id (%s) from extsys." % vim_id)
- return json.JSONDecoder().decode(ret[1])
+ ret = json.JSONDecoder().decode(ret[1])
+ ret['type'] = ret['cloud-type']
+ ret['version'] = ret['cloud-region-version']
+ ret['vimId'] = vim_id
+ return ret
import uuid
import httplib2
-
+from multivimbroker.pub.config.config import AAI_SCHEMA_VERSION
+from multivimbroker.pub.config.config import AAI_SERVICE_URL
+from multivimbroker.pub.config.config import AAI_USERNAME
+from multivimbroker.pub.config.config import AAI_PASSWORD
from multivimbroker.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT
rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2
rest_no_auth, resource, method, content, headers)
+def get_res_from_aai(resource, content=''):
+ headers = {
+ 'X-FromAppId': 'MultiCloud',
+ 'X-TransactionId': '9001',
+ 'content-type': 'application/json',
+ 'accept': 'application/json'
+ }
+ base_url = "%s/%s" % (AAI_SERVICE_URL, AAI_SCHEMA_VERSION)
+ return call_req(base_url, AAI_USERNAME, AAI_PASSWORD, rest_no_auth,
+ resource, "GET", content, headers)
+
+
def combine_url(base_url, resource):
full_url = None
if base_url.endswith('/') and resource.startswith('/'):
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-->
-<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">
+<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">
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
<name>multicloud/framework</name>
<description>multivim broker</description>
<build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <appendAssemblyId>false</appendAssemblyId>
- <descriptors>
- <descriptor>assembly.xml</descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
-</project>
+ <profiles>
+ <profile>
+ <id>docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.16.5</version>
+ <inherited>false</inherited>
+ <configuration>
+ <images>
+ <image>
+ <name>onap/multicloud/multicloud-framework</name>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFileDir>${basedir}/docker/</dockerFileDir>
+ <dockerFile>${basedir}/docker/Dockerfile</dockerFile>
+ <tags>
+ <tag>${project.version}-STAGING-latest</tag>
+ </tags>
+ </build>
+ </image>
+ </images>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-images</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>push-images</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
\ No newline at end of file
#!/bin/bash
-# Copyright (c) 2017 Wind River Systems, Inc.
-#
-# 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.
-
-nohup python manage.py runserver 127.0.0.1:9001 > /dev/null &
+
+sed -i "s/MSB_SERVICE_IP =.*/MSB_SERVICE_IP = \"${MSB_ADDR}\"/g" multivimbroker/pub/config/config.py
+sed -i "s/MSB_SERVICE_PORT =.*/MSB_SERVICE_PORT = \"${MSB_PORT}\"/g" multivimbroker/pub/config/config.py
+sed -i "s/AAI_ADDR =.*/AAI_ADDR = \"${AAI_ADDR}\"/g" multivimbroker/pub/config/config.py
+sed -i "s/AAI_PORT =.*/AAI_PORT = \"${AAI_PORT}\"/g" multivimbroker/pub/config/config.py
+sed -i "s/AAI_SCHEMA_VERSION =.*/AAI_SCHEMA_VERSION = \"${AAI_SCHEMA_VERSION}\"/g" multivimbroker/pub/config/config.py
+sed -i "s/AAI_USERNAME =.*/AAI_USERNAME = \"${AAI_USERNAME}\"/g" multivimbroker/pub/config/config.py
+sed -i "s/AAI_PASSWORD =.*/AAI_PASSWORD = \"${AAI_PASSWORD}\"/g" multivimbroker/pub/config/config.py
+
+nohup python manage.py runserver 0.0.0.0:9001 2>&1 &
+
+while [ ! -f logs/runtime_multivimbroker.log ]; do
+ sleep 1
+done
+
+tail -F logs/runtime_multivimbroker.log