Cleanups.

This commit is contained in:
Alberto Donato 2015-08-14 09:34:34 +03:00
parent 005bffd44f
commit d22f37968c
3 changed files with 17 additions and 7 deletions

View File

@ -7,8 +7,13 @@ from charmhelpers.core import hookenv, host
from hooks.keystone_utils import determine_services
def pause_service(service):
result = host.service_pause(service)
if not result:
hookenv.action_fail("Failed to pause service {}.".format(service))
return result
if __name__ == "__main__":
for service in determine_services():
if not host.service_pause(service):
hookenv.action_fail("Failed to pause service {}.".format(service))
if not pause_service(service):
sys.exit(-1)

View File

@ -7,8 +7,13 @@ from charmhelpers.core import hookenv, host
from hooks.keystone_utils import determine_services
def resume_service(service):
result = host.service_resume(service)
if not result:
hookenv.action_fail("Failed to resume service {}.".format(service))
return result
if __name__ == "__main__":
for service in determine_services():
if not host.service_resume(service):
hookenv.action_fail("Failed to resume service {}.".format(service))
if not resume_service(service):
sys.exit(-1)

View File

@ -13,7 +13,7 @@ from charmhelpers.contrib.openstack.amulet.deployment import (
class PauseResume(OpenStackAmuletDeployment):
KEYSTONE_SERVICES = ("keystone", "apache2", "haproxy")
SERVICES = ("keystone", "apache2", "haproxy")
def __init__(self, series=None, openstack=None,
source=None, stable=False):
@ -28,7 +28,7 @@ class PauseResume(OpenStackAmuletDeployment):
def is_keystone_running(self, unit):
"""Return whether services on the keystone unit are running."""
running = []
for service in self.KEYSTONE_SERVICES:
for service in self.SERVICES:
_, code = unit.run(
"service {} status | grep -q running".format(service))
running.append(code == 0)
@ -42,7 +42,7 @@ class PauseResume(OpenStackAmuletDeployment):
init_contents = unit.directory_contents("/etc/init/")
return {
service: "{}.override".format(service) in init_contents["files"]
for service in self.KEYSTONE_SERVICES}
for service in self.SERVICES}
def _add_services(self):
super(PauseResume, self)._add_services({"name": "keystone"}, [])