def osd_in(args): """Resume the ceph-osd units on this local machine only @raises subprocess.CalledProcessError should the osd units fails to osd_in. @raises OSError if the unit can't get the local osd ids """ for local_id in get_local_osd_ids(): cmd = ['ceph', '--id', 'osd-upgrade', 'osd', 'in', str(local_id)] check_call(cmd) assess_status()
def aa_profile_changed(service_name='ceph-osd-all'): """ Reload AA profie and restart OSD processes. """ log("Loading new AppArmor profile") service_reload('apparmor') log("Restarting ceph-osd services with new AppArmor profile") if ceph.systemd(): for osd_id in ceph.get_local_osd_ids(): service_restart('ceph-osd@{}'.format(osd_id)) else: service_restart(service_name)
def osd_out(args): """Pause the ceph-osd units on the local machine only. Optionally uses the 'osd-number' from juju action param to only osd_out a specific osd. @raises CalledProcessError if the ceph commands fails. @raises OSError if it can't get the local osd ids. """ for local_id in get_local_osd_ids(): cmd = ['ceph', '--id', 'osd-upgrade', 'osd', 'out', str(local_id)] check_call(cmd) assess_status()
def check_osd_id(osds): """Check ceph OSDs existence. :param osds: list of osds IDs :type osds: set :returns: list of osds IDs present on the local machine and list of failed osds IDs :rtype: Tuple[set, set] :raises OSError: if the unit can't get the local osd ids """ all_local_osd = get_local_osd_ids() if ALL in osds: return set(all_local_osd), set() failed_osds = osds.difference(all_local_osd) if failed_osds: log("Ceph OSDs not present: {}".format(", ".join(failed_osds)), level=ERROR) return osds, failed_osds