Esempio n. 1
0
#!/usr/bin/env python

from celery import Celery
import urllib, json, os, jinja2, db, helper
from ansible.playbook import PlayBook
from ansible import callbacks
from ansible import utils
from config import CREDS

app = Celery('tasks', backend='db+mysql://' + CREDS.get('user') + ':' + CREDS.get('pass') + '@' + CREDS.get('host') + '/' + CREDS.get('db'), broker='amqp://guest@localhost//')

@app.task
def install_stuff(ip_list, sshpass, req_list):
    task_id = str(install_stuff.request.id)
    db.write_in_progress(req_list, ip_list, task_id)
    pb_name = helper.write_playbook(req_list)

    playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
    stats = callbacks.AggregateStats()
    runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)

    pb = PlayBook(remote_user='******',
        remote_pass=sshpass,
        playbook=pb_name,
        callbacks=playbook_cb,
        runner_callbacks=runner_cb,
        stats=stats,
        host_list=ip_list,
    )
    results = pb.run()
    if results[ip_list[:-1]]['unreachable'] != 0:
Esempio n. 2
0
File: db.py Progetto: dev-ace/build
def conn():
    conn = MySQLdb.connect(host=CREDS.get('host'), user=CREDS.get('user'), passwd=CREDS.get('pass'), db=CREDS.get('db'))
    return conn
Esempio n. 3
0
#!/usr/bin/env python

from celery import Celery
import urllib, json, os, jinja2, db, helper
from ansible.playbook import PlayBook
from ansible import callbacks
from ansible import utils
from config import CREDS

app = Celery('tasks',
             backend='db+mysql://' + CREDS.get('user') + ':' +
             CREDS.get('pass') + '@' + CREDS.get('host') + '/' +
             CREDS.get('db'),
             broker='amqp://guest@localhost//')


@app.task
def install_stuff(ip_list, sshpass, req_list):
    task_id = str(install_stuff.request.id)
    db.write_in_progress(req_list, ip_list, task_id)
    pb_name = helper.write_playbook(req_list)

    playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
    stats = callbacks.AggregateStats()
    runner_cb = callbacks.PlaybookRunnerCallbacks(stats,
                                                  verbose=utils.VERBOSITY)

    pb = PlayBook(
        remote_user='******',
        remote_pass=sshpass,
        playbook=pb_name,
Esempio n. 4
0
            firstPrediction = resp['prd']
        route = firstPrediction['rt']
        routeName = firstPrediction['des']
        direction = firstPrediction['rtdir']
        nextStop = firstPrediction['stpnm']
        stopId = firstPrediction['stpid']
        predictedTime = firstPrediction['prdtm']
        await client.say('Bus ' + str(busid) + ' is on ' + str(route) + ' ' + direction + ' ' \
            + routeName + '. Next stop ' + nextStop + ' (ID ' + stopId + ') at ' + predictedTime)
    else:
        await client.say('Bus ' + str(busid) + ' is currently offline.')


@client.command()
async def github():
    await client.say('https://github.com/alis0nc/bendyboi-tracker')


@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('----------------')


client.loop.create_task(
    trackBuses(tracker, CREDS.get('channelID', None),
               OPTIONS.get('interval', 60)))
client.run(CREDS.get('token'))