Switch all of the commands in YAML files to simple strings and

parse them into lists in the code that fetches commands from
the config.
This commit is contained in:
Doug Hellmann 2012-03-21 11:23:09 -04:00
parent 462eee3a99
commit cefd378401
9 changed files with 583 additions and 724 deletions

View File

@ -1,522 +1,498 @@
# Fedora 16
---
name: fedora-16
distro_pattern: fedora-16
packager_name: devstack.packaging.yum:YumPackager
commands:
pip: python-pip
apache:
restart: ["service", "httpd", "restart"]
start: ["service", "httpd", "start"]
stop: ["service", "httpd", "stop"]
status: ["service", "httpd", "status"]
restart: service httpd restart
settings:
#ensure runs after wsgi.conf (naming wise)
conf-link-target: /etc/httpd/conf.d/wsgi-horizon-000-default.conf
mysql:
start: ["service", "mysql", 'start']
stop: ["service", 'mysql', "stop"]
status: ["service", 'mysql', "status"]
restart: ["service", 'mysql', "restart"]
#NOTE: we aren't stopping any sql injection...
set_pwd: ['mysql', '--user=%USER%', '--password=%OLD_PASSWORD%', '-e',
"\"USE mysql; UPDATE user SET password=PASSWORD('%NEW_PASSWORD%') WHERE User='%USER%'; FLUSH PRIVILEGES;\""]
create_db: ['mysql', '--user=%USER%', '--password=%PASSWORD%', '-e', 'CREATE DATABASE %DB%;']
drop_db: ['mysql', '--user=%USER%', '--password=%PASSWORD%', '-e', 'DROP DATABASE IF EXISTS %DB%;']
grant_all: ["mysql", "--user=%USER%", "--password=%PASSWORD%", '-e',
"\"GRANT ALL PRIVILEGES ON *.* TO '%USER%'@'%' IDENTIFIED BY '%PASSWORD%'; FLUSH PRIVILEGES;\""]
start: service httpd start
status: service httpd status
stop: service httpd stop
git:
checkout:
- git
- checkout
clone:
- git
- clone
pull:
- git
- pull
checkout: git checkout
clone: git clone
pull: git pull
libvirt:
restart: ['service', 'libvirtd', 'restart']
status: ['service', 'libvirtd', 'status']
restart: service libvirtd restart
status: service libvirtd status
mysql:
create_db: mysql --user=%USER% --password=%PASSWORD% -e "CREATE DATABASE %DB%;"
drop_db: mysql --user=%USER% --password=%PASSWORD% -e "DROP DATABASE IF EXISTS
%DB%;"
grant_all: mysql --user=%USER% --password=%PASSWORD% -e "GRANT ALL PRIVILEGES
ON *.* TO '%USER%'@'%' IDENTIFIED BY '%PASSWORD%'; FLUSH PRIVILEGES;"
restart: service mysqld restart
set_pwd: mysql --user=%USER% --password=%OLD_PASSWORD% -e "USE mysql; UPDATE
user SET password=PASSWORD('%NEW_PASSWORD%') WHERE User='%USER%'; FLUSH
PRIVILEGES;"
start: service mysqld start
status: service mysqld status
stop: service mysqld stop
pip: python-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']
change_password: rabbitmqctl change_password guest
restart: service rabbitmq-server restart
start: service rabbitmq-server start
status: service rabbitmq-server status
stop: service rabbitmq-server stop
components:
db:
packages:
- name: mysql
removable: True
removable: true
version: 5.5*
- name: mysql-server
removable: True
removable: true
version: 5.5*
general:
packages:
- name: curl
removable: False
removable: false
version: 7.21.7*
- name: euca2ools
removable: False
removable: false
version: 1.3.1*
- name: gawk
removable: False
removable: false
version: 4.0*
- name: git
removable: False
removable: false
version: 1.7*
- name: iputils
removable: False
removable: false
version: 20101006*
- name: libxml2-devel
removable: False
removable: false
version: 2.7*
- name: libxslt-devel
removable: False
removable: false
version: 1.1.26*
- name: lsof
removable: False
removable: false
version: 4.84*
- name: mlocate
removable: False
removable: false
version: 0.24*
- name: openssh-server
removable: False
removable: false
version: 5.8*
- name: psmisc
removable: False
removable: false
version: 22.13*
- name: pylint
removable: False
removable: false
version: 0.24*
- name: python
removable: False
removable: false
version: 2.7*
- name: python-coverage
removable: False
removable: false
version: 3.5*
- name: python-devel
removable: False
removable: false
version: 2.7*
- name: python-distutils-extra
removable: False
removable: false
version: 2.29*
- name: python-mox
removable: False
removable: false
version: 0.5.3*
- name: python-nose
removable: False
removable: false
version: 1.1*
- name: python-pep8
removable: False
removable: false
version: 0.6*
- name: python-pip
removable: False
removable: false
version: 0.8*
- name: python-setuptools
removable: False
removable: false
version: 0.6.24*
- name: python-unittest2
removable: False
removable: false
version: 0.5.1*
- name: python-virtualenv
removable: False
removable: false
version: 1.7*
- name: screen
removable: False
removable: false
version: 4.1.0*
- name: sudo
removable: False
removable: false
version: 1.8.3*
- name: tcpdump
removable: False
removable: false
version: 4.1*
- name: unzip
removable: False
removable: false
version: 6.0*
- name: wget
removable: False
removable: false
version: 1.12*
glance:
packages:
- name: MySQL-python
removable: True
removable: true
version: 1.2*
- name: python-argparse
removable: True
removable: true
version: 1.1*
- name: python-dateutil
removable: True
removable: true
version: 1.5*
- name: python-eventlet
removable: True
removable: true
version: 0.9*
- name: python-greenlet
removable: True
removable: true
version: 0.3.1*
- name: python-httplib2
removable: True
removable: true
version: 0.6*
- name: python-prettytable
removable: True
removable: true
version: 0.5*
- name: python-routes
removable: True
removable: true
version: 1.12*
- name: pyxattr
removable: True
removable: true
version: 0.5*
horizon:
packages:
- name: Django
removable: True
removable: true
version: 1.3*
- name: django-registration
removable: True
removable: true
version: 0.7*
- name: httpd
removable: True
removable: true
version: 2.2*
- name: mod_wsgi
removable: True
removable: true
version: 3.3*
- name: python-cherrypy
removable: True
removable: true
version: 3.2*
- name: python-cloudfiles
removable: True
removable: true
version: 1.7.9*
- name: python-dateutil
removable: True
removable: true
version: 1.5*
- name: python-eventlet
removable: True
removable: true
version: 0.9*
- name: python-kombu
removable: True
removable: true
version: 1.1*
- name: python-migrate
removable: True
removable: true
version: 0.7*
- name: python-paste
removable: True
removable: true
version: 1.7.5*
- name: python-paste-deploy
removable: True
removable: true
version: 1.5.0*
- name: python-routes
removable: True
removable: true
version: 1.12*
- name: python-sphinx
removable: True
removable: true
version: 1.0.7*
- name: python-sqlalchemy
removable: True
removable: true
version: 0.7*
- name: python-webob
removable: True
removable: true
version: 1.0*
- name: pyxattr
removable: True
removable: true
version: 0.5*
keystone-client:
packages:
- name: python-argparse
removable: True
version: 1.1*
- name: python-prettytable
removable: True
version: 0.5*
keystone:
packages:
- name: MySQL-python
removable: True
removable: true
version: 1.2*
- name: cyrus-sasl-lib
removable: False
removable: false
version: 2.1*
- name: openldap
removable: False
removable: false
version: 2.4*
- name: python-argparse
removable: True
removable: true
version: 1.1*
- name: python-eventlet
removable: True
removable: true
version: 0.9*
- name: python-greenlet
removable: True
removable: true
version: 0.3.1*
- name: python-lxml
removable: True
removable: true
version: 2.3*
- name: python-migrate
removable: True
removable: true
version: 0.7*
- name: python-passlib
removable: True
removable: true
version: 1.5*
- name: python-paste
removable: True
removable: true
version: 1.7.5*
- name: python-paste-deploy
removable: True
removable: true
version: 1.5*
- name: python-paste-script
removable: True
removable: true
version: 1.7*
- name: python-prettytable
removable: True
removable: true
version: 0.5*
- name: python-routes
removable: True
removable: true
version: 1.12*
- name: python-sqlalchemy
removable: True
removable: true
version: 0.7*
- name: python-sqlite2
removable: True
removable: true
version: 2.3*
- name: python-webob
removable: True
removable: true
version: 1.0*
- name: sqlite
removable: False
removable: false
version: 3.7*
melange:
keystone-client:
packages:
- name: python-argparse
removable: true
version: 1.1*
- name: python-prettytable
removable: true
version: 0.5*
melange:
packages: null
n-api:
packages:
- name: python-dateutil
removable: False
removable: false
version: 1.5*
n-cpu:
packages:
- name: iscsi-initiator-utils
removable: True
removable: true
version: 6.2*
- name: libvirt
removable: True
removable: true
version: 0.9.6*
- name: libvirt-client
removable: True
removable: true
version: 0.9.6*
- name: libvirt-python
removable: True
removable: true
version: 0.9.6*
- name: lvm2
removable: True
removable: true
version: 2.02*
- name: qemu-img
removable: True
removable: true
version: 0.15*
- name: qemu-system-x86
removable: True
removable: true
version: 0.15*
n-vnc:
packages:
- name: numpy
removable: True
removable: true
version: 1.6*
n-vol:
packages:
- name: iscsi-initiator-utils
removable: True
removable: true
version: 6.2*
- name: lvm2
removable: True
removable: true
version: 2.02*
- name: scsi-target-utils
removable: True
removable: true
version: 1.0*
nova-client:
packages:
- name: python-argparse
removable: True
version: 1.1*
- name: python-prettytable
removable: True
version: 0.5*
nova:
packages:
- name: MySQL-python
removable: True
removable: true
version: 1.2*
- name: dnsmasq
removable: False
removable: false
version: 2.58*
- name: ebtables
removable: False
removable: false
version: 2.0*
- name: iptables
removable: False
removable: false
version: 1.4*
- name: iputils
removable: False
removable: false
version: 20101006*
- name: kpartx
removable: False
removable: false
version: 0.4*
- name: libxml2-python
removable: False
removable: false
version: 2.7*
- name: parted
removable: False
removable: false
version: 3.0*
- name: python-boto
removable: True
removable: true
version: 2.0*
- name: python-carrot
removable: True
removable: true
version: 0.10*
- name: python-cheetah
removable: True
removable: true
version: 2.4*
- name: python-crypto
removable: False
removable: false
version: 2.3*
- name: python-eventlet
removable: True
removable: true
version: 0.9*
- name: python-feedparser
removable: True
removable: true
version: 5.0*
- name: python-gflags
removable: True
removable: true
version: 1.5*
- name: python-greenlet
removable: True
removable: true
version: 0.3.1*
- name: python-kombu
removable: True
removable: true
version: 1.1*
- name: python-lockfile
removable: True
removable: true
version: 0.9*
- name: python-lxml
removable: True
removable: true
version: 2.3*
- name: python-netaddr
removable: True
removable: true
version: 0.7*
- name: python-paste
removable: True
removable: true
version: 1.7.5*
- name: python-routes
removable: True
removable: true
version: 1.12*
- name: python-suds
removable: True
removable: true
version: 0.4*
- name: pyxattr
removable: True
removable: true
version: 0.5*
- name: socat
removable: True
removable: true
version: 1.7*
- name: sqlite
removable: False
removable: false
version: 3.7*
quantum-client:
nova-client:
packages:
- name: python-gflags
removable: True
version: 1.5*
quantum-openvswitch:
packages:
- name: MySQL-python
removable: True
version: 1.2*
- name: python-sqlalchemy
removable: True
version: 0.7*
- name: python-argparse
removable: true
version: 1.1*
- name: python-prettytable
removable: true
version: 0.5*
quantum:
packages:
- name: python-eventlet
removable: True
removable: true
version: 0.9*
- name: python-gflags
removable: True
removable: true
version: 1.5*
- name: python-greenlet
removable: True
removable: true
version: 0.3*
- name: python-lxml
removable: True
removable: true
version: 2.3*
- name: python-paste
removable: True
removable: true
version: 1.7*
- name: python-paste-deploy
removable: True
removable: true
version: 1.5*
- name: python-routes
removable: True
removable: true
version: 1.12*
quantum-client:
packages:
- name: python-gflags
removable: true
version: 1.5*
quantum-openvswitch:
packages:
- name: MySQL-python
removable: true
version: 1.2*
- name: python-sqlalchemy
removable: true
version: 0.7*
rabbit-mq:
packages:
- name: rabbitmq-server
pre-install:
- cmd: ['service', 'qpidd', 'stop']
run_as_root: True
- cmd: ['chkconfig', 'qpidd', 'off']
run_as_root: True
ignore_failure: True
removable: True
- cmd:
- service
- qpidd
- stop
run_as_root: true
- cmd:
- chkconfig
- qpidd
- 'off'
ignore_failure: true
run_as_root: true
removable: true
version: 2.6*
swift:
packages:
- name: memcached
removable: True
removable: true
version: 1.4*
- name: python-configobj
removable: True
removable: true
version: 4.7*
- name: python-eventlet
removable: True
removable: true
version: 0.9*
- name: python-greenlet
removable: True
removable: true
version: 0.3*
- name: python-netifaces
removable: True
removable: true
version: 0.5*
- name: python-paste-deploy
removable: True
removable: true
version: 1.5*
- name: python-webob
removable: True
removable: true
version: 1.0*
- name: pyxattr
removable: True
removable: true
version: 0.5*
- name: sqlite
removable: True
removable: true
version: 3.7*
packager_name: devstack.packaging.yum:YumPackager
...

