blob: 1b28d0c4bdb6c02f2ee6e03eef969647e2d1df2a [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
18import static com.google.common.base.Preconditions.checkNotNull;
19
20
21/**
22 * Represents the network information given by Neutron.
23 */
24public final class OpenstackNetwork {
25
26 private String name;
27 private String tenantId;
28 private String segmentId;
sanghoshin94872a12015-10-16 18:04:34 +090029 private String id;
danielbb83ebc2015-10-29 15:13:06 +090030 private NetworkType networkType;
31
32 public enum NetworkType {
33 /**
34 * Currently only VXLAN moded is supported.
35 */
36 VXLAN,
37 VLAN,
38 STT,
39 LOCAL
40 }
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,
danielbb83ebc2015-10-29 15:13:06 +090052 NetworkType type) {
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;
sanghoshin94872a12015-10-16 18:04:34 +090058 }
59
60 public String name() {
61 return this.name;
62 }
63
64 public String tenantId() {
65 return this.tenantId;
66 }
67
68 public String id() {
69 return this.id;
70 }
71
72 public String segmentId() {
73 return this.segmentId;
74 }
75
danielbb83ebc2015-10-29 15:13:06 +090076 public NetworkType networkType() {
sanghoshin94872a12015-10-16 18:04:34 +090077 return this.networkType;
78 }
79
sanghoshin46297d22015-11-03 17:51:24 +090080 @Override
81 protected Object clone() throws CloneNotSupportedException {
82 return super.clone();
83 }
84
sanghoshin94872a12015-10-16 18:04:34 +090085 public static final class Builder {
86 private String name;
87 private String tenantId;
88 private String id;
89 private String sid;
danielbb83ebc2015-10-29 15:13:06 +090090 private NetworkType networkType;
sanghoshin94872a12015-10-16 18:04:34 +090091
92 public Builder name(String name) {
93 this.name = name;
94
95 return this;
96 }
97
98 public Builder tenantId(String tenantId) {
99 this.tenantId = tenantId;
100
101 return this;
102 }
103
104 public Builder id(String id) {
105 this.id = id;
106
107 return this;
108 }
109
110 public Builder segmentId(String sid) {
111 this.sid = sid;
112
113 return this;
114 }
115
danielbb83ebc2015-10-29 15:13:06 +0900116 public Builder networkType(NetworkType type) {
sanghoshin94872a12015-10-16 18:04:34 +0900117 this.networkType = type;
118
119 return this;
120 }
121
122 public OpenstackNetwork build() {
123 return new OpenstackNetwork(name, tenantId, id, sid, networkType);
124 }
125
126 }
127}