summaryrefslogtreecommitdiffstats
path: root/lib
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
parent8b6af178a5987f16325771691bde5956111cda01 (diff)
parentb6bda2fe154d067084a99733f42663252ff9b399 (diff)
Merge "Handling file loads and tmp dirs differently"
Diffstat (limited to 'lib')
-rwxr-xr-xlib/parse-functions.sh2
-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
-rwxr-xr-xlib/undercloud-functions.sh4
-rwxr-xr-xlib/virtual-setup-functions.sh4
9 files changed, 19 insertions, 12 deletions
diff --git a/lib/parse-functions.sh b/lib/parse-functions.sh
index 40cdb826..ef388f44 100755
--- a/lib/parse-functions.sh
+++ b/lib/parse-functions.sh
@@ -65,7 +65,7 @@ parse_network_settings() {
done
fi
- if output=$(python3 -B $LIB/python/apex_python_utils.py parse-net-settings -s $NETSETS $net_isolation_arg -e $CONFIG/network-environment.yaml $parse_ext); then
+ if output=$(python3 -B $LIB/python/apex_python_utils.py parse-net-settings -s $NETSETS $net_isolation_arg -td $APEX_TMP_DIR -e $CONFIG/network-environment.yaml $parse_ext); then
echo -e "${blue}${output}${reset}"
eval "$output"
else
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',
diff --git a/lib/undercloud-functions.sh b/lib/undercloud-functions.sh
index d2ba6bca..ccf39c02 100755
--- a/lib/undercloud-functions.sh
+++ b/lib/undercloud-functions.sh
@@ -122,8 +122,8 @@ function configure_undercloud {
echo "Copying configuration files to Undercloud"
if [[ "$net_isolation_enabled" == "TRUE" ]]; then
echo -e "${blue}Network Environment set for Deployment: ${reset}"
- cat /tmp/network-environment.yaml
- scp ${SSH_OPTIONS[@]} /tmp/network-environment.yaml "stack@$UNDERCLOUD":
+ cat $APEX_TMP_DIR/network-environment.yaml
+ scp ${SSH_OPTIONS[@]} $APEX_TMP_DIR/network-environment.yaml "stack@$UNDERCLOUD":
# check for ODL L3/ONOS
if [ "${deploy_options_array['sdn_l3']}" == 'True' ]; then
diff --git a/lib/virtual-setup-functions.sh b/lib/virtual-setup-functions.sh
index 61dc6799..116d19b6 100755
--- a/lib/virtual-setup-functions.sh
+++ b/lib/virtual-setup-functions.sh
@@ -23,7 +23,7 @@ function setup_virtual_baremetal {
ramsize=$(($2*1024))
fi
#start by generating the opening yaml for the inventory-virt.yaml file
- cat > /tmp/inventory-virt.yaml << EOF
+ cat > $APEX_TMP_DIR/inventory-virt.yaml << EOF
nodes:
EOF
@@ -64,7 +64,7 @@ EOF
#virsh vol-list default | grep baremetal${i} 2>&1> /dev/null || virsh vol-create-as default baremetal${i}.qcow2 41G --format qcow2
mac=$(virsh domiflist baremetal${i} | grep admin_network | awk '{ print $5 }')
- cat >> /tmp/inventory-virt.yaml << EOF
+ cat >> $APEX_TMP_DIR/inventory-virt.yaml << EOF
node${i}:
mac_address: "$mac"
ipmi_ip: 192.168.122.1