Skip to content

Commit

Permalink
Fix issues in fab on xenial
Browse files Browse the repository at this point in the history
1. Check that the services list is not empty in install_xenial_prerequisites
   so that empty string is not added to list of services
2. Change verify_service to use systemctl is-active and check the return code
   on xenial

Change-Id: Ie6ef9c653ac854d4c4bd25e99f32ac0dcf44f28a
Closes-Bug: #1662393
  • Loading branch information
Megh Bhatt committed Feb 7, 2017
1 parent 8c9a271 commit 5a31b6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
11 changes: 7 additions & 4 deletions fabfile/tasks/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ def disable_sysv_auto_generation():
@parallel(pool_size=20)
@roles('all')
def install_xenial_prerequisites():
services_list = []
contrail_systemd_services = run("ls -l /etc/systemd/system | grep .service | grep contrail | awk '{print $9}'")
services_list = contrail_systemd_services.split('\r\n')
if contrail_systemd_services:
services_list = contrail_systemd_services.split('\r\n')

nova_systemd_services = run("ls -l /etc/systemd/system | grep .service | grep nova | awk '{print $9}'")
nova_services_list = nova_systemd_services.split('\r\n')
for svc in nova_services_list:
services_list.append(svc)
if nova_systemd_services:
nova_services_list = nova_systemd_services.split('\r\n')
for svc in nova_services_list:
services_list.append(svc)

other_services = ['cassandra.service', 'ifmap.service', 'zookeeper.service']
for svc in other_services:
Expand Down
14 changes: 9 additions & 5 deletions fabfile/tasks/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
class OpenStackSetupError(Exception):
pass

def verify_service(service, initd_service=False):
def verify_service(service, check_return_code=False):
for x in xrange(10):
with settings(warn_only=True):
output = sudo("service %s status" % service)
if initd_service:
if is_xenial_or_above():
output = sudo("systemctl is-active %s" % service)
check_return_code = True
else:
output = sudo("service %s status" % service)
if check_return_code:
if output.succeeded or re.search('Active:.*active', output):
return
else:
Expand All @@ -31,7 +35,7 @@ def verify_service(service, initd_service=False):
def verify_database():
if not is_xenial_or_above():
verify_service("supervisor-database")
verify_service("contrail-database", initd_service=True)
verify_service("contrail-database", check_return_code=True)

@task
@roles('webui')
Expand Down Expand Up @@ -66,7 +70,7 @@ def verify_openstack():
def verify_cfgm():
verify_service("zookeeper")
if manage_config_db():
verify_service("contrail-database", initd_service=True)
verify_service("contrail-database", check_return_code=True)
if not is_xenial_or_above():
verify_service("supervisor-config")
verify_service("contrail-api")
Expand Down

0 comments on commit 5a31b6d

Please sign in to comment.