def get_response(args): lower = get_string_arg(args, 'from') if lower == 'start': lower = '0.0.0.0' limit = get_int_arg(args, 'limit') leases = kea.LeaseMgr().getLeases4(lower_bound_address=lower, page_size=limit) return make_lease_list_response(leases)
def get_response(args): lease = parse_lease4(args) force_create = get_bool_arg(args, 'force-create', False) lease_mgr = kea.LeaseMgr() if force_create and lease_mgr.getLease4(addr=lease.addr) is None: lease_mgr.addLease(lease) return {'result': 0, 'text': 'IPv4 lease added'} lease_mgr.updateLease4(lease) return {'result': 0, 'text': 'IPv4 lease updated'}
def get_response(args): lease = parse_lease4(args) kea.LeaseMgr().addLease(lease) return { 'result': 0, 'text': 'lease for address %s, subnet-id %s added' % (lease.addr, lease.subnet_id) }
def get_response(args): lease_mgr = kea.LeaseMgr() if args: subnets = get_list_arg(args, 'subnets') leases = [] for subnet_id in subnets: if not isinstance(subnet_id, int): raise CommandError( "listed subnet identifiers must be numbers") leases.extend(lease_mgr.getLeases4(subnet_id=subnet_id)) else: leases = lease_mgr.getLeases4() return make_lease_list_response(leases, include_count=False)
def get_response(args): lease_mgr = kea.LeaseMgr() kwargs = get_lease4_kwargs(args) lease = lease_mgr.getLease4(**kwargs) if not lease: raise CommandError("IPv4 lease not found") if kea.__version__ >= '1.7.3': arg = lease else: arg = lease.addr if lease_mgr.deleteLease(arg): return {'result': 0, 'text': 'IPv4 lease deleted'} else: return {'result': 3, 'text': 'IPv4 lease not found'}
def get_response(args): subnet_id = get_arg(args, 'subnet-id', None) if subnet_id is None: config = kea.CfgMgr().getCurrentCfg() subnet_ids = [s.getID() for s in config.getCfgSubnets4().getAll()] elif not isinstance(subnet_id, int): raise CommandError("'subnet-id' is not integer") else: subnet_ids = [subnet_id] num = 0 lease_mgr = kea.LeaseMgr() for s in subnet_ids: num += lease_mgr.wipeLeases4(s) msg = ('deleted %d IPv4 lease(s) from subnet(s) %s' % (num, ' '.join([str(s) for s in subnet_ids]))) return {'result': 0 if num else 3, 'text': msg}
def get_response(args): hostname = get_string_arg('hostname').lower() if not hostname: raise CommandError("'hostname' parameter is empty") leases = kea.LeaseMgr().getLeases4(hostname=hostname) return make_lease_list_response(leases)
def get_response(args): client_id = get_string_arg(args, 'client-id') leases = kea.LeaseMgr().getLease4(client_id=client_id) return make_lease_list_response(leases)
def get_response(args): hwaddr = get_string_arg(args, 'hw-address') leases = kea.LeaseMgr().getLease4(hwaddr=hwaddr) return make_lease_list_response(leases)
def get_response(args): kwargs = get_lease4_kwargs(args) lease = kea.LeaseMgr().getLease4(**kwargs) return make_lease_response(lease)
def test_ok(self): with self.assertRaises(TypeError) as cm: kea.LeaseMgr() self.assertEqual(("no current lease manager is available", ), cm.exception.args)