def add(dbtype): if request.method == 'POST': name = request.form.get('name') ml = request.form.get('memory_limit') pm = request.form.get('port_mapping', 'off') if pm == 'on': pm = True else: pm = False docker.create_container(dbtype, name, ml, pm) flash('Server successfully started.', 'success') return redirect(url_for('index')) return render_template('add.html', dbtype=dbtype)
def create(dbtype, name, nopm=False, memorylimit=256): """dbaas create DB_TYPE NAME""" try: pm = not nopm container = docker.create_container(dbtype, name, memorylimit, pm) print "%s Started container %s" % (ok(), container['Id']) print 'Waiting for database to boot...' time.sleep(5) return test(container['Id']) except Exception, e: print '%s %s' % (ko(), e)