def repocreate(): """ repo form """ config = Kconfig() return render_template('repocreate.html', title='CreateRepo', client=config.client)
def delete_plan(self, request, context): print("Handling delete_plan call for:\n%s" % request) config = Kconfig() result = config.plan(request.plan, delete=True) response = kcli_pb2.result(**result) return response
def serial_console(self, request, context): print("Handling serial_console call for:\n%s" % request) config = Kconfig() cmd = config.k.serialconsole(request.name, web=True) response = kcli_pb2.cmd(cmd=cmd) return response
def list(self, request, context): print("Handling list call") config = Kconfig() vmlist = config.k.list() response = kcli_pb2.vmlist(vms=[kcli_pb2.vminfo(**x) for x in vmlist]) return response
def list_isos(self, request, context): print("Handling list call") config = Kconfig() response = kcli_pb2.isoslist(isos=config.k.volumes(iso=True)) return response
def get_config(self, request, context): print("Handling get_config call") config = Kconfig() configinfo = {'client': config.client, 'extraclients': [c for c in config.extraclients]} response = kcli_pb2.config(**configinfo) return response
def info(self, request, context): print("Handling info call for:\n%s" % request) config = Kconfig() result = config.k.info(request.name, debug=request.debug) response = kcli_pb2.vminfo(**result) return response
def isos(): config = Kconfig() return render_template('isos.html', title='Isos', client=config.client)
def containerprofiles(): """ retrieves all containerprofiles """ config = Kconfig() return render_template('containerprofiles.html', title='ContainerProfiles', client=config.client)
def templates(): config = Kconfig() return render_template('templates.html', title='Templates', client=config.client)
def vmprofiles(): config = Kconfig() return render_template('vmprofiles.html', title='VmProfiles', client=config.client)
def plans(): config = Kconfig() return render_template('plans.html', title='Plans', client=config.client)
def productcreate(): """ product form """ config = Kconfig() return render_template('productcreate.html', title='CreateProduct', client=config.client)
def products(): config = Kconfig() return render_template('products.html', title='Products', client=config.client)
def get_lastvm(self, request, context): print("Handling get_lastvm for:\n%s" % request) config = Kconfig() name = common.get_lastvm(config.client if request.client == '' else request.client) response = kcli_pb2.vm(name=name) return response
# <bitbar.author.github>karmab</bitbar.author.github> # <bitbar.desc>Lists running vms using kcli</bitbar.desc> # <bitbar.image>https://raw.githubusercontent.com/karmab/kcli/master/kcli.jpg</bitbar.image> # <bitbar.abouturl>https://github.com/karmab/kcli</bitbar.abouturl> import sys try: from kvirt.config import Kconfig except: warning = u"\u26A0" warning = warning.encode('utf-8') print("%s\n" % warning) print("---\n") print("Kcli could not be found in your path. Is it installed?") sys.exit(1) config = Kconfig(quiet=True) k = config.k vms = k.list() running = [vm[0] for vm in vms if vm[1] == 'up'] off = [vm[0] for vm in vms if vm[1] == 'down'] print("Kcli %s/%s Running" % (len(running), len(vms))) print('---') for vm in sorted(running): print("%s| color=green" % vm) # print("%s| color=green bash=kcli param1=ssh param2=%s" % (vm, vm)) print('---') for vm in sorted(off): print(vm) # print("%s| terminal=false refresh=true bash=kcli param1=start param2=%s" % (vm, vm))
def list_pools(self, request, context): print("Handling list_pool call") config = Kconfig() k = config.k response = kcli_pb2.poolslist(pools=[{'pool': pool, 'path': k.get_pool_path(pool)} for pool in k.list_pools()]) return response
def list(args): """List hosts, profiles, templates, isos, pools or vms""" hosts = args.hosts profiles = args.profiles templates = args.templates isos = args.isos disks = args.disks pools = args.pools networks = args.networks containers = args.containers images = args.images plans = args.plans filters = args.filters short = args.short global config if config.client == 'all': clis = [] for cli in sorted(config.clients): clientconfig = Kconfig(client=cli) if clientconfig.k is not None: clis.append(clientconfig) else: k = config.k if pools: pools = k.list_pools() if short: poolstable = PrettyTable(["Pool"]) for pool in sorted(pools): poolstable.add_row([pool]) else: poolstable = PrettyTable(["Pool", "Path"]) for pool in sorted(pools): poolpath = k.get_pool_path(pool) poolstable.add_row([pool, poolpath]) poolstable.align["Pool"] = "l" print(poolstable) return if hosts: clientstable = PrettyTable(["Host", "Enabled", "Current"]) clientstable.align["Host"] = "l" for client in sorted(config.clients): enabled = config.ini[client].get('enabled', True) if client == config.client: clientstable.add_row([client, enabled, 'X']) else: clientstable.add_row([client, enabled, '']) print(clientstable) return if networks: networks = k.list_networks() common.pprint("Listing Networks...", color='green') if short: networkstable = PrettyTable(["Network"]) for network in sorted(networks): networkstable.add_row([network]) else: # networkstable = PrettyTable(["Network", "Type", "Cidr", "Dhcp", "Domain", "Mode", "Plan"]) networkstable = PrettyTable( ["Network", "Type", "Cidr", "Dhcp", "Domain", "Mode"]) for network in sorted(networks): networktype = networks[network]['type'] cidr = networks[network]['cidr'] dhcp = networks[network]['dhcp'] mode = networks[network]['mode'] if 'domain' in networks[network]: domain = networks[network]['domain'] else: domain = 'N/A' # if 'plan' in networks[network]: # plan = networks[network]['plan'] # else: # plan = 'N/A' # networkstable.add_row([network, networktype, cidr, dhcp, domain, mode, plan]) networkstable.add_row( [network, networktype, cidr, dhcp, domain, mode]) networkstable.align["Network"] = "l" print(networkstable) return elif profiles: if containers: profiles = config.list_containerprofiles() if short: profilestable = PrettyTable(["Profile"]) for profile in sorted(profiles): profilename = profile[0] profilestable.add_row([profilename]) else: profilestable = PrettyTable( ["Profile", "Image", "Nets", "Ports", "Volumes", "Cmd"]) for profile in sorted(profiles): profilestable.add_row(profile) profilestable.align["Profile"] = "l" print(profilestable) else: profiles = config.list_profiles() if short: profilestable = PrettyTable(["Profile"]) for profile in sorted(profiles): profilename = profile[0] profilestable.add_row([profilename]) else: profilestable = PrettyTable([ "Profile", "Numcpus", "Memory", "Pool", "Disks", "Template", "Nets", "Cloudinit", "Nested", "Reservedns", "Reservehost" ]) for profile in sorted(profiles): profilestable.add_row(profile) profilestable.align["Profile"] = "l" print(profilestable) return elif templates: templatestable = PrettyTable(["Template"]) templatestable.align["Template"] = "l" for template in k.volumes(): templatestable.add_row([template]) print(templatestable) elif isos: isostable = PrettyTable(["Iso"]) isostable.align["Iso"] = "l" for iso in k.volumes(iso=True): isostable.add_row([iso]) print(isostable) elif disks: common.pprint("Listing disks...", color='green') diskstable = PrettyTable(["Name", "Pool", "Path"]) diskstable.align["Name"] = "l" disks = k.list_disks() for disk in sorted(disks): path = disks[disk]['path'] pool = disks[disk]['pool'] diskstable.add_row([disk, pool, path]) print(diskstable) elif containers: common.pprint("Listing containers...", color='green') containers = PrettyTable( ["Name", "Status", "Image", "Plan", "Command", "Ports"]) for container in dockerutils.list_containers(k): if filters: status = container[1] if status == filters: containers.add_row(container) else: containers.add_row(container) print(containers) elif images: common.pprint("Listing images...", color='green') images = PrettyTable(["Name"]) for image in dockerutils.list_images(k): images.add_row([image]) print(images) elif plans: vms = {} plans = PrettyTable(["Name", "Vms"]) for plan in config.list_plans(): planname = plan[0] planvms = plan[1] plans.add_row([planname, planvms]) print(plans) else: if config.client == 'all': vms = PrettyTable([ "Name", "Host", "Status", "Ips", "Source", "Plan", "Profile", "Report" ]) for cli in sorted(clis, key=lambda x: x.client): for vm in sorted(cli.k.list()): vm.insert(1, cli.client) if filters: status = vm[2] if status == filters: vms.add_row(vm) else: vms.add_row(vm) print(vms) return else: vms = PrettyTable([ "Name", "Status", "Ips", "Source", "Plan", "Profile", "Report" ]) for vm in sorted(k.list()): if config.planview and vm[4] != config.currentplan: continue if filters: status = vm[1] if status == filters: vms.add_row(vm) else: vms.add_row(vm) print(vms) return
def delete_network(self, request, context): print("Handling delete_network call for:\n%s" % request) config = Kconfig() result = config.k.delete_network(request.network) response = kcli_pb2.result(**result) return response
def cli(): global config parser = argparse.ArgumentParser( description= 'Libvirt/VirtualBox wrapper on steroids. Check out https://github.com/karmab/kcli!' ) parser.add_argument('-C', '--client') parser.add_argument('-d', '--debug', action='store_true') parser.add_argument('--version', action='version', version=__version__) subparsers = parser.add_subparsers(metavar='') bootstrap_info = 'Generate basic config file' bootstrap_parser = subparsers.add_parser('bootstrap', help=bootstrap_info, description=bootstrap_info) bootstrap_parser.add_argument('-n', '--name', help='Name to use', metavar='CLIENT') bootstrap_parser.add_argument('-H', '--host', help='Host to use', metavar='HOST') bootstrap_parser.add_argument('-p', '--port', help='Port to use', metavar='PORT') bootstrap_parser.add_argument('-u', '--user', help='User to use', default='root', metavar='USER') bootstrap_parser.add_argument('-P', '--protocol', help='Protocol to use', default='ssh', metavar='PROTOCOL') bootstrap_parser.add_argument('-U', '--url', help='URL to use', metavar='URL') bootstrap_parser.add_argument('--pool', help='Pool to use', metavar='POOL') bootstrap_parser.add_argument('--poolpath', help='Pool Path to use', metavar='POOLPATH') bootstrap_parser.set_defaults(func=bootstrap) clone_info = 'Clone existing vm' clone_parser = subparsers.add_parser('clone', description=clone_info, help=clone_info) clone_parser.add_argument('-b', '--base', help='Base VM', metavar='BASE') clone_parser.add_argument('-f', '--full', action='store_true', help='Full Clone') clone_parser.add_argument('-s', '--start', action='store_true', help='Start cloned VM') clone_parser.add_argument('name', metavar='VMNAME') clone_parser.set_defaults(func=clone) console_info = 'Vnc/Spice/Serial/Container console' console_parser = subparsers.add_parser('console', description=console_info, help=console_info) console_parser.add_argument('-s', '--serial', action='store_true') console_parser.add_argument('--container', action='store_true') console_parser.add_argument('name', metavar='VMNAME') console_parser.set_defaults(func=console) container_info = 'Create container' container_parser = subparsers.add_parser('container', description=container_info, help=container_info) container_parser.add_argument('-p', '--profile', help='Profile to use', metavar='PROFILE') container_parser.add_argument('name', metavar='NAME', nargs='?') container_parser.set_defaults(func=container) delete_info = 'Delete vm/container' delete_parser = subparsers.add_parser('delete', description=delete_info, help=delete_info) delete_parser.add_argument('-y', '--yes', action='store_true', help='Dont ask for confirmation') delete_parser.add_argument('--container', action='store_true') delete_parser.add_argument('--snapshots', action='store_true', help='Remove snapshots if needed') delete_parser.add_argument('names', metavar='VMNAMES', nargs='+') delete_parser.set_defaults(func=delete) disk_info = 'Add/Delete disk of vm' disk_parser = subparsers.add_parser('disk', description=disk_info, help=disk_info) disk_parser.add_argument('-d', '--delete', action='store_true') disk_parser.add_argument('-s', '--size', help='Size of the disk to add, in GB', metavar='SIZE') disk_parser.add_argument('-n', '--diskname', help='Name or Path of the disk, when deleting', metavar='DISKNAME') disk_parser.add_argument('-t', '--template', help='Name or Path of a Template, when adding', metavar='TEMPLATE') disk_parser.add_argument('-p', '--pool', default='default', help='Pool', metavar='POOL') disk_parser.add_argument('name') disk_parser.set_defaults(func=disk) download_info = 'Download template' download_parser = subparsers.add_parser('download', description=download_info, help=download_info) download_parser.add_argument( '-c', '--cmd', help='Extra command to launch after downloading', metavar='CMD') download_parser.add_argument('-p', '--pool', default='default', help='Pool to use', metavar='POOL') download_parser.add_argument('template', choices=sorted(TEMPLATES.keys()), help='Template/Image to download') download_parser.set_defaults(func=download) host_info = 'List and Handle host' host_parser = subparsers.add_parser('host', description=host_info, help=host_info) host_parser.add_argument('-d', '--disable', help='Disable indicated client', metavar='CLIENT') host_parser.add_argument('-e', '--enable', help='Enable indicated client', metavar='CLIENT') host_parser.add_argument('-s', '--switch', help='Switch To indicated client', metavar='CLIENT') host_parser.set_defaults(func=host) info_info = 'Info vms' info_parser = subparsers.add_parser('info', description=info_info, help=info_info) info_parser.add_argument('-o', '--output', choices=['plain', 'yaml'], help='Format of the output') info_parser.add_argument('names', help='VMNAMES', nargs='+') info_parser.set_defaults(func=info) list_info = 'List hosts, profiles, templates, isos,...' list_parser = subparsers.add_parser('list', description=list_info, help=list_info) list_parser.add_argument('-H', '--hosts', action='store_true') list_parser.add_argument('-p', '--profiles', action='store_true') list_parser.add_argument('-t', '--templates', action='store_true') list_parser.add_argument('-i', '--isos', action='store_true') list_parser.add_argument('-d', '--disks', action='store_true') list_parser.add_argument('-P', '--pools', action='store_true') list_parser.add_argument('-n', '--networks', action='store_true') list_parser.add_argument('--containers', action='store_true') list_parser.add_argument('--images', action='store_true') list_parser.add_argument('--short', action='store_true') list_parser.add_argument('--plans', action='store_true') list_parser.add_argument('-f', '--filters', choices=('up', 'down')) list_parser.set_defaults(func=list) network_info = 'Create/Delete Network' network_parser = subparsers.add_parser('network', description=network_info, help=network_info) network_parser.add_argument('-d', '--delete', action='store_true') network_parser.add_argument('-i', '--isolated', action='store_true', help='Isolated Network') network_parser.add_argument('-c', '--cidr', help='Cidr of the net', metavar='CIDR') network_parser.add_argument('--nodhcp', action='store_true', help='Disable dhcp on the net') network_parser.add_argument('--domain', help='DNS domain. Defaults to network name') network_parser.add_argument('-p', '--pxe', help='Ip of a Pxe Server', metavar='PXE') network_parser.add_argument('name', metavar='NETWORK') network_parser.set_defaults(func=network) nic_info = 'Add/Delete nic of vm' nic_parser = subparsers.add_parser('nic', description=nic_info, help=nic_info) nic_parser.add_argument('-d', '--delete', action='store_true') nic_parser.add_argument('-i', '--interface', help='Name of the interface, when deleting', metavar='INTERFACE') nic_parser.add_argument('-n', '--network', help='Network', metavar='NETWORK') nic_parser.add_argument('name', metavar='VMNAME') nic_parser.set_defaults(func=nic) plan_info = 'Create/Delete/Stop/Start vms from plan file' plan_parser = subparsers.add_parser('plan', description=plan_info, help=plan_info) plan_parser.add_argument('-A', '--ansible', help='Generate ansible inventory', action='store_true') plan_parser.add_argument('-d', '--delete', action='store_true') plan_parser.add_argument( '-g', '--get', help='Download specific plan(s). Use --path for specific directory', metavar='URL') plan_parser.add_argument( '-p', '--path', default='plans', help='Path where to download plans. Defaults to plan', metavar='PATH') plan_parser.add_argument('-a', '--autostart', action='store_true', help='Set all vms from plan to autostart') plan_parser.add_argument('-c', '--container', action='store_true', help='Handle container') plan_parser.add_argument('-n', '--noautostart', action='store_true', help='Prevent all vms from plan to autostart') plan_parser.add_argument('-f', '--inputfile', help='Input file') plan_parser.add_argument('-s', '--start', action='store_true', help='start all vms from plan') plan_parser.add_argument('-w', '--stop', action='store_true') plan_parser.add_argument('--scale', help='Scale plan using provided parameters') plan_parser.add_argument('-t', '--topologyfile', help='Topology file') plan_parser.add_argument('-u', '--use', nargs='?', const='kvirt', help='Plan to set as current. Defaults to kvirt', metavar='USE') plan_parser.add_argument('-y', '--yes', action='store_true', help='Dont ask for confirmation') plan_parser.add_argument('--delay', default=0, help="Delay between each vm's creation", metavar='DELAY') plan_parser.add_argument('plan', metavar='PLAN', nargs='?') plan_parser.set_defaults(func=plan) pool_info = 'Create/Delete pool' pool_parser = subparsers.add_parser('pool', description=pool_info, help=pool_info) pool_parser.add_argument('-d', '--delete', action='store_true') pool_parser.add_argument('-f', '--full', action='store_true') pool_parser.add_argument('-t', '--pooltype', help='Type of the pool', choices=('dir', 'logical'), default='dir') pool_parser.add_argument('-p', '--path', help='Path of the pool', metavar='PATH') pool_parser.add_argument('pool') pool_parser.set_defaults(func=pool) report_info = 'Report Info about Host' report_parser = subparsers.add_parser('report', description=report_info, help=report_info) report_parser.set_defaults(func=report) scp_info = 'Scp into vm' scp_parser = subparsers.add_parser('scp', description=scp_info, help=scp_info) scp_parser.add_argument('-r', '--recursive', help='Recursive', action='store_true') scp_parser.add_argument('source', nargs=1) scp_parser.add_argument('destination', nargs=1) scp_parser.set_defaults(func=scp) snapshot_info = 'Create/Delete/Revert snapshot' snapshot_parser = subparsers.add_parser('snapshot', description=snapshot_info, help=snapshot_info) snapshot_parser.add_argument('-n', '--name', help='Use vm name for creation/revert/delete', required=True, metavar='VMNAME') snapshot_parser.add_argument('-r', '--revert', help='Revert to indicated snapshot', action='store_true') snapshot_parser.add_argument('-d', '--delete', help='Delete indicated snapshot', action='store_true') snapshot_parser.add_argument('-l', '--listing', help='List snapshots', action='store_true') snapshot_parser.add_argument('snapshot', nargs='?') snapshot_parser.set_defaults(func=snapshot) ssh_info = 'Ssh into vm' ssh_parser = subparsers.add_parser('ssh', description=ssh_info, help=ssh_info) ssh_parser.add_argument('-L', help='Local Forwarding', metavar='LOCAL') ssh_parser.add_argument('-R', help='Remote Forwarding', metavar='REMOTE') ssh_parser.add_argument('name', metavar='VMNAME', nargs='+') ssh_parser.set_defaults(func=ssh) start_info = 'Start vms/containers' start_parser = subparsers.add_parser('start', description=start_info, help=start_info) start_parser.add_argument('-c', '--container', action='store_true') start_parser.add_argument('names', metavar='VMNAMES', nargs='+') start_parser.set_defaults(func=start) stop_info = 'Stop vms/containers' stop_parser = subparsers.add_parser('stop', description=stop_info, help=stop_info) stop_parser.add_argument('-c', '--container', action='store_true') stop_parser.add_argument('names', metavar='VMNAMES', nargs='+') stop_parser.set_defaults(func=stop) switch_info = 'Switch host' switch_parser = subparsers.add_parser('switch', description=switch_info, help=switch_info) switch_parser.add_argument('host', help='HOST') switch_parser.set_defaults(func=switch) update_info = 'Update ip, memory or numcpus' update_parser = subparsers.add_parser('update', description=update_info, help=update_info) update_parser.add_argument('-1', '--ip1', help='Ip to set', metavar='IP1') update_parser.add_argument('--network', '--net', help='Network to update', metavar='NETWORK') update_parser.add_argument('-m', '--memory', help='Memory to set', metavar='MEMORY') update_parser.add_argument('-c', '--numcpus', help='Number of cpus to set', metavar='NUMCPUS') update_parser.add_argument('-p', '--plan', help='Plan Name to set', metavar='PLAN') update_parser.add_argument('-a', '--autostart', action='store_true', help='Set VM to autostart') update_parser.add_argument('-n', '--noautostart', action='store_true', help='Prevent VM from autostart') update_parser.add_argument('--dns', action='store_true', help='Update Dns entry for the vm') update_parser.add_argument('--host', action='store_true', help='Update Host entry for the vm') update_parser.add_argument('-d', '--domain', help='Domain', metavar='DOMAIN') update_parser.add_argument('-t', '--template', help='Template to set', metavar='TEMPLATE') update_parser.add_argument('--cloudinit', action='store_true', help='Remove Cloudinit Information from vm') update_parser.add_argument('name', metavar='VMNAME') update_parser.set_defaults(func=update) vm_info = 'Create vm' vm_parser = subparsers.add_parser('vm', description=vm_info, help=vm_info) vm_parser.add_argument('-p', '--profile', help='Profile to use', metavar='PROFILE') vm_parser.add_argument( '-1', '--ip1', help= 'Optional Ip to assign to eth0. Netmask and gateway will be retrieved from profile', metavar='IP1') vm_parser.add_argument( '-2', '--ip2', help= 'Optional Ip to assign to eth1. Netmask and gateway will be retrieved from profile', metavar='IP2') vm_parser.add_argument( '-3', '--ip3', help= 'Optional Ip to assign to eth2. Netmask and gateway will be retrieved from profile', metavar='IP3') vm_parser.add_argument( '-4', '--ip4', help= 'Optional Ip to assign to eth3. Netmask and gateway will be retrieved from profile', metavar='IP4') vm_parser.add_argument('name', metavar='VMNAME', nargs='?') vm_parser.set_defaults(func=vm) args = parser.parse_args() if args.func.func_name != 'bootstrap': config = Kconfig(client=args.client, debug=args.debug) if args.client != 'all' and not config.enabled: common.pprint("Disabled hypervisor.Leaving...", color='red') os._exit(1) args.func(args) if args.client != 'all': config.k.close() else: args.func(args)
def stop(self, request, context): print("Handling stop call for:\n%s" % request) config = Kconfig() result = config.k.stop(request.name) response = kcli_pb2.result(**result) return response
def pools(): """ retrieves all pools """ config = Kconfig() return render_template('pools.html', title='Pools', client=config.client)
def list_images(self, request, context): print("Handling list_images call") config = Kconfig() response = kcli_pb2.imageslist(images=config.k.volumes()) return response
def hosts(): """ retrieves all hosts """ config = Kconfig() return render_template('hosts.html', title='Hosts', client=config.client)
def create_vm(self, request, context): print("Handling create_vm call for:\n%s" % request) config = Kconfig() overrides = ast.literal_eval( request.overrides) if request.overrides != '' else {} profile = request.profile customprofile = ast.literal_eval( request.customprofile) if request.customprofile != '' else {} name = request.name if name == '': name = nameutils.get_random_name() if config.type in ['gcp', 'kubevirt']: name = name.replace('_', '-') if config.type != 'aws': pprint("Using %s as name of the vm" % name) if request.image != '': if request.image in config.profiles: pprint("Using %s as profile" % request.image) profile = request.image elif profile is not None: if profile.endswith('.yml'): profilefile = profile profile = None if not os.path.exists(profilefile): error("Missing profile file %s" % profilefile) result = { 'result': 'failure', 'reason': "Missing profile file %s" % profilefile } response = kcli_pb2.result(**result) return response else: with open(profilefile, 'r') as entries: entries = yaml.safe_load(entries) entrieskeys = list(entries.keys()) if len(entrieskeys) == 1: profile = entrieskeys[0] customprofile = entries[profile] pprint("Using data from %s as profile" % profilefile) else: error("Cant' parse %s as profile file" % profilefile) result = { 'result': 'failure', 'reason': "Missing profile file %s" % profilefile } response = kcli_pb2.result(**result) return response elif overrides: profile = 'kvirt' config.profiles[profile] = {} else: error( "You need to either provide a profile, an image or some parameters" ) result = { 'result': 'failure', 'reason': "You need to either provide a profile, an image or some parameters" } response = kcli_pb2.result(**result) response = kcli_pb2.result(**result) return response if request.vmfiles: for _fil in request.vmfiles: origin = _fil.origin content = _fil.content with open(origin, 'w') as f: f.write(content) if request.ignitionfile != '': with open("%s.ign" % name, 'w') as f: f.write(request.ignitionfile) result = config.create_vm(name, profile, overrides=overrides, customprofile=customprofile) result['vm'] = name response = kcli_pb2.result(**result) return response
def planstable(): """ retrieves all plans in table """ config = Kconfig() return render_template('planstable.html', plans=config.list_plans())
def delete_repo(self, request, context): print("Handing delete_profile call for:\n%s" % request) baseconfig = Kconfig() result = baseconfig.delete_repo(request.repo) response = kcli_pb2.result(**result) return response
from kvirt.config import Kconfig private = "default" api_ip = "13.0.0.253" cidr = "13.0.0.0/24" config = Kconfig() config.k.create_network(name=private, cidr=cidr, overrides={'port_security_enabled': False}) config.k.create_network_port("karmab-vip", private, ip=api_ip, floating=True, security=False)
def delete_image(self, request, context): print("Handling delete_image call for:\n%s" % request) config = Kconfig() result = config.k.delete_image(request.image) response = kcli_pb2.result(**result) return response
def repos(): config = Kconfig() return render_template('repos.html', title='Repos', client=config.client)