blob: 295c47218270689515949508682c25b7c50822dc [file] [log] [blame]
Filip Krzywka66e2ad62019-03-20 14:03:02 +01001# ============LICENSE_START=======================================================
2# csit-dcaegen2-collectors-hv-ves
3# ================================================================================
4# Copyright (C) 2018 NOKIA
5# ================================================================================
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17# ============LICENSE_END=========================================================
Gary Wu9abb61c2018-09-27 10:38:50 -070018from robot.api import logger
19import HttpRequests
20
21CONSUL_NAME = "Consul"
22
23class ConsulLibrary:
24
25 def publish_hv_ves_configuration_in_consul(self, consul_url, consul_configuration_filepath):
26 logger.info("Reading consul configuration file from: " + consul_configuration_filepath)
27 file = open(consul_configuration_filepath, "rb")
28 data = file.read()
29 file.close()
30
31 logger.info("PUT at: " + consul_url)
32 resp = HttpRequests.session_without_env().put(consul_url, data=data, timeout=5)
33 HttpRequests.checkStatusCode(resp.status_code, CONSUL_NAME)