blob: 4d38e8f7aaa51ac1ed1728487b8f30183a01ca32 [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) -> {
Saurav Das87a73c62020-10-04 18:44:40 -070035 print("SubscriberId=%s,ConnectPoint=%s,State=%s,MAC=%s,VLAN=%s,"
Saurav Dasa94531f2020-09-12 14:49:27 -070036 + "CircuitId=%s,IP Allocated=%s,Allocation Timestamp=%s",
37 value.subscriberId(), value.location(), value.type(),
38 value.macAddress().toString(), value.vlanId().toString(),
39 value.circuitId(), value.ipAddress().getIp4Address().toString(),
40 value.allocationTime().toString());
Amit Ghosha17354e2017-08-23 12:56:04 +010041 });
42 }
43}