class Timeout(OsmConfigman):
- nsi_deploy: int = None
+ nsi_deploy: int = 2 * 3600 # default global timeout for deployment a nsi
vca_on_error: int = (
5 * 60
) # Time for charm from first time at blocked,error status to mark as failed
port: int = None
uri: str = None
tenant: str = "osm"
- loglevel: str = "DEBUG"
+ loglevel: str = "ERROR"
logfile: str = None
logger_name: str = None
# under the License.
##
-# TODO currently is a pure yaml format. Consider to change it to [ini] style with yaml inside to be coherent with other modules
+# TODO currently is a pure yaml format. Consider to change it to [ini: style with yaml inside to be coherent with other modules
-[global]
+global:
loglevel: DEBUG
# logfile: /app/log # or /var/log/osm/lcm.log
# nologging: True # do no log to stdout/stderr
-[timeout]
+timeout:
# ns_deploy: 7200 # total deploy timeout for a ns 2 hours
# nsi_deploy: 7200 # total deploy timeout for a nsi 2 hours
-[RO]
+RO:
host: ro # hostname or IP
port: 9090
tenant: osm
# loglevel: DEBUG
# logfile: /var/log/osm/lcm-ro.log
-[VCA]
+VCA:
host: vca
port: 17070
user: admin
helm3path: /usr/local/bin/helm3
kubectlpath: /usr/bin/kubectl
jujupath: /usr/local/bin/juju
- eegrpc_tls_enforce: False
+ eegrpc_tls_enforce: false
# public_key: pubkey
# ca_cert: cacert
# api_proxy: apiproxy
# loglevel: DEBUG
# logfile: /var/log/osm/lcm-vca.log
-[database]
+database:
driver: mongo # mongo or memory
host: mongo # hostname or IP
port: 27017
# loglevel: DEBUG
# logfile: /var/log/osm/lcm-database.log
-[storage]
+storage:
driver: local # local filesystem
# for local provide file path
path: /app/storage
# loglevel: DEBUG
# logfile: /var/log/osm/lcm-storage.log
-[message]
+message:
driver: kafka # local or kafka
# for local provide file path
path: /app/storage/kafka
# logfile: /var/log/osm/lcm-message.log
group_id: lcm-server
-[tsdb] # time series database
+tsdb: # time series database
driver: prometheus
# local file to store the configuration
path: /etc/prometheus
import logging.handlers
import getopt
import sys
-import configparser
from osm_lcm import ns, vim_sdn, netslice
from osm_lcm.ng_ro import NgRoException, NgRoClient
self.fs.fs_disconnect()
def read_config_file(self, config_file):
- # TODO make a [ini] + yaml inside parser
- # the configparser library is not suitable, because it does not admit comments at the end of line,
- # and not parse integer or boolean
- conf = {}
try:
- # read file as yaml format
- config = configparser.ConfigParser(inline_comment_prefixes="#")
- config.read(config_file)
- conf = {s: dict(config.items(s)) for s in config.sections()}
+ with open(config_file) as f:
+ return yaml.safe_load(f)
except Exception as e:
self.logger.critical("At config file '{}': {}".format(config_file, e))
- self.logger.critical("Trying to load config as legacy mode")
- try:
- with open(config_file) as f:
- conf = yaml.safe_load(f)
- # Ensure all sections are not empty
- for k in (
- "global",
- "timeout",
- "RO",
- "VCA",
- "database",
- "storage",
- "message",
- ):
- if not conf.get(k):
- conf[k] = {}
- except Exception as e:
- self.logger.critical("At config file '{}': {}".format(config_file, e))
- exit(1)
- return conf
+ exit(1)
@staticmethod
def get_process_id():
class NetsliceLcm(LcmBase):
-
- timeout_nsi_deploy = 2 * 3600 # default global timeout for deployment a nsi
-
def __init__(self, msg, lcm_tasks, config, loop, ns):
"""
Init, Connect to database, filesystem storage, and messaging
if nsi_params and nsi_params.get("timeout_nsi_deploy"):
timeout_nsi_deploy = nsi_params["timeout_nsi_deploy"]
else:
- timeout_nsi_deploy = self.timeout.get(
- "nsi_deploy", self.timeout_nsi_deploy
- )
+ timeout_nsi_deploy = self.timeout.get("nsi_deploy")
# Empty list to keep track of network service records status in the netslice
nsir_admin = db_nsir_admin = db_nsir.get("_admin")
class TestLcm(TestCase):
def setUp(self):
- self.config_file = os.getcwd() + "/osm_lcm/tests/test_lcm_config_file_ini.cfg"
+ self.config_file = os.getcwd() + "/osm_lcm/tests/test_lcm_config_file.yaml"
self.config_file_without_storage_path = tempfile.mkstemp()[1]
Database.instance = None
self.db = Mock(Database({"database": {"driver": "memory"}}).instance.db)
+++ /dev/null
-# Copyright 2022 Canonical Ltd.
-#
-# 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.
-
-[global]
- loglevel: DEBUG
-[RO]
- host: ro
- port: 9090
- tenant: osm
-[VCA]
- host: vca
- port: 17070
- user: admin
- secret: secret
- cloud: localhost
- k8s_cloud: k8scloud
- helmpath: /usr/local/bin/helm
- helm3path: /usr/local/bin/helm3
- kubectlpath: /usr/bin/kubectl
- jujupath: /usr/local/bin/juju
-[database]
- driver: memory # mongo or memory
- # host: mongo # hostname or IP
- port: 27017
- name: osm
-[storage]
- driver: local # local filesystem
- path: /tmp/storage
-[message]
- driver: local # local or kafka
- path: /tmp/kafka
- host: kafka
- port: 9092
- group_id: lcm-server
-[tsdb] # time series database
- driver: prometheus
- path: /tmp/prometheus
- uri: http://prometheus:9090/