Committed by
Gerrit Code Review
Starting work on virtual network subsystem implementation.
Change-Id: Ic702ce425d68fa5c1af5c6d55cad5940665ac562
Showing
12 changed files
with
839 additions
and
28 deletions
incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualDevice.java
0 → 100644
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.incubator.net.virtual; | ||
17 | + | ||
18 | +import org.onlab.packet.ChassisId; | ||
19 | +import org.onosproject.net.DefaultDevice; | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | +import org.onosproject.net.provider.ProviderId; | ||
22 | + | ||
23 | +import java.util.Objects; | ||
24 | + | ||
25 | +import static com.google.common.base.MoreObjects.*; | ||
26 | + | ||
27 | +/** | ||
28 | + * Default representation of a virtual device. | ||
29 | + */ | ||
30 | +public class DefaultVirtualDevice extends DefaultDevice implements VirtualDevice { | ||
31 | + | ||
32 | + private static final String VIRTUAL = "virtual"; | ||
33 | + private static final ProviderId PID = new ProviderId(VIRTUAL, VIRTUAL); | ||
34 | + | ||
35 | + private final NetworkId networkId; | ||
36 | + | ||
37 | + /** | ||
38 | + * Creates a network element attributed to the specified provider. | ||
39 | + * | ||
40 | + * @param networkId network identifier | ||
41 | + * @param id device identifier | ||
42 | + */ | ||
43 | + public DefaultVirtualDevice(NetworkId networkId, DeviceId id) { | ||
44 | + super(PID, id, Type.VIRTUAL, VIRTUAL, VIRTUAL, VIRTUAL, VIRTUAL, | ||
45 | + new ChassisId(0)); | ||
46 | + this.networkId = networkId; | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + public NetworkId networkId() { | ||
51 | + return networkId; | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + public int hashCode() { | ||
56 | + return 31 * super.hashCode() + Objects.hash(networkId); | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public boolean equals(Object obj) { | ||
61 | + if (this == obj) { | ||
62 | + return true; | ||
63 | + } | ||
64 | + if (obj instanceof DefaultVirtualDevice) { | ||
65 | + DefaultVirtualDevice that = (DefaultVirtualDevice) obj; | ||
66 | + return super.equals(that) && Objects.equals(this.networkId, that.networkId); | ||
67 | + } | ||
68 | + return false; | ||
69 | + } | ||
70 | + | ||
71 | + @Override | ||
72 | + public String toString() { | ||
73 | + return toStringHelper(this).add("networkId", networkId).toString(); | ||
74 | + } | ||
75 | +} |
incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualNetwork.java
0 → 100644
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.incubator.net.virtual; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Default implementation of the virtual network descriptor. | ||
24 | + */ | ||
25 | +public class DefaultVirtualNetwork implements VirtualNetwork { | ||
26 | + | ||
27 | + private final NetworkId id; | ||
28 | + private final TenantId tenantId; | ||
29 | + | ||
30 | + /** | ||
31 | + * Creates a new virtual network descriptor. | ||
32 | + * | ||
33 | + * @param id network identifier | ||
34 | + * @param tenantId tenant identifier | ||
35 | + */ | ||
36 | + public DefaultVirtualNetwork(NetworkId id, TenantId tenantId) { | ||
37 | + this.id = id; | ||
38 | + this.tenantId = tenantId; | ||
39 | + } | ||
40 | + | ||
41 | + @Override | ||
42 | + public NetworkId id() { | ||
43 | + return id; | ||
44 | + } | ||
45 | + | ||
46 | + @Override | ||
47 | + public TenantId tenantId() { | ||
48 | + return tenantId; | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public int hashCode() { | ||
53 | + return Objects.hash(id, tenantId); | ||
54 | + } | ||
55 | + | ||
56 | + @Override | ||
57 | + public boolean equals(Object obj) { | ||
58 | + if (this == obj) { | ||
59 | + return true; | ||
60 | + } | ||
61 | + if (obj instanceof DefaultVirtualNetwork) { | ||
62 | + DefaultVirtualNetwork that = (DefaultVirtualNetwork) obj; | ||
63 | + return Objects.equals(this.id, that.id) | ||
64 | + && Objects.equals(this.tenantId, that.tenantId); | ||
65 | + } | ||
66 | + return false; | ||
67 | + } | ||
68 | + | ||
69 | + @Override | ||
70 | + public String toString() { | ||
71 | + return toStringHelper(this) | ||
72 | + .add("id", id) | ||
73 | + .add("tenantId", tenantId) | ||
74 | + .toString(); | ||
75 | + } | ||
76 | +} |
... | @@ -24,13 +24,6 @@ import com.google.common.annotations.Beta; | ... | @@ -24,13 +24,6 @@ import com.google.common.annotations.Beta; |
24 | public interface VirtualElement { | 24 | public interface VirtualElement { |
25 | 25 | ||
26 | /** | 26 | /** |
27 | - * Returns the identifier of the tenant to which this virtual element belongs. | ||
28 | - * | ||
29 | - * @return tenant identifier | ||
30 | - */ | ||
31 | - TenantId tenantId(); | ||
32 | - | ||
33 | - /** | ||
34 | * Returns the network identifier to which this virtual element belongs. | 27 | * Returns the network identifier to which this virtual element belongs. |
35 | * | 28 | * |
36 | * @return network identifier | 29 | * @return network identifier | ... | ... |
... | @@ -16,14 +16,11 @@ | ... | @@ -16,14 +16,11 @@ |
16 | package org.onosproject.incubator.net.virtual; | 16 | package org.onosproject.incubator.net.virtual; |
17 | 17 | ||
18 | import com.google.common.annotations.Beta; | 18 | import com.google.common.annotations.Beta; |
19 | -import org.onosproject.incubator.net.tunnel.Tunnel; | 19 | +import org.onosproject.incubator.net.tunnel.TunnelId; |
20 | import org.onosproject.net.ConnectPoint; | 20 | import org.onosproject.net.ConnectPoint; |
21 | import org.onosproject.net.DeviceId; | 21 | import org.onosproject.net.DeviceId; |
22 | import org.onosproject.net.Port; | 22 | import org.onosproject.net.Port; |
23 | import org.onosproject.net.PortNumber; | 23 | import org.onosproject.net.PortNumber; |
24 | -import org.onosproject.net.device.DeviceDescription; | ||
25 | -import org.onosproject.net.device.PortDescription; | ||
26 | -import org.onosproject.net.link.LinkDescription; | ||
27 | 24 | ||
28 | import java.util.Set; | 25 | import java.util.Set; |
29 | 26 | ||
... | @@ -76,12 +73,12 @@ public interface VirtualNetworkAdminService extends VirtualNetworkService { | ... | @@ -76,12 +73,12 @@ public interface VirtualNetworkAdminService extends VirtualNetworkService { |
76 | * Creates a new virtual device within the specified network. The device id | 73 | * Creates a new virtual device within the specified network. The device id |
77 | * must be unique within the bounds of the network. | 74 | * must be unique within the bounds of the network. |
78 | * | 75 | * |
79 | - * @param networkId network identifier | 76 | + * @param networkId network identifier |
80 | - * @param description device description | 77 | + * @param deviceId device identifier |
81 | * @return newly created device | 78 | * @return newly created device |
82 | * @throws org.onlab.util.ItemNotFoundException if no such network found | 79 | * @throws org.onlab.util.ItemNotFoundException if no such network found |
83 | */ | 80 | */ |
84 | - VirtualDevice createVirtualDevice(NetworkId networkId, DeviceDescription description); | 81 | + VirtualDevice createVirtualDevice(NetworkId networkId, DeviceId deviceId); |
85 | 82 | ||
86 | /** | 83 | /** |
87 | * Removes the specified virtual device and all its ports and affiliated links. | 84 | * Removes the specified virtual device and all its ports and affiliated links. |
... | @@ -96,14 +93,16 @@ public interface VirtualNetworkAdminService extends VirtualNetworkService { | ... | @@ -96,14 +93,16 @@ public interface VirtualNetworkAdminService extends VirtualNetworkService { |
96 | /** | 93 | /** |
97 | * Creates a new virtual link within the specified network. | 94 | * Creates a new virtual link within the specified network. |
98 | * | 95 | * |
99 | - * @param networkId network identifier | 96 | + * @param networkId network identifier |
100 | - * @param description link description | 97 | + * @param src source connection point |
101 | - * @param realizedBy tunnel using which this link is realized | 98 | + * @param dst destination connection point |
99 | + * @param realizedBy identifier of the tunnel using which this link is realized | ||
102 | * @return newly created virtual link | 100 | * @return newly created virtual link |
103 | * @throws org.onlab.util.ItemNotFoundException if no such network found | 101 | * @throws org.onlab.util.ItemNotFoundException if no such network found |
104 | */ | 102 | */ |
105 | - VirtualLink createVirtualLink(NetworkId networkId, LinkDescription description, | 103 | + VirtualLink createVirtualLink(NetworkId networkId, |
106 | - Tunnel realizedBy); | 104 | + ConnectPoint src, ConnectPoint dst, |
105 | + TunnelId realizedBy); | ||
107 | 106 | ||
108 | // TODO: Discuss whether we should provide an alternate createVirtualLink | 107 | // TODO: Discuss whether we should provide an alternate createVirtualLink |
109 | // which is backed by a Path instead; I'm leaning towards not doing that. | 108 | // which is backed by a Path instead; I'm leaning towards not doing that. |
... | @@ -119,20 +118,17 @@ public interface VirtualNetworkAdminService extends VirtualNetworkService { | ... | @@ -119,20 +118,17 @@ public interface VirtualNetworkAdminService extends VirtualNetworkService { |
119 | void removeVirtualLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst); | 118 | void removeVirtualLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst); |
120 | 119 | ||
121 | /** | 120 | /** |
122 | - * Creates a new virtual port on the specified device. Note that the port | 121 | + * Creates a new virtual port on the specified device. |
123 | - * description can only request the resources which the underlying port | ||
124 | - * port is capable of providing. It is, however, permissible to request | ||
125 | - * only portion of those resources. | ||
126 | * | 122 | * |
127 | - * @param networkId network identifier | 123 | + * @param networkId network identifier |
128 | - * @param deviceId device identifier | 124 | + * @param deviceId device identifier |
129 | - * @param description port description | 125 | + * @param portNumber port number |
130 | - * @param realizedBy underlying port using which this virtual port is realized | 126 | + * @param realizedBy underlying port using which this virtual port is realized |
131 | * @return newly created port | 127 | * @return newly created port |
132 | * @throws org.onlab.util.ItemNotFoundException if no such network or device found | 128 | * @throws org.onlab.util.ItemNotFoundException if no such network or device found |
133 | */ | 129 | */ |
134 | VirtualPort createVirtualPort(NetworkId networkId, DeviceId deviceId, | 130 | VirtualPort createVirtualPort(NetworkId networkId, DeviceId deviceId, |
135 | - PortDescription description, Port realizedBy); | 131 | + PortNumber portNumber, Port realizedBy); |
136 | 132 | ||
137 | /** | 133 | /** |
138 | * Removes the specified virtual port. | 134 | * Removes the specified virtual port. | ... | ... |
incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkEvent.java
0 → 100644
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.incubator.net.virtual; | ||
17 | + | ||
18 | +import org.onosproject.event.AbstractEvent; | ||
19 | + | ||
20 | +/** | ||
21 | + * Describes virtual network event. | ||
22 | + */ | ||
23 | +public class VirtualNetworkEvent extends AbstractEvent<VirtualNetworkEvent.Type, NetworkId> { | ||
24 | + | ||
25 | + /** | ||
26 | + * Type of virtual network events. | ||
27 | + */ | ||
28 | + public enum Type { | ||
29 | + /** | ||
30 | + * Signifies that a new tenant identifier was registered. | ||
31 | + */ | ||
32 | + TENANT_REGISTERED, | ||
33 | + /** | ||
34 | + * Signifies that a tenant identifier was unregistered. | ||
35 | + */ | ||
36 | + TENANT_UNREGISTERED, | ||
37 | + /** | ||
38 | + * Signifies that a new virtual network was added. | ||
39 | + */ | ||
40 | + NETWORK_ADDED, | ||
41 | + /** | ||
42 | + * Signifies that a virtual network was updated. | ||
43 | + */ | ||
44 | + NETWORK_UPDATED, | ||
45 | + /** | ||
46 | + * Signifies that a virtual network was removed. | ||
47 | + */ | ||
48 | + NETWORK_REMOVED | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * Creates an event of a given type and for the specified subject and the | ||
53 | + * current time. | ||
54 | + * | ||
55 | + * @param type event type | ||
56 | + * @param subject event subject | ||
57 | + */ | ||
58 | + public VirtualNetworkEvent(Type type, NetworkId subject) { | ||
59 | + super(type, subject); | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * Creates an event of a given type and for the specified subject and time. | ||
64 | + * | ||
65 | + * @param type device event type | ||
66 | + * @param subject event subject | ||
67 | + * @param time occurrence time | ||
68 | + */ | ||
69 | + public VirtualNetworkEvent(Type type, NetworkId subject, long time) { | ||
70 | + super(type, subject, time); | ||
71 | + } | ||
72 | +} |
incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkListener.java
0 → 100644
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.incubator.net.virtual; | ||
17 | + | ||
18 | +import org.onosproject.event.EventListener; | ||
19 | + | ||
20 | +/** | ||
21 | + * Represents entity capable of receiving virtual network events. | ||
22 | + */ | ||
23 | +public interface VirtualNetworkListener extends EventListener<VirtualNetworkEvent> { | ||
24 | +} |
incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkStore.java
0 → 100644
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.incubator.net.virtual; | ||
17 | + | ||
18 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
19 | +import org.onosproject.net.ConnectPoint; | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | +import org.onosproject.net.Port; | ||
22 | +import org.onosproject.net.PortNumber; | ||
23 | +import org.onosproject.store.Store; | ||
24 | + | ||
25 | +import java.util.Set; | ||
26 | + | ||
27 | +/** | ||
28 | + * Mechanism for distributing and storing virtual network model information. | ||
29 | + */ | ||
30 | +public interface VirtualNetworkStore | ||
31 | + extends Store<VirtualNetworkEvent, VirtualNetworkStoreDelegate> { | ||
32 | + | ||
33 | + /** | ||
34 | + * Adds a new tenant ID to the store. | ||
35 | + * | ||
36 | + * @param tenantId tenant identifier | ||
37 | + */ | ||
38 | + void addTenantId(TenantId tenantId); | ||
39 | + | ||
40 | + /** | ||
41 | + * Removes the specified tenant ID from the store. | ||
42 | + * | ||
43 | + * @param tenantId tenant identifier | ||
44 | + */ | ||
45 | + void removeTenantId(TenantId tenantId); | ||
46 | + | ||
47 | + /** | ||
48 | + * Returns set of registered tenant IDs. | ||
49 | + * | ||
50 | + * @return set of tenant identifiers | ||
51 | + */ | ||
52 | + Set<TenantId> getTenantIds(); | ||
53 | + | ||
54 | + /** | ||
55 | + * Adds a new virtual network for the specified tenant to the store. | ||
56 | + * | ||
57 | + * @param tenantId tenant identifier | ||
58 | + * @return the virtual network | ||
59 | + */ | ||
60 | + VirtualNetwork addNetwork(TenantId tenantId); | ||
61 | + | ||
62 | + /** | ||
63 | + * Removes the specified virtual network from the store. | ||
64 | + * | ||
65 | + * @param networkId network identifier | ||
66 | + */ | ||
67 | + void removeNetwork(NetworkId networkId); | ||
68 | + | ||
69 | + /** | ||
70 | + * Adds a new virtual device to the store. This device will have no ports. | ||
71 | + * | ||
72 | + * @param networkId network identifier | ||
73 | + * @param deviceId device identifier | ||
74 | + * @return the virtual device | ||
75 | + */ | ||
76 | + VirtualDevice addDevice(NetworkId networkId, DeviceId deviceId); | ||
77 | + | ||
78 | + /** | ||
79 | + * Renmoves the specified virtual device from the given network. | ||
80 | + * | ||
81 | + * @param networkId network identifier | ||
82 | + * @param deviceId device identifier | ||
83 | + */ | ||
84 | + void removeDevice(NetworkId networkId, DeviceId deviceId); | ||
85 | + | ||
86 | + /** | ||
87 | + * Adds a new virtual link. | ||
88 | + * | ||
89 | + * @param networkId network identifier | ||
90 | + * @param src source end-point of the link | ||
91 | + * @param dst destination end-point of the link | ||
92 | + * @param realizedBy underlying tunnel using which this link is realized | ||
93 | + * @return the virtual link | ||
94 | + */ | ||
95 | + VirtualLink addLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst, | ||
96 | + TunnelId realizedBy); | ||
97 | + | ||
98 | + /** | ||
99 | + * Removes the specified link from the store. | ||
100 | + * | ||
101 | + * @param networkId network identifier | ||
102 | + * @param src source connection point | ||
103 | + * @param dst destination connection point | ||
104 | + */ | ||
105 | + void removeLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst); | ||
106 | + | ||
107 | + /** | ||
108 | + * Adds a new virtual port to the network. | ||
109 | + * | ||
110 | + * @param networkId network identifier | ||
111 | + * @param deviceId device identifier | ||
112 | + * @param portNumber port number | ||
113 | + * @param realizedBy underlying port which realizes the virtual port | ||
114 | + * @return the virtual port | ||
115 | + */ | ||
116 | + VirtualPort addPort(NetworkId networkId, DeviceId deviceId, | ||
117 | + PortNumber portNumber, Port realizedBy); | ||
118 | + | ||
119 | + /** | ||
120 | + * Removes the specified port from the given device and network. | ||
121 | + * | ||
122 | + * @param networkId network identifier | ||
123 | + * @param deviceId device identifier | ||
124 | + * @param portNumber port number | ||
125 | + */ | ||
126 | + void removePort(NetworkId networkId, DeviceId deviceId, PortNumber portNumber); | ||
127 | + | ||
128 | + /** | ||
129 | + * Returns the list of networks. | ||
130 | + * | ||
131 | + * @param tenantId tenant identifier | ||
132 | + * @return set of virtual networks | ||
133 | + */ | ||
134 | + Set<VirtualNetwork> getNetworks(TenantId tenantId); | ||
135 | + | ||
136 | + /** | ||
137 | + * Returns the list of devices in the specified virtual network. | ||
138 | + * | ||
139 | + * @param networkId network identifier | ||
140 | + * @return set of virtual devices | ||
141 | + */ | ||
142 | + Set<VirtualDevice> getDevices(NetworkId networkId); | ||
143 | + | ||
144 | + /** | ||
145 | + * Returns the list of virtual links in the specified virtual network. | ||
146 | + * | ||
147 | + * @param networkId network identifier | ||
148 | + * @return set of virtual links | ||
149 | + */ | ||
150 | + Set<VirtualLink> getLinks(NetworkId networkId); | ||
151 | + | ||
152 | + /** | ||
153 | + * Returns the list of ports of the specified virtual device. | ||
154 | + * | ||
155 | + * @param networkId network identifier | ||
156 | + * @param deviceId device identifier | ||
157 | + * @return set of virtual networks | ||
158 | + */ | ||
159 | + Set<VirtualPort> getPorts(NetworkId networkId, DeviceId deviceId); | ||
160 | + | ||
161 | +} |
incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkStoreDelegate.java
0 → 100644
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.incubator.net.virtual; | ||
17 | + | ||
18 | +import org.onosproject.store.StoreDelegate; | ||
19 | + | ||
20 | +/** | ||
21 | + * Network configuration store delegate abstraction. | ||
22 | + */ | ||
23 | +public interface VirtualNetworkStoreDelegate extends StoreDelegate<VirtualNetworkEvent> { | ||
24 | +} |
incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkManager.java
0 → 100644
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.incubator.net.virtual.impl; | ||
17 | + | ||
18 | +import org.apache.felix.scr.annotations.Activate; | ||
19 | +import org.apache.felix.scr.annotations.Component; | ||
20 | +import org.apache.felix.scr.annotations.Deactivate; | ||
21 | +import org.apache.felix.scr.annotations.Reference; | ||
22 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
23 | +import org.apache.felix.scr.annotations.Service; | ||
24 | +import org.onosproject.event.AbstractListenerManager; | ||
25 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
26 | +import org.onosproject.incubator.net.virtual.NetworkId; | ||
27 | +import org.onosproject.incubator.net.virtual.TenantId; | ||
28 | +import org.onosproject.incubator.net.virtual.VirtualDevice; | ||
29 | +import org.onosproject.incubator.net.virtual.VirtualLink; | ||
30 | +import org.onosproject.incubator.net.virtual.VirtualNetwork; | ||
31 | +import org.onosproject.incubator.net.virtual.VirtualNetworkAdminService; | ||
32 | +import org.onosproject.incubator.net.virtual.VirtualNetworkEvent; | ||
33 | +import org.onosproject.incubator.net.virtual.VirtualNetworkListener; | ||
34 | +import org.onosproject.incubator.net.virtual.VirtualNetworkService; | ||
35 | +import org.onosproject.incubator.net.virtual.VirtualNetworkStore; | ||
36 | +import org.onosproject.incubator.net.virtual.VirtualNetworkStoreDelegate; | ||
37 | +import org.onosproject.incubator.net.virtual.VirtualPort; | ||
38 | +import org.onosproject.net.ConnectPoint; | ||
39 | +import org.onosproject.net.DeviceId; | ||
40 | +import org.onosproject.net.Port; | ||
41 | +import org.onosproject.net.PortNumber; | ||
42 | +import org.slf4j.Logger; | ||
43 | +import org.slf4j.LoggerFactory; | ||
44 | + | ||
45 | +import java.util.Set; | ||
46 | + | ||
47 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
48 | + | ||
49 | +/** | ||
50 | + * Implementation of the virtual network service. | ||
51 | + */ | ||
52 | +@Component(immediate = true) | ||
53 | +@Service | ||
54 | +public class VirtualNetworkManager | ||
55 | + extends AbstractListenerManager<VirtualNetworkEvent, VirtualNetworkListener> | ||
56 | + implements VirtualNetworkService, VirtualNetworkAdminService { | ||
57 | + | ||
58 | + private final Logger log = LoggerFactory.getLogger(getClass()); | ||
59 | + | ||
60 | + private static final String TENANT_NULL = "Tenant ID cannot be null"; | ||
61 | + private static final String NETWORK_NULL = "Network ID cannot be null"; | ||
62 | + private static final String DEVICE_NULL = "Device ID cannot be null"; | ||
63 | + private static final String LINK_POINT_NULL = "Link end-point cannot be null"; | ||
64 | + | ||
65 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
66 | + protected VirtualNetworkStore store; | ||
67 | + | ||
68 | + private VirtualNetworkStoreDelegate delegate = new InternalStoreDelegate(); | ||
69 | + | ||
70 | + // TODO: figure out how to coordinate "implementation" of a virtual network | ||
71 | + | ||
72 | + @Activate | ||
73 | + protected void activate() { | ||
74 | + store.setDelegate(delegate); | ||
75 | + log.info("Started"); | ||
76 | + } | ||
77 | + | ||
78 | + @Deactivate | ||
79 | + protected void deactivate() { | ||
80 | + store.unsetDelegate(delegate); | ||
81 | + log.info("Stopped"); | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public void registerTenantId(TenantId tenantId) { | ||
86 | + checkNotNull(tenantId, TENANT_NULL); | ||
87 | + store.addTenantId(tenantId); | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public void unregisterTenantId(TenantId tenantId) { | ||
92 | + checkNotNull(tenantId, TENANT_NULL); | ||
93 | + store.removeTenantId(tenantId); | ||
94 | + } | ||
95 | + | ||
96 | + @Override | ||
97 | + public Set<TenantId> getTenantIds() { | ||
98 | + return store.getTenantIds(); | ||
99 | + } | ||
100 | + | ||
101 | + @Override | ||
102 | + public VirtualNetwork createVirtualNetwork(TenantId tenantId) { | ||
103 | + checkNotNull(tenantId, TENANT_NULL); | ||
104 | + return store.addNetwork(tenantId); | ||
105 | + } | ||
106 | + | ||
107 | + @Override | ||
108 | + public void removeVirtualNetwork(NetworkId networkId) { | ||
109 | + checkNotNull(networkId, NETWORK_NULL); | ||
110 | + store.removeNetwork(networkId); | ||
111 | + } | ||
112 | + | ||
113 | + @Override | ||
114 | + public VirtualDevice createVirtualDevice(NetworkId networkId, DeviceId deviceId) { | ||
115 | + checkNotNull(networkId, NETWORK_NULL); | ||
116 | + checkNotNull(deviceId, DEVICE_NULL); | ||
117 | + return store.addDevice(networkId, deviceId); | ||
118 | + } | ||
119 | + | ||
120 | + @Override | ||
121 | + public void removeVirtualDevice(NetworkId networkId, DeviceId deviceId) { | ||
122 | + checkNotNull(networkId, NETWORK_NULL); | ||
123 | + checkNotNull(deviceId, DEVICE_NULL); | ||
124 | + store.removeDevice(networkId, deviceId); | ||
125 | + } | ||
126 | + | ||
127 | + @Override | ||
128 | + public VirtualLink createVirtualLink(NetworkId networkId, | ||
129 | + ConnectPoint src, ConnectPoint dst, | ||
130 | + TunnelId realizedBy) { | ||
131 | + checkNotNull(networkId, NETWORK_NULL); | ||
132 | + checkNotNull(src, LINK_POINT_NULL); | ||
133 | + checkNotNull(dst, LINK_POINT_NULL); | ||
134 | + checkNotNull(realizedBy, "Tunnel ID cannot be null"); | ||
135 | + return store.addLink(networkId, src, dst, realizedBy); | ||
136 | + } | ||
137 | + | ||
138 | + @Override | ||
139 | + public void removeVirtualLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst) { | ||
140 | + checkNotNull(networkId, NETWORK_NULL); | ||
141 | + checkNotNull(src, LINK_POINT_NULL); | ||
142 | + checkNotNull(dst, LINK_POINT_NULL); | ||
143 | + store.removeLink(networkId, src, dst); | ||
144 | + } | ||
145 | + | ||
146 | + @Override | ||
147 | + public VirtualPort createVirtualPort(NetworkId networkId, DeviceId deviceId, | ||
148 | + PortNumber portNumber, Port realizedBy) { | ||
149 | + checkNotNull(networkId, NETWORK_NULL); | ||
150 | + checkNotNull(deviceId, DEVICE_NULL); | ||
151 | + checkNotNull(portNumber, "Port description cannot be null"); | ||
152 | + return store.addPort(networkId, deviceId, portNumber, realizedBy); | ||
153 | + } | ||
154 | + | ||
155 | + @Override | ||
156 | + public void removeVirtualPort(NetworkId networkId, DeviceId deviceId, PortNumber portNumber) { | ||
157 | + checkNotNull(networkId, NETWORK_NULL); | ||
158 | + checkNotNull(deviceId, DEVICE_NULL); | ||
159 | + checkNotNull(portNumber, "Port number cannot be null"); | ||
160 | + store.removePort(networkId, deviceId, portNumber); | ||
161 | + } | ||
162 | + | ||
163 | + @Override | ||
164 | + public Set<VirtualNetwork> getVirtualNetworks(TenantId tenantId) { | ||
165 | + checkNotNull(tenantId, TENANT_NULL); | ||
166 | + return store.getNetworks(tenantId); | ||
167 | + } | ||
168 | + | ||
169 | + @Override | ||
170 | + public Set<VirtualDevice> getVirtualDevices(NetworkId networkId) { | ||
171 | + checkNotNull(networkId, NETWORK_NULL); | ||
172 | + return store.getDevices(networkId); | ||
173 | + } | ||
174 | + | ||
175 | + @Override | ||
176 | + public Set<VirtualLink> getVirtualLinks(NetworkId networkId) { | ||
177 | + checkNotNull(networkId, NETWORK_NULL); | ||
178 | + return store.getLinks(networkId); | ||
179 | + } | ||
180 | + | ||
181 | + @Override | ||
182 | + public Set<VirtualPort> getVirtualPorts(NetworkId networkId, DeviceId deviceId) { | ||
183 | + checkNotNull(networkId, NETWORK_NULL); | ||
184 | + checkNotNull(deviceId, DEVICE_NULL); | ||
185 | + return store.getPorts(networkId, deviceId); | ||
186 | + } | ||
187 | + | ||
188 | + @Override | ||
189 | + public <T> T get(NetworkId networkId, Class<T> serviceClass) { | ||
190 | + checkNotNull(networkId, NETWORK_NULL); | ||
191 | + return null; | ||
192 | + } | ||
193 | + | ||
194 | + // Auxiliary store delegate to receive notification about changes in | ||
195 | + // the virtual network configuration store state - by the store itself. | ||
196 | + private class InternalStoreDelegate implements VirtualNetworkStoreDelegate { | ||
197 | + @Override | ||
198 | + public void notify(VirtualNetworkEvent event) { | ||
199 | + post(event); | ||
200 | + } | ||
201 | + } | ||
202 | + | ||
203 | +} |
1 | +/* | ||
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 | + */ | ||
16 | + | ||
17 | +/** | ||
18 | + * Implementation of the virtual network subsystem. | ||
19 | + */ | ||
20 | +package org.onosproject.incubator.net.virtual.impl; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.incubator.store.virtual.impl; | ||
17 | + | ||
18 | +import org.apache.felix.scr.annotations.Activate; | ||
19 | +import org.apache.felix.scr.annotations.Component; | ||
20 | +import org.apache.felix.scr.annotations.Deactivate; | ||
21 | +import org.apache.felix.scr.annotations.Service; | ||
22 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
23 | +import org.onosproject.incubator.net.virtual.DefaultVirtualDevice; | ||
24 | +import org.onosproject.incubator.net.virtual.DefaultVirtualNetwork; | ||
25 | +import org.onosproject.incubator.net.virtual.NetworkId; | ||
26 | +import org.onosproject.incubator.net.virtual.TenantId; | ||
27 | +import org.onosproject.incubator.net.virtual.VirtualDevice; | ||
28 | +import org.onosproject.incubator.net.virtual.VirtualLink; | ||
29 | +import org.onosproject.incubator.net.virtual.VirtualNetwork; | ||
30 | +import org.onosproject.incubator.net.virtual.VirtualNetworkEvent; | ||
31 | +import org.onosproject.incubator.net.virtual.VirtualNetworkStore; | ||
32 | +import org.onosproject.incubator.net.virtual.VirtualNetworkStoreDelegate; | ||
33 | +import org.onosproject.incubator.net.virtual.VirtualPort; | ||
34 | +import org.onosproject.net.ConnectPoint; | ||
35 | +import org.onosproject.net.DeviceId; | ||
36 | +import org.onosproject.net.Port; | ||
37 | +import org.onosproject.net.PortNumber; | ||
38 | +import org.onosproject.store.AbstractStore; | ||
39 | +import org.slf4j.Logger; | ||
40 | + | ||
41 | +import java.util.Set; | ||
42 | + | ||
43 | +import static org.slf4j.LoggerFactory.getLogger; | ||
44 | + | ||
45 | +/** | ||
46 | + * Implementation of the network store. | ||
47 | + */ | ||
48 | +@Component(immediate = true) | ||
49 | +@Service | ||
50 | +public class DistributedVirtualNetworkStore | ||
51 | + extends AbstractStore<VirtualNetworkEvent, VirtualNetworkStoreDelegate> | ||
52 | + implements VirtualNetworkStore { | ||
53 | + | ||
54 | + private final Logger log = getLogger(getClass()); | ||
55 | + | ||
56 | + // TODO: track tenants by ID | ||
57 | + // TODO: track networks by ID and by tenants | ||
58 | + // TODO: track devices by network ID and device ID | ||
59 | + // TODO: track devices by network ID | ||
60 | + // TODO: setup block allocator for network IDs | ||
61 | + | ||
62 | + // TODO: notify delegate | ||
63 | + | ||
64 | + @Activate | ||
65 | + public void activate() { | ||
66 | + log.info("Started"); | ||
67 | + } | ||
68 | + | ||
69 | + @Deactivate | ||
70 | + public void deactivate() { | ||
71 | + log.info("Stopped"); | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public void addTenantId(TenantId tenantId) { | ||
76 | + } | ||
77 | + | ||
78 | + @Override | ||
79 | + public void removeTenantId(TenantId tenantId) { | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public Set<TenantId> getTenantIds() { | ||
84 | + return null; | ||
85 | + } | ||
86 | + | ||
87 | + @Override | ||
88 | + public VirtualNetwork addNetwork(TenantId tenantId) { | ||
89 | + return new DefaultVirtualNetwork(genNetworkId(), tenantId); | ||
90 | + } | ||
91 | + | ||
92 | + private NetworkId genNetworkId() { | ||
93 | + return NetworkId.networkId(0); // TODO: use a block allocator | ||
94 | + } | ||
95 | + | ||
96 | + | ||
97 | + @Override | ||
98 | + public void removeNetwork(NetworkId networkId) { | ||
99 | + } | ||
100 | + | ||
101 | + @Override | ||
102 | + public VirtualDevice addDevice(NetworkId networkId, DeviceId deviceId) { | ||
103 | + return new DefaultVirtualDevice(networkId, deviceId); | ||
104 | + } | ||
105 | + | ||
106 | + @Override | ||
107 | + public void removeDevice(NetworkId networkId, DeviceId deviceId) { | ||
108 | + } | ||
109 | + | ||
110 | + @Override | ||
111 | + public VirtualLink addLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst, TunnelId realizedBy) { | ||
112 | + return null; | ||
113 | + } | ||
114 | + | ||
115 | + @Override | ||
116 | + public void removeLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst) { | ||
117 | + } | ||
118 | + | ||
119 | + @Override | ||
120 | + public VirtualPort addPort(NetworkId networkId, DeviceId deviceId, PortNumber portNumber, Port realizedBy) { | ||
121 | + return null; | ||
122 | + } | ||
123 | + | ||
124 | + @Override | ||
125 | + public void removePort(NetworkId networkId, DeviceId deviceId, PortNumber portNumber) { | ||
126 | + } | ||
127 | + | ||
128 | + @Override | ||
129 | + public Set<VirtualNetwork> getNetworks(TenantId tenantId) { | ||
130 | + return null; | ||
131 | + } | ||
132 | + | ||
133 | + @Override | ||
134 | + public Set<VirtualDevice> getDevices(NetworkId networkId) { | ||
135 | + return null; | ||
136 | + } | ||
137 | + | ||
138 | + @Override | ||
139 | + public Set<VirtualLink> getLinks(NetworkId networkId) { | ||
140 | + return null; | ||
141 | + } | ||
142 | + | ||
143 | + @Override | ||
144 | + public Set<VirtualPort> getPorts(NetworkId networkId, DeviceId deviceId) { | ||
145 | + return null; | ||
146 | + } | ||
147 | +} |
incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/package-info.java
0 → 100644
1 | +/* | ||
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 | + */ | ||
16 | + | ||
17 | +/** | ||
18 | + * Implementation of distributed virtual network store. | ||
19 | + */ | ||
20 | +package org.onosproject.incubator.store.virtual.impl; |
-
Please register or login to post a comment