Initial pause action

This commit is contained in:
Adam Collard 2015-07-17 11:43:48 +01:00
parent d96c05237d
commit 211de2f3d0
2 changed files with 39 additions and 0 deletions

38
actions/actions.py Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/python
import argparse
import os
import sys
import yaml
def get_action_parser(actions_yaml_path, action_name):
with open(actions_yaml_path) as fh:
doc = yaml.load(fh)[action_name]["description"]
parser = argparse.ArgumentParser(doc)
# TODO: Add arguments for params defined in the actions.yaml
return parser
def pause(args):
from swift_storage_utils import SWIFT_SVCS
from charmhelpers.core.host import service_pause
for service in SWIFT_SVCS:
service_pause(service)
def main(argv):
cwd, action_name = os.path.split(__file__)
actions_yaml_path = os.path.join(cwd, "..", "actions.yaml")
parser = get_action_parser(actions_yaml_path, action_name)
args = parser.parse_args(argv)
try:
action = globals()[action_name]
except AttributeError:
return "Action %s undefined" % action_name
else:
return action(args)
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))

1
actions/pause Symbolic link
View File

@ -0,0 +1 @@
actions.py