blob: 96f2fe0f02b43edb918c0f7441779c3c58c0f4cb [file] [log] [blame]
Shad Ansari3a48b642021-12-01 22:42:19 +00001"""
2SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
3SPDX-License-Identifier: LicenseRef-ONF-Member-1.01
4"""
5
6import requests
7import json
8from requests.structures import CaseInsensitiveDict
9
10TOKEN = '### A VALID TOKEN ###'
11
12#URL = "https://roc.aetherproject.org/aether-roc-api/aether/v4.0.0/connectivity-service-v4/"
13URL = "https://roc.staging.aether.onlab.us/aether-roc-api/aether/v4.0.0/connectivity-service-v4/"
14
15roc_headers = CaseInsensitiveDict()
16roc_headers["Content-Type"] = "application/json"
17roc_headers["Authorization"] = "Bearer " + TOKEN
18
19
20def get_mbr(device_group):
21 url = URL + "vcs/vcs/vcs-{}/slice/mbr".format(device_group)
22 response = requests.get(url, headers=roc_headers)
23 assert response.status_code == 200, "Failed to get mbr"
24 mbr = json.loads(response.text)
25 return mbr
26
27
28def set_mbr(device_group, mbr):
29 url = URL + "vcs/vcs/vcs-{}/slice/mbr".format(device_group)
30 response = requests.post(url, headers=roc_headers, json=mbr)
31 assert response.status_code == 201, "Failed to set mbr"
32
33
34if __name__ == '__main__':
35 mbr = get_mbr("cameras-4g")
36 print("uplink mbr:{}, downlink mbr: {}".format(mbr["uplink"], mbr["downlink"]))
37 mbr={'downlink':mbr["downlink"],'uplink':mbr["uplink"]}
38 set_mbr("cameras-4g", mbr)
39 mbr = get_mbr("cameras-4g")
40 print("uplink mbr:{}, downlink mbr: {}".format(mbr["uplink"], mbr["downlink"]))