blob: 181caf8ccfa211345bb04db72a0a7b0535293b50 [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 */
16package org.onosproject.openstackswitching;
17
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 */
39 VXLAN,
40 VLAN,
41 STT,
42 LOCAL
43 }
sanghoshin94872a12015-10-16 18:04:34 +090044
45 /**
46 * Returns the builder object of the OpenstackNetwork class.
47 *
48 * @return OpenstackNetwork builder object
49 */
50 public static OpenstackNetwork.Builder builder() {
51 return new Builder();
52 }
53
54 private OpenstackNetwork(String name, String tenantId, String id, String sid,
sanghoshinf4ffb942015-12-10 11:28:24 +090055 NetworkType type, Collection<OpenstackSubnet> subnets) {
sanghoshin94872a12015-10-16 18:04:34 +090056 this.name = checkNotNull(name);
57 this.tenantId = checkNotNull(tenantId);
58 this.segmentId = checkNotNull(sid);
59 this.id = checkNotNull(id);
danielbb83ebc2015-10-29 15:13:06 +090060 this.networkType = type;
sanghoshinf4ffb942015-12-10 11:28:24 +090061 this.subnets = subnets;
sanghoshin94872a12015-10-16 18:04:34 +090062 }
63
64 public String name() {
65 return this.name;
66 }
67
68 public String tenantId() {
69 return this.tenantId;
70 }
71
72 public String id() {
73 return this.id;
74 }
75
76 public String segmentId() {
77 return this.segmentId;
78 }
79
danielbb83ebc2015-10-29 15:13:06 +090080 public NetworkType networkType() {
sanghoshin94872a12015-10-16 18:04:34 +090081 return this.networkType;
82 }
83
sanghoshinf4ffb942015-12-10 11:28:24 +090084 public Collection<OpenstackSubnet> subnets() {
85 return this.subnets;
86 }
87
sanghoshin46297d22015-11-03 17:51:24 +090088 @Override
89 protected Object clone() throws CloneNotSupportedException {
90 return super.clone();
91 }
92
sanghoshin94872a12015-10-16 18:04:34 +090093 public static final class Builder {
94 private String name;
95 private String tenantId;
96 private String id;
97 private String sid;
danielbb83ebc2015-10-29 15:13:06 +090098 private NetworkType networkType;
sanghoshinf4ffb942015-12-10 11:28:24 +090099 private Collection<OpenstackSubnet> subnets;
sanghoshin94872a12015-10-16 18:04:34 +0900100
101 public Builder name(String name) {
102 this.name = name;
103
104 return this;
105 }
106
107 public Builder tenantId(String tenantId) {
108 this.tenantId = tenantId;
109
110 return this;
111 }
112
113 public Builder id(String id) {
114 this.id = id;
115
116 return this;
117 }
118
119 public Builder segmentId(String sid) {
120 this.sid = sid;
121
122 return this;
123 }
124
danielbb83ebc2015-10-29 15:13:06 +0900125 public Builder networkType(NetworkType type) {
sanghoshin94872a12015-10-16 18:04:34 +0900126 this.networkType = type;
127
128 return this;
129 }
130
sanghoshinf4ffb942015-12-10 11:28:24 +0900131 public Builder subnets(Collection<OpenstackSubnet> subnets) {
132 this.subnets = subnets;
133
134 return this;
sanghoshin94872a12015-10-16 18:04:34 +0900135 }
136
sanghoshinf4ffb942015-12-10 11:28:24 +0900137 public OpenstackNetwork build() {
138 return new OpenstackNetwork(name, tenantId, id, sid, networkType, subnets);
139 }
sanghoshin94872a12015-10-16 18:04:34 +0900140 }
141}