def _cleanup_after_rebundle(): cnf = bus.cnf pl = bus.platform logger = logging.getLogger(__name__) if 'volumes' not in pl.features: # Destory mysql storages if os.path.exists(cnf.private_path('storage/mysql.json')) and pl.name == 'rackspace': logger.info('Cleanuping old MySQL storage') mysql_bhv = firstmatched(lambda x: x in node.__node__['behavior'], ('mysql', 'mysql2', 'percona')) vol = node.__node__[mysql_bhv]['volume'] vol.destroy(force=True) if os.path.exists('/etc/chef/client.pem'): os.remove('/etc/chef/client.pem') if os.path.exists('/etc/chef/client.rb'): os.remove('/etc/chef/client.rb') # Reset private configuration priv_path = cnf.private_path() for file in os.listdir(priv_path): if file in ('.user-data', '.update'): continue path = os.path.join(priv_path, file) coreutils.chmod_r(path, 0700) os.remove(path) if (os.path.isfile(path) or os.path.islink(path)) else shutil.rmtree(path) if not linux.os.windows_family: system2('sync', shell=True)
def _cleanup_after_rebundle(): cnf = bus.cnf pl = bus.platform logger = logging.getLogger(__name__) if os.path.exists('/etc/chef/client.pem'): os.remove('/etc/chef/client.pem') if os.path.exists('/etc/chef/client.rb'): os.remove('/etc/chef/client.rb') # remove storage devices from fstab if not linux.os.windows_family: fstab = mount.fstab() for entry in fstab: if 'comment=scalr' in entry.options: fstab.remove(entry.device) # Reset private configuration priv_path = cnf.private_path() for file in os.listdir(priv_path): if file in ('.user-data', 'update.status', 'keys'): # protect user-data and UpdateClient status # keys/default maybe already refreshed by UpdateClient continue path = os.path.join(priv_path, file) coreutils.chmod_r(path, 0700) try: os.remove(path) if (os.path.isfile(path) or os.path.islink(path)) else shutil.rmtree(path) except: if linux.os.windows and sys.exc_info()[0] == WindowsError: # ScalrUpdClient locks db.sqlite logger.debug(sys.exc_info()[1]) else: raise if not linux.os.windows_family: system2('sync', shell=True)