blob: 23a0674a5d4a7a34089f79c05fa228c5b02c1a47 [file] [log] [blame]
sanghoshin94872a12015-10-16 18:04:34 +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 */
sangho0c2a3da2016-02-16 13:39:07 +090016package org.onosproject.openstacknetworking;
sanghoshin94872a12015-10-16 18:04:34 +090017
sanghoshinf4ffb942015-12-10 11:28:24 +090018import java.util.Collection;
19
sanghoshin94872a12015-10-16 18:04:34 +090020import static com.google.common.base.Preconditions.checkNotNull;
21
22
23/**
24 * Represents the network information given by Neutron.
25 */
26public final class OpenstackNetwork {
27
28 private String name;
29 private String tenantId;
30 private String segmentId;
sanghoshin94872a12015-10-16 18:04:34 +090031 private String id;
danielbb83ebc2015-10-29 15:13:06 +090032 private NetworkType networkType;
sanghoshinf4ffb942015-12-10 11:28:24 +090033 private Collection<OpenstackSubnet> subnets;
danielbb83ebc2015-10-29 15:13:06 +090034
35 public enum NetworkType {
36 /**
37 * Currently only VXLAN moded is supported.
38 */
Hyunsun Moonf7895202016-01-12 12:21:48 -080039 VXLAN
danielbb83ebc2015-10-29 15:13:06 +090040 }
sanghoshin94872a12015-10-16 18:04:34 +090041
42 /**
43 * Returns the builder object of the OpenstackNetwork class.
44 *
45 * @return OpenstackNetwork builder object
46 */
47 public static OpenstackNetwork.Builder builder() {
48 return new Builder();
49 }
50
51 private OpenstackNetwork(String name, String tenantId, String id, String sid,
sanghoshinf4ffb942015-12-10 11:28:24 +090052 NetworkType type, Collection<OpenstackSubnet> subnets) {
sanghoshin94872a12015-10-16 18:04:34 +090053 this.name = checkNotNull(name);
54 this.tenantId = checkNotNull(tenantId);
55 this.segmentId = checkNotNull(sid);
56 this.id = checkNotNull(id);
danielbb83ebc2015-10-29 15:13:06 +090057 this.networkType = type;
sanghoshinf4ffb942015-12-10 11:28:24 +090058 this.subnets = subnets;
sanghoshin94872a12015-10-16 18:04:34 +090059 }
60
61 public String name() {
62 return this.name;
63 }
64
65 public String tenantId() {
66 return this.tenantId;
67 }
68
69 public String id() {
70 return this.id;
71 }
72
73 public String segmentId() {
74 return this.segmentId;
75 }
76
danielbb83ebc2015-10-29 15:13:06 +090077 public NetworkType networkType() {
sanghoshin94872a12015-10-16 18:04:34 +090078 return this.networkType;
79 }
80
sanghoshinf4ffb942015-12-10 11:28:24 +090081 public Collection<OpenstackSubnet> subnets() {
82 return this.subnets;
83 }
84
sanghoshin46297d22015-11-03 17:51:24 +090085 @Override
86 protected Object clone() throws CloneNotSupportedException {
87 return super.clone();
88 }
89
sanghoshin94872a12015-10-16 18:04:34 +090090 public static final class Builder {
91 private String name;
92 private String tenantId;
93 private String id;
94 private String sid;
danielbb83ebc2015-10-29 15:13:06 +090095 private NetworkType networkType;
sanghoshinf4ffb942015-12-10 11:28:24 +090096 private Collection<OpenstackSubnet> subnets;
sanghoshin94872a12015-10-16 18:04:34 +090097
98 public Builder name(String name) {
99 this.name = name;
100
101 return this;
102 }
103
104 public Builder tenantId(String tenantId) {
105 this.tenantId = tenantId;
106
107 return this;
108 }
109
110 public Builder id(String id) {
111 this.id = id;
112
113 return this;
114 }
115
116 public Builder segmentId(String sid) {
117 this.sid = sid;
118
119 return this;
120 }
121
danielbb83ebc2015-10-29 15:13:06 +0900122 public Builder networkType(NetworkType type) {
sanghoshin94872a12015-10-16 18:04:34 +0900123 this.networkType = type;
124
125 return this;
126 }
127
sanghoshinf4ffb942015-12-10 11:28:24 +0900128 public Builder subnets(Collection<OpenstackSubnet> subnets) {
129 this.subnets = subnets;
130
131 return this;
sanghoshin94872a12015-10-16 18:04:34 +0900132 }
133
sanghoshinf4ffb942015-12-10 11:28:24 +0900134 public OpenstackNetwork build() {
135 return new OpenstackNetwork(name, tenantId, id, sid, networkType, subnets);
136 }
sanghoshin94872a12015-10-16 18:04:34 +0900137 }
138}