diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2015-03-25 13:34:09 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@baserock.org> | 2015-03-25 13:34:09 +0000 |
commit | 3723e04ade96aee6a2bc0a13387aa46e5b2718b5 (patch) | |
tree | fd10aedace9ec4b258b6d084aa74fa65d0c77560 | |
parent | 51fd71bceb68ed4a24d2e587a9e5ff3345de624c (diff) | |
parent | 7af6598f7019f71833bd9362d580ac07abdb92dd (diff) | |
download | morph-3723e04ade96aee6a2bc0a13387aa46e5b2718b5.tar.gz |
Merge "simple-network: Add functionn to create a path if it doesnt exist"
-rwxr-xr-x | morphlib/exts/simple-network.configure | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/morphlib/exts/simple-network.configure b/morphlib/exts/simple-network.configure index 42bf1b82..b4988125 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. |