diff --git a/tendrl/ceph_integration/objects/definition/ceph.yaml b/tendrl/ceph_integration/objects/definition/ceph.yaml index bf1edfa61..d507980d6 100644 --- a/tendrl/ceph_integration/objects/definition/ceph.yaml +++ b/tendrl/ceph_integration/objects/definition/ceph.yaml @@ -558,6 +558,170 @@ namespace.ceph: enabled: true value: clusters/$TendrlContext.integration_id/Utilization Osd: + atoms: + MarkDown: + enabled: true + help: mark osd down + inputs: + mandatory: + - Osd.id + name: osd down + run: ceph.objects.Osd.atoms.MarkDown + type: Update + uuid: 112df258-9b24-4fd3-a66f-ee346e2e3832 + MarkIn: + enabled: true + help: mark osd in + inputs: + mandatory: + - Osd.id + name: osd in + run: ceph.objects.Osd.atoms.MarkIn + type: Update + uuid: 112df258-9b24-4fd3-a66f-ee346e2e3833 + MarkOut: + enabled: true + help: mark osd out + inputs: + mandatory: + - Osd.id + name: osd out + run: ceph.objects.Osd.atoms.MarkOut + type: Update + uuid: 112df258-9b24-4fd3-a66f-ee346e2e3834 + Repair: + enabled: true + help: repair osd + inputs: + mandatory: + - Osd.id + name: repair osd + run: ceph.objects.Osd.atoms.Repair + type: Update + uuid: 112df258-9b24-4fd3-a66f-ee346e2e3835 + Reweight: + enabled: true + help: reweight osd + inputs: + mandatory: + - Osd.id + - Osd.weight + name: reweight osd + run: ceph.objects.Osd.atoms.Reweight + type: Update + uuid: 112df258-9b24-4fd3-a66f-ee346e2e3836 + Scrub: + enabled: true + help: scrub osd + inputs: + mandatory: + - Osd.id + name: scrub osd + run: ceph.objects.Osd.atoms.Scrub + type: Update + uuid: 112df258-9b24-4fd3-a66f-ee346e2e3837 + OsdExists: + enabled: true + help: check if osd exists + inputs: + mandatory: + - Osd.id + name: check osd exists + run: ceph.objects.Osd.atoms.OsdExists + type: Get + uuid: 112df258-9b24-4fd3-a66f-ee346e2e3838 + flows: + MarkOsdDown: + tags: + - "tendrl/integration/$TendrlContext.integration_id" + atoms: + - ceph.objects.Osd.atoms.MarkDown + help: mark osd down + enabled: true + inputs: + mandatory: + - Osd.id + pre_run: + - ceph.objects.Osd.atoms.OsdExists + run: ceph.objects.Osd.flows.MarkOsdDown + type: Update + uuid: 1ac41d8f-a0cf-420a-b2fe-18761e07f3b2 + MarkOsdIn: + tags: + - "tendrl/integration/$TendrlContext.integration_id" + atoms: + - ceph.objects.Osd.atoms.MarkIn + help: mark osd in + enabled: true + inputs: + mandatory: + - Osd.id + pre_run: + - ceph.objects.Osd.atoms.OsdExists + run: ceph.objects.Osd.flows.MarkOsdIn + type: Update + uuid: 1ac41d8f-a0cf-420a-b2fe-18761e07f3b3 + MarkOsdOut: + tags: + - "tendrl/integration/$TendrlContext.integration_id" + atoms: + - ceph.objects.Osd.atoms.MarkOut + help: mark osd out + enabled: true + inputs: + mandatory: + - Osd.id + pre_run: + - ceph.objects.Osd.atoms.OsdExists + run: ceph.objects.Osd.flows.MarkOsdOut + type: Update + uuid: 1ac41d8f-a0cf-420a-b2fe-18761e07f3b4 + RepairOsd: + tags: + - "tendrl/integration/$TendrlContext.integration_id" + atoms: + - ceph.objects.Osd.atoms.Repair + help: repair osd + enabled: true + inputs: + mandatory: + - Osd.id + pre_run: + - ceph.objects.Osd.atoms.OsdExists + run: ceph.objects.Osd.flows.RepairOsd + type: Update + uuid: 1ac41d8f-a0cf-420a-b2fe-18761e07f3b5 + ReweightOsd: + tags: + - "tendrl/integration/$TendrlContext.integration_id" + atoms: + - ceph.objects.Osd.atoms.Reweight + help: reweight osd + enabled: true + inputs: + mandatory: + - Osd.id + - Osd.weight + pre_run: + - ceph.objects.Osd.atoms.OsdExists + run: ceph.objects.Osd.flows.ReweightOsd + type: Update + uuid: 1ac41d8f-a0cf-420a-b2fe-18761e07f3b6 + ScrubOsd: + tags: + - "tendrl/integration/$TendrlContext.integration_id" + atoms: + - ceph.objects.Osd.atoms.Scrub + help: scrub osd + enabled: true + inputs: + mandatory: + - Osd.id + pre_run: + - ceph.objects.Osd.atoms.OsdExists + run: ceph.objects.Osd.flows.ScrubOsd + type: Update + uuid: 1ac41d8f-a0cf-420a-b2fe-18761e07f3b7 attrs: id: help: Id of the OSD diff --git a/tendrl/ceph_integration/objects/osd/atoms/__init__.py b/tendrl/ceph_integration/objects/osd/atoms/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tendrl/ceph_integration/objects/osd/atoms/mark_down/__init__.py b/tendrl/ceph_integration/objects/osd/atoms/mark_down/__init__.py new file mode 100644 index 000000000..43764cf8b --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/atoms/mark_down/__init__.py @@ -0,0 +1,51 @@ +from tendrl.ceph_integration import ceph +from tendrl.commons.event import Event +from tendrl.commons.message import Message +from tendrl.commons import objects +from tendrl.commons.objects import AtomExecutionFailedError + + +class MarkDown(objects.BaseAtom): + def __init__(self, *args, **kwargs): + super(MarkDown, self).__init__(*args, **kwargs) + + def run(self): + commands = ['osd', 'down', str(self.parameters['Osd.id'])] + cmd_out = ceph.ceph_command( + NS.tendrl_context.cluster_name, + commands + ) + if cmd_out['status'] != 0: + Event( + Message( + priority="error", + publisher=NS.publisher_id, + payload={ + "message": "Failed to mark OSD.%s as DOWN" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + raise AtomExecutionFaledError( + "Failed to mark OSD.%s as DOWN" % + self.parameters['Osd.id'] + ) + + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Successfully marked OSD.%s DOWN" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + return True diff --git a/tendrl/ceph_integration/objects/osd/atoms/mark_in/__init__.py b/tendrl/ceph_integration/objects/osd/atoms/mark_in/__init__.py new file mode 100644 index 000000000..ac824061a --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/atoms/mark_in/__init__.py @@ -0,0 +1,51 @@ +from tendrl.ceph_integration import ceph +from tendrl.commons.event import Event +from tendrl.commons.message import Message +from tendrl.commons import objects +from tendrl.commons.objects import AtomExecutionFailedError + + +class MarkIn(objects.BaseAtom): + def __init__(self, *args, **kwargs): + super(MarkIn, self).__init__(*args, **kwargs) + + def run(self): + commands = ['osd', 'in', str(self.parameters['Osd.id'])] + cmd_out = ceph.ceph_command( + NS.tendrl_context.cluster_name, + commands + ) + if cmd_out['status'] != 0: + Event( + Message( + priority="error", + publisher=NS.publisher_id, + payload={ + "message": "Failed to mark OSD.%s as IN" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + raise AtomExecutionFaledError( + "Failed to mark OSD.%s as IN" % + self.parameters['Osd.id'] + ) + + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Successfully marked OSD.%s IN" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + return True diff --git a/tendrl/ceph_integration/objects/osd/atoms/mark_out/__init__.py b/tendrl/ceph_integration/objects/osd/atoms/mark_out/__init__.py new file mode 100644 index 000000000..85af869e7 --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/atoms/mark_out/__init__.py @@ -0,0 +1,51 @@ +from tendrl.ceph_integration import ceph +from tendrl.commons.event import Event +from tendrl.commons.message import Message +from tendrl.commons import objects +from tendrl.commons.objects import AtomExecutionFailedError + + +class MarkOut(objects.BaseAtom): + def __init__(self, *args, **kwargs): + super(MarkOut, self).__init__(*args, **kwargs) + + def run(self): + commands = ['osd', 'out', str(self.parameters['Osd.id'])] + cmd_out = ceph.ceph_command( + NS.tendrl_context.cluster_name, + commands + ) + if cmd_out['status'] != 0: + Event( + Message( + priority="error", + publisher=NS.publisher_id, + payload={ + "message": "Failed to mark OSD.%s as OUT" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + raise AtomExecutionFaledError( + "Failed to mark OSD.%s as OUT" % + self.parameters['Osd.id'] + ) + + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Successfully marked OSD.%s OUT" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + return True diff --git a/tendrl/ceph_integration/objects/osd/atoms/osd_exists/__init__.py b/tendrl/ceph_integration/objects/osd/atoms/osd_exists/__init__.py new file mode 100644 index 000000000..a9b3d08da --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/atoms/osd_exists/__init__.py @@ -0,0 +1,45 @@ +import etcd + +from tendrl.commons.event import Event +from tendrl.commons.message import Message +from tendrl.commons import objects + + +class OsdExists(objects.BaseAtom): + def __init__(self, *args, **kwargs): + super(OsdExists, self).__init__(*args, **kwargs) + + def run(self): + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Checking if OSD.%s exists" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + try: + NS.ceph.objects.Osd( + id=self.parameters['Osd.id'] + ).load() + return True + except etcd.EtcdKeyNotFound: + Event( + Message( + priority="error", + publisher=NS.publisher_id, + payload={ + "message": "OSD.%s doesnt exist" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + return False diff --git a/tendrl/ceph_integration/objects/osd/atoms/repair/__init__.py b/tendrl/ceph_integration/objects/osd/atoms/repair/__init__.py new file mode 100644 index 000000000..785c67969 --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/atoms/repair/__init__.py @@ -0,0 +1,51 @@ +from tendrl.ceph_integration import ceph +from tendrl.commons.event import Event +from tendrl.commons.message import Message +from tendrl.commons import objects +from tendrl.commons.objects import AtomExecutionFailedError + + +class Repair(objects.BaseAtom): + def __init__(self, *args, **kwargs): + super(Repair, self).__init__(*args, **kwargs) + + def run(self): + commands = ['osd', 'repair', str(self.parameters['Osd.id'])] + cmd_out = ceph.ceph_command( + NS.tendrl_context.cluster_name, + commands + ) + if cmd_out['status'] != 0: + Event( + Message( + priority="error", + publisher=NS.publisher_id, + payload={ + "message": "Failed to start repair for OSD.%s" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + raise AtomExecutionFaledError( + "Failed to start repair for OSD.%s" % + self.parameters['Osd.id'] + ) + + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Successfully started repair for OSD.%s" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + return True diff --git a/tendrl/ceph_integration/objects/osd/atoms/reweight/__init__.py b/tendrl/ceph_integration/objects/osd/atoms/reweight/__init__.py new file mode 100644 index 000000000..132fa2b63 --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/atoms/reweight/__init__.py @@ -0,0 +1,56 @@ +from tendrl.ceph_integration import ceph +from tendrl.commons.event import Event +from tendrl.commons.message import Message +from tendrl.commons import objects +from tendrl.commons.objects import AtomExecutionFailedError + + +class Reweight(objects.BaseAtom): + def __init__(self, *args, **kwargs): + super(Reweight, self).__init__(*args, **kwargs) + + def run(self): + commands = [ + 'osd', + 'reweight', + str(self.parameters['Osd.id']), + str(self.parameters['Osd.weight']) + ] + cmd_out = ceph.ceph_command( + NS.tendrl_context.cluster_name, + commands + ) + if cmd_out['status'] != 0: + Event( + Message( + priority="error", + publisher=NS.publisher_id, + payload={ + "message": "Failed to start reweight for OSD.%s" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + raise AtomExecutionFaledError( + "Failed to start reweight for OSD.%s" % + self.parameters['Osd.id'] + ) + + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Successfully started reweight for OSD.%s" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + return True diff --git a/tendrl/ceph_integration/objects/osd/atoms/scrub/__init__.py b/tendrl/ceph_integration/objects/osd/atoms/scrub/__init__.py new file mode 100644 index 000000000..ecb6320e0 --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/atoms/scrub/__init__.py @@ -0,0 +1,51 @@ +from tendrl.ceph_integration import ceph +from tendrl.commons.event import Event +from tendrl.commons.message import Message +from tendrl.commons import objects +from tendrl.commons.objects import AtomExecutionFailedError + + +class Scrub(objects.BaseAtom): + def __init__(self, *args, **kwargs): + super(Scrub, self).__init__(*args, **kwargs) + + def run(self): + commands = ['osd', 'scrub', str(self.parameters['Osd.id'])] + cmd_out = ceph.ceph_command( + NS.tendrl_context.cluster_name, + commands + ) + if cmd_out['status'] != 0: + Event( + Message( + priority="error", + publisher=NS.publisher_id, + payload={ + "message": "Failed to start scrub for OSD.%s" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + raise AtomExecutionFaledError( + "Failed to satrt scrub for OSD.%s" % + self.parameters['Osd.id'] + ) + + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Successfully started scrub for OSD.%s" % + self.parameters['Osd.id'], + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + return True diff --git a/tendrl/ceph_integration/objects/osd/flows/__init__.py b/tendrl/ceph_integration/objects/osd/flows/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tendrl/ceph_integration/objects/osd/flows/mark_osd_down/__init__.py b/tendrl/ceph_integration/objects/osd/flows/mark_osd_down/__init__.py new file mode 100644 index 000000000..79c160596 --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/flows/mark_osd_down/__init__.py @@ -0,0 +1,26 @@ +from tendrl.commons.event import Event +from tendrl.commons import flows +from tendrl.commons.message import Message + + +class MarkOsdDown(flows.BaseFlow): + + def __init__(self, *args, **kwargs): + super(MarkOsdDown, self).__init__(*args, **kwargs) + + def run(self): + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Marking the OSD.%s DOWN" % + (self.parameters['Osd.id']) + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + super(MarkOsdDown, self).run() diff --git a/tendrl/ceph_integration/objects/osd/flows/mark_osd_in/__init__.py b/tendrl/ceph_integration/objects/osd/flows/mark_osd_in/__init__.py new file mode 100644 index 000000000..930a2662c --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/flows/mark_osd_in/__init__.py @@ -0,0 +1,26 @@ +from tendrl.commons.event import Event +from tendrl.commons import flows +from tendrl.commons.message import Message + + +class MarkOsdIn(flows.BaseFlow): + + def __init__(self, *args, **kwargs): + super(MarkOsdIn, self).__init__(*args, **kwargs) + + def run(self): + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Marking the OSD.%s IN" % + (self.parameters['Osd.id']) + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + super(MarkOsdIn, self).run() diff --git a/tendrl/ceph_integration/objects/osd/flows/mark_osd_out/__init__.py b/tendrl/ceph_integration/objects/osd/flows/mark_osd_out/__init__.py new file mode 100644 index 000000000..4de6074cd --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/flows/mark_osd_out/__init__.py @@ -0,0 +1,26 @@ +from tendrl.commons.event import Event +from tendrl.commons import flows +from tendrl.commons.message import Message + + +class MarkOsdOut(flows.BaseFlow): + + def __init__(self, *args, **kwargs): + super(MarkOsdOut, self).__init__(*args, **kwargs) + + def run(self): + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Marking the OSD.%s OUT" % + (self.parameters['Osd.id']) + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + super(MarkOsdOut, self).run() diff --git a/tendrl/ceph_integration/objects/osd/flows/repair_osd/__init__.py b/tendrl/ceph_integration/objects/osd/flows/repair_osd/__init__.py new file mode 100644 index 000000000..48e4d1ea6 --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/flows/repair_osd/__init__.py @@ -0,0 +1,26 @@ +from tendrl.commons.event import Event +from tendrl.commons import flows +from tendrl.commons.message import Message + + +class RepairOsd(flows.BaseFlow): + + def __init__(self, *args, **kwargs): + super(RepairOsd, self).__init__(*args, **kwargs) + + def run(self): + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Starting repair of OSD.%s" % + (self.parameters['Osd.id']) + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + super(RepairOsd, self).run() diff --git a/tendrl/ceph_integration/objects/osd/flows/reweight_osd/__init__.py b/tendrl/ceph_integration/objects/osd/flows/reweight_osd/__init__.py new file mode 100644 index 000000000..e5725e652 --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/flows/reweight_osd/__init__.py @@ -0,0 +1,26 @@ +from tendrl.commons.event import Event +from tendrl.commons import flows +from tendrl.commons.message import Message + + +class ReweightOsd(flows.BaseFlow): + + def __init__(self, *args, **kwargs): + super(ReweightOsd, self).__init__(*args, **kwargs) + + def run(self): + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Starting reweight of OSD.%s" % + (self.parameters['Osd.id']) + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + super(ReweightOsd, self).run() diff --git a/tendrl/ceph_integration/objects/osd/flows/scrub_osd/__init__.py b/tendrl/ceph_integration/objects/osd/flows/scrub_osd/__init__.py new file mode 100644 index 000000000..3c5ec8fae --- /dev/null +++ b/tendrl/ceph_integration/objects/osd/flows/scrub_osd/__init__.py @@ -0,0 +1,26 @@ +from tendrl.commons.event import Event +from tendrl.commons import flows +from tendrl.commons.message import Message + + +class ScrubOsd(flows.BaseFlow): + + def __init__(self, *args, **kwargs): + super(ScrubOsd, self).__init__(*args, **kwargs) + + def run(self): + Event( + Message( + priority="info", + publisher=NS.publisher_id, + payload={ + "message": "Starting scrub of OSD.%s" % + (self.parameters['Osd.id']) + }, + job_id=self.parameters['job_id'], + flow_id=self.parameters['flow_id'], + cluster_id=NS.tendrl_context.integration_id, + ) + ) + + super(ScrubOsd, self).run()