View File

@ -1,101 +1,42 @@
---
# RedHat Enterprise Linux 6
distro_pattern: redhat-6(.*)
name: rhel-6
packager_name: devstack.distros.rhel6:YumPackager
distro_pattern: redhat-6(.*)
commands:
apache:
restart:
- service
- httpd
- restart
restart: service httpd restart
settings:
# Ensure runs after wsgi.conf (file naming wise)
conf-link-target: /etc/httpd/conf.d/wsgi-horizon-000-default.conf
start:
- service
- httpd
- start
status:
- service
- httpd
- status
stop:
- service
- httpd
- stop
start: service httpd start
status: service httpd status
stop: service httpd stop
git:
checkout:
- git
- checkout
clone:
- git
- clone
pull:
- git
- pull
checkout: git checkout
clone: git clone
pull: git pull
libvirt:
restart:
- service
- libvirtd
- restart
status:
- service
- libvirtd
- status
restart: service libvirtd restart
status: service libvirtd status
mysql:
# NOTE: we aren't stopping any sql injection...
create_db:
- mysql
- --user=%USER%
- --password=%PASSWORD%
- -e
- CREATE DATABASE %DB%;
drop_db:
- mysql
- --user=%USER%
- --password=%PASSWORD%
- -e
- DROP DATABASE IF EXISTS %DB%;
grant_all:
- mysql
- --user=%USER%
- --password=%PASSWORD%
- -e
- '"GRANT ALL PRIVILEGES ON *.* TO ''%USER%''@''%'' IDENTIFIED BY ''%PASSWORD%'';
FLUSH PRIVILEGES;"'
restart:
- service
- mysqld
- restart
set_pwd:
- mysql
- --user=%USER%
- --password=%OLD_PASSWORD%
- -e
- '"USE mysql; UPDATE user SET password=PASSWORD(''%NEW_PASSWORD%'') WHERE
User=''%USER%''; FLUSH PRIVILEGES;"'
start:
- service
- mysqld
- start
status:
- service
- mysqld
- status
stop:
- service
- mysqld
- stop
create_db: mysql --user=%USER% --password=%PASSWORD% -e "CREATE DATABASE %DB%;"
drop_db: mysql --user=%USER% --password=%PASSWORD% -e "DROP DATABASE IF EXISTS
%DB%;"
grant_all: mysql --user=%USER% --password=%PASSWORD% -e "GRANT ALL PRIVILEGES
ON *.* TO '%USER%'@'%' IDENTIFIED BY '%PASSWORD%'; FLUSH PRIVILEGES;"
restart: service mysqld restart
set_pwd: mysql --user=%USER% --password=%OLD_PASSWORD% -e "USE mysql; UPDATE
user SET password=PASSWORD('%NEW_PASSWORD%') WHERE User='%USER%'; FLUSH
PRIVILEGES;"
start: service mysqld start
status: service mysqld status
stop: service 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']
change_password: rabbitmqctl change_password guest
restart: service rabbitmq-server restart
start: service rabbitmq-server start
status: service rabbitmq-server status
stop: service rabbitmq-server stop
components:
db:
install: devstack.distros.rhel6:DBInstaller
@ -702,5 +643,6 @@ components:
start: devstack.components.swift:SwiftRuntime
stop: devstack.components.swift:SwiftRuntime
uninstall: devstack.components.swift:SwiftUninstaller
packager_name: devstack.distros.rhel6:YumPackager
...

