diff --git a/requirements.txt b/requirements.txt index 0be90dc..d55dd06 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ requests -tabulate -jq \ No newline at end of file +tabulate \ No newline at end of file diff --git a/unmount_oracle_livemount.py b/unmount_oracle_livemount.py new file mode 100755 index 0000000..cba3245 --- /dev/null +++ b/unmount_oracle_livemount.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 + +import json +import sys +import argparse +from rsc import RSCAuth, RSCGraphQL + +def unmount_oracle_livemount(livemount_id, force=False): + # Initialize auth + auth = RSCAuth() + + # Initialize GraphQL client + gql = RSCGraphQL(auth) + + # GraphQL mutation to unmount Oracle Live Mount + mutation = """ + mutation OracleLiveMountUnmountMutation($input: DeleteOracleMountInput!) { + deleteOracleMount(input: $input) { + id + links { + href + rel + } + } + } + """ + + variables = { + "input": { + "id": livemount_id, + "force": force + } + } + + # Execute mutation + response = gql.query(mutation, variables) + + # Print result + result = response['data']['deleteOracleMount'] + print(f"Successfully initiated unmount for Live Mount ID: {result['id']}") + if result['links']: + print("Links:") + for link in result['links']: + print(f" {link['rel']}: {link['href']}") + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Unmount an Oracle Live Mount') + parser.add_argument('id', help='RSC ID of the Oracle Live Mount to unmount') + parser.add_argument('--force', action='store_true', help='Force unmount even if in use') + + args = parser.parse_args() + + try: + unmount_oracle_livemount(args.id, args.force) + except Exception as e: + print(f"Error: {e}", file=sys.stderr) + sys.exit(1) \ No newline at end of file