Committed by
Gerrit Code Review
CORD-536 Support bidirectional connectivity between two services with dependency
Change-Id: I6530cd6d4865567d878a8269e09b98f5694b0454
Showing
4 changed files
with
37 additions
and
26 deletions
| ... | @@ -209,7 +209,8 @@ public class CordVtn extends AbstractProvider implements CordVtnService, HostPro | ... | @@ -209,7 +209,8 @@ public class CordVtn extends AbstractProvider implements CordVtnService, HostPro |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | @Override | 211 | @Override |
| 212 | - public void createServiceDependency(CordServiceId tServiceId, CordServiceId pServiceId) { | 212 | + public void createServiceDependency(CordServiceId tServiceId, CordServiceId pServiceId, |
| 213 | + boolean isBidirectional) { | ||
| 213 | CordService tService = getCordService(tServiceId); | 214 | CordService tService = getCordService(tServiceId); |
| 214 | CordService pService = getCordService(pServiceId); | 215 | CordService pService = getCordService(pServiceId); |
| 215 | 216 | ||
| ... | @@ -219,7 +220,7 @@ public class CordVtn extends AbstractProvider implements CordVtnService, HostPro | ... | @@ -219,7 +220,7 @@ public class CordVtn extends AbstractProvider implements CordVtnService, HostPro |
| 219 | } | 220 | } |
| 220 | 221 | ||
| 221 | log.info("Service dependency from {} to {} created.", tService.id().id(), pService.id().id()); | 222 | log.info("Service dependency from {} to {} created.", tService.id().id(), pService.id().id()); |
| 222 | - ruleInstaller.populateServiceDependencyRules(tService, pService); | 223 | + ruleInstaller.populateServiceDependencyRules(tService, pService, isBidirectional); |
| 223 | } | 224 | } |
| 224 | 225 | ||
| 225 | @Override | 226 | @Override | ... | ... |
| ... | @@ -254,8 +254,10 @@ public class CordVtnRuleInstaller { | ... | @@ -254,8 +254,10 @@ public class CordVtnRuleInstaller { |
| 254 | * | 254 | * |
| 255 | * @param tService tenant cord service | 255 | * @param tService tenant cord service |
| 256 | * @param pService provider cord service | 256 | * @param pService provider cord service |
| 257 | + * @param isBidirectional true to enable bidirectional connection between two services | ||
| 257 | */ | 258 | */ |
| 258 | - public void populateServiceDependencyRules(CordService tService, CordService pService) { | 259 | + public void populateServiceDependencyRules(CordService tService, CordService pService, |
| 260 | + boolean isBidirectional) { | ||
| 259 | checkNotNull(tService); | 261 | checkNotNull(tService); |
| 260 | checkNotNull(pService); | 262 | checkNotNull(pService); |
| 261 | 263 | ||
| ... | @@ -280,6 +282,9 @@ public class CordVtnRuleInstaller { | ... | @@ -280,6 +282,9 @@ public class CordVtnRuleInstaller { |
| 280 | 282 | ||
| 281 | populateIndirectAccessRule(srcRange, serviceIp, outGroups); | 283 | populateIndirectAccessRule(srcRange, serviceIp, outGroups); |
| 282 | populateDirectAccessRule(srcRange, dstRange); | 284 | populateDirectAccessRule(srcRange, dstRange); |
| 285 | + if (isBidirectional) { | ||
| 286 | + populateDirectAccessRule(dstRange, srcRange); | ||
| 287 | + } | ||
| 283 | populateInServiceRule(inPorts, outGroups); | 288 | populateInServiceRule(inPorts, outGroups); |
| 284 | } | 289 | } |
| 285 | 290 | ... | ... |
| ... | @@ -44,8 +44,11 @@ public interface CordVtnService { | ... | @@ -44,8 +44,11 @@ public interface CordVtnService { |
| 44 | * | 44 | * |
| 45 | * @param tServiceId id of the service which has a dependency | 45 | * @param tServiceId id of the service which has a dependency |
| 46 | * @param pServiceId id of the service which provide dependency | 46 | * @param pServiceId id of the service which provide dependency |
| 47 | + * @param isBidirectional true to enable bidirectional connectivity between two services | ||
| 47 | */ | 48 | */ |
| 48 | - void createServiceDependency(CordServiceId tServiceId, CordServiceId pServiceId); | 49 | + void createServiceDependency(CordServiceId tServiceId, |
| 50 | + CordServiceId pServiceId, | ||
| 51 | + boolean isBidirectional); | ||
| 49 | 52 | ||
| 50 | /** | 53 | /** |
| 51 | * Removes all dependencies from a given tenant service. | 54 | * Removes all dependencies from a given tenant service. | ... | ... |
| ... | @@ -19,16 +19,13 @@ import org.onosproject.cordvtn.CordVtnService; | ... | @@ -19,16 +19,13 @@ import org.onosproject.cordvtn.CordVtnService; |
| 19 | import org.onosproject.cordvtn.CordServiceId; | 19 | import org.onosproject.cordvtn.CordServiceId; |
| 20 | import org.onosproject.rest.AbstractWebResource; | 20 | import org.onosproject.rest.AbstractWebResource; |
| 21 | 21 | ||
| 22 | -import javax.ws.rs.Consumes; | ||
| 23 | import javax.ws.rs.DELETE; | 22 | import javax.ws.rs.DELETE; |
| 24 | import javax.ws.rs.POST; | 23 | import javax.ws.rs.POST; |
| 25 | -import javax.ws.rs.PUT; | ||
| 26 | import javax.ws.rs.Path; | 24 | import javax.ws.rs.Path; |
| 27 | import javax.ws.rs.PathParam; | 25 | import javax.ws.rs.PathParam; |
| 28 | import javax.ws.rs.Produces; | 26 | import javax.ws.rs.Produces; |
| 29 | import javax.ws.rs.core.MediaType; | 27 | import javax.ws.rs.core.MediaType; |
| 30 | import javax.ws.rs.core.Response; | 28 | import javax.ws.rs.core.Response; |
| 31 | -import java.io.InputStream; | ||
| 32 | 29 | ||
| 33 | /** | 30 | /** |
| 34 | * Manages service dependency. | 31 | * Manages service dependency. |
| ... | @@ -37,9 +34,10 @@ import java.io.InputStream; | ... | @@ -37,9 +34,10 @@ import java.io.InputStream; |
| 37 | public class ServiceDependencyWebResource extends AbstractWebResource { | 34 | public class ServiceDependencyWebResource extends AbstractWebResource { |
| 38 | 35 | ||
| 39 | private final CordVtnService service = get(CordVtnService.class); | 36 | private final CordVtnService service = get(CordVtnService.class); |
| 37 | + private static final String BIDIRECTION = "b"; | ||
| 40 | 38 | ||
| 41 | /** | 39 | /** |
| 42 | - * Creates service dependencies. | 40 | + * Creates service dependencies with unidirectional access between the services. |
| 43 | * | 41 | * |
| 44 | * @param tServiceId tenant service id | 42 | * @param tServiceId tenant service id |
| 45 | * @param pServiceId provider service id | 43 | * @param pServiceId provider service id |
| ... | @@ -48,43 +46,47 @@ public class ServiceDependencyWebResource extends AbstractWebResource { | ... | @@ -48,43 +46,47 @@ public class ServiceDependencyWebResource extends AbstractWebResource { |
| 48 | @POST | 46 | @POST |
| 49 | @Path("{tenantServiceId}/{providerServiceId}") | 47 | @Path("{tenantServiceId}/{providerServiceId}") |
| 50 | @Produces(MediaType.APPLICATION_JSON) | 48 | @Produces(MediaType.APPLICATION_JSON) |
| 51 | - @Consumes(MediaType.APPLICATION_JSON) | ||
| 52 | public Response createServiceDependency(@PathParam("tenantServiceId") String tServiceId, | 49 | public Response createServiceDependency(@PathParam("tenantServiceId") String tServiceId, |
| 53 | @PathParam("providerServiceId") String pServiceId) { | 50 | @PathParam("providerServiceId") String pServiceId) { |
| 54 | - service.createServiceDependency(CordServiceId.of(tServiceId), CordServiceId.of(pServiceId)); | 51 | + service.createServiceDependency(CordServiceId.of(tServiceId), |
| 52 | + CordServiceId.of(pServiceId), | ||
| 53 | + false); | ||
| 55 | return Response.status(Response.Status.OK).build(); | 54 | return Response.status(Response.Status.OK).build(); |
| 56 | } | 55 | } |
| 57 | 56 | ||
| 58 | /** | 57 | /** |
| 59 | - * Removes service dependencies. | 58 | + * Creates service dependencies with an access type extension between the services. |
| 60 | * | 59 | * |
| 61 | * @param tServiceId tenant service id | 60 | * @param tServiceId tenant service id |
| 62 | * @param pServiceId provider service id | 61 | * @param pServiceId provider service id |
| 63 | - * @return 200 OK, or 400 Bad Request | 62 | + * @param direction b for bidirectional access, otherwise unidirectional access |
| 63 | + * @return 200 OK | ||
| 64 | */ | 64 | */ |
| 65 | - @DELETE | 65 | + @POST |
| 66 | - @Path("{tenantServiceId}/{providerServiceId}") | 66 | + @Path("{tenantServiceId}/{providerServiceId}/{direction}") |
| 67 | @Produces(MediaType.APPLICATION_JSON) | 67 | @Produces(MediaType.APPLICATION_JSON) |
| 68 | - public Response removeServiceDependency(@PathParam("tenantServiceId") String tServiceId, | 68 | + public Response createServiceDependency(@PathParam("tenantServiceId") String tServiceId, |
| 69 | - @PathParam("providerServiceId") String pServiceId) { | 69 | + @PathParam("providerServiceId") String pServiceId, |
| 70 | - service.removeServiceDependency(CordServiceId.of(tServiceId), CordServiceId.of(pServiceId)); | 70 | + @PathParam("direction") String direction) { |
| 71 | + service.createServiceDependency(CordServiceId.of(tServiceId), | ||
| 72 | + CordServiceId.of(pServiceId), | ||
| 73 | + direction.equals(BIDIRECTION)); | ||
| 71 | return Response.status(Response.Status.OK).build(); | 74 | return Response.status(Response.Status.OK).build(); |
| 72 | } | 75 | } |
| 73 | 76 | ||
| 74 | /** | 77 | /** |
| 75 | - * Updates service dependencies. | 78 | + * Removes service dependencies. |
| 76 | * | 79 | * |
| 77 | - * @param serviceId service id | 80 | + * @param tServiceId tenant service id |
| 78 | - * @param stream input JSON | 81 | + * @param pServiceId provider service id |
| 79 | * @return 200 OK, or 400 Bad Request | 82 | * @return 200 OK, or 400 Bad Request |
| 80 | */ | 83 | */ |
| 81 | - @PUT | 84 | + @DELETE |
| 82 | - @Path("{serviceId}") | 85 | + @Path("{tenantServiceId}/{providerServiceId}") |
| 83 | @Produces(MediaType.APPLICATION_JSON) | 86 | @Produces(MediaType.APPLICATION_JSON) |
| 84 | - @Consumes(MediaType.APPLICATION_JSON) | 87 | + public Response removeServiceDependency(@PathParam("tenantServiceId") String tServiceId, |
| 85 | - public Response updateServiceDependency(@PathParam("serviceId") String serviceId, | 88 | + @PathParam("providerServiceId") String pServiceId) { |
| 86 | - InputStream stream) { | 89 | + service.removeServiceDependency(CordServiceId.of(tServiceId), CordServiceId.of(pServiceId)); |
| 87 | - // TODO define input stream | ||
| 88 | return Response.status(Response.Status.OK).build(); | 90 | return Response.status(Response.Status.OK).build(); |
| 89 | } | 91 | } |
| 90 | } | 92 | } | ... | ... |
-
Please register or login to post a comment