forked from Tendrl/ceph-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - Added flows and atoms for OSD operations
tendrl-bug-id: Tendrl#289 Signed-off-by: Shubhendu <[email protected]>
- Loading branch information
Shubhendu
committed
Jun 15, 2017
1 parent
fb08c0c
commit 0afde72
Showing
16 changed files
with
676 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
51 changes: 51 additions & 0 deletions
51
tendrl/ceph_integration/objects/osd/atoms/mark_down/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
51
tendrl/ceph_integration/objects/osd/atoms/mark_in/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
51
tendrl/ceph_integration/objects/osd/atoms/mark_out/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
45
tendrl/ceph_integration/objects/osd/atoms/osd_exists/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.