2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.openstackswitching;
18 import static com.google.common.base.Preconditions.checkNotNull;
21 * Represents the subnet information given by Neutron.
24 public final class OpenstackSubnet {
26 private boolean enableHhcp;
27 private String networkId;
28 private String tenantId;
29 private String dnsNameservers;
30 private String gatewayIp;
34 private OpenstackSubnet(String name, boolean enableHhcp, String networkId,
35 String tenantId, String dnsNameservers, String gatewayIp,
36 String cidr, String id) {
38 this.enableHhcp = enableHhcp;
39 this.networkId = checkNotNull(networkId);
40 this.tenantId = checkNotNull(tenantId);
41 this.dnsNameservers = dnsNameservers;
42 this.gatewayIp = gatewayIp;
43 this.cidr = checkNotNull(cidr);
44 this.id = checkNotNull(id);
48 * Returns OpenstackSubnet builder object.
50 * @return OpenstackSubnet builder
52 public static OpenstackSubnet.Builder builder() {
56 public String name() {
60 public boolean enableHhcp() {
64 public String networkId() {
68 public String tenantId() {
72 public String dnsNameservers() {
73 return dnsNameservers;
76 public String gatewayIp() {
80 public String cidr() {
88 // TODO : Implement the following functions when necessary
91 * OpenstackSubnet Builder class.
94 public static final class Builder {
96 private boolean enableDhcp;
97 private String networkId;
98 private String tenantId;
99 private String dnsNameservers;
100 private String gatewayIp;
106 public Builder setName(String name) {
112 public Builder setEnableDhcp(boolean enableDhcp) {
113 this.enableDhcp = enableDhcp;
118 public Builder setNetworkId(String networkId) {
119 this.networkId = networkId;
124 public Builder setTenantId(String tenantId) {
125 this.tenantId = tenantId;
130 public Builder setDnsNameservers(String dnsNameservers) {
131 this.dnsNameservers = dnsNameservers;
136 public Builder setGatewayIp(String gatewayIp) {
137 this.gatewayIp = gatewayIp;
142 public Builder setCidr(String cidr) {
148 public Builder setId(String id) {
154 public OpenstackSubnet build() {
155 return new OpenstackSubnet(name, enableDhcp, networkId, tenantId,
156 dnsNameservers, gatewayIp, cidr, id);