Update PRH tests to use file based conifg
[integration/csit.git] / tests / dcaegen2-collectors-hv-ves / testcases / libraries / ConsulLibrary.py
1 # ============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=========================================================
18 from robot.api import logger
19 import HttpRequests
20
21 CONSUL_NAME = "Consul"
22
23 class 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)