Ejemplo n.º 1
0
def get_password_data(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--instance-id', required=True)
    processed, remaining = parser.parse_known_args(args)
    utils.populate_params_from_cli_args(params, processed)
    response = requestify.make_request(url, verb, headers, params)
    parser = utils.get_argument_parser()
    parser.add_argument('--private-key-file', required=False, default=None)
    parser.add_argument('--key-passphrase', required=False, default=None)
    processed = parser.parse_args(remaining)
    processed = vars(processed)
    private_key_file = processed.get('private_key_file')
    passphrase = processed.get('key_passphrase')
    response_json = utils.web_response_to_json(response)
    try:
        response_body = response_json['GetPasswordDataResponse']
        encrypted_password = response_body['passwordData']
        if not private_key_file or not encrypted_password:
            return response
        decrypted_password = decrypt_instance_password(encrypted_password,
                                                       private_key_file,
                                                       passphrase)
        response_json['GetPasswordDataResponse']['passwordData'] = \
                                                  decrypted_password
        return response_json
    except KeyError as ke:
        raise exception.UnknownOutputFormat()
Ejemplo n.º 2
0
def get_metric_statistics(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--metric-name', nargs='?', required=True)
    parser.add_argument('--namespace', nargs='?', required=True)
    parser.add_argument('--start-time', nargs='?', required=True)
    parser.add_argument('--end-time', nargs='?', required=True)
    parser.add_argument('--period', nargs='?', type=int, required=True)
    parser.add_argument('--units', nargs='?',
                        choices=['Seconds', 'Microseconds', 'Milliseconds',
                        'Bytes', 'Kilobytes', 'Megabytes', 'Gigabytes',
                        'Terabytes', 'Bits', 'Kilobits', 'Megabits',
                        'Gigabits', 'Terabits', 'Percent', 'Count',
                        'Bytes/Second', 'Kilobytes/Second', 'Megabytes/Second',
                        'Gigabytes/Second', 'Terabytes/Second', 'Bits/Second',
                        'Kilobits/Second', 'Megabits/Second',
                        'Gigabits/Second', 'Terabits/Second', 'Count/Second',
                        'None'], required=False)
    parser.add_argument('--statistics', nargs='+',
                        choices=['SampleCount', 'Average', 'Sum',
                                 'Minimum', 'Maximum'], required=True)
    parser.add_argument('--dimensions', nargs='+', required=False)
    args = parser.parse_args(args)
    mon_utils.populate_monitoring_params_from_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 3
0
def get_password_data(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--instance-id', required=True)
    processed, remaining = parser.parse_known_args(args)
    utils.populate_params_from_cli_args(params, processed)
    response = requestify.make_request(url, verb, headers, params)
    parser = utils.get_argument_parser()
    parser.add_argument('--private-key-file', required=False, default=None)
    parser.add_argument('--key-passphrase', required=False, default=None)
    processed = parser.parse_args(remaining)
    processed = vars(processed)
    private_key_file = processed.get('private_key_file')
    passphrase = processed.get('key_passphrase')
    if response.status_code != 200:
        return response
    response_json = utils.web_response_to_json(response)
    try:
        response_body = response_json['GetPasswordDataResponse']
        encrypted_password = response_body['passwordData']
        if not private_key_file or not encrypted_password:
            return response
        decrypted_password = decrypt_instance_password(encrypted_password,
                                                       private_key_file,
                                                       passphrase)
        response_json['GetPasswordDataResponse']['passwordData'] = \
                                                  decrypted_password
        return response_json
    except KeyError as ke:
        raise exception.UnknownOutputFormat()
Ejemplo n.º 4
0
def get_metric_statistics(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--metric-name', nargs='?', required=True)
    parser.add_argument('--namespace', nargs='?', required=True)
    parser.add_argument('--start-time', nargs='?', required=True)
    parser.add_argument('--end-time', nargs='?', required=True)
    parser.add_argument('--period', nargs='?', type=int, required=True)
    parser.add_argument(
        '--units',
        nargs='?',
        choices=[
            'Seconds', 'Microseconds', 'Milliseconds', 'Bytes', 'Kilobytes',
            'Megabytes', 'Gigabytes', 'Terabytes', 'Bits', 'Kilobits',
            'Megabits', 'Gigabits', 'Terabits', 'Percent', 'Count',
            'Bytes/Second', 'Kilobytes/Second', 'Megabytes/Second',
            'Gigabytes/Second', 'Terabytes/Second', 'Bits/Second',
            'Kilobits/Second', 'Megabits/Second', 'Gigabits/Second',
            'Terabits/Second', 'Count/Second', 'None'
        ],
        required=False)
    parser.add_argument(
        '--statistics',
        nargs='+',
        choices=['SampleCount', 'Average', 'Sum', 'Minimum', 'Maximum'],
        required=True)
    parser.add_argument('--dimensions', nargs='+', required=False)
    args = parser.parse_args(args)
    mon_utils.populate_monitoring_params_from_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 5
0
def revoke_security_group_egress(url, verb, headers, version, args):

    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    create_sec_group_rule(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 6
0
def revoke_security_group_egress(url, verb, headers, version, args):

    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    create_sec_group_rule(params,args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 7
0
def describe_key_pairs(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    if len(args):
        msg = "Unexpected input received. Please check help for valid arguments."
        raise KeyError(msg)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 8
0
def describe_key_pairs(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])                    
    params['Version'] = version
    args = args[1:]
    if len(args):
        msg = "Unexpected input received. Please check help for valid arguments."
        raise KeyError(msg)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 9
0
def describe_instance_types(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--instance-type-ids', nargs='+', required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 10
0
def describe_db_instances(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--db-instance-identifier', required=False, help='server name')
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 11
0
def delete_key_pair(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--key-name', required=True)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 12
0
def delete_volume(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--volume-id', required=True)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 13
0
def describe_images(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--image-ids', nargs='+', required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 14
0
def create_db_snapshot(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--db-instance-identifier', required=True)
    parser.add_argument('--db-snapshot-identifier', required=True)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 15
0
def create_db_snapshot(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--db-instance-identifier', required=True)
    parser.add_argument('--db-snapshot-identifier', required=True)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 16
0
def import_key_pair(url, verb, headers, version, args): 
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])                    
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--key-name', required=True)
    parser.add_argument('--public-key-material', required=True)
    args= parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params) 
Ejemplo n.º 17
0
def create_snapshot(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--volume-id', required=True)
    parser.add_argument('--size', type=int, required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 18
0
def create_subnet(url, verb, headers, version, args):

    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--vpc-id', required=True)
    parser.add_argument('--cidr-block', required=True)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 19
0
def associate_address(url, verb, headers, version, args):

    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--allocation-id', required=True)
    parser.add_argument('--instance-id', required=True)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 20
0
def describe_snapshots(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--snapshot-ids', nargs='+', required=False)
    parser.add_argument('--max-results', type=int, required=False)
    parser.add_argument('--next-token', required=False)
    parser.add_argument('--detail', type=bool, required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 21
0
def describe_volumes(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--volume-ids', nargs='+', required=False)
    parser.add_argument('--max-results', type=int, required=False)
    parser.add_argument('--next-token', required=False)
    parser.add_argument('--detail', type=bool, required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 22
0
def create_route(url, verb, headers, version, args):

    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--route-table-id',required=True)
    parser.add_argument('--destination-cidr-block',required=True)
    parser.add_argument('--instance-id',required=True)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 23
0
def describe_instances(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--instance-ids', nargs='+', required=False)
    # Right now filters functionality is broken, it works only
    # for cases like --filters "Name=abc,Values=def"
    parser.add_argument('--filters', nargs='+', required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 24
0
def describe_instances(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--instance-ids', nargs='+', required=False)
    # Right now filters functionality is broken, it works only
    # for cases like --filters "Name=abc,Values=def"
    parser.add_argument('--filters', nargs='+', required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 25
0
def modify_db_instance(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--db-instance-identifier', required=True)
    parser.add_argument('--preferred-maintenance-window', required=False)
    parser.add_argument('--preferred-backup-window', required=False)
    parser.add_argument('--backup-retention-period', required=False)
    parser.add_argument('--new-db-instance-identifier', required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 26
0
def create_security_group(url, verb, headers, version, args):

    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--vpc-id', required=True)
    parser.add_argument('--group-name', required=True)
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('--description', dest='group_description')
    group.add_argument('--group-description', dest='group_description')
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 27
0
def restore_db_instance_from_db_snapshot(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--db-instance-identifier', required=True)
    parser.add_argument('--db-snapshot-identifier', required=True)
    parser.add_argument('--db-instance-class', required=False)
    parser.add_argument('--preferred-maintenance-window', required=False)
    parser.add_argument('--preferred-backup-window', required=False)
    parser.add_argument('--backup-retention-period', required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 28
0
def create_db_instance(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--db-instance-identifier', required=True, help='server name')
    parser.add_argument('--db-instance-class', required=True)
    parser.add_argument('--engine', required=True)
    parser.add_argument('--allocated-storage', required=True)
    parser.add_argument('--master-username', required=True)
    parser.add_argument('--master-user-password', required=True)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 29
0
def list_metrics(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--metric-name', nargs='?', required=False)
    parser.add_argument('--starting-token', nargs='?', required=False,
                        dest='next_token')
    parser.add_argument('--max-items', nargs='?', type=int, required=False)
    parser.add_argument('--namespace', nargs='?', required=False)
    parser.add_argument('--dimensions', nargs='+', required=False)
    args = parser.parse_args(args)
    mon_utils.populate_monitoring_params_from_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 30
0
def create_security_group(url, verb, headers, version, args):

    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--vpc-id',required=True)
    parser.add_argument('--group-name',required=True)
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('--description', dest='group_description')
    group.add_argument('--group-description', dest='group_description')
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 31
0
def run_instances(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--instance-type-id', required=True)
    parser.add_argument('--image-id', required=True)
    parser.add_argument('--subnet-id', required=False)
    parser.add_argument('--security-group-ids', nargs='+', required=False)
    parser.add_argument('--key-name', required=False)
    parser.add_argument('--instance-count', type=int, required=False)
    parser.add_argument('--private-ip-address', required=False)
    parser.add_argument('--block-device-mappings', nargs='+', required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 32
0
def list_metrics(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--metric-name', nargs='?', required=False)
    parser.add_argument('--starting-token',
                        nargs='?',
                        required=False,
                        dest='next_token')
    parser.add_argument('--max-items', nargs='?', type=int, required=False)
    parser.add_argument('--namespace', nargs='?', required=False)
    parser.add_argument('--dimensions', nargs='+', required=False)
    args = parser.parse_args(args)
    mon_utils.populate_monitoring_params_from_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 33
0
def delete_db_instance(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--db-instance-identifier', required=True)
    # TODO(rushiagr): If one doesn't specify skip-final-snapshot, then he/she
    # has to specify final-db-snapshot-identifier compulsarily. Add this check
    final_arg = parser.add_mutually_exclusive_group(required=True)
    final_arg.add_argument('--skip-final-snapshot', dest='skip_final_snapshot',
            action='store_true')
    final_arg.set_defaults(skip_final_snapshot=False)
    final_arg.add_argument('--final-db-snapshot-identifier', required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 34
0
def delete_db_instance(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--db-instance-identifier', required=True)
    # TODO(rushiagr): If one doesn't specify skip-final-snapshot, then he/she
    # has to specify final-db-snapshot-identifier compulsarily. Add this check
    final_arg = parser.add_mutually_exclusive_group(required=True)
    final_arg.add_argument('--skip-final-snapshot', dest='skip_final_snapshot',
            action='store_true')
    final_arg.set_defaults(skip_final_snapshot=False)
    final_arg.add_argument('--final-db-snapshot-identifier', required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 35
0
def run_instances(url, verb, headers, version, args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    params['Version'] = version
    args = args[1:]
    parser = utils.get_argument_parser()
    parser.add_argument('--instance-type-id', required=True)
    parser.add_argument('--image-id', required=True)
    parser.add_argument('--subnet-id', required=False)
    parser.add_argument('--security-group-ids', nargs='+', required=False)
    parser.add_argument('--key-name', required=False)
    parser.add_argument('--instance-count', type=int, required=False)
    parser.add_argument('--private-ip-address', required=False)
    parser.add_argument('--block-device-mappings', nargs='+', required=False)
    args = parser.parse_args(args)
    utils.populate_params_from_cli_args(params, args)
    return requestify.make_request(url, verb, headers, params)
Ejemplo n.º 36
0
def utility(args):
    params = {}
    params['Action'] = utils.dash_to_camelcase(args[0])
    args = args[1:]
    parser = utils.get_argument_parser()
    return params, parser, args