Unmount script
This commit is contained in:
@@ -1,3 +1,2 @@
|
||||
requests
|
||||
tabulate
|
||||
jq
|
||||
tabulate
|
||||
57
unmount_oracle_livemount.py
Executable file
57
unmount_oracle_livemount.py
Executable file
@@ -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)
|
||||
Reference in New Issue
Block a user