Skip to content

Commit 3deb1d5

Browse files
committed
Dev - Fix small issues
1 parent 41d42d8 commit 3deb1d5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

networkd.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import re
44
import os
5+
import pathlib
6+
import subprocess
57
from ansible.module_utils.basic import AnsibleModule
68
from ansible.module_utils.common.text.converters import to_text
79

@@ -24,7 +26,8 @@ def same_list_file(list1, filepath):
2426
return same
2527

2628
def write_list_to_file(list1, filepath):
27-
os.makedirs(filepath.split('/')[:-1], mode = 0o755, exist_ok=True)
29+
path = pathlib.Path(filepath)
30+
os.makedirs(path.parent, mode = 0o755, exist_ok=True)
2831
f = open(filepath, "w")
2932
for it in list1:
3033
f.write(it + "\n")
@@ -103,6 +106,7 @@ def generate_netdev(self):
103106
else:
104107
netdev.append("Mode=802.3ad")
105108

109+
return netdev
106110

107111
def main():
108112
# Parsing argument file
@@ -176,9 +180,10 @@ def main():
176180
write_list_to_file(netdev, netdev_file)
177181

178182
# Post actions
179-
if changed == 1:
180-
stdout, stderr = os.subprocess.Popen("networkctl reload", stdout=os.subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate()
181-
stdout, stderr = os.subprocess.Popen("networkctl reconfigure " + networkd.conn_name, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate()
183+
#if changed == 1:
184+
#stdout, stderr = subprocess.Popen("networkctl reload", stdout=os.subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate()
185+
#stdout, stderr = subprocess.Popen("networkctl reconfigure " + networkd.conn_name, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate()
186+
182187

183188
except NetworkdModuleError as e:
184189
module.fail_json(name=networkd.conn_name, msg=str(e))

0 commit comments

Comments
 (0)