View File

@ -5,111 +5,41 @@ name: ubuntu-oneiric
packager_name: devstack.distros.oneiric:AptPackager
commands:
apache:
restart:
- service
- apache2
- restart
restart: service apache2 restart
settings:
conf-link-target: /etc/apache2/sites-enabled/000-default
start:
- service
- apache2
- start
status:
- service
- apache2
- status
stop:
- service
- apache2
- stop
start: service apache2 start
status: service apache2 status
stop: service apache2 stop
git:
checkout:
- git
- checkout
clone:
- git
- clone
pull:
- git
- pull
checkout: git checkout
clone: git clone
pull: git pull
iscsi:
restart:
- service
- tgt
- restart
start:
- service
- tgt
- start
status:
- service
- tgt
- status
stop:
- service
- tgt
- stop
restart: service tgt restart
start: service tgt start
status: service tgt status
stop: service tgt stop
libvirt:
restart:
- service
- libvirt-bin
- restart
status:
- service
- libvirt-bin
- status
restart: service libvirt-bin restart
status: service libvirt-bin status
mysql:
# NOTE: we aren't stopping any sql injection...
create_db:
- mysql
- --user=%USER%
- --password=%PASSWORD%
- -e
- CREATE DATABASE %DB%;
drop_db:
- mysql
- --user=%USER%
- --password=%PASSWORD%
- -e
- DROP DATABASE IF EXISTS %DB%;
grant_all:
- mysql
- --user=%USER%
- --password=%PASSWORD%
- -e
- '"GRANT ALL PRIVILEGES ON *.* TO ''%USER%''@''%'' IDENTIFIED BY ''%PASSWORD%'';
FLUSH PRIVILEGES;"'
restart:
- service
- mysql
- restart
set_pwd:
- mysql
- --user=%USER%
- --password=%OLD_PASSWORD%
- -e
- '"USE mysql; UPDATE user SET password=PASSWORD(''%NEW_PASSWORD%'') WHERE
User=''%USER%''; FLUSH PRIVILEGES;"'
start:
- service
- mysql
- start
status:
- service
- mysql
- status
stop:
- service
- mysql
- stop
create_db: mysql --user=%USER% --password=%PASSWORD% -e "CREATE DATABASE %DB%;"
drop_db: mysql --user=%USER% --password=%PASSWORD% -e "DROP DATABASE IF EXISTS %DB%;"
grant_all: mysql --user=%USER% --password=%PASSWORD% -e "GRANT ALL PRIVILEGES ON *.* TO '%USER%'@'%' IDENTIFIED BY '%PASSWORD%'; FLUSH PRIVILEGES;"
restart: service mysql restart
set_pwd: mysql --user=%USER% --password=%OLD_PASSWORD% -e "USE mysql; UPDATE user SET password=PASSWORD('%NEW_PASSWORD%') WHERE User='%USER%'; FLUSH PRIVILEGES;"
start: service mysql start
status: service mysql status
stop: service 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']
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:

