summaryrefslogtreecommitdiffstats
path: root/lib/python
diff options
context:
space:
mode:
authorDan Radez <dradez@redhat.com>2016-09-21 14:13:58 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-09-21 14:13:59 +0000
commit4523fd8c90acf923a526cae390922c1dbcd6220e (patch)
tree641b5aaeefcfff9ba567b427aa6481255e22850b /lib/python
parent8b6af178a5987f16325771691bde5956111cda01 (diff)
parentb6bda2fe154d067084a99733f42663252ff9b399 (diff)
Merge "Handling file loads and tmp dirs differently"
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/apex/common/utils.py2
-rw-r--r--lib/python/apex/deploy_settings.py2
-rw-r--r--lib/python/apex/inventory.py2
-rw-r--r--lib/python/apex/network_environment.py2
-rw-r--r--lib/python/apex/network_settings.py2
-rwxr-xr-xlib/python/apex_python_utils.py11
6 files changed, 14 insertions, 7 deletions
diff --git a/lib/python/apex/common/utils.py b/lib/python/apex/common/utils.py
index fe34096d..d623638c 100644
--- a/lib/python/apex/common/utils.py
+++ b/lib/python/apex/common/utils.py
@@ -19,5 +19,5 @@ def str2bool(var):
def parse_yaml(yaml_file):
with open(yaml_file) as f:
- parsed_dict = yaml.load(f)
+ parsed_dict = yaml.safe_load(f)
return parsed_dict
diff --git a/lib/python/apex/deploy_settings.py b/lib/python/apex/deploy_settings.py
index b70efdac..c27eecf9 100644
--- a/lib/python/apex/deploy_settings.py
+++ b/lib/python/apex/deploy_settings.py
@@ -40,7 +40,7 @@ class DeploySettings(dict):
init_dict = {}
if type(filename) is str:
with open(filename, 'r') as deploy_settings_file:
- init_dict = yaml.load(deploy_settings_file)
+ init_dict = yaml.safe_load(deploy_settings_file)
else:
# assume input is a dict to build from
init_dict = filename
diff --git a/lib/python/apex/inventory.py b/lib/python/apex/inventory.py
index f4a33b28..aa219680 100644
--- a/lib/python/apex/inventory.py
+++ b/lib/python/apex/inventory.py
@@ -24,7 +24,7 @@ class Inventory(dict):
init_dict = {}
if type(source) is str:
with open(source, 'r') as network_settings_file:
- yaml_dict = yaml.load(network_settings_file)
+ yaml_dict = yaml.safe_load(network_settings_file)
# collapse node identifiers from the structure
init_dict['nodes'] = list(map(lambda n: n[1],
yaml_dict['nodes'].items()))
diff --git a/lib/python/apex/network_environment.py b/lib/python/apex/network_environment.py
index 175f408f..15fe873f 100644
--- a/lib/python/apex/network_environment.py
+++ b/lib/python/apex/network_environment.py
@@ -59,7 +59,7 @@ class NetworkEnvironment(dict):
init_dict = {}
if type(filename) is str:
with open(filename, 'r') as net_env_fh:
- init_dict = yaml.load(net_env_fh)
+ init_dict = yaml.safe_load(net_env_fh)
super().__init__(init_dict)
try:
diff --git a/lib/python/apex/network_settings.py b/lib/python/apex/network_settings.py
index ca91b8cf..8e39afd6 100644
--- a/lib/python/apex/network_settings.py
+++ b/lib/python/apex/network_settings.py
@@ -42,7 +42,7 @@ class NetworkSettings(dict):
init_dict = {}
if type(filename) is str:
with open(filename, 'r') as network_settings_file:
- init_dict = yaml.load(network_settings_file)
+ init_dict = yaml.safe_load(network_settings_file)
else:
# assume input is a dict to build from
init_dict = filename
diff --git a/lib/python/apex_python_utils.py b/lib/python/apex_python_utils.py
index ebc49dc5..9d6110bb 100755
--- a/lib/python/apex_python_utils.py
+++ b/lib/python/apex_python_utils.py
@@ -43,7 +43,9 @@ def parse_net_settings(args):
net_env = NetworkEnvironment(settings, args.net_env_file,
args.compute_pre_config,
args.controller_pre_config)
- dump_yaml(dict(net_env), '/tmp/network-environment.yaml')
+ target = args.target_dir.split('/')
+ target.append('network-environment.yaml')
+ dump_yaml(dict(net_env), '/'.join(target))
settings.dump_bash()
@@ -108,7 +110,7 @@ def build_nic_template(args):
netsets = NetworkSettings(args.net_settings_file,
args.network_isolation)
- env = Environment(loader=FileSystemLoader(template_dir))
+ env = Environment(loader=FileSystemLoader(template_dir), autoescape=True)
template = env.get_template(template)
# gather vlan values into a dict
@@ -148,6 +150,11 @@ def get_parser():
default="network-environment.yaml",
dest='net_env_file',
help='path to network environment file')
+ net_settings.add_argument('-td', '--target-dir',
+ default="/tmp",
+ dest='target_dir',
+ help='directory to write the'
+ 'network-environment.yaml file')
net_settings.add_argument('--compute-pre-config',
default=False,
action='store_true',