def _migrate_legacy_sems(cloud, log): legacy_adjust = { 'apt-update-upgrade': [ 'apt-configure', 'package-update-upgrade-install', ], } paths = (cloud.paths.get_ipath('sem'), cloud.paths.get_cpath('sem')) for sem_path in paths: if not sem_path or not os.path.exists(sem_path): continue sem_helper = helpers.FileSemaphores(sem_path) for (mod_name, migrate_to) in legacy_adjust.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 activate(self, cfg, is_new_instance): """Adjust set-passwords module to run 'always' during each boot""" # We run the set password config module on every boot in order to # enable resetting the instance's password via the exoscale console # (and a subsequent instance reboot). # Exoscale password server only provides set-passwords user-data if # a user has triggered a password reset. So calling that password # service generally results in no additional cloud-config. # TODO(Create util functions for overriding merged sys_cfg module freq) mod = 'set_passwords' sem_path = self.paths.get_ipath_cur('sem') sem_helper = helpers.FileSemaphores(sem_path) if sem_helper.clear('config_' + mod, None): LOG.debug('Overriding module set-passwords with frequency always')
def _get_per_boot_network_semaphore(self): return namedtuple("Semaphore", "semaphore args")( helpers.FileSemaphores(self.paths.get_runpath("sem")), ("apply_network_config", PER_ONCE), )
def _get_per_boot_network_semaphore(self): return namedtuple('Semaphore', 'semaphore args')(helpers.FileSemaphores( self.paths.get_runpath('sem')), ('apply_network_config', PER_ONCE))