Commit 699b9be6 authored by Jason Frisvold's avatar Jason Frisvold
Browse files

- Initial code to retrieve configurations for a given cloud id

parent 6960ff2d
......@@ -110,14 +110,14 @@ def main(argv):
# Build configs (based on what criteria? always?
# Only when changed?)
configlist = build_config(server)
configlist = build_config(dbhandle, server['id'])
# SCP configs over (if there are configs)
if (len(configlist) > 0):
push_config(server, key)
push_config(server, server['ssh_key'])
# Get results from server
get_results(server, key)
get_results(server, server['ssh_key'])
# Process results, update database, store results
......@@ -161,17 +161,37 @@ def get_servers(dbhandle):
serverlist = []
rows = cur.fetchall()
if (len(rows) > 0) :
for row in rows :
if (len(rows) > 0):
for row in rows:
logger.debug('Database Retrieval : ' + str(row))
serverlist.append({ 'id' : row[0], 'ip' : str(IPAddress(row[1])),
'gpg_key' : row[2], 'ssh_key' : row[3]})
return serverlist
def build_config(server):
def build_config(dbhandle, server_id):
logger.info('Building server configuration')
cur = dbhandle.cursor()
cur.execute('''SELECT ti.id, c.server_ip, s.options, s.override, t.address,
ti.hour, ti.minute, ti.day, ti.month FROM timers AS
ti, cloud AS c, spawn AS s, target AS t WHERE c.id =
ti.cloud_id AND s.id = ti.spawn_id AND t.id =
ti.target_id AND ti.cloud_id = ''' + str(server_id))
configlist = []
rows = cur.fetchall()
if (len(rows) > 0):
for row in rows:
logger.debug('Database Retrieval : ' + str(row))
configlist.append({ 'id' : row[0], 'ip' : str(IPAddress(row[1])),
'options' : row[2], 'override' : row[3],
'address' : row[4], 'hour' : row[5],
'minute' : row[6], 'day' : row[7],
'month' : row[8]})
return configlist
def push_config(server, key):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment