blob: b411b8788e27ef3a0ca23ca47db53a6f4a2ab45d [file] [log] [blame]
janani bf41dec32017-03-24 18:44:07 +05301/*
2 * Copyright 2017-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
17package org.onosproject.l3vpn.netl3vpn;
18
19import org.onosproject.net.DeviceId;
20
21import java.util.LinkedHashMap;
22import java.util.Map;
23
24/**
25 * Representation of stored VPN instance, which contains the configuration
26 * such as RD and RT, also the device info and the VPN type.
27 */
28public class VpnInstance<T extends VpnConfig> {
29
30 /**
31 * VPN instance name.
32 */
33 private String vpnName;
34
35 /**
36 * List of devices for the VPN.
37 */
38 private Map<DeviceId, DeviceInfo> devInfo;
39
40 /**
41 * Type of the VPN.
42 */
43 private VpnType type;
44
45 /**
46 * VPN config information.
47 */
48 private T vpnConfig;
49
50 /**
51 * Creates VPN instance with VPN name.
52 *
53 * @param v VPN name
54 */
55 public VpnInstance(String v) {
56 vpnName = v;
57 }
58
59 /**
60 * Returns the type of the VPN instance.
61 *
62 * @return VPN type
63 */
64 VpnType type() {
65 return type;
66 }
67
68 /**
69 * Sets the type of the VPN instance.
70 *
71 * @param type VPN type
72 */
73 void type(VpnType type) {
74 this.type = type;
75 }
76
77 /**
78 * Returns the configuration of VPN instance.
79 *
80 * @return VPN config
81 */
82 T vpnConfig() {
83 return vpnConfig;
84 }
85
86 /**
87 * Sets the configuration of VPN instance.
88 *
89 * @param vpnConfig VPN config
90 */
91 void vpnConfig(T vpnConfig) {
92 this.vpnConfig = vpnConfig;
93 }
94
95 /**
96 * Returns the device info map.
97 *
98 * @return device info map
99 */
100 Map<DeviceId, DeviceInfo> devInfo() {
101 return devInfo;
102 }
103
104 /**
105 * Sets the device info map.
106 *
107 * @param devInfo device info map
108 */
109 void devInfo(Map<DeviceId, DeviceInfo> devInfo) {
110 this.devInfo = devInfo;
111 }
112
113 /**
114 * Adds the content to device info map.
115 *
116 * @param id device id
117 * @param info device info
118 */
119 void devInfo(DeviceId id, DeviceInfo info) {
120 if (devInfo == null) {
121 devInfo = new LinkedHashMap<>();
122 }
123 devInfo.put(id, info);
124 }
125
126 /**
127 * Returns the VPN instance name.
128 *
129 * @return VPN name
130 */
131 String vpnName() {
132 return vpnName;
133 }
134}