blob: 1841675f15603bd0bac61ebe962408066daf5034 [file] [log] [blame]
Pingping Linffa27d32015-04-30 14:41:03 -07001/*
2 * Copyright 2015 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 */
16package org.onosproject.virtualbng;
17
18import com.fasterxml.jackson.annotation.JsonCreator;
19import com.fasterxml.jackson.annotation.JsonProperty;
Pingping Linffa27d32015-04-30 14:41:03 -070020import org.onlab.packet.IpAddress;
21import org.onlab.packet.IpPrefix;
Pingping Linbe126562015-05-06 17:57:10 -070022import org.onlab.packet.MacAddress;
Jonathan Hartbbc352f2015-10-27 19:24:36 -070023import org.onosproject.net.ConnectPoint;
24
25import java.util.Collections;
26import java.util.List;
27import java.util.Map;
28import java.util.stream.Collectors;
Pingping Linffa27d32015-04-30 14:41:03 -070029
30/**
31 * Contains the configuration data for virtual BNG that has been read from a
32 * JSON-formatted configuration file.
33 */
34public final class VbngConfiguration {
35
36 private final List<IpPrefix> localPublicIpPrefixes;
37 private final IpAddress nextHopIpAddress;
Pingping Linbe126562015-05-06 17:57:10 -070038 private final MacAddress publicFacingMac;
Pingping Line10ece02015-06-11 19:26:24 -070039 private final IpAddress xosIpAddress;
40 private final int xosRestPort;
Jonathan Hartbbc352f2015-10-27 19:24:36 -070041 private final Map<String, ConnectPointConfiguration> hosts;
Pingping Linffa27d32015-04-30 14:41:03 -070042
43 /**
44 * Default constructor.
45 */
46 private VbngConfiguration() {
47 localPublicIpPrefixes = null;
48 nextHopIpAddress = null;
Pingping Linbe126562015-05-06 17:57:10 -070049 publicFacingMac = null;
Pingping Line10ece02015-06-11 19:26:24 -070050 xosIpAddress = null;
51 xosRestPort = 0;
Jonathan Hartbbc352f2015-10-27 19:24:36 -070052 hosts = null;
Pingping Linffa27d32015-04-30 14:41:03 -070053 }
54
55 /**
56 * Constructor.
57 *
58 * @param nextHopIpAddress the IP address of the next hop
59 * @param prefixes the public IP prefix list for local SDN network
Pingping Linbe126562015-05-06 17:57:10 -070060 * @param publicFacingMac the MAC address configured for all local
61 * public IP addresses
Pingping Line10ece02015-06-11 19:26:24 -070062 * @param xosIpAddress the XOS server IP address
63 * @param xosRestPort the port of the XOS server for REST
Ray Milkeyf64cf412015-10-28 16:17:30 -070064 * @param hosts map of hosts
Pingping Linffa27d32015-04-30 14:41:03 -070065 */
66 @JsonCreator
67 public VbngConfiguration(@JsonProperty("localPublicIpPrefixes")
68 List<IpPrefix> prefixes,
69 @JsonProperty("nextHopIpAddress")
Pingping Linbe126562015-05-06 17:57:10 -070070 IpAddress nextHopIpAddress,
71 @JsonProperty("publicFacingMac")
Pingping Line10ece02015-06-11 19:26:24 -070072 MacAddress publicFacingMac,
73 @JsonProperty("xosIpAddress")
74 IpAddress xosIpAddress,
75 @JsonProperty("xosRestPort")
Jonathan Hartbbc352f2015-10-27 19:24:36 -070076 int xosRestPort,
77 @JsonProperty("hosts")
78 Map<String, ConnectPointConfiguration> hosts) {
Pingping Linffa27d32015-04-30 14:41:03 -070079 localPublicIpPrefixes = prefixes;
80 this.nextHopIpAddress = nextHopIpAddress;
Pingping Linbe126562015-05-06 17:57:10 -070081 this.publicFacingMac = publicFacingMac;
Pingping Line10ece02015-06-11 19:26:24 -070082 this.xosIpAddress = xosIpAddress;
83 this.xosRestPort = xosRestPort;
Jonathan Hartbbc352f2015-10-27 19:24:36 -070084 this.hosts = hosts;
Pingping Linffa27d32015-04-30 14:41:03 -070085 }
86
87 /**
88 * Gets a list of public IP prefixes configured for local SDN network.
89 *
90 * @return the list of public IP prefixes
91 */
92 public List<IpPrefix> getLocalPublicIpPrefixes() {
93 return Collections.unmodifiableList(localPublicIpPrefixes);
94 }
95
96 /**
97 * Gets the IP address configured for the next hop (upstream gateway).
98 *
99 * @return the IP address of the next hop
100 */
101 public IpAddress getNextHopIpAddress() {
102 return nextHopIpAddress;
103 }
Pingping Linbe126562015-05-06 17:57:10 -0700104
105 /**
106 * Gets the MAC address configured for all the public IP addresses.
107 *
108 * @return the MAC address
109 */
110 public MacAddress getPublicFacingMac() {
111 return publicFacingMac;
112 }
Pingping Line10ece02015-06-11 19:26:24 -0700113
114 /**
115 * Gets the IP address configured for XOS server.
116 *
117 * @return the IP address configured for the XOS server
118 */
119 public IpAddress getXosIpAddress() {
120 return xosIpAddress;
121 }
122
123 /**
124 * Gets the REST communication port configured for XOS server.
125 *
126 * @return the REST communication port configured for XOS server
127 */
128 public int getXosRestPort() {
129 return xosRestPort;
130 }
Jonathan Hartbbc352f2015-10-27 19:24:36 -0700131
132 public Map<String, ConnectPoint> getHosts() {
133 return hosts.entrySet()
134 .stream()
135 .collect(Collectors.toMap(
136 e -> e.getKey(),
137 e -> e.getValue().connectPoint()
138 ));
139 }
Pingping Linffa27d32015-04-30 14:41:03 -0700140}