diff options
author | 2020-08-06 09:20:55 +0800 | |
---|---|---|
committer | 2020-08-07 15:37:08 +0800 | |
commit | 46bd3041d522ddce28ae3450e98c9c49b44b02cc (patch) | |
tree | 765a04f0a0bc4531d8bb6a0b4aba2304e894a34c /catalog/pub | |
parent | 824413f6f354330f868b38a2ec8cb93b3c8d2808 (diff) |
1. Remove the mandatory dependency on MSB
2. Refactor config file
Change-Id: I8317ee0e1440e177a54e5510c6393529b6a3a5fe
Issue-ID: MODELING-411
Signed-off-by: dyh <dengyuanhong@chinamobile.com>
Diffstat (limited to 'catalog/pub')
-rw-r--r-- | catalog/pub/config/config.py | 69 | ||||
-rw-r--r-- | catalog/pub/msapi/sdc_controller.py | 4 | ||||
-rw-r--r-- | catalog/pub/utils/restcall.py | 5 |
3 files changed, 37 insertions, 41 deletions
diff --git a/catalog/pub/config/config.py b/catalog/pub/config/config.py index 2c42c7a..49d1d84 100644 --- a/catalog/pub/config/config.py +++ b/catalog/pub/config/config.py @@ -13,20 +13,34 @@ # limitations under the License. import os -env_dict = os.environ # [MSB] -MSB_SERVICE_PROTOCOL = env_dict.get("MSB_PROTO", "http") -MSB_SERVICE_IP = env_dict.get("MSB_ADDR", "127.0.0.1:80").split(':')[0] -MSB_SERVICE_PORT = env_dict.get("MSB_ADDR", "127.0.0.1:80").split(':')[1] -MSB_BASE_URL = "%s://%s:%s" % (MSB_SERVICE_PROTOCOL, MSB_SERVICE_IP, MSB_SERVICE_PORT) +MSB_BASE_URL = os.getenv("MSB_ADDR", "http://127.0.0.1:80") +MSB_ENABLED = os.getenv("MSB_ENABLED", "true") + +# [SDC config] +if MSB_ENABLED == "true": + SDC_BASE_URL = MSB_BASE_URL + "/api" +else: + SDC_BASE_URL = os.getenv("SDC_ADDR") +SDC_USER = "modeling" +SDC_PASSWD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" + +SERVICE_IP = os.getenv("SERVICE_IP", "127.0.0.1") + +# [DMAAP config] +DMAAP_ENABLED = os.getenv("DMAAP_ENABLED", False) +DMAAP_MR_BASE_URL = os.getenv("DMAAP_ADDR") +CONSUMER_GROUP = "consumerGroup" +CONSUMER_ID = "consumerId" +POLLING_INTERVAL = 15 # [mysql] -DB_IP = env_dict.get("MYSQL_ADDR", "127.0.0.1:3306").split(':')[0] -DB_PORT = env_dict.get("MYSQL_ADDR", "127.0.0.1:3306").split(':')[1] +DB_IP = os.getenv("DB_IP", "127.0.0.1") +DB_PORT = os.getenv("DB_PORT", "3306") DB_NAME = "etsicatalog" -DB_USER = "etsicatalog" -DB_PASSWD = "etsicatalog" +DB_USER = os.getenv("DB_USER", "etsicatalog") +DB_PASSWD = os.getenv("DB_PASSWD", "etsicatalog") # [MDC] SERVICE_NAME = "catalog" @@ -34,59 +48,54 @@ FORWARDED_FOR_FIELDS = ["HTTP_X_FORWARDED_FOR", "HTTP_X_FORWARDED_HOST", "HTTP_X_FORWARDED_SERVER"] # [register] -REG_TO_MSB_WHEN_START = True +REG_TO_MSB_WHEN_START = False REG_TO_MSB_REG_URL = "/api/microservices/v1/services" -SSL_ENABLED = env_dict.get("SSL_ENABLED", "true") -if SSL_ENABLED == "true": - enable_ssl = "true" -else: - enable_ssl = "false" -svc_ip = env_dict.get("SERVICE_IP", "127.0.0.1") +SSL_ENABLED = os.getenv("SSL_ENABLED", "false") REG_TO_MSB_REG_PARAM = [{ "serviceName": "catalog", "version": "v1", - "enable_ssl": enable_ssl, + "enable_ssl": SSL_ENABLED, "url": "/api/catalog/v1", "protocol": "REST", "visualRange": "1", "nodes": [{ - "ip": svc_ip, + "ip": SERVICE_IP, "port": "8806", "ttl": 0 }] }, { "serviceName": "nsd", "version": "v1", - "enable_ssl": enable_ssl, + "enable_ssl": SSL_ENABLED, "url": "/api/nsd/v1", "protocol": "REST", "visualRange": "1", "nodes": [{ - "ip": svc_ip, + "ip": SERVICE_IP, "port": "8806", "ttl": 0 }] }, { "serviceName": "vnfpkgm", "version": "v1", - "enable_ssl": enable_ssl, + "enable_ssl": SSL_ENABLED, "url": "/api/vnfpkgm/v1", "protocol": "REST", "visualRange": "1", "nodes": [{ - "ip": svc_ip, + "ip": SERVICE_IP, "port": "8806", "ttl": 0 }] }, { "serviceName": "parser", "version": "v1", - "enable_ssl": enable_ssl, + "enable_ssl": SSL_ENABLED, "url": "/api/parser/v1", "protocol": "REST", "visualRange": "1", "nodes": [{ - "ip": svc_ip, + "ip": SERVICE_IP, "port": "8806", "ttl": 0 }] @@ -100,16 +109,4 @@ MSB_SVC_PARSER_URL = "/api/microservices/v1/services/parser/version/v1" CATALOG_ROOT_PATH = None CATALOG_URL_PATH = None -# [sdc config] -SDC_BASE_URL = MSB_BASE_URL + "/api" -SDC_USER = "modeling" -SDC_PASSWD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" - -# [dmaap config] -DMAAP_MR_IP = MSB_SERVICE_IP -DMAAP_MR_PORT = '30226' -CONSUMER_GROUP = "consumerGroup" -CONSUMER_ID = "consumerId" -POLLING_INTERVAL = 15 - VNFD_SCHEMA_VERSION_DEFAULT = "base" diff --git a/catalog/pub/msapi/sdc_controller.py b/catalog/pub/msapi/sdc_controller.py index 505443a..74a5ae8 100644 --- a/catalog/pub/msapi/sdc_controller.py +++ b/catalog/pub/msapi/sdc_controller.py @@ -12,13 +12,11 @@ from apscheduler.scheduler import Scheduler from catalog.pub.Dmaap_lib.dmaap.consumer import ConsumerClient from catalog.pub.Dmaap_lib.dmaap.identity import IdentityClient from catalog.pub.Dmaap_lib.dmaap.publisher import BatchPublisherClient -from catalog.pub.config.config import CONSUMER_GROUP, CONSUMER_ID, POLLING_INTERVAL, DMAAP_MR_IP, \ - DMAAP_MR_PORT +from catalog.pub.config.config import CONSUMER_GROUP, CONSUMER_ID, POLLING_INTERVAL, DMAAP_MR_BASE_URL from catalog.pub.msapi import sdc logger = logging.getLogger(__name__) -DMAAP_MR_BASE_URL = "https://%s:%s" % (DMAAP_MR_IP, DMAAP_MR_PORT) ARTIFACT_TYPES_LIST = ["TOSCA_TEMPLATE", "TOSCA_CSAR"] diff --git a/catalog/pub/utils/restcall.py b/catalog/pub/utils/restcall.py index 4d40068..6dbab78 100644 --- a/catalog/pub/utils/restcall.py +++ b/catalog/pub/utils/restcall.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import base64 +import logging import sys import traceback -import logging import urllib import uuid + import httplib2 -import base64 from catalog.pub.config.config import MSB_BASE_URL |