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()
def create_resource_based_policy(self, args): params, parser, args = utility(args) parser.add_argument('--policy-document', required = True) args = parser.parse_args(args) utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)
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()
def create_group(self, args): params, parser, args = utility(args) parser.add_argument('--name', required = True) parser.add_argument('--description') args = parser.parse_args(args) utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)
def create_user(self, args): params, parser, args = utility(args) parser.add_argument('--name', required = True) parser.add_argument('--email') parser.add_argument('--password') args = parser.parse_args(args) utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)
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)
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)
def get_resource_based_policy_summary(self, args): params, parser, args = utility(args) parser.add_argument('--name') parser.add_argument('--id') args = parser.parse_args(args) if args.name is None and args.id is None: parser.error("at least one of --name and --id required") utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)
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)
def delete_user(self, args): params, parser, args = utility(args) parser.add_argument('--name', required = False) parser.add_argument('--id', required = False) args = parser.parse_args(args) if args.name is None and args.id is None: parser.error("at least one of --name and --id required") utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)
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)
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)
def delete_credential(self, args): params, parser, args = utility(args) parser.add_argument('--access-key') parser.add_argument('--id') args = parser.parse_args(args) if args.access_key is None and args.id is None: parser.error("at least one of --access-key and --id required") utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)
def get_user_credential(self, args): params, parser, args = utility(args) parser.add_argument('--user-name') parser.add_argument('--user-id') args = parser.parse_args(args) if args.user_name is None and args.user_id is None: parser.error("at least one of --user-name and --user-id required") utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)
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)
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)
def detach_policy_from_resource(self, args): params, parser, args = utility(args) parser.add_argument('--policy-name') parser.add_argument('--policy-id') parser.add_argument('--policy-document', required = True) args = parser.parse_args(args) if args.policy_name is None and args.policy_id is None: parser.error("at least one of --policy-name and --policy-id required") utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)
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)
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)
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)
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)
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)
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)
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)
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)
def attach_policy_to_group(self, args): params, parser, args = utility(args) parser.add_argument('--group-name') parser.add_argument('--group-id') parser.add_argument('--policy-name') parser.add_argument('--policy-id') args = parser.parse_args(args) if args.group_name is None and args.group_id is None: parser.error("at least one of --group-name and --group-id required") if args.policy_name is None and args.policy_id is None: parser.error("at least one of --policy-name and --policy-id required") utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)
def update_group(self, args): params, parser, args = utility(args) parser.add_argument('--name') parser.add_argument('--id') parser.add_argument('--new-name') parser.add_argument('--new-description') args = parser.parse_args(args) if args.name is None and args.id is None: parser.error("at least one of --name and --id required") if args.new_name is None and args.new_description is None: parser.error("at least one of --new-name and --new-description is required") utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)
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)
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)
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)
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)
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)
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)
def list_users(self, args): params, parser, args = utility(args) args = parser.parse_args(args) utils.populate_params_from_cli_args(params, args) return requestify.make_request(self.url, self.verb, self.headers, params)