blob: 7bfdf290a9f5240d6a16799f6bc1baad54533524 [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
80 public static final class Builder {
81 private String name;
82 private String tenantId;
83 private String id;
84 private String sid;
danielbb83ebc2015-10-29 15:13:06 +090085 private NetworkType networkType;
sanghoshin94872a12015-10-16 18:04:34 +090086
87 public Builder name(String name) {
88 this.name = name;
89
90 return this;
91 }
92
93 public Builder tenantId(String tenantId) {
94 this.tenantId = tenantId;
95
96 return this;
97 }
98
99 public Builder id(String id) {
100 this.id = id;
101
102 return this;
103 }
104
105 public Builder segmentId(String sid) {
106 this.sid = sid;
107
108 return this;
109 }
110
danielbb83ebc2015-10-29 15:13:06 +0900111 public Builder networkType(NetworkType type) {
sanghoshin94872a12015-10-16 18:04:34 +0900112 this.networkType = type;
113
114 return this;
115 }
116
117 public OpenstackNetwork build() {
118 return new OpenstackNetwork(name, tenantId, id, sid, networkType);
119 }
120
121 }
122}