/scripts/galaxy_messaging/server/setup_rabbitmq.py

https://bitbucket.org/cistrome/cistrome-harvard/ · Python · 38 lines · 24 code · 5 blank · 9 comment · 5 complexity · e04cf8253c530741fd16b743d41ecec3 MD5 · raw file

  1. #
  2. # Configuration script for RabbitMQ in Galaxy
  3. #
  4. # Requirements:
  5. # - set the rabbitmqctl_path variable in the 'galaxy_amqp' section in Galaxy config file
  6. #
  7. # Usage:
  8. # $ python setup_rabbitmq.py <Galaxy config file>
  9. #
  10. import os, sys, csv, ConfigParser
  11. def main( config_file ):
  12. try:
  13. config = ConfigParser.ConfigParser()
  14. config.read( config_file )
  15. rabbitmqctl_path = config.get( 'galaxy_amqp', 'rabbitmqctl_path' )
  16. username = config.get( 'galaxy_amqp', 'userid' )
  17. password = config.get( 'galaxy_amqp', 'password' )
  18. virtual_host = config.get( 'galaxy_amqp', 'virtual_host' )
  19. except Exception, e:
  20. print 'Fatal error:', str(e)
  21. sys.exit(1)
  22. cmd_list = [
  23. 'add_user %s %s' % ( username, password ),
  24. 'add_vhost %s' % virtual_host,
  25. 'set_permissions -p %s %s ".*" ".*" ".*"' % ( virtual_host, username )
  26. ]
  27. for cmd in cmd_list:
  28. retval = os.system( rabbitmqctl_path + ' ' + cmd )
  29. if retval:
  30. print "Failed command: %s" % cmd
  31. sys.exit(1)
  32. if __name__ == '__main__':
  33. main( sys.argv[1] )