alshabib | 1f36ab8 | 2016-04-29 15:38:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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.cordconfig.access; |
| 18 | |
| 19 | import com.google.common.collect.ImmutableMap; |
| 20 | import org.onlab.packet.MacAddress; |
| 21 | import org.onosproject.net.ConnectPoint; |
| 22 | import org.onosproject.net.DeviceId; |
| 23 | |
| 24 | import java.util.Map; |
| 25 | import java.util.Optional; |
| 26 | |
| 27 | import static com.google.common.base.Preconditions.checkNotNull; |
| 28 | |
| 29 | /** |
| 30 | * Information about an access agent. |
| 31 | */ |
| 32 | public class AccessAgentData { |
| 33 | private static final String DEVICE_ID_MISSING = "Device ID cannot be null"; |
| 34 | private static final String OLT_INFO_MISSING = "OLT information cannot be null"; |
| 35 | private static final String AGENT_MAC_MISSING = "Agent mac cannot be null"; |
| 36 | private static final String VTN_MISSING = "VTN location cannot be null"; |
| 37 | |
| 38 | |
| 39 | private final Map<ConnectPoint, MacAddress> oltMacInfo; |
| 40 | private final MacAddress agentMac; |
| 41 | private final Optional<ConnectPoint> vtnLocation; |
| 42 | private final DeviceId deviceId; |
| 43 | |
| 44 | |
| 45 | /** |
| 46 | * Constucts an agent configuration for a given device. |
| 47 | * |
| 48 | * @param deviceId access device id |
| 49 | * @param oltMacInfo a map of olt chips and their mac address |
| 50 | * @param agentMac the mac address of the agent |
| 51 | * @param vtnLocation the location of the agent |
| 52 | */ |
| 53 | public AccessAgentData(DeviceId deviceId, Map<ConnectPoint, MacAddress> oltMacInfo, |
| 54 | MacAddress agentMac, Optional<ConnectPoint> vtnLocation) { |
| 55 | this.deviceId = checkNotNull(deviceId, DEVICE_ID_MISSING); |
| 56 | this.oltMacInfo = checkNotNull(oltMacInfo, OLT_INFO_MISSING); |
| 57 | this.agentMac = checkNotNull(agentMac, AGENT_MAC_MISSING); |
| 58 | this.vtnLocation = checkNotNull(vtnLocation, VTN_MISSING); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Retrieves the access device ID. |
| 63 | * |
| 64 | * @return device ID |
| 65 | */ |
| 66 | public DeviceId deviceId() { |
| 67 | return deviceId; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Returns the mapping of olt chips to mac addresses. Each chip is |
| 72 | * symbolized by a connect point. |
| 73 | * |
| 74 | * @return a mapping of chips (as connect points) to mac addresses |
| 75 | */ |
| 76 | public Map<ConnectPoint, MacAddress> getOltMacInfo() { |
| 77 | return ImmutableMap.copyOf(oltMacInfo); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Reuturns the agents mac address. |
| 82 | * |
| 83 | * @return a mac address |
| 84 | */ |
| 85 | public MacAddress getAgentMac() { |
| 86 | return agentMac; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Returns the location of the agent. |
| 91 | * |
| 92 | * @return a connection point |
| 93 | */ |
| 94 | public Optional<ConnectPoint> getVtnLocation() { |
| 95 | return vtnLocation; |
| 96 | } |
| 97 | } |