Exemplo n.º 1
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"})