def is_ip_assigned(ip_pool_id, is_private): if is_private: private_ip_pool = db.private_ip_pool[ip_pool_id] if (db.vm_data(private_ip = private_ip_pool.id)) or (db.host(host_ip = private_ip_pool.id)): return PRIVATE_IP_DELETE_MESSAGE else: public_ip_pool = db.public_ip_pool[ip_pool_id] if (db.vm_data(public_ip = public_ip_pool.id)) or (db.host(public_ip = public_ip_pool.id)): return PUBLIC_IP_DELETE_MESSAGE
def get_private_ip_ref_link(row): """Returns link to VM settings page if IP is assigned to a VM or to host details page if IP is assigned to a Host""" vm_data = db.vm_data(private_ip=row.id) host_data = db.host(host_ip=row.id) if vm_data: return A(vm_data.vm_name, _href=URL(r=request, c='user',f='settings', args=vm_data.id)) elif host_data: return A(host_data.host_name, _href=URL(r=request, c='admin',f='host_config', args=host_data.id)) else: return 'Unassigned'