View File

@ -53,12 +53,12 @@ class DBUninstaller(comp.PkgUninstallComponent):
def pre_uninstall(self):
dbtype = self.cfg.get("db", "type")
dbactions = self.distro.get_command(dbtype, quiet=True)
dbactions = self.distro.get_command_config(dbtype, quiet=True)
try:
if dbactions:
LOG.info(("Attempting to reset your db password to \"%s\" so"
" that we can set it the next time you install.") % (RESET_BASE_PW))
pwd_cmd = dbactions.get('set_pwd')
pwd_cmd = self.distro.get_command(dbtype, 'set_pwd')
if pwd_cmd:
LOG.info("Ensuring your database is started before we operate on it.")
self.runtime.restart()
@ -68,7 +68,7 @@ class DBUninstaller(comp.PkgUninstallComponent):
'USER': self.cfg.getdefaulted("db", "sql_user", 'root'),
}
cmds = [{'cmd': pwd_cmd}]
utils.execute_template(*cmds, params=params, shell=True)
utils.execute_template(*cmds, params=params)
except IOError:
LOG.warn(("Could not reset the database password. You might have to manually "
"reset the password to \"%s\" before the next install") % (RESET_BASE_PW))
@ -111,12 +111,12 @@ class DBInstaller(comp.PkgInstallComponent):
# Extra actions to ensure we are granted access
dbtype = self.cfg.get("db", "type")
dbactions = self.distro.get_command(dbtype, quiet=True)
dbactions = self.distro.get_command_config(dbtype, quiet=True)
# Set your password
try:
if dbactions:
pwd_cmd = dbactions.get('set_pwd')
pwd_cmd = self.distro.get_command(dbtype, 'set_pwd')
if pwd_cmd:
LOG.info(("Attempting to set your db password"
" just incase it wasn't set previously."))
@ -128,14 +128,14 @@ class DBInstaller(comp.PkgInstallComponent):
'OLD_PASSWORD': RESET_BASE_PW,
}
cmds = [{'cmd': pwd_cmd}]
utils.execute_template(*cmds, params=params, shell=True)
utils.execute_template(*cmds, params=params)
except IOError:
LOG.warn(("Couldn't set your db password. It might have already been "
"set by a previous process."))
# Ensure access granted
if dbactions:
grant_cmd = dbactions.get('grant_all')
grant_cmd = self.distro.get_command(dbtype, 'grant_all')
if grant_cmd:
user = self.cfg.getdefaulted("db", "sql_user", 'root')
LOG.info("Updating the DB to give user '%s' full control of all databases." % (user))
@ -148,7 +148,7 @@ class DBInstaller(comp.PkgInstallComponent):
cmds = [{'cmd': grant_cmd}]
# Shell seems to be needed here
# since python escapes this to much...
utils.execute_template(*cmds, params=params, shell=True)
utils.execute_template(*cmds, params=params)
class DBRuntime(comp.EmptyRuntime):
@ -158,11 +158,11 @@ class DBRuntime(comp.EmptyRuntime):
def _get_run_actions(self, act, exception_cls):
dbtype = self.cfg.get("db", "type")
distro_options = self.distro.get_command(dbtype)
distro_options = self.distro.get_command_config(dbtype)
if distro_options is None:
msg = BASE_ERROR % (act, dbtype)
raise NotImplementedError(msg)
return distro_options.get(act)
return self.distro.get_command(dbtype, act)
def start(self):
if self.status() != comp.STATUS_STARTED:
@ -217,9 +217,8 @@ class DBRuntime(comp.EmptyRuntime):
def drop_db(cfg, pw_gen, distro, dbname):
dbtype = cfg.get("db", "type")
dbactions = distro.get_command(dbtype)
if dbactions and dbactions.get('drop_db'):
dropcmd = dbactions.get('drop_db')
dropcmd = distro.get_command(dbtype, 'drop_db', silent=True)
if dropcmd:
params = dict()
params['PASSWORD'] = pw_gen.get_password("sql", PASSWORD_PROMPT)
params['USER'] = cfg.getdefaulted("db", "sql_user", 'root')
@ -237,9 +236,8 @@ def drop_db(cfg, pw_gen, distro, dbname):
def create_db(cfg, pw_gen, distro, dbname):
dbtype = cfg.get("db", "type")
dbactions = distro.get_command(dbtype)
if dbactions and dbactions.get('create_db'):
createcmd = dbactions.get('create_db')
createcmd = distro.get_command(dbtype, 'create_db', silent=True)
if createcmd:
params = dict()
params['PASSWORD'] = pw_gen.get_password("sql", PASSWORD_PROMPT)
params['USER'] = cfg.getdefaulted("db", "sql_user", 'root')

