Fix up the imports on a recent change to follow coding spec
Essentially, we want to avoid doing: from module import f1, f2, f2 and instead doL import module module.f1() This helps with reading the code and understanding where the functions come from. Change-Id: I1bc06441dc5595e8a0c84a5b5c3db5d88b68a4f2
This commit is contained in:
parent
52306f8419
commit
b15237b3c5
|
@ -21,35 +21,23 @@ import sys
|
||||||
sys.path.append('lib')
|
sys.path.append('lib')
|
||||||
sys.path.append('hooks')
|
sys.path.append('hooks')
|
||||||
|
|
||||||
from charmhelpers.core.hookenv import (
|
import charmhelpers.contrib.storage.linux.ceph as ch_ceph
|
||||||
config,
|
import charmhelpers.core.hookenv as hookenv
|
||||||
action_get,
|
|
||||||
)
|
|
||||||
|
|
||||||
from charmhelpers.contrib.storage.linux.ceph import (
|
import ceph_hooks
|
||||||
CephBrokerRq,
|
import ceph.utils
|
||||||
send_request_if_needed,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ceph.utils import (
|
|
||||||
osdize,
|
|
||||||
tune_dev,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ceph_hooks import (
|
|
||||||
get_journal_devices,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def add_device(request, device_path, bucket=None):
|
def add_device(request, device_path, bucket=None):
|
||||||
osdize(dev, config('osd-format'),
|
ceph.utils.osdize(dev, hookenv.config('osd-format'),
|
||||||
get_journal_devices(), config('osd-reformat'),
|
ceph_hooks.get_journal_devices(),
|
||||||
config('ignore-device-errors'),
|
hookenv.config('osd-reformat'),
|
||||||
config('osd-encrypt'),
|
hookenv.config('ignore-device-errors'),
|
||||||
config('bluestore'))
|
hookenv.config('osd-encrypt'),
|
||||||
|
hookenv.config('bluestore'))
|
||||||
# Make it fast!
|
# Make it fast!
|
||||||
if config('autotune'):
|
if hookenv.config('autotune'):
|
||||||
tune_dev(dev)
|
ceph.utils.tune_dev(dev)
|
||||||
mounts = filter(lambda disk: device_path
|
mounts = filter(lambda disk: device_path
|
||||||
in disk.device, psutil.disk_partitions())
|
in disk.device, psutil.disk_partitions())
|
||||||
if mounts:
|
if mounts:
|
||||||
|
@ -64,7 +52,7 @@ def add_device(request, device_path, bucket=None):
|
||||||
|
|
||||||
def get_devices():
|
def get_devices():
|
||||||
devices = []
|
devices = []
|
||||||
for path in action_get('osd-devices').split(' '):
|
for path in hookenv.action_get('osd-devices').split(' '):
|
||||||
path = path.strip()
|
path = path.strip()
|
||||||
if os.path.isabs(path):
|
if os.path.isabs(path):
|
||||||
devices.append(path)
|
devices.append(path)
|
||||||
|
@ -73,9 +61,9 @@ def get_devices():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
request = CephBrokerRq()
|
request = ch_ceph.CephBrokerRq()
|
||||||
for dev in get_devices():
|
for dev in get_devices():
|
||||||
request = add_device(request=request,
|
request = add_device(request=request,
|
||||||
device_path=dev,
|
device_path=dev,
|
||||||
bucket=action_get("bucket"))
|
bucket=hookenv.action_get("bucket"))
|
||||||
send_request_if_needed(request, relation='mon')
|
ch_ceph.send_request_if_needed(request, relation='mon')
|
||||||
|
|
|
@ -26,10 +26,10 @@ import sys
|
||||||
sys.path.append('hooks/')
|
sys.path.append('hooks/')
|
||||||
sys.path.append('lib/')
|
sys.path.append('lib/')
|
||||||
|
|
||||||
from charmhelpers.core.hookenv import action_set
|
import charmhelpers.core.hookenv as hookenv
|
||||||
|
|
||||||
from ceph.utils import unmounted_disks
|
import ceph.utils
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
action_set({
|
hookenv.action_set({
|
||||||
'disks': unmounted_disks()})
|
'disks': ceph.utils.unmounted_disks()})
|
||||||
|
|
|
@ -20,11 +20,9 @@ import sys
|
||||||
sys.path.append('hooks/')
|
sys.path.append('hooks/')
|
||||||
sys.path.append('lib/')
|
sys.path.append('lib/')
|
||||||
|
|
||||||
from charmhelpers.core.hookenv import action_get, log, config, action_fail
|
import charmhelpers.core.hookenv as hookenv
|
||||||
|
|
||||||
from ceph.utils import (
|
import ceph.utils
|
||||||
replace_osd,
|
|
||||||
)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Given a OSD number this script will attempt to turn that back into a mount
|
Given a OSD number this script will attempt to turn that back into a mount
|
||||||
|
@ -38,9 +36,11 @@ def get_disk_stats():
|
||||||
with open('/proc/diskstats', 'r') as diskstats:
|
with open('/proc/diskstats', 'r') as diskstats:
|
||||||
return diskstats.readlines()
|
return diskstats.readlines()
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
log('Could not open /proc/diskstats. Error: {}'.format(err.message))
|
hookenv.log('Could not open /proc/diskstats. Error: {}'
|
||||||
action_fail('replace-osd failed because /proc/diskstats could not '
|
.format(err.message))
|
||||||
'be opened {}'.format(err.message))
|
hookenv.action_fail(
|
||||||
|
'replace-osd failed because /proc/diskstats could not '
|
||||||
|
'be opened {}'.format(err.message))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ def lookup_device_name(major_number, minor_number):
|
||||||
# Found our device. Return its name
|
# Found our device. Return its name
|
||||||
return parts[2]
|
return parts[2]
|
||||||
except ValueError as value_err:
|
except ValueError as value_err:
|
||||||
log('Could not convert {} or {} into an integer. Error: {}'
|
hookenv.log('Could not convert {} or {} into an integer. Error: {}'
|
||||||
.format(parts[0], parts[1], value_err.message))
|
.format(parts[0], parts[1], value_err.message))
|
||||||
continue
|
continue
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -85,15 +85,15 @@ def get_device_number(osd_number):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
dead_osd_number = action_get("osd-number")
|
dead_osd_number = hookenv.action_get("osd-number")
|
||||||
replacement_device = action_get("replacement-device")
|
replacement_device = hookenv.action_get("replacement-device")
|
||||||
major, minor = get_device_number(dead_osd_number)
|
major, minor = get_device_number(dead_osd_number)
|
||||||
device_name = lookup_device_name(major, minor)
|
device_name = lookup_device_name(major, minor)
|
||||||
osd_format = config('osd-format')
|
osd_format = hookenv.config('osd-format')
|
||||||
osd_journal = config('osd-journal')
|
osd_journal = hookenv.config('osd-journal')
|
||||||
|
|
||||||
replace_osd(dead_osd_number=dead_osd_number,
|
ceph.utils.replace_osd(dead_osd_number=dead_osd_number,
|
||||||
dead_osd_device="/dev/{}".format(device_name),
|
dead_osd_device="/dev/{}".format(device_name),
|
||||||
new_osd_device=replacement_device,
|
new_osd_device=replacement_device,
|
||||||
osd_format=osd_format,
|
osd_format=osd_format,
|
||||||
osd_journal=osd_journal)
|
osd_journal=osd_journal)
|
||||||
|
|
Loading…
Reference in New Issue