Jian Li | 3e81b18 | 2021-01-11 02:35:06 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021-present Open Networking Foundation |
| 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 | */ |
| 16 | package org.onosproject.kubevirtnetworking.api; |
| 17 | |
| 18 | import org.onlab.packet.IpAddress; |
Jian Li | b5ab63c | 2021-02-03 17:54:28 +0900 | [diff] [blame^] | 19 | import org.onosproject.net.DeviceId; |
Jian Li | 3e81b18 | 2021-01-11 02:35:06 +0900 | [diff] [blame] | 20 | |
| 21 | import java.util.Set; |
| 22 | |
| 23 | /** |
| 24 | * Representation of kubevirt network. |
| 25 | */ |
| 26 | public interface KubevirtNetwork { |
| 27 | |
| 28 | /** |
| 29 | * Lists of network type. |
| 30 | */ |
| 31 | enum Type { |
| 32 | |
| 33 | /** |
| 34 | * VXLAN typed virtual network. |
| 35 | */ |
| 36 | VXLAN, |
| 37 | |
| 38 | /** |
| 39 | * GRE typed virtual network. |
| 40 | */ |
| 41 | GRE, |
| 42 | |
| 43 | /** |
| 44 | * GENEVE typed virtual network. |
| 45 | */ |
| 46 | GENEVE, |
| 47 | |
| 48 | /** |
| 49 | * FLAT typed provider network. |
| 50 | */ |
| 51 | FLAT, |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Returns the kubernetes network ID. |
| 56 | * |
| 57 | * @return kubernetes network ID |
| 58 | */ |
| 59 | String networkId(); |
| 60 | |
| 61 | /** |
| 62 | * Returns kubernetes network type. |
| 63 | * |
| 64 | * @return kubernetes network type |
| 65 | */ |
| 66 | Type type(); |
| 67 | |
| 68 | /** |
| 69 | * Returns kubernetes network name. |
| 70 | * |
| 71 | * @return kubernetes network name |
| 72 | */ |
| 73 | String name(); |
| 74 | |
| 75 | /** |
| 76 | * Returns maximum transmission unit (MTU) value to address fragmentation. |
| 77 | * |
| 78 | * @return maximum transmission unit (MTU) value to address fragmentation |
| 79 | */ |
| 80 | Integer mtu(); |
| 81 | |
| 82 | /** |
| 83 | * Returns segmentation ID. |
| 84 | * |
| 85 | * @return segmentation ID |
| 86 | */ |
| 87 | String segmentId(); |
| 88 | |
| 89 | /** |
| 90 | * Returns gateway IP address. |
| 91 | * |
| 92 | * @return gateway IP address |
| 93 | */ |
| 94 | IpAddress gatewayIp(); |
| 95 | |
| 96 | /** |
| 97 | * Returns network CIDR. |
| 98 | * |
| 99 | * @return network CIDR |
| 100 | */ |
| 101 | String cidr(); |
| 102 | |
| 103 | /** |
| 104 | * Returns host routes. |
| 105 | * |
| 106 | * @return host routes |
| 107 | */ |
Jian Li | feb8480 | 2021-01-12 16:34:49 +0900 | [diff] [blame] | 108 | Set<KubevirtHostRoute> hostRoutes(); |
Jian Li | 3e81b18 | 2021-01-11 02:35:06 +0900 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Returns the IP pool. |
| 112 | * |
| 113 | * @return IP pool |
| 114 | */ |
| 115 | KubevirtIpPool ipPool(); |
| 116 | |
| 117 | /** |
Jian Li | 97e6fc3 | 2021-02-01 20:36:45 +0900 | [diff] [blame] | 118 | * Returns a set of DNS. |
| 119 | * |
| 120 | * @return a set of DNS |
| 121 | */ |
| 122 | Set<IpAddress> dnses(); |
| 123 | |
| 124 | /** |
Jian Li | b5ab63c | 2021-02-03 17:54:28 +0900 | [diff] [blame^] | 125 | * Returns the tenant integration bridge name in case the bridge type |
| 126 | * is VXLAN/GRE/GENEVE. |
| 127 | * |
| 128 | * @return tunnel bridge name |
| 129 | */ |
| 130 | String tenantBridgeName(); |
| 131 | |
| 132 | /** |
| 133 | * Returns the tenant integration bridge's device identifier. |
| 134 | * |
| 135 | * @param hostname kubevirt node hostname |
| 136 | * @return device identifier |
| 137 | */ |
| 138 | DeviceId tenantDeviceId(String hostname); |
| 139 | |
| 140 | /** |
Jian Li | 3e81b18 | 2021-01-11 02:35:06 +0900 | [diff] [blame] | 141 | * Builder of new network. |
| 142 | */ |
| 143 | interface Builder { |
| 144 | |
| 145 | /** |
| 146 | * Builds an immutable network instance. |
| 147 | * |
| 148 | * @return kubernetes network |
| 149 | */ |
| 150 | KubevirtNetwork build(); |
| 151 | |
| 152 | /** |
| 153 | * Returns network builder with supplied network ID. |
| 154 | * |
| 155 | * @param networkId network ID |
| 156 | * @return network builder |
| 157 | */ |
| 158 | Builder networkId(String networkId); |
| 159 | |
| 160 | /** |
| 161 | * Returns network builder with supplied network name. |
| 162 | * |
| 163 | * @param name network name |
| 164 | * @return network builder |
| 165 | */ |
| 166 | Builder name(String name); |
| 167 | |
| 168 | /** |
| 169 | * Returns network builder with supplied network type. |
| 170 | * |
| 171 | * @param type network type |
| 172 | * @return network builder |
| 173 | */ |
| 174 | Builder type(Type type); |
| 175 | |
| 176 | /** |
| 177 | * Returns network builder with supplied MTU. |
| 178 | * |
| 179 | * @param mtu maximum transmission unit |
| 180 | * @return network builder |
| 181 | */ |
| 182 | Builder mtu(Integer mtu); |
| 183 | |
| 184 | /** |
| 185 | * Returns network builder with supplied segment ID. |
| 186 | * |
| 187 | * @param segmentId segment ID |
| 188 | * @return network builder |
| 189 | */ |
| 190 | Builder segmentId(String segmentId); |
| 191 | |
| 192 | /** |
| 193 | * Returns network builder with supplied gateway IP address. |
| 194 | * |
| 195 | * @param ipAddress gateway IP address |
| 196 | * @return network builder |
| 197 | */ |
| 198 | Builder gatewayIp(IpAddress ipAddress); |
| 199 | |
| 200 | /** |
| 201 | * Returns network builder with supplied network CIDR. |
| 202 | * |
| 203 | * @param cidr Classless Inter-Domain Routing |
| 204 | * @return network builder |
| 205 | */ |
| 206 | Builder cidr(String cidr); |
| 207 | |
| 208 | /** |
Jian Li | 97e6fc3 | 2021-02-01 20:36:45 +0900 | [diff] [blame] | 209 | * Returns network builder with the supplied IP pool. |
Jian Li | 3e81b18 | 2021-01-11 02:35:06 +0900 | [diff] [blame] | 210 | * |
| 211 | * @param ipPool IP pool |
| 212 | * @return network builder |
| 213 | */ |
| 214 | Builder ipPool(KubevirtIpPool ipPool); |
| 215 | |
| 216 | /** |
Jian Li | 97e6fc3 | 2021-02-01 20:36:45 +0900 | [diff] [blame] | 217 | * Returns network builder with the host routes. |
Jian Li | 3e81b18 | 2021-01-11 02:35:06 +0900 | [diff] [blame] | 218 | * |
| 219 | * @param hostRoutes host routes |
| 220 | * @return network builder |
| 221 | */ |
| 222 | Builder hostRoutes(Set<KubevirtHostRoute> hostRoutes); |
Jian Li | 97e6fc3 | 2021-02-01 20:36:45 +0900 | [diff] [blame] | 223 | |
| 224 | /** |
| 225 | * Returns network builder with supplied DNSes. |
| 226 | * |
| 227 | * @param dnses a set of DNS |
| 228 | * @return network builder |
| 229 | */ |
| 230 | Builder dnses(Set<IpAddress> dnses); |
Jian Li | 3e81b18 | 2021-01-11 02:35:06 +0900 | [diff] [blame] | 231 | } |
| 232 | } |