mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2026-01-11 14:45:32 +00:00
cloudsdk: Support deleting equipment profiles.
Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
@@ -637,7 +637,7 @@ for key in equipment_ids:
|
||||
|
||||
# First, remove any existing profiles
|
||||
# Paginated reads means we get an array of json objects back, one object per 'page'
|
||||
# NOTE: Cloud gives error when I try to remove these. Not sure removal works?
|
||||
# NOTE: You cannot remove profiles in use
|
||||
#profs = cloud.get_customer_profiles(cloudSDK_url, bearer, customer_id)
|
||||
#for p in profs:
|
||||
# for e in p['items']:
|
||||
@@ -650,11 +650,11 @@ for key in equipment_ids:
|
||||
# for pn in prof_names:
|
||||
# if pn == prof_name:
|
||||
# print("Deleting existing profile name: ", pn)
|
||||
# cloud.delete_customer_profile(cloudSDK_url, bearer, customer_id, prof_id)
|
||||
# cloud.delete_profile(cloudSDK_url, bearer, prof_id)
|
||||
# for pn in prof_names_eap:
|
||||
# if pn == prof_name:
|
||||
# print("Deleting existing profile name: ", pn)
|
||||
# cloud.delete_customer_profile(cloudSDK_url, bearer, customer_id, prof_id)
|
||||
# cloud.delete_profile(cloudSDK_url, bearer, prof_id)
|
||||
|
||||
### Create RADIUS profile - used for all EAP SSIDs
|
||||
radius_template = "Radius-Profile" # Default radius profile found in cloud-sdk
|
||||
|
||||
@@ -178,7 +178,7 @@ class CloudSDK:
|
||||
return e
|
||||
return None
|
||||
|
||||
def delete_customer_profile(self, cloudSDK_url, bearer, customer_id, profile_id):
|
||||
def delete_customer_profile(self, cloudSDK_url, bearer, profile_id):
|
||||
url = cloudSDK_url + '/portal/profile/?profileId=' + profile_id
|
||||
print("Deleting customer profile with url: " + url)
|
||||
payload = {}
|
||||
@@ -188,6 +188,16 @@ class CloudSDK:
|
||||
response = requests.request("DELETE", url, headers=headers, data=payload)
|
||||
return(response)
|
||||
|
||||
def delete_equipment(self, cloudSDK_url, bearer, eq_id):
|
||||
url = cloudSDK_url + '/portal/equipment/?equipmentId=' + eq_id
|
||||
print("Deleting equipment with url: " + url)
|
||||
payload = {}
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + bearer
|
||||
}
|
||||
response = requests.request("DELETE", url, headers=headers, data=payload)
|
||||
return(response)
|
||||
|
||||
def get_customer_locations(self, cloudSDK_url, bearer, customer_id):
|
||||
url_base = cloudSDK_url + "/portal/location/forCustomer" + "?customerId=" + customer_id
|
||||
return self.get_paged_url(bearer, url_base)
|
||||
|
||||
@@ -46,14 +46,14 @@ if qtype == 'all' or qtype == 'profile':
|
||||
if cmd == "delete":
|
||||
delid = base.command_line_args.object_id;
|
||||
if delid.isdigit():
|
||||
rv = base.cloud.delete_customer_profile(base.cloudSDK_url, base.bearer, base.customer_id, base.command_line_args.object_id)
|
||||
rv = base.cloud.delete_profile(base.cloudSDK_url, base.bearer, base.command_line_args.object_id)
|
||||
print("Delete profile for customer %s, id: %s results:"%(base.customer_id, base.command_line_args.object_id))
|
||||
print(rv.json())
|
||||
else:
|
||||
# Query object by name to find its ID
|
||||
targets = get_profile(base.cloudSDK_url, base.bearer, base.customer_id, base.command_line_args.object_id)
|
||||
for me in targets:
|
||||
rv = base.cloud.delete_customer_profile(base.cloudSDK_url, base.bearer, base.customer_id, str(me['id']))
|
||||
rv = base.cloud.delete_profile(base.cloudSDK_url, base.bearer, str(me['id']))
|
||||
print("Delete profile for customer %s, id: %s results:"%(base.customer_id, base.command_line_args.object_id))
|
||||
print(rv.json())
|
||||
|
||||
@@ -107,15 +107,22 @@ if qtype == 'all' or qtype == 'location':
|
||||
if qtype == 'all' or qtype == 'equipment':
|
||||
# Get equipment info
|
||||
try:
|
||||
rv = base.cloud.get_customer_equipment(base.cloudSDK_url, base.bearer, base.customer_id)
|
||||
print("Equipment for customer %s:"%(base.customer_id))
|
||||
#jobj = json.load(ssids)
|
||||
for e in rv:
|
||||
if brief:
|
||||
for eq in e['items']:
|
||||
print("Equipment id: %s inventoryId: %s profileId: %s type: %s"%(eq['id'], eq['inventoryId'], eq['profileId'], eq['equipmentType']))
|
||||
else:
|
||||
print(json.dumps(e, indent=4, sort_keys=True))
|
||||
if cmd == "get":
|
||||
rv = base.cloud.get_customer_equipment(base.cloudSDK_url, base.bearer, base.customer_id)
|
||||
print("Equipment for customer %s:"%(base.customer_id))
|
||||
#jobj = json.load(ssids)
|
||||
for e in rv:
|
||||
if brief:
|
||||
for eq in e['items']:
|
||||
print("Equipment id: %s inventoryId: %s profileId: %s type: %s"%(eq['id'], eq['inventoryId'], eq['profileId'], eq['equipmentType']))
|
||||
else:
|
||||
print(json.dumps(e, indent=4, sort_keys=True))
|
||||
if cmd == "delete":
|
||||
delid = base.command_line_args.object_id;
|
||||
rv = base.cloud.delete_equipment(base.cloudSDK_url, base.bearer, base.command_line_args.object_id)
|
||||
print("Delete Equipment, id: %s results:"%(base.command_line_args.object_id))
|
||||
print(rv.json())
|
||||
|
||||
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
|
||||
Reference in New Issue
Block a user