in awscli/customizations/opsworks.py [0:0]
def prevalidate_arguments(self, args):
"""
Validates command line arguments before doing anything else.
"""
if not args.target and not args.local:
raise ValueError("One of target or --local is required.")
elif args.target and args.local:
raise ValueError(
"Arguments target and --local are mutually exclusive.")
if args.local and platform.system() != 'Linux':
raise ValueError(
"Non-Linux instances are not supported by AWS OpsWorks.")
if args.ssh and (args.username or args.private_key):
raise ValueError(
"Argument --override-ssh cannot be used together with "
"--ssh-username or --ssh-private-key.")
if args.infrastructure_class == 'ec2':
if args.private_ip:
raise ValueError(
"--override-private-ip is not supported for EC2.")
if args.public_ip:
raise ValueError(
"--override-public-ip is not supported for EC2.")
if args.infrastructure_class == 'on-premises' and \
args.use_instance_profile:
raise ValueError(
"--use-instance-profile is only supported for EC2.")
if args.hostname:
if not HOSTNAME_RE.match(args.hostname):
raise ValueError(
"Invalid hostname: '%s'. Hostnames must consist of "
"letters, digits and dashes only and must not start or "
"end with a dash." % args.hostname)