summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_migrator.py
diff options
context:
space:
mode:
authorharlowja <harlowja@virtualbox.rhel>2012-11-07 23:16:21 -0800
committerharlowja <harlowja@virtualbox.rhel>2012-11-07 23:16:21 -0800
commit3de3c535f37e40a79b36997a93fa218534117397 (patch)
tree9e2126123042c30832f481a8b644129531012b95 /cloudinit/config/cc_migrator.py
parent791598f2929a5b8b6bb380f7f16ec568db96aba6 (diff)
downloadvyos-cloud-init-3de3c535f37e40a79b36997a93fa218534117397.tar.gz
vyos-cloud-init-3de3c535f37e40a79b36997a93fa218534117397.zip
1. Check the name and not the full path
when applying the canon routine. 2. Add in a function to migrate legacy semaphores to new semaphores.
Diffstat (limited to 'cloudinit/config/cc_migrator.py')
-rw-r--r--cloudinit/config/cc_migrator.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/cloudinit/config/cc_migrator.py b/cloudinit/config/cc_migrator.py
index b71d1d17..56f33d42 100644
--- a/cloudinit/config/cc_migrator.py
+++ b/cloudinit/config/cc_migrator.py
@@ -35,14 +35,41 @@ def _migrate_canon_sems(cloud):
for p in os.listdir(sem_path):
full_path = os.path.join(sem_path, p)
if os.path.isfile(full_path):
- canon_p = helpers.canon_sem_name(p)
- if canon_p != p:
- new_path = os.path.join(sem_path, p)
+ (name, ext) = os.path.splitext(p)
+ canon_name = helpers.canon_sem_name(name)
+ if canon_name != name:
+ new_path = os.path.join(sem_path, canon_name + ext)
shutil.move(full_path, new_path)
am_adjusted += 1
return am_adjusted
+def _migrate_legacy_sems(cloud, log):
+ sem_path = cloud.paths.get_ipath('sem')
+ touch_there = {
+ 'apt-update-upgrade': [
+ 'apt-configure',
+ 'package-update-upgrade-install',
+ ],
+ }
+ sem_helper = helpers.FileSemaphores(sem_path)
+ for (mod_name, migrate_to) in touch_there.items():
+ possibles = [mod_name, helpers.canon_sem_name(mod_name)]
+ old_exists = []
+ for p in os.listdir(sem_path):
+ (name, _ext) = os.path.splitext(p)
+ if name in possibles and os.path.isfile(p):
+ old_exists.append(p)
+ for p in old_exists:
+ util.del_file(os.path.join(sem_path, p))
+ (_name, freq) = os.path.splitext(p)
+ for m in migrate_to:
+ log.debug("Migrating %s => %s with the same frequency",
+ p, m)
+ with sem_helper.lock(m, freq):
+ pass
+
+
def handle(name, cfg, cloud, log, _args):
do_migrate = util.get_cfg_option_str(cfg, "migrate", True)
if not util.translate_bool(do_migrate):
@@ -51,3 +78,4 @@ def handle(name, cfg, cloud, log, _args):
sems_moved = _migrate_canon_sems(cloud)
log.debug("Migrated %s semaphore files to there canonicalized names",
sems_moved)
+ _migrate_legacy_sems(cloud, log)