View File

@ -80,8 +80,9 @@ class HorizonInstaller(comp.PythonInstallComponent):
def _get_symlinks(self):
links = comp.PythonInstallComponent._get_symlinks(self)
link_tgt = self.distro.get_command('apache', 'settings',
'conf-link-target', quiet=True)
link_tgt = self.distro.get_command_config(
'apache', 'settings', 'conf-link-target',
quiet=True)
if link_tgt:
src = self._get_target_config_name(HORIZON_APACHE_CONF)
links[src] = link_tgt

View File

@ -49,6 +49,8 @@ RSYNC_SERVICE_RESTART = ['service', 'rsync', 'restart']
RSYSLOG_SERVICE_RESTART = ['service', 'rsyslog', 'restart']
RSYNC_ON_OFF_RE = re.compile(r'^\s*RSYNC_ENABLE\s*=\s*(.*)$', re.I)
# FIXME: This should come from the persona, if we really expect
# people to change it.
# Defines our auth service type
AUTH_SERVICE = 'keystone'

View File

@ -18,6 +18,7 @@
import glob
import platform
import re
import shlex
import yaml
@ -84,7 +85,7 @@ class Distro(object):
self._commands = commands
self._components = components
def get_command(self, key, *more_keys, **kargs):
def get_command_config(self, key, *more_keys, **kargs):
""" Gets a end object for a given set of keys """
root = self._commands
acutal_keys = [key] + list(more_keys)
@ -105,9 +106,18 @@ class Distro(object):
end_value = root[end_key]
else:
end_value = root.get(end_key)
LOG.debug("Retrieved end command: %s", end_value)
LOG.debug("Retrieved end command config: %s", end_value)
return end_value
def get_command(self, key, *more_keys, **kargs):
"""Retrieves a string for running a command from the setup
and splits it to return a list.
"""
val = self.get_command_config(key, *more_keys, **kargs)
ret_val = shlex.split(val) if val else []
LOG.debug("Parsed configured command: %s", ret_val)
return ret_val
def known_component(self, name):
return name in self._components

View File

@ -32,7 +32,7 @@ def _make_pip_name(name, version):
def install(pip, distro):
name = pip['name']
root_cmd = distro.get_command('pip')
root_cmd = distro.get_command_config('pip')
LOG.audit("Installing python package (%s) using pip command (%s)" % (name, root_cmd))
name_full = _make_pip_name(name, pip.get('version'))
real_cmd = [root_cmd, 'install'] + PIP_INSTALL_CMD_OPTS

View File

@ -101,9 +101,9 @@ def execute(*cmd, **kwargs):
execute_cmd = str_cmd.strip()
if not shell:
LOG.audit('Running cmd: %s' % (execute_cmd))
LOG.audit('Running cmd: %r' % (execute_cmd))
else:
LOG.audit('Running shell cmd: %s' % (execute_cmd))
LOG.audit('Running shell cmd: %r' % (execute_cmd))
if process_input is not None:
LOG.audit('With stdin: %s' % (process_input))