Skip to content

Commit

Permalink
WIP - Added flows and atoms for OSD operations
Browse files Browse the repository at this point in the history
tendrl-bug-id: Tendrl#289
Signed-off-by: Shubhendu <[email protected]>
  • Loading branch information
Shubhendu committed Jun 15, 2017
1 parent fb08c0c commit 0afde72
Show file tree
Hide file tree
Showing 16 changed files with 676 additions and 0 deletions.
164 changes: 164 additions & 0 deletions tendrl/ceph_integration/objects/definition/ceph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file.
51 changes: 51 additions & 0 deletions tendrl/ceph_integration/objects/osd/atoms/mark_down/__init__.py
Original file line number Diff line number Diff line change
@@ -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
51 changes: 51 additions & 0 deletions tendrl/ceph_integration/objects/osd/atoms/mark_in/__init__.py
Original file line number Diff line number Diff line change
@@ -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
51 changes: 51 additions & 0 deletions tendrl/ceph_integration/objects/osd/atoms/mark_out/__init__.py
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions tendrl/ceph_integration/objects/osd/atoms/osd_exists/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 0afde72

Please sign in to comment.