def change_weight(key, name): ip, port = name.split(':') routes.add( utils.get_frontend_ip(), 5500, key, ip, int(port), int(request.form['weight']) ) return redirect(url_for('deployer.routing'))
def add_route(): client = Client(version='1.6') containers = [] deploy_repo = '{}/{}'.format( current_app.config['DOCKER_REGISTRY'], current_app.config['DOCKER_BUILDS_REPOSITORY'], ) for c in client.containers(trunc=False): try: repo, tag = c['Image'].split(':') except ValueError: continue if repo == deploy_repo: c['Tag'] = tag c['Repo'] = repo c['Created'] = datetime.fromtimestamp(c['Created']) c['Names'] = [n[1:] for n in c['Names']] containers.append(c) form = forms.add_route_form(containers, request.form) if request.method == 'POST' and form.validate(): container_ip = utils.get_container_ip( client, form.data['container'] ) frontend_ip = utils.get_frontend_ip(client) routes.add( frontend_ip, 5500, form.data['routing_key'], container_ip, 5510, form.data['weight'] ) return redirect(url_for('deployer.routing')) return render_template('add-route.html', form=form)
def routing(): subscriptions = routes.getall(utils.get_frontend_ip(), 1717) return render_template('routing.html', subscriptions=subscriptions)