def main(): 'build and install a vyos debian package' arg = arguments.setup(__doc__, ['build']) control = Control(arg.dry, not arg.quiet) if not config.exists(arg.server): sys.exit(f'machine "{arg.server}" is not configured\n') if not config.exists(arg.router): sys.exit(f'machine "{arg.router}" is not configured\n') role = config.get(arg.server, 'role') if role != 'build': sys.exit(f'target "{arg.server}" is not a build machine\n') role = config.get(arg.router, 'role') if role != 'router': sys.exit(f'target "{arg.router}" is not a VyOS router\n') control.git(arg.server, f'checkout current') control.git(arg.server, f'pull') control.cleanup(arg.server) for package in arg.packages: control.build(arg.server, package, 'current', arg.working) control.install(arg.server, arg.router, package, arg.working) log.completed('package(s) installed')
def main(): 'test a VyOS router' arg = arguments.setup(__doc__, ['test']) control = Control(arg.dry, not arg.quiet) for command in commands: show = f'/opt/vyatta/bin/vyatta-op-cmd-wrapper {command}' running(command) out, err = control.communicate(config.ssh(arg.machine, show)) # some command reply on stderr ! sigh ! if err: if 'not configured' in err: skipped(command) continue for errror in errors: if errror in err: failed(command, out, err, errror) continue for errror in errors: if errror in out: failed(command, out, err, errror) continue passed(command)
def main(): 'convert an iso image to docker' arg = arguments.setup(__doc__, ['docker']) control = Control(arg.dry, not arg.quiet) control.docker(arg.server) log.completed('docker image built')
def main(): 'setup a branch of a vyos repository' arg = arguments.setup(__doc__, ['branch']) control = Control(arg.dry, not arg.quiet) control.setup_source(arg.repository) control.setup_branch(arg.branch, arg.repository) log.completed('build complete') if arg.edit: control.edit(control.branched_repo(arg.branch, arg.repository))
def main(target=''): 'call vyos-build make within docker' options = ['make'] if not target: options = ['target'] + options arg = arguments.setup(__doc__, options) if not target: target = arg.target release = arg.release or 'current' control = Control(arg.dry, not arg.quiet) if not config.exists(arg.server): sys.exit(f'machine "{arg.server}" is not configured') role = config.get(arg.server, 'role') if role != 'build': sys.exit(f'target "{arg.server}" is not a build machine') control.cleanup(arg.server) # to re-add the vyos-1x folder we deleted control.git(arg.server, 'checkout packages') control.git(arg.server, f'checkout {release}') control.git(arg.server, 'pull') control.docker_pull(arg.server, release) if target == 'test': control.make(arg.server, release, 'test') return done = False if not arg.release: for package in arg.packages: done = control.build(arg.server, package, 'current', arg.working) if done: control.backdoor(arg.server, arg.backdoor) if done or arg.release: control.configure(arg.server, release, arg.extra, arg.name) control.make(arg.server, release, target) if target == 'iso' and arg.test: control.make(arg.server, release, 'test') if arg.save: control.fetch(arg.server) log.completed('iso built and tested')
def main(): 'update a VyOS router filesystem with newer vyos-1x code' arg = arguments.setup(__doc__, ['update']) control = Control(arg.dry, not arg.quiet) if not config.exists(arg.router): sys.exit(f'machine "{arg.router}" is not configured\n') role = config.get(arg.router, 'role') if role != 'router': sys.exit(f'target "{arg.router}" is not a VyOS router\n') control.permission(arg.router, arg.working) control.rsync(arg.router, arg.working) control.update(arg.router, arg.working)
def main(): 'set a machine for this tool' arg = arguments.setup(__doc__, ['setup']) control = Control(arg.dry, not arg.quiet) if not config.exists(arg.machine): sys.exit(f'machine "{arg.machine}" is not configured\n') role = config.get(arg.machine, 'role') if not role: print('the machine "{arg.machine}" is not setup') if role == 'router': control.setup_router(arg.machine) elif role == 'build': control.setup_build(arg.machine, arg.sudo) else: log.completed('the machine "{arg.machine}" is not correctly setup')
def main(): 'ssh to a configured machine' arg = arguments.setup(__doc__, ['ssh']) if not config.exists(arg.machine): sys.exit(f'machine "{arg.machine}" is not configured\n') connect = config.ssh(arg.machine, '') if arg.dry or arg.quiet: print(connect) if arg.dry: return log.timed(f'connecting to {arg.machine}') fullssh = subprocess.check_output(['which', 'ssh']).decode().strip() os.execvp(fullssh, connect.split()) log.completed('session terminated')
def main(): 'upgrade router to latest VyOS image' arg = arguments.setup(__doc__, ['upgrade']) control = Control(arg.dry, not arg.quiet) if not config.exists(arg.router): sys.exit(f'machine "{arg.router}" is not configured\n') role = config.get(arg.router, 'role') if role != 'router': sys.exit(f'target "{arg.router}" is not a VyOS router\n') location = os.path.abspath(arg.iso) if arg.iso else fetch(arg.iso) time.sleep(0.5) control.upgrade(arg.router, arg.bind, location, arg.local, arg.remote, arg.dry) if arg.reboot: control.reboot(arg.router)
def main(): 'edit vyos code' arg = arguments.setup(__doc__, ['edit']) control = Control(arg.dry, not arg.quiet) control.edit(control.branched_repo(arg.branch, arg.repository))
def main(): 'download latest VyOS rolling image' arg = arguments.setup(__doc__, ['download']) fetch(arg.file)