Committed by
Gerrit Code Review
[Falcon][WIP] CORD-368 Added APIs for service dependency
- Added create/remove service dependency to CordVtn - Added new type for service ID Change-Id: If836ab6bcc5e60c1707b2dbf0a244a204529b007
Showing
8 changed files
with
337 additions
and
0 deletions
... | @@ -70,6 +70,33 @@ | ... | @@ -70,6 +70,33 @@ |
70 | </dependency> | 70 | </dependency> |
71 | <dependency> | 71 | <dependency> |
72 | <groupId>org.onosproject</groupId> | 72 | <groupId>org.onosproject</groupId> |
73 | + <artifactId>onos-rest</artifactId> | ||
74 | + <version>${project.version}</version> | ||
75 | + </dependency> | ||
76 | + <dependency> | ||
77 | + <groupId>org.onosproject</groupId> | ||
78 | + <artifactId>onlab-rest</artifactId> | ||
79 | + <version>${project.version}</version> | ||
80 | + </dependency> | ||
81 | + <dependency> | ||
82 | + <groupId>javax.ws.rs</groupId> | ||
83 | + <artifactId>jsr311-api</artifactId> | ||
84 | + <version>1.1.1</version> | ||
85 | + </dependency> | ||
86 | + <dependency> | ||
87 | + <groupId>com.sun.jersey</groupId> | ||
88 | + <artifactId>jersey-servlet</artifactId> | ||
89 | + </dependency> | ||
90 | + <dependency> | ||
91 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
92 | + <artifactId>jackson-databind</artifactId> | ||
93 | + </dependency> | ||
94 | + <dependency> | ||
95 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
96 | + <artifactId>jackson-annotations</artifactId> | ||
97 | + </dependency> | ||
98 | + <dependency> | ||
99 | + <groupId>org.onosproject</groupId> | ||
73 | <artifactId>onos-app-openstackswitching-api</artifactId> | 100 | <artifactId>onos-app-openstackswitching-api</artifactId> |
74 | <version>${project.version}</version> | 101 | <version>${project.version}</version> |
75 | </dependency> | 102 | </dependency> | ... | ... |
... | @@ -282,6 +282,14 @@ public class CordVtn implements CordVtnService { | ... | @@ -282,6 +282,14 @@ public class CordVtn implements CordVtnService { |
282 | return state != null && state.equals(NodeState.COMPLETE); | 282 | return state != null && state.equals(NodeState.COMPLETE); |
283 | } | 283 | } |
284 | 284 | ||
285 | + @Override | ||
286 | + public void createServiceDependency(ServiceId tenantServiceId, ServiceId providerServiceId) { | ||
287 | + } | ||
288 | + | ||
289 | + @Override | ||
290 | + public void removeServiceDependency(ServiceId tenantServiceId, ServiceId providerServiceId) { | ||
291 | + } | ||
292 | + | ||
285 | /** | 293 | /** |
286 | * Returns state of a given cordvtn node. | 294 | * Returns state of a given cordvtn node. |
287 | * | 295 | * | ... | ... |
... | @@ -65,4 +65,20 @@ public interface CordVtnService { | ... | @@ -65,4 +65,20 @@ public interface CordVtnService { |
65 | * @return list of nodes | 65 | * @return list of nodes |
66 | */ | 66 | */ |
67 | List<CordVtnNode> getNodes(); | 67 | List<CordVtnNode> getNodes(); |
68 | + | ||
69 | + /** | ||
70 | + * Creates a dependency between two services. | ||
71 | + * | ||
72 | + * @param tenantServiceId id of the service which has a dependency | ||
73 | + * @param providerServiceId id of the service which provides dependency | ||
74 | + */ | ||
75 | + void createServiceDependency(ServiceId tenantServiceId, ServiceId providerServiceId); | ||
76 | + | ||
77 | + /** | ||
78 | + * Removes a dependency between two services. | ||
79 | + * | ||
80 | + * @param tenantServiceId id of the service which has a dependency | ||
81 | + * @param providerServiceId id of the service which provides dependency | ||
82 | + */ | ||
83 | + void removeServiceDependency(ServiceId tenantServiceId, ServiceId providerServiceId); | ||
68 | } | 84 | } | ... | ... |
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.cordvtn; | ||
17 | + | ||
18 | +import com.google.common.base.MoreObjects; | ||
19 | +import org.onlab.packet.IpAddress; | ||
20 | +import org.onlab.packet.IpPrefix; | ||
21 | + | ||
22 | +import java.util.Objects; | ||
23 | + | ||
24 | +public final class Service { | ||
25 | + | ||
26 | + enum ServiceType { | ||
27 | + PRIVATE, | ||
28 | + PRIVATE_DIRECT, | ||
29 | + PRIVATE_INDIRECT, | ||
30 | + PUBLIC_DIRECT, | ||
31 | + PUBLIC_INDIRECT | ||
32 | + } | ||
33 | + | ||
34 | + private final ServiceId serviceId; | ||
35 | + private final String networkId; | ||
36 | + private final ServiceType serviceType; | ||
37 | + private final IpPrefix serviceIpRange; | ||
38 | + private final IpAddress serviceIp; | ||
39 | + | ||
40 | + /** | ||
41 | + * Default constructor. | ||
42 | + * | ||
43 | + * @param serviceId service id | ||
44 | + * @param networkId OpenStack Neutron network id | ||
45 | + * @param serviceType service type | ||
46 | + * @param serviceIpRange service ip range | ||
47 | + * @param serviceIp service ip | ||
48 | + */ | ||
49 | + public Service(ServiceId serviceId, String networkId, ServiceType serviceType, | ||
50 | + IpPrefix serviceIpRange, IpAddress serviceIp) { | ||
51 | + this.serviceId = serviceId; | ||
52 | + this.networkId = networkId; | ||
53 | + this.serviceType = serviceType; | ||
54 | + this.serviceIpRange = serviceIpRange; | ||
55 | + this.serviceIp = serviceIp; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * Returns service ID. | ||
60 | + * | ||
61 | + * @return service id | ||
62 | + */ | ||
63 | + public ServiceId serviceId() { | ||
64 | + return serviceId; | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Returns OpenStack Neutron network ID of this service. | ||
69 | + * | ||
70 | + * @return network id | ||
71 | + */ | ||
72 | + public String networkId() { | ||
73 | + return networkId; | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * Returns service type. | ||
78 | + * | ||
79 | + * @return service type | ||
80 | + */ | ||
81 | + public ServiceType serviceType() { | ||
82 | + return serviceType; | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Returns service IP range. | ||
87 | + * | ||
88 | + * @return CIDR | ||
89 | + */ | ||
90 | + public IpPrefix serviceIpRange() { | ||
91 | + return serviceIpRange; | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Returns service IP address. | ||
96 | + * | ||
97 | + * @return ip address | ||
98 | + */ | ||
99 | + public IpAddress serviceIp() { | ||
100 | + return serviceIp; | ||
101 | + } | ||
102 | + | ||
103 | + @Override | ||
104 | + public int hashCode() { | ||
105 | + return Objects.hash(serviceId); | ||
106 | + } | ||
107 | + | ||
108 | + @Override | ||
109 | + public boolean equals(Object obj) { | ||
110 | + if (this == obj) { | ||
111 | + return true; | ||
112 | + } | ||
113 | + if (!(obj instanceof Service)) { | ||
114 | + return false; | ||
115 | + } | ||
116 | + final Service other = (Service) obj; | ||
117 | + return Objects.equals(this.serviceId, other.serviceId); | ||
118 | + } | ||
119 | + | ||
120 | + @Override | ||
121 | + public String toString() { | ||
122 | + return MoreObjects.toStringHelper(this) | ||
123 | + .add("serviceId", serviceId) | ||
124 | + .add("networkId", networkId) | ||
125 | + .add("serviceType", serviceType) | ||
126 | + .add("serviceIpRange", serviceIpRange) | ||
127 | + .add("serviceIp", serviceIp) | ||
128 | + .toString(); | ||
129 | + } | ||
130 | +} |
1 | +/* | ||
2 | + * Copyright 2014-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.cordvtn; | ||
17 | + | ||
18 | +import com.google.common.base.MoreObjects; | ||
19 | + | ||
20 | +import java.util.Objects; | ||
21 | + | ||
22 | +/** | ||
23 | + * Representation of service identifier. | ||
24 | + */ | ||
25 | +public final class ServiceId { | ||
26 | + | ||
27 | + private final long serviceId; | ||
28 | + | ||
29 | + /** | ||
30 | + * Default constructor. | ||
31 | + * | ||
32 | + * @param serviceId service identifier | ||
33 | + */ | ||
34 | + private ServiceId(long serviceId) { | ||
35 | + this.serviceId = serviceId; | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * Returns the ServiceId with value. | ||
40 | + * | ||
41 | + * @param serviceId service id | ||
42 | + * @return ServiceId | ||
43 | + */ | ||
44 | + public static ServiceId of(long serviceId) { | ||
45 | + return new ServiceId(serviceId); | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Returns service identifier. | ||
50 | + * | ||
51 | + * @return service id | ||
52 | + */ | ||
53 | + public long serviceId() { | ||
54 | + return serviceId; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public int hashCode() { | ||
59 | + return Objects.hash(serviceId); | ||
60 | + } | ||
61 | + | ||
62 | + @Override | ||
63 | + public boolean equals(Object obj) { | ||
64 | + if (this == obj) { | ||
65 | + return true; | ||
66 | + } | ||
67 | + if (!(obj instanceof ServiceId)) { | ||
68 | + return false; | ||
69 | + } | ||
70 | + final ServiceId other = (ServiceId) obj; | ||
71 | + return Objects.equals(this.serviceId, other.serviceId); | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public String toString() { | ||
76 | + return MoreObjects.toStringHelper(this) | ||
77 | + .add("serviceId", serviceId) | ||
78 | + .toString(); | ||
79 | + } | ||
80 | +} |
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.cordvtn.rest; | ||
17 | + | ||
18 | +import org.apache.felix.scr.annotations.Component; | ||
19 | +import org.onosproject.rest.AbstractApiDocRegistrator; | ||
20 | +import org.onosproject.rest.ApiDocProvider; | ||
21 | + | ||
22 | +@Component(immediate = true) | ||
23 | +public class ApiDocRegistrator extends AbstractApiDocRegistrator { | ||
24 | + public ApiDocRegistrator() { | ||
25 | + super(new ApiDocProvider("/onos/cordvtn", | ||
26 | + "CORD VTN Service REST API", | ||
27 | + ApiDocRegistrator.class.getClassLoader())); | ||
28 | + } | ||
29 | +} |
apps/cordvtn/src/main/java/org/onosproject/cordvtn/rest/ServiceDependencyWebResource.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.cordvtn.rest; | ||
17 | + | ||
18 | +import org.onosproject.rest.AbstractWebResource; | ||
19 | + | ||
20 | +import javax.ws.rs.Path; | ||
21 | + | ||
22 | +/** | ||
23 | + * Manages service dependency. | ||
24 | + */ | ||
25 | +@Path("service-dependency") | ||
26 | +public class ServiceDependencyWebResource extends AbstractWebResource { | ||
27 | +} |
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 | + * REST APIs for CORD VTN. | ||
19 | + */ | ||
20 | +package org.onosproject.cordvtn.rest; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment