Add pause/resume actions.
This commit is contained in:
parent
208b628467
commit
88f263f98b
1
actions/charmhelpers
Symbolic link
1
actions/charmhelpers
Symbolic link
@ -0,0 +1 @@
|
||||
../charmhelpers
|
20
actions/pause
Executable file
20
actions/pause
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/python
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from charmhelpers.core import hookenv
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
subprocess.check_call(["/usr/sbin/service", "mysql", "stop"])
|
||||
except (OSError, subprocess.CalledProcessError), e:
|
||||
hookenv.action_fail("Failed to stop service mysql. %s" % e)
|
||||
sys.exit(-1)
|
||||
try:
|
||||
override_file = open('/etc/init/mysql.override', 'w')
|
||||
except IOError, e:
|
||||
hookenv.action_fail(
|
||||
"Error creating override file: %s\n" % e)
|
||||
sys.exit(-2)
|
||||
override_file.write("manual\n")
|
||||
override_file.close()
|
26
actions/resume
Executable file
26
actions/resume
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from charmhelpers.core import hookenv
|
||||
|
||||
if __name__ == "__main__":
|
||||
override_path = '/etc/init/mysql.override'
|
||||
if os.path.exists(override_path):
|
||||
try:
|
||||
os.remove(override_path)
|
||||
except OSError, e:
|
||||
hookenv.action_fail(
|
||||
"Error removing override file: %s\n" % e)
|
||||
sys.exit(-1)
|
||||
else:
|
||||
print "No override file."
|
||||
|
||||
try:
|
||||
subprocess.check_call(["/usr/sbin/service", "mysql", "start"])
|
||||
except subprocess.CalledProcessError, e:
|
||||
hookenv.action_fail("Failed to start service mysql. %s" % e)
|
||||
sys.exit(-2)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user