blob: 7d087371d511700a4185655c11bc00578af5efcd [file] [log] [blame]
Amit Ghosha17354e2017-08-23 12:56:04 +01001/*
2 * Copyright 2016-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Carmelo Casconede1e6e32019-07-15 19:39:08 -070016package org.opencord.dhcpl2relay.cli;
Amit Ghosha17354e2017-08-23 12:56:04 +010017
Carmelo Casconede1e6e32019-07-15 19:39:08 -070018import org.apache.karaf.shell.api.action.Command;
19import org.apache.karaf.shell.api.action.lifecycle.Service;
Amit Ghosha17354e2017-08-23 12:56:04 +010020import org.onosproject.cli.AbstractShellCommand;
Jonathan Hart617bc3e2020-02-14 10:42:23 -080021import org.opencord.dhcpl2relay.DhcpL2RelayService;
Amit Ghosha17354e2017-08-23 12:56:04 +010022
23/**
24 * Shows the Successful DHCP allocations relayed by the dhcpl2relay.
25 */
Carmelo Casconede1e6e32019-07-15 19:39:08 -070026@Service
Amit Ghosha17354e2017-08-23 12:56:04 +010027@Command(scope = "onos", name = "dhcpl2relay-allocations",
28 description = "Shows the Successful DHCP allocations relayed by the dhcpl2relay")
29public class DhcpL2RelayAllocationsCommand extends AbstractShellCommand {
30 @Override
Carmelo Casconede1e6e32019-07-15 19:39:08 -070031 protected void doExecute() {
Jonathan Hart617bc3e2020-02-14 10:42:23 -080032 DhcpL2RelayService service = get(DhcpL2RelayService.class);
33
34 service.getAllocationInfo().forEach((key, value) -> {
Jonathan Hartc36c9552018-07-31 15:07:53 -040035 print("SubscriberId=%s,ConnectPoint=%s,State=%s,MAC=%s,CircuitId=%s" +
36 ",IP Allocated=%s,Allocation Timestamp=%s",
37 key, value.location(), value.type(), value.macAddress().toString(), value.circuitId(),
Amit Ghosha17354e2017-08-23 12:56:04 +010038 value.ipAddress().getIp4Address().toString(), value.allocationTime().toString());
39 });
40 }
41}