Jonathan Hart | 249b4cf | 2017-02-03 18:02:58 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | ce2a03d | 2017-08-03 19:21:03 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Jonathan Hart | 249b4cf | 2017-02-03 18:02:58 -0800 | [diff] [blame] | 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.routing; |
| 18 | |
| 19 | import org.onosproject.incubator.net.intf.Interface; |
| 20 | import org.onosproject.net.ConnectPoint; |
| 21 | |
| 22 | import static com.google.common.base.Preconditions.checkNotNull; |
| 23 | |
| 24 | /** |
| 25 | * Encapsulates information needed to provision a router interface. |
| 26 | */ |
| 27 | public final class InterfaceProvisionRequest { |
| 28 | |
| 29 | private final RouterInfo info; |
| 30 | private final Interface intf; |
| 31 | |
| 32 | private InterfaceProvisionRequest(RouterInfo info, Interface intf) { |
| 33 | this.info = checkNotNull(info); |
| 34 | this.intf = checkNotNull(intf); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Retrieves the router's control plane connect point. |
| 39 | * |
| 40 | * @return connect point |
| 41 | */ |
| 42 | public ConnectPoint controlPlaneConnectPoint() { |
| 43 | return info.controlPlaneConnectPoint(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Retrieves the router configuration info. |
| 48 | * |
| 49 | * @return router configuration info |
| 50 | */ |
| 51 | public RouterInfo info() { |
| 52 | return info; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Retrieves the interface to be (un)provisioned. |
| 57 | * |
| 58 | * @return interface |
| 59 | */ |
| 60 | public Interface intf() { |
| 61 | return intf; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Creates a new provision request from a router configuration and an |
| 66 | * interface. |
| 67 | * |
| 68 | * @param info router configuration info |
| 69 | * @param intf interface |
| 70 | * @return provision request |
| 71 | */ |
| 72 | public static InterfaceProvisionRequest of(RouterInfo info, Interface intf) { |
| 73 | return new InterfaceProvisionRequest(info, intf); |
| 74 | } |
| 75 | } |