-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Smith
committed
Oct 30, 2019
1 parent
6521311
commit 2c73a29
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |