blob: bc536e881491b2e772d8567093b50b9c3815dde7 [file] [log] [blame]
danielbb83ebc2015-10-29 15:13:06 +09001/*
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.openstackswitching;
17
sanghoshin46297d22015-11-03 17:51:24 +090018import org.onlab.packet.Ip4Address;
19
20import java.util.List;
21
danielbb83ebc2015-10-29 15:13:06 +090022import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
25 * Represents the subnet information given by Neutron.
26 *
27 */
28public final class OpenstackSubnet {
29 private String name;
30 private boolean enableHhcp;
31 private String networkId;
32 private String tenantId;
sanghoshin46297d22015-11-03 17:51:24 +090033 private List<Ip4Address> dnsNameservers;
danielbb83ebc2015-10-29 15:13:06 +090034 private String gatewayIp;
35 private String cidr;
36 private String id;
37
38 private OpenstackSubnet(String name, boolean enableHhcp, String networkId,
sanghoshin46297d22015-11-03 17:51:24 +090039 String tenantId, List<Ip4Address> dnsNameservers, String gatewayIp,
danielbb83ebc2015-10-29 15:13:06 +090040 String cidr, String id) {
41 this.name = name;
42 this.enableHhcp = enableHhcp;
43 this.networkId = checkNotNull(networkId);
44 this.tenantId = checkNotNull(tenantId);
45 this.dnsNameservers = dnsNameservers;
46 this.gatewayIp = gatewayIp;
47 this.cidr = checkNotNull(cidr);
48 this.id = checkNotNull(id);
49 }
50
51 /**
52 * Returns OpenstackSubnet builder object.
53 *
54 * @return OpenstackSubnet builder
55 */
56 public static OpenstackSubnet.Builder builder() {
57 return new Builder();
58 }
59
60 public String name() {
61 return name;
62 }
63
64 public boolean enableHhcp() {
65 return enableHhcp;
66 }
67
68 public String networkId() {
69 return networkId;
70 }
71
72 public String tenantId() {
73 return tenantId;
74 }
75
sanghoshin46297d22015-11-03 17:51:24 +090076 public List<Ip4Address> dnsNameservers() {
danielbb83ebc2015-10-29 15:13:06 +090077 return dnsNameservers;
78 }
79
80 public String gatewayIp() {
81 return gatewayIp;
82 }
83
84 public String cidr() {
85 return cidr;
86 }
87
88 public String id() {
89 return id;
90 }
91
danielbb83ebc2015-10-29 15:13:06 +090092 /**
93 * OpenstackSubnet Builder class.
94 *
95 */
96 public static final class Builder {
97 private String name;
98 private boolean enableDhcp;
99 private String networkId;
100 private String tenantId;
sanghoshin46297d22015-11-03 17:51:24 +0900101 private List<Ip4Address> dnsNameservers;
danielbb83ebc2015-10-29 15:13:06 +0900102 private String gatewayIp;
103 private String cidr;
104 private String id;
105
106 Builder() {}
107
108 public Builder setName(String name) {
109 this.name = name;
110
111 return this;
112 }
113
114 public Builder setEnableDhcp(boolean enableDhcp) {
115 this.enableDhcp = enableDhcp;
116
117 return this;
118 }
119
120 public Builder setNetworkId(String networkId) {
121 this.networkId = networkId;
122
123 return this;
124 }
125
126 public Builder setTenantId(String tenantId) {
127 this.tenantId = tenantId;
128
129 return this;
130 }
131
sanghoshin46297d22015-11-03 17:51:24 +0900132 public Builder setDnsNameservers(List<Ip4Address> dnsNameservers) {
danielbb83ebc2015-10-29 15:13:06 +0900133 this.dnsNameservers = dnsNameservers;
134
135 return this;
136 }
137
138 public Builder setGatewayIp(String gatewayIp) {
139 this.gatewayIp = gatewayIp;
140
141 return this;
142 }
143
144 public Builder setCidr(String cidr) {
145 this.cidr = cidr;
146
147 return this;
148 }
149
150 public Builder setId(String id) {
151 this.id = id;
152
153 return this;
154 }
155
156 public OpenstackSubnet build() {
157 return new OpenstackSubnet(name, enableDhcp, networkId, tenantId,
158 dnsNameservers, gatewayIp, cidr, id);
159 }
160 }
161}