Kalhee Kim | ba36606 | 2017-11-07 16:32:09 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.dhcprelay.cli; |
| 18 | |
| 19 | //import org.apache.karaf.shell.commands.Argument; |
| 20 | import org.apache.karaf.shell.commands.Command; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.apache.karaf.shell.commands.Argument; |
| 23 | import org.onlab.packet.IpPrefix; |
| 24 | import org.onlab.packet.IpAddress; |
| 25 | import org.onosproject.routing.fpm.api.FpmRecord; |
| 26 | import org.onosproject.dhcprelay.api.DhcpRelayService; |
| 27 | |
| 28 | /** |
| 29 | * Prints Dhcp FPM Routes information. |
| 30 | */ |
| 31 | @Command(scope = "onos", name = "dhcp-fpm-add", |
| 32 | description = "Add DHCP FPM prefix in dhcp-fpm-store.") |
| 33 | public class DhcpFpmAddCommand extends AbstractShellCommand { |
| 34 | |
| 35 | private static final DhcpRelayService DHCP_RELAY_SERVICE = get(DhcpRelayService.class); |
| 36 | |
| 37 | @Argument(index = 0, name = "prefix", |
| 38 | description = "prefix", |
| 39 | required = true, multiValued = false) |
| 40 | String prefixString = null; |
| 41 | |
| 42 | @Argument(index = 1, name = "next hop", |
| 43 | description = "next hop", |
| 44 | required = true, multiValued = false) |
| 45 | String nextHopString = null; |
| 46 | |
| 47 | @Override |
| 48 | protected void execute() { |
| 49 | |
| 50 | IpPrefix prefix = IpPrefix.valueOf(prefixString); |
| 51 | IpAddress nextHop = IpAddress.valueOf(nextHopString); |
| 52 | FpmRecord record = new FpmRecord(prefix, nextHop, FpmRecord.Type.DHCP_RELAY); |
| 53 | |
| 54 | DHCP_RELAY_SERVICE.addFpmRecord(prefix, record); |
| 55 | } |
| 56 | } |