Skip to content

Instantly share code, notes, and snippets.

@mtellin
Created March 9, 2019 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtellin/9b5d59ff06b2708fbd792c8f6da85090 to your computer and use it in GitHub Desktop.
Save mtellin/9b5d59ff06b2708fbd792c8f6da85090 to your computer and use it in GitHub Desktop.
Shows getting a list of all VMs using the requests module instead of the Rubrik SDK
#!/usr/bin/env python3
rubrik_server = "10.0.11.14"
rubrik_user = "admin"
rubrik_pass = "password"
import requests
session = requests.post('https://{}/api/v1/session'.format(rubrik_server), verify = False, auth =(rubrik_user,rubrik_pass))
session_token = session.json()
authorization = 'Bearer ' + session_token['token']
vm_list = requests.get('https://{}/api/v1/vmware/vm'.format(rubrik_server), verify = False, headers = {'Content-Type': 'application/json', 'Authorization': authorization})
vm_list_json = vm_list.json()
print(vm_list_json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment