Skip to content

Commit

Permalink
Adding a simple MSO example
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Smith committed Oct 30, 2019
1 parent 6521311 commit 2c73a29
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions samples/aci-show-tenants-in-multisite-orchestrator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Sample code accessing the Cisco Multisite Orchestrator
from requests import Session


# Replace the following variables with the correct values for your deployment.
username = 'admin'
password = 'password'
mso_ip = '10.10.10.10'


def show_tenants():
# Login to Multisite Orchestrator
session = Session()
data = {'username': username, 'password': password}
resp = session.post('https://%s/api/v1/auth/login' % mso_ip, json=data, verify=False)
if not resp.ok:
print('Could not login to Multisite Orchestrator')
return

# Get the tenants
headers = {"Authorization": "Bearer %s" % resp.json()['token']}
resp = session.get('https://%s/api/v1/tenants' % mso_ip, headers=headers)
if not resp.ok:
print('Could not get tenants from Multisite Orchestrator')
return

# Print the result
print('Tenants')
print('-' * len('Tenants'))
for tenant in resp.json()['tenants']:
print(tenant['displayName'])


if __name__ == '__main__':
show_tenants()

0 comments on commit 2c73a29

Please sign in to comment.