Merge pull request #119 from dreamhost/distro-work-libvirt-rabbit-956265

move libvirt and rabbitmq commands to yaml file
This commit is contained in:
Joshua Harlow 2012-03-19 12:49:33 -07:00
commit 928ece372b
5 changed files with 36 additions and 31 deletions

View File

@ -31,6 +31,17 @@ commands:
grant_all: ["mysql", "--user=%USER%", "--password=%PASSWORD%", '-e',
"\"GRANT ALL PRIVILEGES ON *.* TO '%USER%'@'%' IDENTIFIED BY '%PASSWORD%'; FLUSH PRIVILEGES;\""]
libvirt:
restart: ['service', 'libvirtd', 'restart']
status: ['service', 'libvirtd', 'status']
rabbit-mq:
start: ['service', "rabbitmq-server", "start"]
stop: ['service', "rabbitmq-server", "stop"]
status: ['service', "rabbitmq-server", "status"]
restart: ['service', "rabbitmq-server", "restart"]
change_password: ['rabbitmqctl', 'change_password', 'guest']
components:
db:
@ -459,7 +470,7 @@ components:
removable: True
version: 1.12*
rabbitmq:
rabbit-mq:
packages:
- name: rabbitmq-server
pre-install:

View File

@ -33,7 +33,6 @@ commands:
- service
- libvirtd
- status
libvirt-daemon: libvirtd
mysql:
# NOTE: we aren't stopping any sql injection...
create_db:
@ -79,6 +78,14 @@ commands:
- mysqld
- stop
pip: pip-python
rabbit-mq:
start: ['service', "rabbitmq-server", "start"]
stop: ['service', "rabbitmq-server", "stop"]
status: ['service', "rabbitmq-server", "status"]
restart: ['service', "rabbitmq-server", "restart"]
change_password: ['rabbitmqctl', 'change_password', 'guest']
components:
db:
install: devstack.distros.rhel6:DBInstaller

View File

@ -49,7 +49,6 @@ commands:
- service
- libvirt-bin
- status
libvirt-daemon: libvirt-bin
mysql:
# NOTE: we aren't stopping any sql injection...
create_db:
@ -95,6 +94,13 @@ commands:
- mysql
- stop
pip: pip
rabbit-mq:
start: ['service', "rabbitmq-server", "start"]
stop: ['service', "rabbitmq-server", "stop"]
status: ['service', "rabbitmq-server", "status"]
restart: ['service', "rabbitmq-server", "restart"]
change_password: ['rabbitmqctl', 'change_password', 'guest']
components:
db:
install: devstack.distros.oneiric:DBInstaller

View File

@ -23,13 +23,6 @@ from devstack import shell as sh
LOG = logging.getLogger("devstack.components.rabbit")
# So far these are distro independent..
START_CMD = ['service', "rabbitmq-server", "start"]
STOP_CMD = ['service', "rabbitmq-server", "stop"]
STATUS_CMD = ['service', "rabbitmq-server", "status"]
RESTART_CMD = ['service', "rabbitmq-server", "restart"]
PWD_CMD = ['rabbitmqctl', 'change_password', 'guest']
# Default password (guest)
RESET_BASE_PW = ''
@ -52,7 +45,7 @@ class RabbitUninstaller(comp.PkgUninstallComponent):
try:
self.runtime.restart()
LOG.info("Attempting to reset the rabbit-mq guest password to \"%s\"", RESET_BASE_PW)
cmd = PWD_CMD + [RESET_BASE_PW]
cmd = self.distro.get_command('rabbit-mq', 'change_password') + [RESET_BASE_PW]
sh.execute(*cmd, run_as_root=True)
except IOError:
LOG.warn(("Could not reset the rabbit-mq password. You might have to manually "
@ -72,7 +65,7 @@ class RabbitInstaller(comp.PkgInstallComponent):
LOG.info("Setting up your rabbit-mq guest password.")
self.runtime.restart()
passwd = self.pw_gen.get_password("rabbit", PW_USER_PROMPT)
cmd = PWD_CMD + [passwd]
cmd = self.distro.get_command('rabbit-mq', 'change_password') + [passwd]
sh.execute(*cmd, run_as_root=True)
LOG.info("Restarting so that your rabbit-mq guest password is reflected.")
self.runtime.restart()
@ -88,7 +81,7 @@ class RabbitRuntime(comp.EmptyRuntime):
def start(self):
if self.status() != comp.STATUS_STARTED:
self._run_cmd(START_CMD)
self._run_cmd(self.distro.get_command('rabbit-mq', 'start'))
return 1
else:
return 0
@ -97,7 +90,8 @@ class RabbitRuntime(comp.EmptyRuntime):
# This has got to be the worst status output.
#
# I have ever seen (its like a weird mix json+crap)
run_result = sh.execute(*STATUS_CMD,
run_result = sh.execute(
*self.distro.get_command('rabbit-mq', 'status'),
check_exit_code=False,
run_as_root=True)
if not run_result:
@ -129,14 +123,14 @@ class RabbitRuntime(comp.EmptyRuntime):
def restart(self):
LOG.info("Restarting rabbit-mq.")
self._run_cmd(RESTART_CMD)
self._run_cmd(self.distro.get_command('rabbit-mq', 'restart'))
LOG.info("Please wait %s seconds while it starts up." % (WAIT_ON_TIME))
sh.sleep(WAIT_ON_TIME)
return 1
def stop(self):
if self.status() != comp.STATUS_STOPPED:
self._run_cmd(STOP_CMD)
self._run_cmd(self.distro.get_command('rabbit-mq', 'stop'))
return 1
else:
return 0

View File

@ -32,19 +32,6 @@ LIBVIRT_PROTOCOL_MAP = {
}
VIRT_LIB = 'libvirt'
# #distros name the libvirt service differently :-(
# SV_NAME_MAP = {
# settings.RHEL6: 'libvirtd',
# settings.FEDORA16: 'libvirtd',
# settings.UBUNTU11: 'libvirt-bin',
# }
# #how libvirt is restarted
# LIBVIRT_RESTART_CMD = ['service', '%SERVICE%', 'restart']
# #how we check its status
# LIBVIRT_STATUS_CMD = ['service', '%SERVICE%', 'status']
# This is just used to check that libvirt will work with
# a given protocol, may not be ideal but does seem to crap
# out if it won't work, so thats good...