summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_snappy.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-03-27 16:20:05 -0400
committerScott Moser <smoser@ubuntu.com>2015-03-27 16:20:05 -0400
commit09cc5909e3d69c03622b7dc2c4cb35fd378743cb (patch)
treede15adf402db75ff4f6da45c569c10b10d2338cb /cloudinit/config/cc_snappy.py
parentcb03a028430902c79f82097230abb7120f366bbd (diff)
downloadvyos-cloud-init-09cc5909e3d69c03622b7dc2c4cb35fd378743cb.tar.gz
vyos-cloud-init-09cc5909e3d69c03622b7dc2c4cb35fd378743cb.zip
be more user-friendly when looking for matching .config
On fspath installs, look for .config files harder. Given a file named: pkg.namespace_0.version_arch.snap We'll search for config files named: pkg.namespace_0.version_arch.config pkg.namespace.config pkg.config
Diffstat (limited to 'cloudinit/config/cc_snappy.py')
-rw-r--r--cloudinit/config/cc_snappy.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/cloudinit/config/cc_snappy.py b/cloudinit/config/cc_snappy.py
index d9dd9771..74ae3ac0 100644
--- a/cloudinit/config/cc_snappy.py
+++ b/cloudinit/config/cc_snappy.py
@@ -67,15 +67,26 @@ BUILTIN_CFG = {
}
+def parse_filename(fname):
+ fname = os.path.basename(fname)
+ fname_noext = fname.rpartition(".")[0]
+ name = fname_noext.partition("_")[0]
+ shortname = name.partition(".")[0]
+ return(name, shortname, fname_noext)
+
+
def get_fs_package_ops(fspath):
if not fspath:
return []
ops = []
- for snapfile in glob.glob(os.path.sep.join([fspath, '*.snap'])):
- cfg = snapfile.rpartition(".")[0] + ".config"
- name = os.path.basename(snapfile).rpartition(".")[0]
- if not os.path.isfile(cfg):
- cfg = None
+ for snapfile in sorted(glob.glob(os.path.sep.join([fspath, '*.snap']))):
+ (name, shortname, fname_noext) = parse_filename(snapfile)
+ cfg = None
+ for cand in set((fname_noext, name, shortname,)):
+ fpcand = os.path.sep.join([fspath, cand]) + ".config"
+ if os.path.isfile(fpcand):
+ cfg = fpcand
+ break
ops.append(makeop('install', name, config=None,
path=snapfile, cfgfile=cfg))
return ops