blob: 6b4d1ea77790e3987d36d32c49d5f22201ecb4ad [file] [log] [blame]
Kyuhwi Choi5d7c9982016-01-20 13:55:55 +09001/*
2 * Copyright 2016 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.openstackrouting;
17
18import org.onlab.packet.Ip4Address;
19
20import java.util.HashMap;
21
22/**
23 * A configurable external gateway modes extension model in openstack router.
24 */
25public final class OpenstackExternalGateway {
26
27 private String networkId;
28 private boolean enablePNAT;
29 private HashMap<String, Ip4Address> externalFixedIps;
30
31 private OpenstackExternalGateway(String networkId, boolean enablePNAT,
32 HashMap externalFixedIps) {
33 this.networkId = networkId;
34 this.enablePNAT = enablePNAT;
35 this.externalFixedIps = externalFixedIps;
36 }
37
38 /**
39 * Returns network ID.
40 *
41 * @return Network ID
42 */
43 public String networkId() {
44 return networkId;
45 }
46
47 /**
48 * Returns the PNAT status for external gateway.
49 *
50 * @return PNAT status
51 */
52 public boolean isEnablePNAT() {
53 return enablePNAT;
54 }
55
56 /**
57 * An Openstack External Gateway Builder class.
58 */
59 public static final class Builder {
60 private String networkId;
61 private boolean enablePNAT;
62 private HashMap<String, Ip4Address> externalFixedIPs;
63
64 Builder() {
65 externalFixedIPs = new HashMap<>();
66 }
67
68 /**
69 * Sets network ID.
70 *
71 * @param networkId Network ID
72 * @return Builder object
73 */
74 public Builder networkId(String networkId) {
75 this.networkId = networkId;
76 return this;
77 }
78
79 /**
80 * Sets whether PNAT status is enabled or not.
81 *
82 * @param enablePNAT true if PNAT status is enabled, false otherwise
83 * @return Builder object
84 */
85 public Builder enablePNAT(boolean enablePNAT) {
86 this.enablePNAT = enablePNAT;
87 return this;
88 }
89
90 /**
91 * Sets external fixed IP address information.
92 *
93 * @param externalFixedIPs External fixed IP information
94 * @return Builder object
95 */
96 public Builder externalFixedIPs(HashMap<String, Ip4Address> externalFixedIPs) {
97 this.externalFixedIPs.putAll(externalFixedIPs);
98 return this;
99 }
100
101 /**
102 * Builds an OpenstackExternalGateway object.
103 *
104 * @return OpenstackExternalGateway object
105 */
106 public OpenstackExternalGateway build() {
107 return new OpenstackExternalGateway(networkId, enablePNAT, externalFixedIPs);
108 }
109 }
110
111}