- my = config_dic['http_threads'][ threading.current_thread().name ]
- #check permissions
- r, tenants_flavors = my.db.get_table(FROM='tenants_flavors', SELECT=('flavor_id','tenant_id'), WHERE={'tenant_id': tenant_id})
- if r<=0:
- tenants_flavors=()
- r, tenants_images = my.db.get_table(FROM='tenants_images', SELECT=('image_id','tenant_id'), WHERE={'tenant_id': tenant_id})
- if r<=0:
- tenants_images=()
- result, content = my.db.delete_row('tenants', tenant_id)
- if result == 0:
- bottle.abort(HTTP_Not_Found, content)
- elif result >0:
- print "alf", tenants_flavors, tenants_images
- for flavor in tenants_flavors:
- my.db.delete_row_by_key("flavors", "uuid", flavor['flavor_id'])
- for image in tenants_images:
- my.db.delete_row_by_key("images", "uuid", image['image_id'])
- data={'result' : content}
- return format_out(data)
- else:
- print "http_delete_tenant_id error",result, content
- bottle.abort(-result, content)
- return
+ """
+ Delete a tenant from the database.
+ :param tenant_id: tenant id
+ :return:
+ """
+ my = config_dic['http_threads'][threading.current_thread().name]