Пример #1
0
def apps():
    configstuff = utils.configstuff()
    logger.info("Got request for apps")
    cfi = CloudFoundryInterface('https://api.run.pivotal.io', username=configstuff['cf_user'], password=configstuff['cf_pass']) #connect to CF
    cfi.login() #login

    app_list = [cf_app.name for cf_app in cfi.apps.itervalues()] #get the list of apps (this technique is called a list comprehension, BTW)
    applications = {'applications': sorted(app_list)} #sort it to be nice.
    return jsonify(applications) #send a JSON list of applications.
Пример #2
0
def scale_app(appname, target):
    configstuff = utils.configstuff()
    logger.info("Got request to scale app \'{}\' to {}".format(appname, target))
    cfi = CloudFoundryInterface('https://api.run.pivotal.io', username=configstuff['cf_user'], password=configstuff['cf_pass']) #again, connect to CF
    cfi.login() #and login

    app_list = [cf_app.name for cf_app in cfi.apps.itervalues()] # make sure the app we got was in the list of apps.
    if appname not in app_list:
        return jsonify({'status': 'failure'})
    else:
        cfi.scale_app(cfi.get_app_by_name(appname),target) #and if it is, scale it as requested.
        return jsonify({"status":"success"})
Пример #3
0
import dweepy #see dweet.io
import logging, logging.config
import utils
import datetime

logging.config.dictConfig(utils.get_log_dict())

logger = logging.getLogger('vascodagama.dashboard')


redis_images = utils.get_images_redis_conn()
r = utils.get_rq_redis_conn()
q = utils.get_rq()

#Setup our redis and RQ connections.   see twitter_watch for more details.
configstuff = utils.configstuff()

@job("dashboard", connection=r, timeout=10, result_ttl=10)
def send_update(metric, value): #method for sending updates about metrics as needed.
    logger.debug("Sending update for {}: {}".format(metric, value))
    dweepy.dweet_for(configstuff['dweet_thing'], {metric: value})




def update_dashboard(): # the primary function.
    logger.info("updating")


    #For each one of the metrics, collected the data and issue a job to actually send that out.
    get_queue_len()
Пример #4
0
def check_auth(username, password):
    """This function is called to check if a username /
    password combination is valid.  It only accepts 1 set of values :). TODO.
    """
    configstuff = utils.configstuff()
    return username == configstuff['cf_user'] and password == configstuff['cf_pass']
Пример #5
0
from rq.decorators import job  #funtion decoration
import dweepy  #see dweet.io
import logging, logging.config
import utils
import datetime

logging.config.dictConfig(utils.get_log_dict())

logger = logging.getLogger('vascodagama.dashboard')

redis_images = utils.get_images_redis_conn()
r = utils.get_rq_redis_conn()
q = utils.get_rq()

#Setup our redis and RQ connections.   see twitter_watch for more details.
configstuff = utils.configstuff()


@job("dashboard", connection=r, timeout=10, result_ttl=10)
def send_update(metric,
                value):  #method for sending updates about metrics as needed.
    logger.debug("Sending update for {}: {}".format(metric, value))
    dweepy.dweet_for(configstuff['dweet_thing'], {metric: value})


def update_dashboard():  # the primary function.
    logger.info("updating")

    #For each one of the metrics, collected the data and issue a job to actually send that out.
    get_queue_len()
    # logging.debug("{}: {}".format("tweets in queue",tweets_in_queue))