summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2015-03-25 13:34:09 (GMT)
committerGerrit Code Review <gerrit@baserock.org>2015-03-25 13:34:09 (GMT)
commit3723e04ade96aee6a2bc0a13387aa46e5b2718b5 (patch)
treefd10aedace9ec4b258b6d084aa74fa65d0c77560
parent51fd71bceb68ed4a24d2e587a9e5ff3345de624c (diff)
parent7af6598f7019f71833bd9362d580ac07abdb92dd (diff)
downloadmorph-3723e04ade96aee6a2bc0a13387aa46e5b2718b5.tar.gz
Merge "simple-network: Add functionn to create a path if it doesnt exist"
-rwxr-xr-xmorphlib/exts/simple-network.configure11
1 files changed, 11 insertions, 0 deletions
diff --git a/morphlib/exts/simple-network.configure b/morphlib/exts/simple-network.configure
index 42bf1b8..b498812 100755
--- a/morphlib/exts/simple-network.configure
+++ b/morphlib/exts/simple-network.configure
@@ -27,6 +27,7 @@ for DHCP
import os
import sys
+import errno
import cliapp
import morphlib
@@ -256,6 +257,16 @@ class SimpleNetworkConfigurationExtension(cliapp.Application):
return output_stanza
+ def make_sure_path_exists(self, path):
+ try:
+ os.makedirs(path)
+ except OSError as e:
+ if e.errno == errno.EEXIST and os.path.isdir(path):
+ pass
+ else:
+ raise SimpleNetworkError("Unable to create directory '%s'"
+ % path)
+
def status(self, **kwargs):
'''Provide status output.