Update to Alpine 3.14
[functest.git] / functest / opnfv_tests / vnf / router / vnf_controller / command_generator.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2017 Okinawa Open Laboratory and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 # pylint: disable=missing-docstring
11
12 """command generator module for vrouter testing"""
13
14 import logging
15 from jinja2 import Environment, FileSystemLoader
16
17
18 class CommandGenerator():
19     """command generator class for vrouter testing"""
20
21     logger = logging.getLogger(__name__)
22
23     def __init__(self):
24         self.logger.debug("init command generator")
25
26     @staticmethod
27     def load_template(template_dir, template):
28         # pylint disable=missing-docstring
29         loader = FileSystemLoader(template_dir,
30                                   encoding='utf8')
31         env = Environment(loader=loader)
32         return env.get_template(template)
33
34     @staticmethod
35     def command_create(template, parameter):
36         # pylint disable=missing-docstring
37         commands = template.render(parameter)
38         return commands.split('\n')