old_contents: def start(lab, log, args):
      import time
      from fabric.context_managers import shell_env
  
      grep_host = args.get('grep_host', 'overcloud-')
      duration = args['duration']
      period = args['period']
  
      statuses = {'up': 1, 'down': 0}
  
      server = lab.director()
      start_time = time.time()
      while start_time + duration > time.time():
          with shell_env(OS_AUTH_URL=lab.cloud.end_point, OS_USERNAME=lab.cloud.user, OS_PASSWORD=lab.cloud.password, OS_TENANT_NAME=lab.cloud.tenant):
              res = server.run("nova service-list | grep {0} | awk '{{print $4 \" \" $6 \" \" $12}}'".format(grep_host), warn_only=True)
          results = [line.split() for line in res.split('\n')]
          msg = ' '.join(['{1}:{0}={2}'.format(r[0], r[1], statuses[r[2]]) for r in results])
          log.info('{1}'.format(grep_host, msg))
          time.sleep(period)
  
  
new_contents: def start(lab, log, args):
      from fabric.context_managers import shell_env
  
      grep_host = args.get('grep_host', 'overcloud-')
  
      statuses = {'up': 1, 'down': 0}
  
      server = lab.director()
  
      with shell_env(OS_AUTH_URL=lab.cloud.end_point, OS_USERNAME=lab.cloud.user, OS_PASSWORD=lab.cloud.password, OS_TENANT_NAME=lab.cloud.tenant):
          res = server.run("nova service-list | grep {0} | awk '{{print $4 \" \" $6 \" \" $12}}'".format(grep_host), warn_only=True)
      results = [line.split() for line in res.split('\n')]
      msg = ' '.join(['{1}:{0}={2}'.format(r[0], r[1], statuses[r[2]]) for r in results])
      log.info('{1}'.format(grep_host, msg))
  
  
subject: Verify services status if FI is rebooted