Esempio n. 1
0
        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)
Esempio n. 2
0
        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)
Esempio n. 3
0
 def action(args):
     with FailureHandler('list'):
         client = Client.build(hostname=args.host)
         rs = ResourceSession(client, client.get_session())
         rs.list(args.resource, args.recursive)
Esempio n. 4
0
 def action(args):
     with FailureHandler('delete'):
         client = Client.build(hostname=args.host)
         rs = ResourceSession(client, client.get_session())
         rs.delete(args.resource, args)