blob: db1abde8043908afd6988fa4bacf313100b727d8 [file] [log] [blame]
Kalhee Kimba366062017-11-07 16:32:09 +00001/*
2 * Copyright 2017-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 */
16
17package org.onosproject.dhcprelay.cli;
18
Ray Milkey86ad7bb2018-09-27 12:32:28 -070019//import org.apache.karaf.shell.api.action.Argument;
20import org.apache.karaf.shell.api.action.Command;
Ray Milkey7a2dee52018-09-28 10:58:28 -070021import org.apache.karaf.shell.api.action.lifecycle.Service;
Kalhee Kimba366062017-11-07 16:32:09 +000022import org.onosproject.cli.AbstractShellCommand;
Ray Milkey86ad7bb2018-09-27 12:32:28 -070023import org.apache.karaf.shell.api.action.Argument;
Kalhee Kimba366062017-11-07 16:32:09 +000024import org.onlab.packet.IpPrefix;
25import org.onlab.packet.IpAddress;
26import org.onosproject.routing.fpm.api.FpmRecord;
27import org.onosproject.dhcprelay.api.DhcpRelayService;
28
29/**
30 * Prints Dhcp FPM Routes information.
31 */
Ray Milkey7a2dee52018-09-28 10:58:28 -070032@Service
Kalhee Kimba366062017-11-07 16:32:09 +000033@Command(scope = "onos", name = "dhcp-fpm-add",
34 description = "Add DHCP FPM prefix in dhcp-fpm-store.")
35public class DhcpFpmAddCommand extends AbstractShellCommand {
36
37 private static final DhcpRelayService DHCP_RELAY_SERVICE = get(DhcpRelayService.class);
38
39 @Argument(index = 0, name = "prefix",
40 description = "prefix",
41 required = true, multiValued = false)
42 String prefixString = null;
43
44 @Argument(index = 1, name = "next hop",
45 description = "next hop",
46 required = true, multiValued = false)
47 String nextHopString = null;
48
49 @Override
Ray Milkey86ad7bb2018-09-27 12:32:28 -070050 protected void doExecute() {
Kalhee Kimba366062017-11-07 16:32:09 +000051
52 IpPrefix prefix = IpPrefix.valueOf(prefixString);
53 IpAddress nextHop = IpAddress.valueOf(nextHopString);
54 FpmRecord record = new FpmRecord(prefix, nextHop, FpmRecord.Type.DHCP_RELAY);
55
56 DHCP_RELAY_SERVICE.addFpmRecord(prefix, record);
57 }
58}