X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=policy_module%2Fosm_policy_module%2Fcommon%2Flcm_client.py;fp=policy_module%2Fosm_policy_module%2Fcommon%2Flcm_client.py;h=0000000000000000000000000000000000000000;hb=f315c3bf13c14d6a71c2909b4e4a8632f7df1c2e;hp=be44efe361eb381909cfe2905de870bb2220119d;hpb=8ddd3b9ad9b588a712b040a0ebc6dfd4e019b7c3;p=osm%2FMON.git diff --git a/policy_module/osm_policy_module/common/lcm_client.py b/policy_module/osm_policy_module/common/lcm_client.py deleted file mode 100644 index be44efe..0000000 --- a/policy_module/osm_policy_module/common/lcm_client.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2018 Whitestack, LLC -# ************************************************************* - -# This file is part of OSM Monitoring module -# All Rights Reserved to Whitestack, LLC - -# 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. - -# For those usages not covered by the Apache License, Version 2.0 please -# contact: bdiaz@whitestack.com or glavado@whitestack.com -## -import json -import logging - -from kafka import KafkaProducer - -from osm_policy_module.core.config import Config - -log = logging.getLogger(__name__) - - -class LcmClient: - def __init__(self): - cfg = Config.instance() - self.kafka_server = '{}:{}'.format(cfg.get('policy_module', 'kafka_server_host'), - cfg.get('policy_module', 'kafka_server_port')) - self.producer = KafkaProducer(bootstrap_servers=self.kafka_server, - key_serializer=str.encode, - value_serializer=str.encode) - - def scale(self, nsr_id: str, name: str, action: str): - msg = self._create_scale_action_payload(nsr_id, name, action) - log.info("Sending scale action message: %s", json.dumps(msg)) - self.producer.send(topic='lcm_pm', key='trigger_scaling', value=json.dumps(msg)) - self.producer.flush() - - def _create_scale_action_payload(self, nsr_id: str, name: str, action: str): - msg = { - "ns_id": nsr_id, - "scaling_group_descriptor": { - "name": name, - "action": action - } - } - return msg