Merge "More support of snaps for VNF"
[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 """command generator module for vrouter testing"""
11
12 import logging
13 from jinja2 import Environment, FileSystemLoader
14
15
16 class CommandGenerator(object):
17     """command generator class for vrouter testing"""
18
19     logger = logging.getLogger(__name__)
20
21     def __init__(self):
22         self.logger.debug("init command generator")
23
24     def load_template(self, template_dir, template):
25         loader = FileSystemLoader(template_dir,
26                                   encoding='utf8')
27         env = Environment(loader=loader)
28         return env.get_template(template)
29
30     def command_create(self, template, parameter):
31         commands = template.render(parameter)
32         return commands.split('\n')