def action(args): # Argument validation if args.directory and not args.output: sh.die( "Unable to output to a directory without the output flag (-o)." ) return with FailureHandler('get'): client = Client.build(hostname=args.host) rs = ResourceSession(client, client.get_session()) rs.get(args.resource, args)
def action(args): with FailureHandler('apply'): client = Client.build(hostname=args.host) creds = credentials.load_credentials(args.credentials) if args.config is not None: config_file = args.config try: with open(config_file, 'r') as f: args.config = yaml.load(f.read(), Loader=yaml.SafeLoader) except Exception as e: raise Exception( f'Failure to load config from {config_file}: {e}') else: args.config = {} rs = ResourceSession(client, client.get_session()) rs.apply(args.resource, creds, args)
def action(args): with FailureHandler('list'): client = Client.build(hostname=args.host) rs = ResourceSession(client, client.get_session()) rs.list(args.resource, args.recursive)
def action(args): with FailureHandler('delete'): client = Client.build(hostname=args.host) rs = ResourceSession(client, client.get_session()) rs.delete(args.resource, args)