def vmprofilestable(): """ retrieves vm profiles in table """ baseconfig = Kbaseconfig() profiles = baseconfig.list_profiles() return render_template('vmprofilestable.html', profiles=profiles)
def containerprofilestable(): """ retrieves container profiles in table """ baseconfig = Kbaseconfig() profiles = baseconfig.list_containerprofiles() return render_template('containerprofilestable.html', profiles=profiles)
def hostaction(): """ enable/disable/default host """ baseconfig = Kbaseconfig() if 'name' in request.form: name = request.form['name'] action = request.form['action'] if action not in ['enable', 'disable', 'switch']: result = {'result': 'failure', 'reason': "Invalid Action"} response = jsonify(result) response.status_code = 400 else: if action == 'enable': result = baseconfig.enable_host(name) elif action == 'disable': result = baseconfig.disable_host(name) elif action == 'switch': result = baseconfig.switch_host(name) response = jsonify(result) response.status_code = 200 else: result = {'result': 'failure', 'reason': "Invalid Data"} response = jsonify(result) response.status_code = 400 return response
def containercreate(): """ create container """ baseconfig = Kbaseconfig() profiles = baseconfig.list_containerprofiles() return render_template('containercreate.html', title='CreateContainer', profiles=profiles, client=baseconfig.client)
def productcreate(prod): """ product form """ config = Kbaseconfig() info = config.info_product(prod, verbose=False) parameters = info['parameters'] description = info['description'] comments = info['comments'] return render_template('productcreate.html', title='CreateProduct', client=config.client, product=prod, parameters=parameters, description=description, comments=comments)
def productstable(): """ retrieves all products in table """ baseconfig = Kbaseconfig() products = [] for product in baseconfig.list_products(): repo = product['repo'] group = product['group'] name = product['name'] description = product['description'] numvms = product['numvms'] products.append([repo, group, name, description, numvms]) return render_template('productstable.html', products=products)
def vms(): """ :return: """ baseconfig = Kbaseconfig() return render_template('vms.html', title='Home', client=baseconfig.client)
def productcreate(prod): """ product form """ config = Kbaseconfig() productinfo = config.info_product(prod, web=True) parameters = productinfo.get('parameters', {}) description = parameters.get('description', '') info = parameters.get('info', '') return render_template('productcreate.html', title='CreateProduct', client=config.client, product=prod, parameters=parameters, description=description, info=info)
def containerprofiles(): """ retrieves all containerprofiles """ baseconfig = Kbaseconfig() return render_template('containerprofiles.html', title='ContainerProfiles', client=baseconfig.client)
def products(): """ :return: """ baseconfig = Kbaseconfig() return render_template('products.html', title='Products', client=baseconfig.client)
def vmprofiles(): """ :return: """ baseconfig = Kbaseconfig() return render_template('vmprofiles.html', title='VmProfiles', client=baseconfig.client)
def hoststable(): """ retrieves all hosts in table """ baseconfig = Kbaseconfig() clients = [] for client in sorted(baseconfig.clients): enabled = baseconfig.ini[client].get('enabled', True) _type = baseconfig.ini[client].get('type', 'kvm') if client == baseconfig.client: clients.append([client, _type, enabled, 'X']) else: clients.append([client, _type, enabled, '']) return render_template('hoststable.html', clients=clients)