mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2025-11-03 12:27:53 +00:00
removed file IO for radius
This commit is contained in:
@@ -882,25 +882,22 @@ class CloudSDK:
|
|||||||
def create_or_update_radius_profile(self, cloudSDK_url, bearer, customer_id, template, name, subnet_name, subnet,
|
def create_or_update_radius_profile(self, cloudSDK_url, bearer, customer_id, template, name, subnet_name, subnet,
|
||||||
subnet_mask,
|
subnet_mask,
|
||||||
region, server_name, server_ip, secret, auth_port):
|
region, server_name, server_ip, secret, auth_port):
|
||||||
with open(template, 'r+') as radius_profile:
|
null = None
|
||||||
profile = json.load(radius_profile)
|
profile = {"model_type": "Profile", "id": 129, "customerId": "2", "profileType": "radius", "name": "Automation_Radius_Nightly-1553", "details": {"model_type": "RadiusProfile", "primaryRadiusAuthServer": {"model_type": "RadiusServer", "ipAddress": "18.189.25.141", "secret": "testing123", "port": 1812, "timeout": 5}, "secondaryRadiusAuthServer": null, "primaryRadiusAccountingServer": null, "secondaryRadiusAccountingServer": null, "profileType": "radius"}, "createdTimestamp": 1602263176599, "lastModifiedTimestamp": 1611708334061, "childProfileIds": []}
|
||||||
|
|
||||||
# profile = {"model_type": "Profile", "id": 129, "customerId": "2", "profileType": "radius", "name": "Automation_Radius_Nightly", "details": {"model_type": "RadiusProfile", "primaryRadiusAuthServer": {"model_type": "RadiusServer", "ipAddress": "18.189.25.141", "secret": "testing123", "port": 1812, "timeout": 5}, "secondaryRadiusAuthServer": null, "primaryRadiusAccountingServer": null, "secondaryRadiusAccountingServer": null, "profileType": "radius"}, "createdTimestamp": 1602263176599, "lastModifiedTimestamp": 1611708334061, "childProfileIds": []}
|
|
||||||
profile['name'] = name
|
profile['name'] = name
|
||||||
profile['customerId'] = customer_id
|
profile['customerId'] = customer_id
|
||||||
profile['details']["primaryRadiusAuthServer"]['ipAddress'] = server_ip
|
profile['details']["primaryRadiusAuthServer"]['ipAddress'] = server_ip
|
||||||
profile['details']["primaryRadiusAuthServer"]['secret'] = secret
|
profile['details']["primaryRadiusAuthServer"]['secret'] = secret
|
||||||
profile['details']["primaryRadiusAuthServer"]['port'] = auth_port
|
profile['details']["primaryRadiusAuthServer"]['port'] = auth_port
|
||||||
|
|
||||||
with open(template, 'w') as radius_profile:
|
|
||||||
json.dump(profile, radius_profile)
|
|
||||||
|
|
||||||
url = cloudSDK_url + "/portal/profile"
|
url = cloudSDK_url + "/portal/profile"
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'Bearer ' + bearer
|
'Authorization': 'Bearer ' + bearer
|
||||||
}
|
}
|
||||||
response = requests.request("POST", url, headers=headers, data=open(template, 'rb'))
|
|
||||||
|
json_profile_data = json.dumps(profile).encode("utf-8")
|
||||||
|
response = requests.request("POST", url, headers=headers, data=json_profile_data)
|
||||||
radius_profile = response.json()
|
radius_profile = response.json()
|
||||||
radius_profile_id = radius_profile['id']
|
radius_profile_id = radius_profile['id']
|
||||||
return radius_profile_id
|
return radius_profile_id
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ def main():
|
|||||||
if not args.skip_profiles:
|
if not args.skip_profiles:
|
||||||
if not args.skip_radius:
|
if not args.skip_radius:
|
||||||
# Radius Profile needs to be set here
|
# Radius Profile needs to be set here
|
||||||
radius_name = "Automation_Radius_Nightly-09"
|
radius_name = "Test_Radius" + str(time.time()).split(".")[0]
|
||||||
radius_template = "templates/radius_profile_template.json"
|
radius_template = "templates/radius_profile_template.json"
|
||||||
ap_object.create_radius_profile(radius_name=radius_name, radius_template=radius_template, rid=rid, key=fw_model)
|
ap_object.create_radius_profile(radius_name=radius_name, radius_template=radius_template, rid=rid, key=fw_model)
|
||||||
|
|
||||||
@@ -206,3 +206,4 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user