deep_scrub_choked
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,154 @@
|
||||
"""Ansible callback plugin to print a summary completion status of installation
|
||||
phases.
|
||||
"""
|
||||
from datetime import datetime
|
||||
from ansible.plugins.callback import CallbackBase
|
||||
from ansible import constants as C
|
||||
|
||||
|
||||
class CallbackModule(CallbackBase):
|
||||
"""This callback summarizes installation phase status."""
|
||||
|
||||
CALLBACK_VERSION = 2.0
|
||||
CALLBACK_TYPE = 'aggregate'
|
||||
CALLBACK_NAME = 'installer_checkpoint'
|
||||
CALLBACK_NEEDS_WHITELIST = False
|
||||
|
||||
def __init__(self):
|
||||
super(CallbackModule, self).__init__()
|
||||
|
||||
def v2_playbook_on_stats(self, stats):
|
||||
|
||||
# Set the order of the installer phases
|
||||
installer_phases = [
|
||||
'installer_phase_ceph_mon',
|
||||
'installer_phase_ceph_mgr',
|
||||
'installer_phase_ceph_osd',
|
||||
'installer_phase_ceph_mds',
|
||||
'installer_phase_ceph_rgw',
|
||||
'installer_phase_ceph_nfs',
|
||||
'installer_phase_ceph_rbdmirror',
|
||||
'installer_phase_ceph_client',
|
||||
'installer_phase_ceph_rgw_loadbalancer',
|
||||
'installer_phase_ceph_dashboard',
|
||||
'installer_phase_ceph_grafana',
|
||||
'installer_phase_ceph_node_exporter',
|
||||
'installer_phase_ceph_crash',
|
||||
'installer_phase_ceph_exporter',
|
||||
]
|
||||
|
||||
# Define the attributes of the installer phases
|
||||
phase_attributes = {
|
||||
'installer_phase_ceph_mon': {
|
||||
'title': 'Install Ceph Monitor',
|
||||
'playbook': 'roles/ceph-mon/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_mgr': {
|
||||
'title': 'Install Ceph Manager',
|
||||
'playbook': 'roles/ceph-mgr/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_osd': {
|
||||
'title': 'Install Ceph OSD',
|
||||
'playbook': 'roles/ceph-osd/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_mds': {
|
||||
'title': 'Install Ceph MDS',
|
||||
'playbook': 'roles/ceph-mds/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_rgw': {
|
||||
'title': 'Install Ceph RGW',
|
||||
'playbook': 'roles/ceph-rgw/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_nfs': {
|
||||
'title': 'Install Ceph NFS',
|
||||
'playbook': 'roles/ceph-nfs/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_rbdmirror': {
|
||||
'title': 'Install Ceph RBD Mirror',
|
||||
'playbook': 'roles/ceph-rbd-mirror/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_client': {
|
||||
'title': 'Install Ceph Client',
|
||||
'playbook': 'roles/ceph-client/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_rgw_loadbalancer': {
|
||||
'title': 'Install Ceph RGW LoadBalancer',
|
||||
'playbook': 'roles/ceph-rgw-loadbalancer/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_dashboard': {
|
||||
'title': 'Install Ceph Dashboard',
|
||||
'playbook': 'roles/ceph-dashboard/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_grafana': {
|
||||
'title': 'Install Ceph Grafana',
|
||||
'playbook': 'roles/ceph-grafana/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_node_exporter': {
|
||||
'title': 'Install Ceph Node Exporter',
|
||||
'playbook': 'roles/ceph-node-exporter/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_crash': {
|
||||
'title': 'Install Ceph Crash',
|
||||
'playbook': 'roles/ceph-crash/tasks/main.yml'
|
||||
},
|
||||
'installer_phase_ceph_exporter': {
|
||||
'title': 'Install Ceph Exporter',
|
||||
'playbook': 'roles/ceph-exporter/tasks/main.yml'
|
||||
},
|
||||
}
|
||||
|
||||
# Find the longest phase title
|
||||
max_column = 0
|
||||
for phase in phase_attributes:
|
||||
max_column = max(max_column, len(phase_attributes[phase]['title']))
|
||||
|
||||
if '_run' in stats.custom:
|
||||
self._display.banner('INSTALLER STATUS')
|
||||
for phase in installer_phases:
|
||||
phase_title = phase_attributes[phase]['title']
|
||||
padding = max_column - len(phase_title) + 2
|
||||
if phase in stats.custom['_run']:
|
||||
phase_status = stats.custom['_run'][phase]['status']
|
||||
phase_time = phase_time_delta(stats.custom['_run'][phase])
|
||||
self._display.display(
|
||||
'{}{}: {} ({})'.format(phase_title, ' ' * padding, phase_status, phase_time),
|
||||
color=self.phase_color(phase_status))
|
||||
if phase_status == 'In Progress' and phase != 'installer_phase_initialize':
|
||||
self._display.display(
|
||||
'\tThis phase can be restarted by running: {}'.format(
|
||||
phase_attributes[phase]['playbook']))
|
||||
|
||||
self._display.display("", screen_only=True)
|
||||
|
||||
def phase_color(self, status):
|
||||
""" Return color code for installer phase"""
|
||||
valid_status = [
|
||||
'In Progress',
|
||||
'Complete',
|
||||
]
|
||||
|
||||
if status not in valid_status:
|
||||
self._display.warning('Invalid phase status defined: {}'.format(status))
|
||||
|
||||
if status == 'Complete':
|
||||
phase_color = C.COLOR_OK
|
||||
elif status == 'In Progress':
|
||||
phase_color = C.COLOR_ERROR
|
||||
else:
|
||||
phase_color = C.COLOR_WARN
|
||||
|
||||
return phase_color
|
||||
|
||||
|
||||
def phase_time_delta(phase):
|
||||
""" Calculate the difference between phase start and end times """
|
||||
time_format = '%Y%m%d%H%M%SZ'
|
||||
phase_start = datetime.strptime(phase['start'], time_format)
|
||||
if 'end' not in phase:
|
||||
# The phase failed so set the end time to now
|
||||
phase_end = datetime.now()
|
||||
else:
|
||||
phase_end = datetime.strptime(phase['end'], time_format)
|
||||
delta = str(phase_end - phase_start).split(".")[0] # Trim microseconds
|
||||
|
||||
return delta
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
''' Loop over nested dictionaries '''
|
||||
|
||||
def dict2dict(self, nested_dict):
|
||||
items = []
|
||||
for key, value in nested_dict.items():
|
||||
for k, v in value.items():
|
||||
items.append(
|
||||
(
|
||||
{'key': key, 'value': value},
|
||||
{'key': k, 'value': v},
|
||||
),
|
||||
)
|
||||
return items
|
||||
|
||||
def filters(self):
|
||||
return {
|
||||
'dict2dict': self.dict2dict
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible import errors
|
||||
|
||||
try:
|
||||
import netaddr
|
||||
except ImportError:
|
||||
# in this case, we'll make the filter return an error message (see bottom)
|
||||
netaddr = None
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
''' IP addresses within IP ranges '''
|
||||
|
||||
def ips_in_ranges(self, ip_addresses, ip_ranges):
|
||||
ips_in_ranges = []
|
||||
for ip_addr in ip_addresses:
|
||||
for ip_range in ip_ranges:
|
||||
if netaddr.IPAddress(ip_addr) in netaddr.IPNetwork(ip_range):
|
||||
ips_in_ranges.append(ip_addr)
|
||||
return ips_in_ranges
|
||||
|
||||
def filters(self):
|
||||
if netaddr:
|
||||
return {
|
||||
'ips_in_ranges': self.ips_in_ranges
|
||||
}
|
||||
else:
|
||||
# Need to install python's netaddr for these filters to work
|
||||
raise errors.AnsibleFilterError(
|
||||
"The ips_in_ranges filter requires python's netaddr be "
|
||||
"installed on the ansible controller.")
|
||||
Reference in New Issue
Block a user