mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 11:18:03 +00:00
Nightly Sanity - Create RADIUS profile via API
This commit is contained in:
@@ -269,6 +269,7 @@ from lab_ap_info import ap_models
|
||||
from lab_ap_info import customer_id
|
||||
from lab_ap_info import cloud_type
|
||||
from lab_ap_info import test_cases
|
||||
from lab_ap_info import radius_info
|
||||
|
||||
|
||||
############################################################################
|
||||
@@ -624,6 +625,34 @@ for key in equipment_id_dict:
|
||||
with open(report_path + today + '/report_data.json', 'w') as report_json_file:
|
||||
json.dump(report_data, report_json_file)
|
||||
|
||||
### Create RADIUS profile - used for all EAP SSIDs
|
||||
radius_template = "templates/radius_profile_template.json"
|
||||
radius_name = radius_info['name']
|
||||
subnet_name = radius_info['subnet_name']
|
||||
subnet = radius_info['subnet']
|
||||
subnet_mask = radius_info['subnet_mask']
|
||||
region = radius_info['region']
|
||||
server_name = radius_info['server_name']
|
||||
server_ip = radius_info['server_ip']
|
||||
secret = radius_info['secret']
|
||||
auth_port = radius_info['auth_port']
|
||||
try:
|
||||
radius_profile = CloudSDK.create_radius_profile(cloudSDK_url, bearer, radius_template, radius_name, subnet_name, subnet,
|
||||
subnet_mask, region, server_name, server_ip, secret, auth_port)
|
||||
print("radius profile Id is", radius_profile)
|
||||
client.update_testrail(case_id=test_cases["radius_profile"], run_id=rid, status_id=1,
|
||||
msg='RADIUS profile created successfully')
|
||||
report_data['tests'][key][test_cases["radius_profile"]] = "passed"
|
||||
except:
|
||||
radius_profile = 'error'
|
||||
print("RADIUS Profile Create Error, will use existing profile for tests")
|
||||
#Set backup profile ID so test can continue
|
||||
radius_profile = lab_ap_info.radius_profile
|
||||
server_name = "Lab-RADIUS"
|
||||
client.update_testrail(case_id=test_cases["radius_profile"], run_id=rid, status_id=5,
|
||||
msg='Failed to create RADIUS profile')
|
||||
report_data['tests'][key][test_cases["radius_profile"]] = "failed"
|
||||
|
||||
###########################################################################
|
||||
############## Bridge Mode Client Connectivity ############################
|
||||
###########################################################################
|
||||
@@ -635,7 +664,7 @@ for key in equipment_id_dict:
|
||||
try:
|
||||
fiveG_eap = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, fw_model + '_5G_EAP_' + today,
|
||||
profile_info_dict[fw_model]["fiveG_WPA2-EAP_SSID"], None,
|
||||
"Lab-RADIUS",
|
||||
radius_name,
|
||||
"wpa2OnlyRadius", "BRIDGE", 1, ["is5GHzU", "is5GHz", "is5GHzL"])
|
||||
print("5G EAP SSID created successfully - bridge mode")
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_eap_bridge"], run_id=rid, status_id=1, msg='5G EAP SSID created successfully - bridge mode')
|
||||
@@ -689,7 +718,7 @@ for key in equipment_id_dict:
|
||||
twoFourG_eap = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template,
|
||||
fw_model + '_2G_EAP_' + today,
|
||||
profile_info_dict[fw_model]["twoFourG_WPA2-EAP_SSID"], None,
|
||||
"Lab-RADIUS", "wpa2OnlyRadius", "BRIDGE", 1, ["is2dot4GHz"])
|
||||
radius_name, "wpa2OnlyRadius", "BRIDGE", 1, ["is2dot4GHz"])
|
||||
print("2.4G EAP SSID created successfully - bridge mode")
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_eap_bridge"], run_id=rid, status_id=1,
|
||||
msg='2.4G EAP SSID created successfully - bridge mode')
|
||||
@@ -716,7 +745,7 @@ for key in equipment_id_dict:
|
||||
except:
|
||||
twoFourG_wpa2 = "error"
|
||||
print("2.4G WPA2 SSID create failed - bridge mode")
|
||||
client.update_testrail(case_id="5645", run_id=rid, status_id=5,
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_wpa2_bridge"], run_id=rid, status_id=5,
|
||||
msg='2.4G WPA2 SSID create failed - bridge mode')
|
||||
report_data['tests'][key][test_cases["ssid_2g_wpa2_bridge"]] = "failed"
|
||||
twoFourG_wpa2 = profile_info_dict[fw_model]["twoFourG_WPA2_SSID"]
|
||||
@@ -741,8 +770,8 @@ for key in equipment_id_dict:
|
||||
twoFourG_wpa = profile_info_dict[fw_model]["twoFourG_WPA_SSID"]
|
||||
|
||||
### Create AP Bridge Profile
|
||||
rfProfileId = lab_ap_info.radius_profile
|
||||
radiusProfileId = lab_ap_info.rf_profile
|
||||
rfProfileId = lab_ap_info.rf_profile
|
||||
radiusProfileId = radius_profile
|
||||
child_profiles = [fiveG_eap, fiveG_wpa2, fiveG_wpa, twoFourG_eap, twoFourG_wpa2, twoFourG_wpa, rfProfileId, radiusProfileId]
|
||||
print(child_profiles)
|
||||
|
||||
@@ -961,7 +990,7 @@ for key in equipment_id_dict:
|
||||
fiveG_eap = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template,
|
||||
fw_model + '_5G_EAP_NAT_' + today,
|
||||
profile_info_dict[fw_model + '_nat']["fiveG_WPA2-EAP_SSID"], None,
|
||||
"Lab-RADIUS",
|
||||
radius_name,
|
||||
"wpa2OnlyRadius", "NAT", 1,
|
||||
["is5GHzU", "is5GHz", "is5GHzL"])
|
||||
print("5G EAP SSID created successfully - NAT mode")
|
||||
@@ -1021,7 +1050,7 @@ for key in equipment_id_dict:
|
||||
fw_model + '_2G_EAP_NAT_' + today,
|
||||
profile_info_dict[fw_model + '_nat']["twoFourG_WPA2-EAP_SSID"],
|
||||
None,
|
||||
"Lab-RADIUS", "wpa2OnlyRadius", "NAT", 1, ["is2dot4GHz"])
|
||||
radius_name, "wpa2OnlyRadius", "NAT", 1, ["is2dot4GHz"])
|
||||
print("2.4G EAP SSID created successfully - NAT mode")
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_eap_nat"], run_id=rid, status_id=1,
|
||||
msg='2.4G EAP SSID created successfully - NAT mode')
|
||||
@@ -1073,8 +1102,8 @@ for key in equipment_id_dict:
|
||||
twoFourG_wpa = profile_info_dict[fw_model + '_nat']["twoFourG_WPA_SSID"]
|
||||
|
||||
### Create AP NAT Profile
|
||||
rfProfileId = lab_ap_info.radius_profile
|
||||
radiusProfileId = lab_ap_info.rf_profile
|
||||
rfProfileId = lab_ap_info.rf_profile
|
||||
radiusProfileId = radius_profile
|
||||
child_profiles = [fiveG_eap, fiveG_wpa2, fiveG_wpa, twoFourG_eap, twoFourG_wpa2, twoFourG_wpa, rfProfileId,
|
||||
radiusProfileId]
|
||||
print(child_profiles)
|
||||
@@ -1290,7 +1319,7 @@ for key in equipment_id_dict:
|
||||
fiveG_eap = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template,
|
||||
fw_model + '_5G_EAP_VLAN' + today,
|
||||
profile_info_dict[fw_model + '_vlan']["fiveG_WPA2-EAP_SSID"], None,
|
||||
"Lab-RADIUS",
|
||||
radius_name,
|
||||
"wpa2OnlyRadius", "BRIDGE", 100, ["is5GHzU", "is5GHz", "is5GHzL"])
|
||||
print("5G EAP SSID created successfully - custom VLAN mode")
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_eap_vlan"], run_id=rid, status_id=1,
|
||||
@@ -1349,7 +1378,7 @@ for key in equipment_id_dict:
|
||||
fw_model + '_2G_EAP_VLAN_' + today,
|
||||
profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2-EAP_SSID"],
|
||||
None,
|
||||
"Lab-RADIUS", "wpa2OnlyRadius", "BRIDGE", 100, ["is2dot4GHz"])
|
||||
radius_name, "wpa2OnlyRadius", "BRIDGE", 100, ["is2dot4GHz"])
|
||||
print("2.4G EAP SSID created successfully - custom VLAN mode")
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_eap_vlan"], run_id=rid, status_id=1,
|
||||
msg='2.4G EAP SSID created successfully - custom VLAN mode')
|
||||
@@ -1401,8 +1430,8 @@ for key in equipment_id_dict:
|
||||
twoFourG_wpa = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_SSID"]
|
||||
|
||||
### Create AP VLAN Profile
|
||||
rfProfileId = lab_ap_info.radius_profile
|
||||
radiusProfileId = lab_ap_info.rf_profile
|
||||
rfProfileId = lab_ap_info.rf_profile
|
||||
radiusProfileId = radius_profile
|
||||
child_profiles = [fiveG_eap, fiveG_wpa2, fiveG_wpa, twoFourG_eap, twoFourG_wpa2, twoFourG_wpa, rfProfileId, radiusProfileId]
|
||||
print(child_profiles)
|
||||
ap_template = "templates/ap_profile_template.json"
|
||||
|
||||
@@ -223,3 +223,45 @@ class CloudSDK:
|
||||
#print(ssid_profile)
|
||||
ssid_profile_id = ssid_profile['id']
|
||||
return ssid_profile_id
|
||||
|
||||
def create_radius_profile(cloudSDK_url, bearer, template, name, subnet_name, subnet, subnet_mask, region, server_name, server_ip, secret, auth_port):
|
||||
with open(template, 'r+') as radius_profile:
|
||||
profile = json.load(radius_profile)
|
||||
|
||||
profile['name'] = name
|
||||
|
||||
subnet_config = profile['details']['subnetConfiguration']
|
||||
old_subnet_name = list(subnet_config.keys())[0]
|
||||
subnet_config[subnet_name] = subnet_config.pop(old_subnet_name)
|
||||
profile['details']['subnetConfiguration'][subnet_name]['subnetAddress'] = subnet
|
||||
profile['details']['subnetConfiguration'][subnet_name]['subnetCidrPrefix'] = subnet_mask
|
||||
profile['details']['subnetConfiguration'][subnet_name]['subnetName'] = subnet_name
|
||||
|
||||
region_map = profile['details']['serviceRegionMap']
|
||||
old_region = list(region_map.keys())[0]
|
||||
region_map[region] = region_map.pop(old_region)
|
||||
profile['details']['serviceRegionName'] = region
|
||||
profile['details']['subnetConfiguration'][subnet_name]['serviceRegionName'] = region
|
||||
profile['details']['serviceRegionMap'][region]['regionName'] = region
|
||||
|
||||
server_map = profile['details']['serviceRegionMap'][region]['serverMap']
|
||||
old_server_name = list(server_map.keys())[0]
|
||||
server_map[server_name] = server_map.pop(old_server_name)
|
||||
profile['details']['serviceRegionMap'][region]['serverMap'][server_name][0]['ipAddress'] = server_ip
|
||||
profile['details']['serviceRegionMap'][region]['serverMap'][server_name][0]['secret'] = secret
|
||||
profile['details']['serviceRegionMap'][region]['serverMap'][server_name][0]['authPort'] = auth_port
|
||||
|
||||
with open(template, 'w') as radius_profile:
|
||||
json.dump(profile, radius_profile)
|
||||
|
||||
url = cloudSDK_url + "/portal/profile"
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + bearer
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=open(template, 'rb'))
|
||||
radius_profile = response.json()
|
||||
#print(radius_profile)
|
||||
#print(ssid_profile)
|
||||
radius_profile_id = radius_profile['id']
|
||||
return radius_profile_id
|
||||
@@ -12,6 +12,19 @@ lanforge_2dot4g = "wiphy0"
|
||||
lanforge_5g = "wiphy3"
|
||||
lanforge_prefix = "sdk"
|
||||
|
||||
##RADIUS Info
|
||||
radius_info = {
|
||||
|
||||
"name": "Lab-RADIUS",
|
||||
"subnet_name": "Lab",
|
||||
"subnet": "10.10.0.0",
|
||||
"subnet_mask": 16,
|
||||
"region": "Toronto",
|
||||
"server_name": "Lab-RADIUS",
|
||||
"server_ip": "10.10.10.203",
|
||||
"secret": "testing123",
|
||||
"auth_port": 1812
|
||||
}
|
||||
##AP Models for firmware upload
|
||||
cloud_sdk_models = {
|
||||
"ec420": "EC420-G1",
|
||||
@@ -118,7 +131,8 @@ test_cases = {
|
||||
"ssid_2g_wpa_vlan": 5658,
|
||||
"ssid_5g_eap_vlan": 5659,
|
||||
"ssid_5g_wpa2_vlan": 5660,
|
||||
"ssid_5g_wpa_vlan": 5661
|
||||
"ssid_5g_wpa_vlan": 5661,
|
||||
"radius_profile": 5808
|
||||
}
|
||||
|
||||
## Other profiles
|
||||
|
||||
@@ -175,6 +175,16 @@ $json = json_decode($results, true);
|
||||
<TD><?php echo print_r($json['tests']['ec420']['5222'],true) ?></TD>
|
||||
</TR>
|
||||
|
||||
<TR ALIGN="CENTER">
|
||||
<TD>5808</TD>
|
||||
<TD>CloudSDK</TD>
|
||||
<TD ALIGN="LEFT">Create RADIUS Profile </TD>
|
||||
<TD><?php echo print_r($json['tests']['ea8300']['5808'],true) ?></TD>
|
||||
<TD><?php echo print_r($json['tests']['ecw5211']['5808'],true) ?></TD>
|
||||
<TD><?php echo print_r($json['tests']['ecw5410']['5808'],true) ?></TD>
|
||||
<TD><?php echo print_r($json['tests']['ec420']['5808'],true) ?></TD>
|
||||
</TR>
|
||||
|
||||
<TR ALIGN="CENTER">
|
||||
<TD>5644</TD>
|
||||
<TD>CloudSDK</TD>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"model_type": "Profile", "id": 718, "customerId": 8, "profileType": "radius", "name": "Lab-RADIUS", "details": {"model_type": "RadiusProfile", "subnetConfiguration": {"Lab": {"model_type": "RadiusSubnetConfiguration", "subnetAddress": "10.10.0.0", "subnetCidrPrefix": 16, "subnetName": "Lab", "proxyConfig": {"model_type": "RadiusProxyConfiguration", "floatingIpAddress": null, "floatingIfCidrPrefix": null, "floatingIfGwAddress": null, "floatingIfVlan": null, "sharedSecret": null}, "probeInterval": null, "serviceRegionName": "Toronto"}}, "serviceRegionMap": {"Toronto": {"model_type": "RadiusServiceRegion", "serverMap": {"Lab-RADIUS": [{"model_type": "RadiusServer", "ipAddress": "10.10.10.203", "secret": "testing123", "authPort": 1812, "timeout": null}]}, "regionName": "Toronto"}}, "profileType": "radius", "serviceRegionName": "Toronto"}, "createdTimestamp": 1610045826067, "lastModifiedTimestamp": 1610045826067, "childProfileIds": []}
|
||||
Reference in New Issue
Block a user