aboutsummaryrefslogtreecommitdiffstats
path: root/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2018-09-27 10:29:30 -0700
committerGary Wu <gary.i.wu@huawei.com>2018-09-27 12:50:28 -0700
commit2d3d8dcf6ef1bd2a161c69d561c629c5ec3f59c4 (patch)
tree652fd47a183c291e96c6721f550a5f63464f6e66 /test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py
parente161173e279a73134dda4c2f429605d6c9ee1fe7 (diff)
Move CSIT to integration/csit repo
To facilite branching of CSIT tests, all CSIT test code and scripts are relocated to the integration/csit repo. Change-Id: I6777cd414e43dbf2bfa6215f7e50849e1a6a2e59 Issue-ID: INT-671 Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py')
-rw-r--r--test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py69
1 files changed, 0 insertions, 69 deletions
diff --git a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py b/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py
deleted file mode 100644
index 989a796ce..000000000
--- a/test/csit/tests/dcaegen2-collectors-hv-ves/testcases/libraries/VesHvContainersUtilsLibrary.py
+++ /dev/null
@@ -1,69 +0,0 @@
-from time import time
-
-from robot.api import logger
-import os.path
-import docker
-from io import BytesIO
-from os.path import basename
-from tarfile import TarFile, TarInfo
-
-LOCALHOST = "localhost"
-
-
-class VesHvContainersUtilsLibrary:
-
- def get_consul_api_access_url(self, method, image_name, port):
- return self.create_url(
- method,
- self.get_instance_address(image_name, port)
- )
-
- def get_xnf_sim_api_access_url(self, method, host):
- if is_running_inside_docker():
- return self.create_url(method, host)
- else:
- logger.info("File `/.dockerenv` not found. Assuming local environment and using localhost.")
- port_from_container_name = str(host)[-4:]
- return self.create_url(method, LOCALHOST + ":" + port_from_container_name)
-
- def get_dcae_app_api_access_url(self, method, image_name, port):
- return self.create_url(
- method,
- self.get_instance_address(image_name, port)
- )
-
- def get_instance_address(self, image_name, port):
- if is_running_inside_docker():
- return image_name + ":" + port
- else:
- logger.info("File `/.dockerenv` not found. Assuming local environment and using localhost.")
- return LOCALHOST + ":" + port
-
- def create_url(self, method, host_address):
- return method + host_address
-
-def is_running_inside_docker():
- return os.path.isfile("/.dockerenv")
-
-def copy_to_container(container_id, filepaths, path='/etc/ves-hv'):
- with create_archive(filepaths) as archive:
- docker.APIClient('unix:///var/run/docker.sock') \
- .put_archive(container=container_id, path=(path), data=archive)
-
-
-def create_archive(filepaths):
- tarstream = BytesIO()
- tarfile = TarFile(fileobj=tarstream, mode='w')
- for filepath in filepaths:
- file = open(filepath, 'r')
- file_data = file.read()
-
- tarinfo = TarInfo(name=basename(file.name))
- tarinfo.size = len(file_data)
- tarinfo.mtime = time()
-
- tarfile.addfile(tarinfo, BytesIO(file_data))
-
- tarfile.close()
- tarstream.seek(0)
- return tarstream