Created
February 20, 2017 16:01
-
-
Save Daviey/61f4d607cbdac3efb7a36176811b2062 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
from oslo.config import cfg | |
from sqlalchemy import create_engine | |
cfg_file = "/etc/nova/nova.conf" | |
def get_sql_connection_cfg(): | |
opt_group = cfg.OptGroup(name='DEFAULT', title='Test example') | |
test_opts = [ | |
cfg.StrOpt( | |
'sql_connection', | |
default='sqlite:///state_path/sqlite_db', | |
help='Connection string for SQL database.'), | |
] | |
CONF = cfg.CONF | |
CONF.register_group(opt_group) | |
CONF.register_opts(test_opts, opt_group) | |
CONF(default_config_files=[cfg_file]) | |
return CONF.DEFAULT.sql_connection | |
sql_connection = get_sql_connection_cfg() | |
engine = create_engine(sql_connection) | |
conn = engine.connect() | |
state, status = conn.execute( | |
"SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment'").fetchall()[0] | |
if status == u'Synced': | |
print "ALL OK" | |
sys.exit(0) | |
else: | |
print "ERROR" | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment