From d44ffe7bb84c6fc21d0ace5a5060c772d600b9f2 Mon Sep 17 00:00:00 2001 From: Vladimir Lavor Date: Tue, 6 Oct 2015 10:43:05 +0200 Subject: [PATCH] OpFlex removed from master Will not be released in Beryllium 2.It is out of date with the LibOpFlex project and it is impacting UT targets for no benefit. Signed-off-by: Vladimir Lavor --- artifacts/pom.xml | 14 +- features/pom.xml | 10 - features/src/main/features/features.xml | 15 - groupbasedpolicy-opflex-config/pom.xml | 47 - .../initial/15-groupbasedpolicy-opflex.xml | 40 - pom.xml | 1 - renderers/opflex/pom.xml | 94 - .../impl/OpflexProviderModule.java | 25 - .../impl/OpflexProviderModuleFactory.java | 13 - .../renderer/opflex/EndpointListener.java | 29 - .../renderer/opflex/EndpointManager.java | 726 ---- .../renderer/opflex/EprContext.java | 178 - .../renderer/opflex/EprOperation.java | 67 - .../renderer/opflex/Identity.java | 345 -- .../renderer/opflex/L2EprOperation.java | 182 - .../renderer/opflex/L3EprOperation.java | 180 - .../renderer/opflex/MessageUtils.java | 2320 ----------- .../renderer/opflex/OpflexRenderer.java | 87 - .../renderer/opflex/PolicyManager.java | 518 --- .../opflex/jsonrpc/ConnectionService.java | 40 - .../opflex/jsonrpc/ExceptionHandler.java | 26 - .../jsonrpc/InvalidEncodingException.java | 25 - .../opflex/jsonrpc/JsonRpc10Response.java | 52 - .../opflex/jsonrpc/JsonRpcDecoder.java | 169 - .../opflex/jsonrpc/JsonRpcEncoder.java | 23 - .../opflex/jsonrpc/JsonRpcEndpoint.java | 221 - .../jsonrpc/JsonRpcServiceBinderHandler.java | 57 - .../renderer/opflex/jsonrpc/RpcBroker.java | 62 - .../renderer/opflex/jsonrpc/RpcMessage.java | 36 - .../opflex/jsonrpc/RpcMessageMap.java | 33 - .../renderer/opflex/jsonrpc/RpcServer.java | 167 - .../renderer/opflex/lib/OpflexAgent.java | 124 - .../opflex/lib/OpflexConnectionService.java | 741 ---- .../renderer/opflex/lib/OpflexRpcServer.java | 165 - .../renderer/opflex/lib/Role.java | 106 - .../lib/messages/EndpointDeclareRequest.java | 118 - .../lib/messages/EndpointDeclareResponse.java | 95 - .../opflex/lib/messages/EndpointIdentity.java | 35 - .../lib/messages/EndpointResolveRequest.java | 135 - .../lib/messages/EndpointResolveResponse.java | 107 - .../messages/EndpointUndeclareRequest.java | 116 - .../messages/EndpointUndeclareResponse.java | 95 - .../messages/EndpointUnresolveRequest.java | 127 - .../messages/EndpointUnresolveResponse.java | 95 - .../lib/messages/EndpointUpdateRequest.java | 118 - .../lib/messages/EndpointUpdateResponse.java | 95 - .../opflex/lib/messages/IdentityRequest.java | 139 - .../opflex/lib/messages/IdentityResponse.java | 164 - .../opflex/lib/messages/ManagedObject.java | 202 - .../opflex/lib/messages/OpflexError.java | 65 - .../opflex/lib/messages/PolicyIdentity.java | 35 - .../lib/messages/PolicyResolveRequest.java | 145 - .../lib/messages/PolicyResolveResponse.java | 107 - .../lib/messages/PolicyUnresolveRequest.java | 127 - .../lib/messages/PolicyUnresolveResponse.java | 95 - .../lib/messages/PolicyUpdateRequest.java | 127 - .../lib/messages/PolicyUpdateResponse.java | 95 - .../lib/messages/StateReportRequest.java | 118 - .../lib/messages/StateReportResponse.java | 95 - .../renderer/opflex/mit/AgentOvsMit.java | 3696 ----------------- .../renderer/opflex/mit/EnumInfo.java | 113 - .../renderer/opflex/mit/MitLib.java | 475 --- .../renderer/opflex/mit/OpflexMit.java | 37 - .../renderer/opflex/mit/PolicyClassInfo.java | 199 - .../opflex/mit/PolicyObjectInstance.java | 791 ---- .../opflex/mit/PolicyPropertyInfo.java | 241 -- .../renderer/opflex/mit/PolicyUri.java | 237 -- .../src/main/yang/opflex-provider-impl.yang | 58 - .../opflex/src/main/yang/opflex-provider.yang | 29 - renderers/opflex/src/main/yang/opflex.yang | 187 - .../renderer/opflex/EndpointManagerTest.java | 417 -- .../renderer/opflex/EprContextTest.java | 139 - .../renderer/opflex/IdentityTest.java | 68 - .../renderer/opflex/L2EprOperationTest.java | 206 - .../renderer/opflex/L3EprOperationTest.java | 213 - .../renderer/opflex/MessageUtilsTest.java | 291 -- .../renderer/opflex/PolicyManagerTest.java | 222 - .../opflex/jsonrpc/JsonRpcDecoderTest.java | 103 - .../opflex/jsonrpc/JsonRpcEndpointTest.java | 297 -- .../JsonRpcServiceBinderHandlerTest.java | 69 - .../opflex/jsonrpc/RpcServerTest.java | 61 - .../lib/OpflexConnectionServiceTest.java | 294 -- .../opflex/lib/OpflexRpcServerTest.java | 95 - .../renderer/opflex/lib/RoleTest.java | 104 - .../lib/messages/OpflexMessageTest.java | 1048 ----- .../renderer/opflex/mit/EnumInfoTest.java | 51 - .../renderer/opflex/mit/MitLibTest.java | 439 -- .../opflex/mit/PolicyClassInfoTest.java | 66 - .../opflex/mit/PolicyPropertyInfoTest.java | 60 - .../renderer/opflex/mit/PolicyUriTest.java | 143 - .../renderer/opflex/jsonrpc/pretty-test.json | 18 - .../renderer/opflex/jsonrpc/test.json | 1 - renderers/pom.xml | 1 - 93 files changed, 1 insertion(+), 20056 deletions(-) delete mode 100644 groupbasedpolicy-opflex-config/pom.xml delete mode 100644 groupbasedpolicy-opflex-config/src/main/resources/initial/15-groupbasedpolicy-opflex.xml delete mode 100644 renderers/opflex/pom.xml delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/controller/config/yang/config/opflex_provider/impl/OpflexProviderModule.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/controller/config/yang/config/opflex_provider/impl/OpflexProviderModuleFactory.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointListener.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointManager.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprContext.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprOperation.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/Identity.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L2EprOperation.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L3EprOperation.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/MessageUtils.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/OpflexRenderer.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/PolicyManager.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/ConnectionService.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/ExceptionHandler.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/InvalidEncodingException.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpc10Response.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcDecoder.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEncoder.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEndpoint.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcServiceBinderHandler.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcBroker.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcMessage.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcMessageMap.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcServer.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexAgent.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexConnectionService.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexRpcServer.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/Role.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointDeclareRequest.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointDeclareResponse.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointIdentity.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointResolveRequest.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointResolveResponse.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUndeclareRequest.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUndeclareResponse.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUnresolveRequest.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUnresolveResponse.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUpdateRequest.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUpdateResponse.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/IdentityRequest.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/IdentityResponse.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/ManagedObject.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/OpflexError.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyIdentity.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyResolveRequest.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyResolveResponse.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUnresolveRequest.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUnresolveResponse.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUpdateRequest.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUpdateResponse.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/StateReportRequest.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/StateReportResponse.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/AgentOvsMit.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/EnumInfo.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/MitLib.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/OpflexMit.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyClassInfo.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyObjectInstance.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyPropertyInfo.java delete mode 100644 renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyUri.java delete mode 100644 renderers/opflex/src/main/yang/opflex-provider-impl.yang delete mode 100644 renderers/opflex/src/main/yang/opflex-provider.yang delete mode 100644 renderers/opflex/src/main/yang/opflex.yang delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointManagerTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprContextTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/IdentityTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L2EprOperationTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L3EprOperationTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/MessageUtilsTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/PolicyManagerTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcDecoderTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEndpointTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcServiceBinderHandlerTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcServerTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexConnectionServiceTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexRpcServerTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/RoleTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/OpflexMessageTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/EnumInfoTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/MitLibTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyClassInfoTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyPropertyInfoTest.java delete mode 100644 renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyUriTest.java delete mode 100644 renderers/opflex/src/test/resources/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/pretty-test.json delete mode 100644 renderers/opflex/src/test/resources/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/test.json diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 1ce131fc6..717edba64 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -13,11 +13,6 @@ groupbasedpolicy ${project.version} - - ${project.groupId} - opflex-renderer - ${project.version} - ${project.groupId} ofoverlay-renderer @@ -57,13 +52,6 @@ xml config - - ${project.groupId} - groupbasedpolicy-opflex-config - ${project.version} - xml - config - ${project.groupId} neutron-mapper-config @@ -96,4 +84,4 @@ - \ No newline at end of file + diff --git a/features/pom.xml b/features/pom.xml index a4e2fe5a0..ef10f9a35 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -198,10 +198,6 @@ org.opendaylight.groupbasedpolicy groupbasedpolicy - - org.opendaylight.groupbasedpolicy - opflex-renderer - org.opendaylight.groupbasedpolicy ofoverlay-renderer @@ -230,12 +226,6 @@ xml config - - org.opendaylight.groupbasedpolicy - groupbasedpolicy-opflex-config - xml - config - org.opendaylight.groupbasedpolicy neutron-mapper-config diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index 56514ce27..364f771bd 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -61,21 +61,6 @@ mvn:org.opendaylight.groupbasedpolicy/groupbasedpolicy-ofoverlay-config/{{VERSION}}/xml/config - - - odl-groupbasedpolicy-base - mvn:com.fasterxml.jackson.core/jackson-annotations/{{VERSION}} - mvn:com.fasterxml.jackson.core/jackson-core/{{VERSION}} - mvn:com.fasterxml.jackson.core/jackson-databind/{{VERSION}} - mvn:org.opendaylight.groupbasedpolicy/opflex-renderer/{{VERSION}} - mvn:org.opendaylight.groupbasedpolicy/groupbasedpolicy-opflex-config/{{VERSION}}/xml/config - - diff --git a/groupbasedpolicy-opflex-config/pom.xml b/groupbasedpolicy-opflex-config/pom.xml deleted file mode 100644 index af8c8ca93..000000000 --- a/groupbasedpolicy-opflex-config/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.groupbasedpolicy - commons.groupbasedpolicy - 0.3.0-SNAPSHOT - ../commons/parent - - - groupbasedpolicy-opflex-config - Controller Configuration files for groupbasedpolicy - jar - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/initial/15-groupbasedpolicy-opflex.xml - xml - config - - - - - - - - - diff --git a/groupbasedpolicy-opflex-config/src/main/resources/initial/15-groupbasedpolicy-opflex.xml b/groupbasedpolicy-opflex-config/src/main/resources/initial/15-groupbasedpolicy-opflex.xml deleted file mode 100644 index 6a6ebce3e..000000000 --- a/groupbasedpolicy-opflex-config/src/main/resources/initial/15-groupbasedpolicy-opflex.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - opflex:opflex-provider-impl - - opflex-provider-impl - - - binding:binding-rpc-registry - binding-rpc-broker - - - - binding:binding-async-data-broker - binding-data-broker - - - - - - - - - urn:opendaylight:params:xml:ns:yang:controller:config:opflex-provider:impl?module=opflex-provider-impl&revision=2014-06-11 - - - - diff --git a/pom.xml b/pom.xml index 16c64090d..1e40da8ab 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,6 @@ groupbasedpolicy renderers groupbasedpolicy-ofoverlay-config - groupbasedpolicy-opflex-config neutron-mapper neutron-mapper-config neutron-ovsdb diff --git a/renderers/opflex/pom.xml b/renderers/opflex/pom.xml deleted file mode 100644 index 0565bfa41..000000000 --- a/renderers/opflex/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.groupbasedpolicy - groupbasedpolicy-renderers - 0.3.0-SNAPSHOT - ../ - - - opflex-renderer - bundle - - - - - org.opendaylight.mdsal.model - yang-ext - - - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - io.netty - netty-all - ${netty.version} - - - - - junit - junit - test - - - org.mockito - mockito-all - test - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - - org.apache.http.*;version="4.3.2", - *;resolution:=optional - - httpclient,httpcore,commons-lang,commons-exec;type=!pom;inline=false - - org.opendaylight.groupbasedpolicy.renderers.opflex.jsonrpc, - - - ${project.basedir}/META-INF - - - - org.opendaylight.yangtools - yang-maven-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - - - diff --git a/renderers/opflex/src/main/java/org/opendaylight/controller/config/yang/config/opflex_provider/impl/OpflexProviderModule.java b/renderers/opflex/src/main/java/org/opendaylight/controller/config/yang/config/opflex_provider/impl/OpflexProviderModule.java deleted file mode 100644 index b7bd43892..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/controller/config/yang/config/opflex_provider/impl/OpflexProviderModule.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.opendaylight.controller.config.yang.config.opflex_provider.impl; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.OpflexRenderer; - -public class OpflexProviderModule extends org.opendaylight.controller.config.yang.config.opflex_provider.impl.AbstractOpflexProviderModule { - public OpflexProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public OpflexProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.opflex_provider.impl.OpflexProviderModule oldModule, java.lang.AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - public void customValidation() { - // add custom validation form module attributes here. - } - - @Override - public java.lang.AutoCloseable createInstance() { - // TODO: getRpcRegistryDependency() - return new OpflexRenderer(getDataBrokerDependency(), null); - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/controller/config/yang/config/opflex_provider/impl/OpflexProviderModuleFactory.java b/renderers/opflex/src/main/java/org/opendaylight/controller/config/yang/config/opflex_provider/impl/OpflexProviderModuleFactory.java deleted file mode 100644 index 621b5e9b1..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/controller/config/yang/config/opflex_provider/impl/OpflexProviderModuleFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -/* -* Generated file -* -* Generated from: yang module name: opflex-provider-impl yang module local name: opflex-provider-impl -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Wed Jul 16 08:30:30 UTC 2014 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.config.opflex_provider.impl; -public class OpflexProviderModuleFactory extends org.opendaylight.controller.config.yang.config.opflex_provider.impl.AbstractOpflexProviderModuleFactory { - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointListener.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointListener.java deleted file mode 100644 index cd0f5a909..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointListener.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import org.opendaylight.groupbasedpolicy.endpoint.EpKey; -import org.opendaylight.groupbasedpolicy.resolver.EgKey; - -/** - * A listener to events related to endpoints being added, removed or updated. - * - * @author tbachman - */ -public interface EndpointListener { - - /** - * An endpoint for an endpoint group have been added, removed, - * or updated. - * - * @param egKey the key for the affected endpoint group - * @param epKey the key for the affected endpoint - */ - public void groupEndpointUpdated(EgKey egKey, EpKey epKey); -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointManager.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointManager.java deleted file mode 100644 index 2e85e81f6..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointManager.java +++ /dev/null @@ -1,726 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Queue; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ScheduledExecutorService; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.groupbasedpolicy.endpoint.EndpointRpcRegistry; -import org.opendaylight.groupbasedpolicy.endpoint.EpKey; -import org.opendaylight.groupbasedpolicy.endpoint.EpRendererAugmentation; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcEndpoint; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcBroker; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessageMap; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexAgent; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexConnectionService; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.Role; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointIdentity; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUndeclareRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUndeclareResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUnresolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUnresolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUpdateRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.ManagedObject; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.MitLib; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyUri; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterL3PrefixEndpointInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3PrefixBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexOverlayContext; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexOverlayContextBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexOverlayContextInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexOverlayContextL3; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexOverlayContextL3Builder; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Keep track of endpoints on the system. Maintain an index of endpoints and - * their locations for queries from agents. The endpoint manager will maintain - * appropriate indexes only for agents that are attached to the current - * controller node. In order to render the policy, we need to be able to - * efficiently enumerate all endpoints on a particular agent and also all the - * agents containing each particular endpoint group - * - */ -public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBroker.RpcCallback, - EprContext.EprCtxCallback { - - protected static final Logger LOG = LoggerFactory.getLogger(EndpointManager.class); - - private static final InstanceIdentifier endpointsIid = InstanceIdentifier.builder(Endpoints.class) - .child(Endpoint.class) - .build(); - private static final InstanceIdentifier endpointsL3Iid = InstanceIdentifier.builder(Endpoints.class) - .child(EndpointL3.class) - .build(); - - final ListenerRegistration listenerReg; - final ListenerRegistration listenerL3Reg; - - private final OpflexConnectionService connectionService; - private final MitLib mitLibrary; - - final Map endpoints = new ConcurrentHashMap<>(); - - private final ConcurrentHashMap> epSubscriptions = new ConcurrentHashMap<>(); - private RpcMessageMap messageMap = null; - - final private OfEndpointAug endpointRpcAug = new OfEndpointAug(); - - final private ScheduledExecutorService executor; - - final private DataBroker dataProvider; - - public EndpointManager(DataBroker dataProvider, RpcProviderRegistry rpcRegistry, ScheduledExecutorService executor, - OpflexConnectionService connectionService, MitLib opflexLibrary) { - this.executor = executor; - this.dataProvider = dataProvider; - EndpointRpcRegistry.register(dataProvider, rpcRegistry, endpointRpcAug); - - if (dataProvider != null) { - listenerReg = dataProvider.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, endpointsIid, this, - DataChangeScope.ONE); - listenerL3Reg = dataProvider.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, endpointsL3Iid, - this, DataChangeScope.ONE); - } else { - listenerReg = null; - listenerL3Reg = null; - } - - this.connectionService = connectionService; - this.mitLibrary = opflexLibrary; - - /* Subscribe to EPR messages */ - messageMap = new RpcMessageMap(); - List messages = Role.ENDPOINT_REGISTRY.getMessages(); - messageMap.addList(messages); - for (RpcMessage msg : messages) { - this.connectionService.subscribe(msg, this); - } - LOG.trace("Initialized OpFlex endpoint manager"); - } - - /** - * Shut down the {@link EndpointManager} - */ - public void shutdown() { - - } - - // *************** - // EndpointManager - // *************** - - /** - * Get the endpoint object for the given key - * - * @param epKey - * the key - * @return the {@link Endpoint} corresponding to the key - */ - public Endpoint getEndpoint(EpKey epKey) { - return endpoints.get(epKey); - } - - // ************************ - // Endpoint Augmentation - // ************************ - private class OfEndpointAug implements EpRendererAugmentation { - - @Override - public Augmentation buildEndpointAugmentation(RegisterEndpointInput input) { - OpflexOverlayContextInput ictx = input.getAugmentation(OpflexOverlayContextInput.class); - if (ictx != null) - return new OpflexOverlayContextBuilder(ictx).build(); - return null; - } - - @Override - public Augmentation buildEndpointL3Augmentation(RegisterEndpointInput input) { - OpflexOverlayContextInput ictx = input.getAugmentation(OpflexOverlayContextInput.class); - if (ictx != null) - return new OpflexOverlayContextL3Builder(ictx).build(); - return null; - } - - @Override - public void buildL3PrefixEndpointAugmentation(EndpointL3PrefixBuilder eb, RegisterL3PrefixEndpointInput input) { - // TODO These methods will be replaced by getAugmentation and - // augmentation applied at caller. - - } - } - - // ************* - // AutoCloseable - // ************* - - @Override - public void close() throws Exception { - if (listenerReg != null) - listenerReg.close(); - EndpointRpcRegistry.unregister(endpointRpcAug); - } - - // ****************** - // DataChangeListener - // ****************** - - @Override - public void onDataChanged(AsyncDataChangeEvent, DataObject> change) { - for (DataObject dao : change.getCreatedData().values()) { - if (dao instanceof Endpoint) - updateEndpoint(null, dao); - } - for (InstanceIdentifier iid : change.getRemovedPaths()) { - DataObject old = change.getOriginalData().get(iid); - if (old != null && old instanceof Endpoint) - updateEndpoint(old, null); - } - Map, DataObject> d = change.getUpdatedData(); - for (Entry, DataObject> entry : d.entrySet()) { - if ((!(entry.getValue() instanceof Endpoint)) && (!(entry.getValue() instanceof EndpointL3))) - continue; - DataObject old = change.getOriginalData().get(entry.getKey()); - DataObject oldEp = null; - if (entry instanceof Endpoint || entry instanceof EndpointL3) { - if (old != null && old instanceof Endpoint) - oldEp = old; - updateEndpoint(oldEp, entry.getValue()); - } - } - } - - // ************** - // Implementation - // ************** - - private Identity getIdentity(DataObject obj) { - Identity id = null; - if (obj instanceof Endpoint) { - Endpoint ep = (Endpoint) obj; - id = new Identity(ep); - id.setContext(ep.getL2Context().getValue()); - } - - if (obj instanceof EndpointL3) { - EndpointL3 ep = (EndpointL3) obj; - id = new Identity(ep); - id.setContext(ep.getL3Context().getValue()); - } - if (id != null && !id.valid()) { - return null; - } - return id; - } - - private synchronized Set getEpSubscriptions(String id) { - return epSubscriptions.get(id); - } - - /** - * Provide endpoint policy update messages based on changes - */ - protected void updateEndpoint(DataObject oldEp, DataObject newEp) { - Identity oldId = getIdentity(oldEp); - Identity newId = getIdentity(newEp); - /* - * If an endpoint has changed, we need to provide notifications to - * agents that have subscribed to that endpoint. Batch up the - * notifications to be sent to the agents. - */ - Queue updateQ = new ConcurrentLinkedQueue(); - - /* This covers additions or updates */ - if (newId != null) { - Set agentList = getEpSubscriptions(newId.identityAsString()); - if (agentList != null) { - for (String agentId : agentList) { - OpflexAgent agent = connectionService.getOpflexAgent(agentId); - if (agent != null) { - updateQ.add(new EndpointUpdate(EndpointUpdate.UpdateType.ADD_CHANGE, agent.getEndpoint(), newEp)); - } - } - } - } - /* this covers deletions */ - if ((newId == null) && (oldId != null)) { - Set agentList = getEpSubscriptions(oldId.identityAsString()); - if (agentList != null) { - for (String agentId : agentList) { - OpflexAgent agent = connectionService.getOpflexAgent(agentId); - if (agent != null) { - updateQ.add(new EndpointUpdate(EndpointUpdate.UpdateType.DELETE, agent.getEndpoint(), oldEp)); - } - } - } - } - - sendEpUpdates(updateQ); - } - - private static class EndpointUpdate implements Runnable { - - public static enum UpdateType { - ADD_CHANGE("add_change"), DELETE("delete"); - - private final String updateType; - - UpdateType(String updateType) { - this.updateType = updateType; - } - - @Override - public String toString() { - return this.updateType; - } - } - - private final UpdateType type; - private final JsonRpcEndpoint agent; - private final ManagedObject mo; - - EndpointUpdate(UpdateType type, JsonRpcEndpoint agent, DataObject obj) { - this.type = type; - this.agent = agent; - mo = MessageUtils.getMoFromEp(obj); - } - - @Override - public void run() { - EndpointUpdateRequest request = new EndpointUpdateRequest(); - EndpointUpdateRequest.Params params = new EndpointUpdateRequest.Params(); - List paramList = new ArrayList(); - - // TODO: how do we get delete URIs from the - // normalized policy? - List delete_uri = new ArrayList(); - List replace = new ArrayList(); - if (mo != null) { - replace.add(mo); - delete_uri.add(mo.getUri()); - } - if (type == EndpointUpdate.UpdateType.ADD_CHANGE) { - params.setReplace(replace); - } else if (type == EndpointUpdate.UpdateType.DELETE) { - params.setDelete_uri(delete_uri); - } - - paramList.add(params); - request.setParams(paramList); - try { - agent.sendRequest(request); - } catch (Exception e) { - - } - - } - - } - - private void sendEpUpdates(Queue updateQ) { - while (!updateQ.isEmpty()) { - executor.execute(updateQ.remove()); - } - } - - /** - * Create an Endpoint Registry Context for an OpFlex Request message. - * - * @param agent - * @param message - * @param dataProvider - * @param executor - * @return - */ - public EprContext create(JsonRpcEndpoint agent, RpcMessage message, DataBroker dataProvider, - ScheduledExecutorService executor) { - - EprContext ec = null; - - if (message instanceof EndpointDeclareRequest) { - EndpointDeclareRequest request = (EndpointDeclareRequest) message; - /* - * There theoretically could be a list of parameters, but we'll - * likely only ever see one element. - */ - ec = new EprContext(agent, request, dataProvider, executor); - for (EndpointDeclareRequest.Params params : request.getParams()) { - - int prr = params.getPrr(); - - /* - * We have a list of endpoints, so iterate through the list and - * register each one, extracting the identities for - * registration. - */ - List endpoints = params.getEndpoint(); - if (endpoints != null) { - for (ManagedObject mo : endpoints) { - EprOperation eo = MessageUtils.getEprOpFromEpMo(mo, prr, agent.getIdentifier()); - ec.addOperation(eo); - } - } - } - } else if (message instanceof EndpointUndeclareRequest) { - EndpointUndeclareRequest request = (EndpointUndeclareRequest) message; - ec = new EprContext(agent, request, dataProvider, executor); - for (EndpointUndeclareRequest.Params params : request.getParams()) { - - /* - * A single URI is provided per param in Undeclare messages - */ - String subject = params.getSubject(); - Uri uri = params.getEndpoint_uri(); - if (uri != null) { - EprOperation op = MessageUtils.getEprOpFromUri(uri, subject); - ec.addOperation(op); - } - } - } else if (message instanceof EndpointResolveRequest) { - EndpointResolveRequest request = (EndpointResolveRequest) message; - ec = new EprContext(agent, request, dataProvider, executor); - for (EndpointResolveRequest.Params params : request.getParams()) { - /* - * The resolve message contains either the URI or a context/URI - * and an identifier. There is only one of these per param array - * entry. - */ - EndpointIdentity eid = params.getEndpoint_ident(); - - String subject = params.getSubject(); - - if (eid != null) { - - EprOperation op = MessageUtils.getEprOpFromEpId(eid, subject); - ec.addOperation(op); - - } else { - /* - * Extract the list to add the EP to from the URI - */ - Uri uri = params.getEndpoint_uri(); - if (uri != null) { - EprOperation op = MessageUtils.getEprOpFromUri(uri, subject); - ec.addOperation(op); - } - } - } - } - return ec; - } - - private synchronized void addEpSubscription(JsonRpcEndpoint agent, String id) { - Set agents = epSubscriptions.get(id); - if (agents == null) { - agents = Collections.newSetFromMap(new ConcurrentHashMap()); - Set result = epSubscriptions.putIfAbsent(id, agents); - if (result != null) { - agents = result; - } - } - agents.add(agent.getIdentifier()); - } - - private synchronized void removeEpSubscription(JsonRpcEndpoint agent, String id) { - Set agents = epSubscriptions.get(id); - if (agents != null) { - agents.remove(id); - } - } - - /** - * This notification handles the OpFlex Endpoint messages. We should only - * receive request messages. Responses are sent in a different context, as - * all requests result in a Future to access the data store. - * - * @param agent - * The JsonRpcEndpoint that received the request - * @param request - * The request message from the endpoint - */ - @Override - public void callback(JsonRpcEndpoint agent, RpcMessage request) { - - if (messageMap.get(request.getMethod()) == null) { - LOG.warn("message {} was not subscribed to, but was delivered.", request); - return; - } - - /* - * For declaration requests, we need to make sure that this EP is in our - * registry. Since we can have multiple identifiers, we create a Set of - * endpoints. - */ - - if (request instanceof EndpointDeclareRequest) { - EndpointDeclareRequest req = (EndpointDeclareRequest) request; - - /* - * valid() ensures presence of params and MOs, so we know those - * won't be null - */ - if (!req.valid()) { - LOG.warn("Invalid declaration request: {}", req); - // TODO: should return error reply? - return; - } - - /* - * OpFlex EP declaration/registration is different from REST EP - * declaration/registration -- REST only allows a single EP to be - * registered at a time. Since each MO represents an Endpoint that's - * being declared, we need add each one up separately,yet provide a - * single response. We also want to know the result of the - * registration so we can provide the appropriate response. We - * create a context for the Endpoint Registry interaction, where we - * can track the status of all the EP registrations, and provide a - * response when all have completed. - */ - EprContext ctx = create(agent, req, dataProvider, executor); - ctx.setCallback(this); - ctx.createEp(); - } else if (request instanceof EndpointUndeclareRequest) { - EndpointUndeclareRequest req = (EndpointUndeclareRequest) request; - - /* - * valid() ensures presence of params and URIs, so we know those - * won't be null - */ - if (!req.valid()) { - LOG.warn("Invalid declaration request: {}", req); - // TODO: should return error reply? - return; - } - - /* - * OpFlex EP undeclaration/unregistration is different from REST EP - * declaration/registration -- REST only allows a single EP to be - * unregistered at a time. Since each MO represents an Endpoint - * that's being undeclared, we need add each one up separately,yet - * provide a single response. We also want to know the result of the - * unregistration so we can provide the appropriate response. We - * create a context for the Endpoint Registry interaction, where we - * can track the status of all the EP unregistrations, and provide a - * response when all have completed. - */ - EprContext ctx = create(agent, req, dataProvider, executor); - ctx.setCallback(this); - ctx.deleteEp(); - } else if (request instanceof EndpointResolveRequest) { - EndpointResolveRequest req = (EndpointResolveRequest) request; - - if (!req.valid()) { - LOG.warn("Invalid endpoint request: {}", req); - // TODO: should return error reply? - return; - } - List paramList = req.getParams(); - - for (EndpointResolveRequest.Params param : paramList) { - EprContext ctx = create(agent, req, dataProvider, executor); - - /* - * We query the EPR for the EP. This is an asynchronous - * operation, so we send the response in the callback - */ - ctx.setCallback(this); - ctx.lookupEndpoint(); - - /* - * A request is effectively a subscription. Add this agent to - * the set of listeners. - */ - Identity id; - if (param.getEndpoint_ident() != null) { - id = new Identity(param.getEndpoint_ident().getIdentifier()); - } else if (param.getEndpoint_uri() != null) { - PolicyUri puri = new PolicyUri(param.getEndpoint_uri().getValue()); - id = new Identity(puri.pop()); - } else { - // TOOD: should return error reply - return; - } - addEpSubscription(agent, id.identityAsString()); - } - } else if (request instanceof EndpointUnresolveRequest) { - EndpointUnresolveRequest req = (EndpointUnresolveRequest) request; - - if (!req.valid()) { - LOG.warn("Invalid endpoint request: {}", req); - // TODO: should return error reply? - return; - } - - List params = ((EndpointUnresolveRequest) request).getParams(); - - for (EndpointUnresolveRequest.Params param : params) { - /* - * No interaction with the Data Store is required -- just cancel - * the notification subscription for this EP.. - */ - Identity id = null; - if (param.getEndpoint_ident() != null) { - id = new Identity(param.getEndpoint_ident().getIdentifier()); - } else if (param.getEndpoint_uri() != null) { - PolicyUri puri = new PolicyUri(param.getEndpoint_uri().getValue()); - id = new Identity(puri.pop()); - } else { - // TOODO: should return an error - return; - } - removeEpSubscription(agent, id.identityAsString()); - } - - /* - * No EprContext is used in unresolve -- so just send the response - * directly - */ - EndpointUnresolveResponse resp = new EndpointUnresolveResponse(); - EndpointUnresolveResponse.Result result = new EndpointUnresolveResponse.Result(); - resp.setResult(result); - resp.setId(req.getId()); - try { - agent.sendResponse(resp); - } catch (Exception e) { - LOG.warn("Response {} could not be sent to {}", resp, agent); - } - - } else { - LOG.warn("Unexpected callback, {}", request); - } - - } - - private class EndpointResponse implements Runnable { - - private final EprContext ctx; - private final RpcMessage resp; - - public EndpointResponse(EprContext ctx, RpcMessage resp) { - this.ctx = ctx; - this.resp = resp; - } - - @Override - public void run() { - try { - ctx.getPeer().sendResponse(resp); - } catch (Exception e) { - // TODO: what to do here - } - - } - - } - - /** - * This notification handles the callback from an interaction with the - * Endpoint Registry. The context for the callback is a notification from - * the data store, so so the code has to ensure that it won't block. - * Responses are sent using an executor - */ - @Override - public void callback(EprContext ctx) { - RpcMessage resp = null; - if (ctx.getRequest() == null) - return; - - if (!(ctx.getRequest() instanceof EndpointDeclareRequest) - && !(ctx.getRequest() instanceof EndpointUndeclareRequest) - && !(ctx.getRequest() instanceof EndpointResolveRequest)) { - return; - } - - if (ctx.getRequest() instanceof EndpointDeclareRequest) { - EndpointDeclareRequest req = (EndpointDeclareRequest) ctx.getRequest(); - EndpointDeclareResponse response = new EndpointDeclareResponse(); - EndpointDeclareResponse.Result result = new EndpointDeclareResponse.Result(); - response.setResult(result); - response.setId(req.getId()); - response.setError(null); // TODO: real errors - resp = response; - } else if (ctx.getRequest() instanceof EndpointUndeclareRequest) { - EndpointUndeclareRequest req = (EndpointUndeclareRequest) ctx.getRequest(); - EndpointUndeclareResponse response = new EndpointUndeclareResponse(); - EndpointUndeclareResponse.Result result = new EndpointUndeclareResponse.Result(); - response.setResult(result); - response.setId(req.getId()); - response.setError(null); // TODO: real errors - resp = response; - } else { - EndpointResolveRequest req = (EndpointResolveRequest) ctx.getRequest(); - EndpointResolveResponse response = new EndpointResolveResponse(); - response.setId(req.getId()); - EndpointResolveResponse.Result result = new EndpointResolveResponse.Result(); - List epList = new ArrayList(); - - if (ctx.getOperations().size() > 0) { - - /* - * If we get any EP, then we can provide a response to the - * original request Note that we could potentially have multiple - * requests outstanding for the same EP, and even using - * different context types (L2 or L3). - */ - for (EprOperation op : ctx.getOperations()) { - - ManagedObject mo = MessageUtils.getMoFromOp(op); - if (mo != null) { - epList.add(mo); - } - /* - * For EPs on a different agent, we need to look up the VTEP - * information. For now, we're only supporting VXLAN VTEPs, - * so we look up the destination tunnel IP, and provide that - * in the data field of the response - */ - // TODO: Need to look this up in op store - // endpoint.setData(); - } - result.setEndpoint(epList); - response.setResult(result); - resp = response; - } - } - if (resp != null) { - executor.execute(new EndpointResponse(ctx, resp)); - } - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprContext.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprContext.java deleted file mode 100644 index 1f061070c..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprContext.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.atomic.AtomicReference; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcEndpoint; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.google.common.util.concurrent.CheckedFuture; - -/** - * A context for managing a related set of operations to the Endpoint Registry's - * lists of Endpoints. It also keeps state from messaging that initiated the - * Endpoint Registry interaction, so that notifications from the registry can be - * used to send responses - * - * @author tbachman - */ -public class EprContext implements Runnable, EprOperation.EprOpCallback { - - private EprCtxCallback cb; - private final DataBroker dataProvider; - private final ScheduledExecutorService executor; - private final JsonRpcEndpoint peer; - private final RpcMessage request; - private final List operations = new ArrayList<>(); - private AtomicReference completedOperations; - private CheckedFuture f; - - public EprContext(JsonRpcEndpoint peer, RpcMessage request, DataBroker dataProvider, - ScheduledExecutorService executor) { - this.dataProvider = dataProvider; - this.executor = executor; - this.peer = peer; - this.request = request; - } - - /** - * Add an operation to this context. This is not thread-safe. - * - * @param operation - */ - public void addOperation(EprOperation operation) { - if (operation != null) { - operations.add(operation); - } - } - - public List getOperations() { - return this.operations; - } - - public JsonRpcEndpoint getPeer() { - return this.peer; - } - - /** - * Provides a callback that is invoked in response to a transaction with the - * EPR. - * - * @author tbachman - */ - public static interface EprCtxCallback { - - public void callback(EprContext ctx); - } - - public void setCallback(EprCtxCallback callback) { - this.cb = callback; - } - - public RpcMessage getRequest() { - return this.request; - } - - /** - * Create an Endpoint in the Endopint Registry. This can only be called in - * response to an {@link org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareRequest} message - */ - public void createEp() { - - WriteTransaction wt = dataProvider.newWriteOnlyTransaction(); - - /* - * Add each of the create/update operations to a single transaction - */ - for (EprOperation eo : operations) { - eo.put(wt); - } - f = wt.submit(); - f.addListener(this, executor); - - } - - /** - * Delete an Endpoint in the Endpoint Registry. This can only be called in - * response to an {@link org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUndeclareRequest} message - */ - public void deleteEp() { - - WriteTransaction wt = dataProvider.newWriteOnlyTransaction(); - - /* - * Add each of the delete operations to a single transaction - */ - for (EprOperation eo : operations) { - eo.delete(wt); - } - f = wt.submit(); - f.addListener(this, executor); - } - - /** - * Look up an endpoint in the Endpoint Registry. This can only be called in - * response to an {@link org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveRequest} message. It initiates all - * of the reads, one by one, and invokes the callback when all of them have - * completed. - */ - public void lookupEndpoint() { - - /* - * Each read operation requires it's own transaction. We add a callback - * for each operation, so we can determine when all of the read - * operations have completed. - */ - this.completedOperations = new AtomicReference(Integer.valueOf(0)); - for (EprOperation eo : operations) { - ReadOnlyTransaction rot = dataProvider.newReadOnlyTransaction(); - - eo.setCallback(this); - eo.read(rot, executor); - } - } - - /** - * This implements the callback for the create and delete operations, from - * the CheckedFuture. - */ - @Override - public void run() { - try { - f.get(); - } catch (Exception e) { - // TODO: Don't use Exception - } - cb.callback(this); - } - - /** - * This implements the callback for the lookup operation. - */ - @Override - public void callback(EprOperation op) { - /* - * Add this to the list of operations that have completed, and if - * finished, invoke our callback - */ - completedOperations.set(completedOperations.get().intValue() + 1); - if (completedOperations.get() >= operations.size()) { - cb.callback(this); - // TODO: way to ensure it doesn't get invoked multiple times - } - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprOperation.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprOperation.java deleted file mode 100644 index c1c0f7726..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprOperation.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import java.util.concurrent.ScheduledExecutorService; - -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; - -/** - * Interface for managing operations with the Endpoint Registry. - * An operation is the smallest granularity of interaction with - * the Endpoint Registry. Put (create/update), Delete, and Read - * operations are supported. - * - * @author thbachma - */ -public interface EprOperation { - - /** - * Callback interface used to provide notifications - * to other objects. - * - * @author thbachma - */ - public interface EprOpCallback { - - public void callback(EprOperation op); - } - - /** - * Perform a PUT operation, which can be either a - * creation or update of an element of the Endpoint - * Registry - * - * @param wt - */ - public void put(WriteTransaction wt); - - /** - * Perform a DELETE operation for the requested Endpoint. - * - * @param wt - */ - public void delete(WriteTransaction wt); - - /** - * Return the data associated with the requested Endpoint. - * - * @param rot - * @param executor - */ - public void read(ReadOnlyTransaction rot, ScheduledExecutorService executor); - - /** - * Set the callback notification - * - * @param callback - */ - public void setCallback(EprOpCallback callback); -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/Identity.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/Identity.java deleted file mode 100644 index d980f6ff3..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/Identity.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Pattern; - -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2BridgeDomainId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3AddressBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3; - -import com.google.common.net.InetAddresses; - -/** - * An Identity for OpFlex. Identities can take on many - * forms, so it's possible that this class may be replaced - * by an abstract class with different concrete types. - * At the moment, we're only dealing with IP and MAC - * addresses. - * This class also provides methods for getting the identity - * in forms by the yang model, and are therefore usable by - * other classes in the policy model (e.g. the objects - * needed by the Endpoint Registry). - */ -public class Identity { - - enum IdentityType { - UNKNOWN, IP_ADDRESS, MAC_ADDRESS - } - - private IdentityType type = IdentityType.UNKNOWN; - private L3ContextId l3Context = null; - private IpAddress primaryIp = null; - private Set ips = null; - private L2BridgeDomainId l2Context = null; - private MacAddress mac = null; - - public Identity(String id) { - /* - * Determine the ID type and populate - */ - if (idIsIp(id)) { - type = IdentityType.IP_ADDRESS; - ips = Collections.newSetFromMap(new ConcurrentHashMap()); - if (primaryIp == null) - primaryIp = normalizeIpAddress(id); - ips.add(normalizeIpAddress(id)); - } else if (idIsMac(id)) { - type = IdentityType.MAC_ADDRESS; - mac = normalizeMacAddress(id); - } - - } - - public Identity(Endpoint ep) { - type = IdentityType.MAC_ADDRESS; - mac = ep.getMacAddress(); - l2Context = ep.getL2Context(); - } - - public Identity(EndpointL3 ep) { - type = IdentityType.IP_ADDRESS; - ips = Collections.newSetFromMap(new ConcurrentHashMap()); - primaryIp = ep.getIpAddress(); - List l3List = ep.getL3Address(); - for (L3Address addr : l3List) { - ips.add(addr.getIpAddress()); - } - } - - public void setContext(String context) { - switch (type) { - case MAC_ADDRESS: - l2Context = new L2BridgeDomainId(context); - break; - case IP_ADDRESS: - l3Context = new L3ContextId(context); - break; - default: - break; - } - } - - /** - * Adds a new identifier to the list. Some types of - * identities allow for list of identifiers (e.g. L3). - * - * @param id The new identifier to add to the list - */ - public void addId(String id) { - switch (type) { - case IP_ADDRESS: - ips.add(normalizeIpAddress(id)); - break; - default: - break; - } - } - - private boolean idIsIp(String id) { - return InetAddresses.isInetAddress(id); - } - - /* - * Verifies MAC addresses with the following formats: - * 0xAA:0xBB:0xCC:0xDD:0xEE:0xFF - * AA:BB:CC:DD:EE:FF - * 0xAA:BB:CC:DD:EE:FF - * 0xAA-0xBB-0xCC-0xDD-0xEE-0xFF - */ - private boolean idIsMac(String id) { - /* - * First check/remove separators - */ - String[] sixFields = id.split(":"); - if (sixFields.length != 6) { - sixFields = id.split("-"); - if (sixFields.length != 6) { - return false; - } - } - - for (String field : sixFields) { - /* Strip '0x' if present */ - field = field.replace("0x", ""); - if (field.length() > 2 || field.length() < 1) { - return false; - } - if (!Pattern.matches("[0-9a-fA-F]{1,2}", field)) { - return false; - } - } - return true; - } - - /** - * Check if this {@link Identity} is an L3 type (Ip Address) - * - * @return true if L3, false if not - */ - public boolean isL3() { - return (type == IdentityType.IP_ADDRESS); - } - - /** - * Check if this {@link Identity} is an L2 type (MAC Address) - * - * @return true if L2, false if not - */ - public boolean isL2() { - return (type == IdentityType.MAC_ADDRESS); - } - - public boolean valid() { - switch (type) { - case MAC_ADDRESS: - if (getL2Context() != null && mac != null) { - return true; - } - break; - case IP_ADDRESS: - if (getL3Context() != null && primaryIp != null) { - return true; - } - default: - break; - - } - return false; - } - - /** - * Return the context, regardless of type, as a string. - * - * @return String representing the context for this Identity - */ - public String contextAsString() { - switch (type) { - case MAC_ADDRESS: - return l2Context.getValue(); - case IP_ADDRESS: - return l3Context.getValue(); - default: - return null; - } - } - - /** - * Returns the identity as a string. The format - * of the string depends on the identity type. - * When the identity is a actually a list, only - * the first identity is returned. - * - * @return null if type is UKNOWN, otherwise String - */ - public String identityAsString() { - switch (type) { - case MAC_ADDRESS: - return mac.getValue(); - case IP_ADDRESS: - List ipl = new ArrayList(ips); - IpAddress i = ipl.get(0); - if (i.getIpv4Address() != null) { - return i.getIpv4Address().getValue(); - } else if (i.getIpv6Address() != null) { - return i.getIpv6Address().getValue(); - } - default: - } - return null; - } - - /** - * Get the L2 context in an Endpoint Registry - * compatible format - * - * @return The Layer 2 context - */ - public L2BridgeDomainId getL2Context() { - return l2Context; - } - - /** - * Get the L2 identity in an Endpoint Registry - * compatible format - * - * @return The Layer 2 identity - */ - public MacAddress getL2Identity() { - return mac; - } - - /** - * Get the L3 context in an Endpoint Registry - * compatible format - * - * @return The Layer 3 context - */ - public L3ContextId getL3Context() { - return l3Context; - } - - /** - * Get the L3 identity in an Endpoint Registry - * compatible format - * - * @return The Layer 3 identity - */ - public IpAddress getL3Identity() { - return primaryIp; - } - - public List getL3Addresses() { - - List l3List = new ArrayList(); - List ipList = new ArrayList(); - ipList.addAll(ips); - for (IpAddress i : ipList) { - L3AddressBuilder l3ab = new L3AddressBuilder(); - l3ab.setIpAddress(i); - l3ab.setL3Context(l3Context); - l3List.add(l3ab.build()); - } - - return l3List; - } - - private IpAddress normalizeIpAddress(String identifier) { - return IpAddressBuilder.getDefaultInstance(identifier); - } - - private MacAddress normalizeMacAddress(String identifier) { - MacAddress m = new MacAddress(identifier); - return m; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((ips == null) ? 0 : ips.hashCode()); - result = prime * result + ((l2Context == null) ? 0 : l2Context.hashCode()); - result = prime * result + ((l3Context == null) ? 0 : l3Context.hashCode()); - result = prime * result + ((mac == null) ? 0 : mac.hashCode()); - result = prime * result + ((primaryIp == null) ? 0 : primaryIp.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Identity other = (Identity) obj; - if (ips == null) { - if (other.ips != null) - return false; - } else if (!ips.equals(other.ips)) - return false; - if (l2Context == null) { - if (other.l2Context != null) - return false; - } else if (!l2Context.equals(other.l2Context)) - return false; - if (l3Context == null) { - if (other.l3Context != null) - return false; - } else if (!l3Context.equals(other.l3Context)) - return false; - if (mac == null) { - if (other.mac != null) - return false; - } else if (!mac.equals(other.mac)) - return false; - if (primaryIp == null) { - if (other.primaryIp != null) - return false; - } else if (!primaryIp.equals(other.primaryIp)) - return false; - if (type != other.type) - return false; - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L2EprOperation.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L2EprOperation.java deleted file mode 100644 index 8111105d4..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L2EprOperation.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ScheduledExecutorService; - -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2BridgeDomainId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexOverlayContext; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexOverlayContextBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * A context for mapping OpFlex messaging to asynchronous - * requests to the Endpoint Registry's list of L2 Endpoints. - * - * @author tbachman - */ -public class L2EprOperation implements EprOperation, FutureCallback> { - - private EprOpCallback cb; - private Endpoint ep; - private InstanceIdentifier iid; - - private String agentId; - private TenantId tid; - private EndpointGroupId egid; - private L2BridgeDomainId l2bdid; - private MacAddress mac; - private List l3al; - private Long timeout; - - public L2EprOperation(int prr) { - this.timeout = Long.valueOf(prr); - this.l3al = new ArrayList(); - } - - public L2EprOperation() {} - - public void setAgentId(String agentId) { - this.agentId = agentId; - } - - public void setTenantId(TenantId tid) { - this.tid = tid; - } - - public void setEndpointGroupId(EndpointGroupId egid) { - this.egid = egid; - } - - public void setContextId(L2BridgeDomainId l2bdid) { - this.l2bdid = l2bdid; - } - - public void setMacAddress(MacAddress mac) { - this.mac = mac; - } - - public void setL3AddressList(List l3al) { - this.l3al = l3al; - } - - public void addL3Address(L3Address l3a) { - this.l3al.add(l3a); - } - - public Endpoint getEp() { - return ep; - } - - public void setEp(Endpoint ep) { - this.ep = ep; - } - - public Endpoint buildEp() { - EndpointBuilder epBuilder = new EndpointBuilder(); - OpflexOverlayContextBuilder oocb = new OpflexOverlayContextBuilder(); - oocb.setAgentId(this.agentId); - - epBuilder.setTenant(this.tid) - .setEndpointGroup(this.egid) - .setL2Context(this.l2bdid) - .setL3Address(l3al) - .setMacAddress(this.mac) - .setTimestamp(this.timeout) - .addAugmentation(OpflexOverlayContext.class, oocb.build()); - - // TODO: add support for conditions - // epBuilder.setCondition(new List()); - - return epBuilder.build(); - } - - /** - * Create or update an L2 Endpoint in the Endpoint Registry - * - * @param wt The Write Transaction - */ - @Override - public void put(WriteTransaction wt) { - - ep = buildEp(); - this.iid = InstanceIdentifier.builder(Endpoints.class).child(Endpoint.class, ep.getKey()).build(); - wt.put(LogicalDatastoreType.OPERATIONAL, iid, ep); - } - - @Override - public void delete(WriteTransaction wt) { - - ep = buildEp(); - this.iid = InstanceIdentifier.builder(Endpoints.class).child(Endpoint.class, ep.getKey()).build(); - wt.delete(LogicalDatastoreType.OPERATIONAL, iid); - } - - /** - * Get/read an L2 endpoint in the registry, given a context - * and an identifier. - * . - * - * @param rot The read transaction - */ - @Override - public void read(ReadOnlyTransaction rot, ScheduledExecutorService executor) { - - ep = buildEp(); - this.iid = InstanceIdentifier.builder(Endpoints.class).child(Endpoint.class, ep.getKey()).build(); - - ListenableFuture> dao = rot.read(LogicalDatastoreType.OPERATIONAL, iid); - Futures.addCallback(dao, this, executor); - } - - @Override - public void setCallback(EprOpCallback callback) { - this.cb = callback; - } - - @Override - public void onSuccess(final Optional result) { - if (!result.isPresent()) { - /* - * This EP doesn't exist in the registry. If - * all of the data store queries have been made, - * and we still don't have any EPs, then provide - * an error result. - */ - this.ep = null; - cb.callback(this); - return; - } - setEp(result.get()); - cb.callback(this); - } - - @Override - public void onFailure(Throwable t) { - cb.callback(this); - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L3EprOperation.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L3EprOperation.java deleted file mode 100644 index 0ef683e53..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L3EprOperation.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import java.util.List; -import java.util.concurrent.ScheduledExecutorService; - -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2BridgeDomainId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexOverlayContextL3; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexOverlayContextL3Builder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * A context for mapping OpFlex messaging to asynchronous - * requests to the Endpoint Registry's list of L3 Endpoints. - * - * @author tbachman - */ -public class L3EprOperation implements EprOperation, FutureCallback> { - - private EprOpCallback cb; - private EndpointL3 ep; - private InstanceIdentifier iid; - - private String agentId; - private TenantId tid; - private EndpointGroupId egid; - private MacAddress mac; - private List l3al; - private L2BridgeDomainId l2bdid; - private L3ContextId l3cid; - private IpAddress ip; - private Long timeout; - - public L3EprOperation(int prr) { - this.timeout = Long.valueOf(prr); - } - - public L3EprOperation() {} - - public void setAgentId(String agentId) { - this.agentId = agentId; - } - - public void setTenantId(TenantId tid) { - this.tid = tid; - } - - public void setEndpointGroupId(EndpointGroupId egid) { - this.egid = egid; - } - - public void setContextId(L3ContextId l3cid) { - this.l3cid = l3cid; - } - - public void setL2BridgDomainId(L2BridgeDomainId l2bdid) { - this.l2bdid = l2bdid; - } - - public void setMacAddress(MacAddress mac) { - this.mac = mac; - } - - public void setIpAddress(IpAddress ip) { - this.ip = ip; - } - - public void setL3AddressList(List l3al) { - this.l3al = l3al; - } - - public void addL3Address(L3Address l3a) { - this.l3al.add(l3a); - } - - public EndpointL3 getEp() { - return ep; - } - - public void setEp(EndpointL3 ep) { - this.ep = ep; - } - - public EndpointL3 buildEp() { - EndpointL3Builder epBuilder = new EndpointL3Builder(); - OpflexOverlayContextL3Builder oocb = new OpflexOverlayContextL3Builder(); - oocb.setAgentId(this.agentId); - - epBuilder.setTenant(this.tid) - .setEndpointGroup(this.egid) - .setL2Context(this.l2bdid) - .setL3Context(this.l3cid) - .setL3Address(l3al) - .setMacAddress(this.mac) - .setIpAddress(this.ip) - .setTimestamp(this.timeout) - .addAugmentation(OpflexOverlayContextL3.class, oocb.build()); - - // TODO: add support for conditions - // epBuilder.setCondition(new List()); - - return epBuilder.build(); - } - - @Override - public void onSuccess(final Optional result) { - if (!result.isPresent()) { - /* - * This EP doesn't exist in the registry. If - * all of the data store queries have been made, - * and we still don't have any EPs, then provide - * an error result. - */ - this.ep = null; - cb.callback(this); - return; - } - setEp(result.get()); - cb.callback(this); - } - - @Override - public void onFailure(Throwable t) { - // TODO: implement another callback - } - - @Override - public void put(WriteTransaction wt) { - ep = buildEp(); - this.iid = InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class, ep.getKey()).build(); - wt.put(LogicalDatastoreType.OPERATIONAL, iid, ep); - } - - @Override - public void delete(WriteTransaction wt) { - ep = buildEp(); - this.iid = InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class, ep.getKey()).build(); - wt.delete(LogicalDatastoreType.OPERATIONAL, iid); - } - - @Override - public void read(ReadOnlyTransaction rot, ScheduledExecutorService executor) { - ep = buildEp(); - this.iid = InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class, ep.getKey()).build(); - - ListenableFuture> dao = rot.read(LogicalDatastoreType.OPERATIONAL, iid); - Futures.addCallback(dao, this, executor); - - } - - @Override - public void setCallback(EprOpCallback callback) { - this.cb = callback; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/MessageUtils.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/MessageUtils.java deleted file mode 100644 index 67e666913..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/MessageUtils.java +++ /dev/null @@ -1,2320 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : tbachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointIdentity; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.ManagedObject; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.ManagedObject.Property; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.AgentOvsMit; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.MitLib; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyClassInfo; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyObjectInstance; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyObjectInstance.PolicyReference; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyUri; -import org.opendaylight.groupbasedpolicy.resolver.IndexedTenant; -import org.opendaylight.groupbasedpolicy.resolver.RuleGroup; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContractId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2BridgeDomainId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.NetworkDomainId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SubjectName; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3AddressBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.HasDirection.Direction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.has.classifier.refs.ClassifierRef; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.Tenant; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.Contract; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.EndpointGroup; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L2BridgeDomain; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L2FloodDomain; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.L3Context; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.Subnet; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.contract.Subject; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.contract.subject.Rule; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.endpoint.group.ConsumerNamedSelector; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.endpoint.group.ProviderNamedSelector; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.subject.feature.instances.ClassifierInstance; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.collect.Sets; - -public class MessageUtils { - - private static final Logger LOG = LoggerFactory.getLogger(MessageUtils.class); - /* - * Endpoint Groups in ODL's Group Based Policy are specified in the - * following format: - * - * /tenants/tenant//endpoint-group/ - */ - public static final String POLICY_ROOT = ""; - public static final String TENANTS_RN = "tenants"; - public static final String TENANT_RN = "tenant"; - public static final String CONTRACT_RN = "contract"; - public static final String SUBJECT_RN = "subject"; - public static final String RULE_RN = "rule"; - public static final String CLAUSE_RN = "clause"; - public static final String EPG_RN = "endpoint-group"; - public static final String ENDPOINTS_RN = "endpoints"; - public static final String ENDPOINT_RN = "endpoint"; - public static final String ENDPOINT_L3_RN = "endpoint-l3"; - public static final String L2_FLOOD_DOMAIN_RN = "l2-flood-domain"; - public static final String L2_BRIDGE_DOMAIN_RN = "l2-bridge-domain"; - public static final String SUBNET_RN = "subnet"; - public static final String L3_CONTEXT_RN = "l3-context"; - public static final String CLASSIFIER_INSTANCE_RN = "classifier-instance"; - public static final String CLASSIFIER_REF_RN = "classifier-ref"; - - public static final String GENIE_EPR_L2_ROOT = "EprL2Universe"; - public static final String GENIE_EPR_L3_ROOT = "EprL3Universe"; - public static final String GENIE_ENDPOINT_RN = "EprL2Ep"; - public static final String GENIE_ENDPOINT_L3_RN = "EprL3Ep"; - - public static final String GENIE_TENANTS_RN = "PolicyUniverse"; - public static final String GENIE_POLICY_ROOT = PolicyUri.POLICY_URI_SEP + GENIE_TENANTS_RN; - public static final String GENIE_TENANT_RN = "PolicySpace"; - public static final String GENIE_CONTRACT_RN = "GbpContract"; - public static final String GENIE_SUBJECT_RN = "GbpSubject"; - public static final String GENIE_RULE_RN = "GbpRule"; - public static final String GENIE_EPG_RN = "GbpEpGroup"; - public static final String GENIE_CLASSIFIER_RN = "GbpeL24Classifier"; - public static final String GENIE_FLOOD_DOMAIN_RN = "GbpFloodDomain"; - public static final String GENIE_BRIDGE_DOMAIN_RN = "GbpBridgeDomain"; - public static final String GENIE_SUBNETS_RN = "GbpSubnets"; - public static final String GENIE_SUBNET_RN = "GbpSubnet"; - public static final String GENIE_ROUTING_DOMAIN_RN = "GbpRoutingDomain"; - public static final String GENIE_ENDPOINT_NET_RN = "EprL3Net"; - - public static final String GENIE_ENDPOINT_CONTEXT = "context"; - public static final String GENIE_ENDPOINT_EPG = "group"; - public static final String GENIE_ENDPOINT_MAC = "mac"; - public static final String GENIE_ENDPOINT_UUID = "uuid"; - public static final String GENIE_ENDPOINT_IP = "ip"; - - public static final String GENIE_SUBNET_NAME_DEFAULT = "default-subnet"; - public static final String GENIE_SUBNET_ADDRESS = "address"; - public static final String GENIE_SUBNET_NAME = "name"; - public static final String GENIE_SUBNET_PREFIX_LEN = "prefixLen"; - public static final String GENIE_SUBNET_VIRTUAL_ROUTER_IP = "virtualRouterIp"; - - public static final String GENIE_CLASSIFIER_REF_RN = "GbpRuleToClassifierRSrc"; - public static final String GENIE_CONSUMER_CONTRACT_REF_RN = "GbpEpGroupToConsContractRSrc"; - public static final String GENIE_PROVIDER_CONTRACT_REF_RN = "GbpEpGroupToProvContractRSrc"; - public static final String GENIE_SUBNETS_TO_NETWORK_RN = "GbpSubnetsToNetworkRSrc"; - public static final String GENIE_FLOOD_DOMAIN_TO_NETWORK_RN = "GbpFloodDomainToNetworkRSrc"; - public static final String GENIE_BRIDGE_DOMAIN_TO_NETWORK_RN = "GbpBridgeDomainToNetworkRSrc"; - public static final String GENIE_INTRA_EPG_RN = "intraGroupPolicy"; - public static final String GENIE_EPG_TO_NETWORK_DOMAIN_RN = "GbpEpGroupToNetworkRSrc"; - public static final String GENIE_SUBNET_TO_NETWORK_SRC_REF = "GbpSubnetsToNetworkRSrc"; - - public static final String TENANT_PREFIX = POLICY_ROOT + PolicyUri.POLICY_URI_SEP + TENANTS_RN - + PolicyUri.POLICY_URI_SEP + TENANT_RN + PolicyUri.POLICY_URI_SEP; - public static final String GENIE_TENANT_PREFIX = GENIE_POLICY_ROOT + PolicyUri.POLICY_URI_SEP + GENIE_TENANT_RN - + PolicyUri.POLICY_URI_SEP; - - public static final String GENIE_CONTRACT_NAME = "name"; - public static final String GENIE_SUBJECT_NAME = "name"; - public static final String GENIE_RULE_NAME = "name"; - public static final String GENIE_CLASSIFIER_NAME = "name"; - public static final String GENIE_ENDPOINT_GROUP_NAME = "name"; - public static final String GENIE_SUBNETS_NAME = "name"; - public static final String GENIE_FLOOD_DOMAIN_NAME = "name"; - public static final String GENIE_BRIDGE_DOMAIN_NAME = "name"; - public static final String GENIE_ROUTING_DOMAIN_NAME = "name"; - public static final String GENIE_CONSUMER_CONTRACT_TARGET = "target"; - public static final String GENIE_PROVIDER_CONTRACT_TARGET = "target"; - public static final String GENIE_CLASSIFIER_REF_TARGET = "target"; - public static final String GENIE_EPG_TO_NETWORK_DOMAIN_TARGET = "target"; - public static final String GENIE_SUBNETS_TO_NETWORK_DOMAIN_TARGET = "target"; - public static final String GENIE_FLOOD_DOMAIN_TO_NETWORK_DOMAIN_TARGET = "target"; - public static final String GENIE_BRIDGE_DOMAIN_TO_NETWORK_DOMAIN_TARGET = "target"; - - public static final String GENIE_RULE_ORDER = "order"; - - public static final String GENIE_CLASSIFIER_CONNECTION_TRACKING = "connectionTracking"; - public static final String GENIE_CLASSIFIER_DIRECTION = "direction"; - public static final String GENIE_CLASSIFIER_ARP_OPC = "arpOpc"; - public static final String GENIE_CLASSIFIER_DFROM_PORT = "dFromPort"; - public static final String GENIE_CLASSIFIER_DTO_PORT = "dToPort"; - public static final String GENIE_CLASSIFIER_ETHERT = "etherT"; - public static final String GENIE_CLASSIFIER_PROT = "prot"; - public static final String GENIE_CLASSIFIER_SFROM_PORT = "sFromPort"; - public static final String GENIE_CLASSIFIER_STO_PORT = "sToPort"; - - private static AgentOvsMit mit; - private static MitLib lib; - - private static ConcurrentMap odlKeys; - private static ConcurrentMap genieKeys; - - private static ConcurrentMap odlToGenieMap; - private static ConcurrentMap genieToOdlMap; - - public static void setMit(AgentOvsMit currentMit) { - mit = currentMit; - - } - - public static ConcurrentMap getOdlKeys() { - return odlKeys; - } - - public static ConcurrentMap getGenieKeys() { - return genieKeys; - } - - public static void init() { - - odlKeys = new ConcurrentHashMap(); - genieKeys = new ConcurrentHashMap(); - - odlKeys.put(ENDPOINT_RN, 2); - odlKeys.put(ENDPOINT_L3_RN, 2); - odlKeys.put(TENANT_RN, 1); - odlKeys.put(L3_CONTEXT_RN, 1); - odlKeys.put(L2_BRIDGE_DOMAIN_RN, 1); - odlKeys.put(L2_FLOOD_DOMAIN_RN, 1); - odlKeys.put(SUBNET_RN, 1); - odlKeys.put(EPG_RN, 1); - odlKeys.put(CLASSIFIER_INSTANCE_RN, 1); - odlKeys.put(CONTRACT_RN, 1); - odlKeys.put(SUBJECT_RN, 1); - odlKeys.put(RULE_RN, 1); - - genieKeys.put(GENIE_ENDPOINT_RN, 2); - genieKeys.put(GENIE_ENDPOINT_L3_RN, 2); - genieKeys.put(GENIE_TENANT_RN, 1); - genieKeys.put(GENIE_ROUTING_DOMAIN_RN, 1); - genieKeys.put(GENIE_BRIDGE_DOMAIN_RN, 1); - genieKeys.put(GENIE_FLOOD_DOMAIN_RN, 1); - genieKeys.put(GENIE_SUBNET_RN, 1); - genieKeys.put(GENIE_SUBNETS_RN, 1); - genieKeys.put(GENIE_EPG_RN, 1); - genieKeys.put(GENIE_CLASSIFIER_RN, 1); - genieKeys.put(GENIE_CONTRACT_RN, 1); - genieKeys.put(GENIE_SUBJECT_RN, 1); - genieKeys.put(GENIE_RULE_RN, 1); - - odlToGenieMap = new ConcurrentHashMap(); - odlToGenieMap.put(ENDPOINTS_RN, ""); - odlToGenieMap.put(ENDPOINT_RN, GENIE_EPR_L2_ROOT + PolicyUri.POLICY_URI_SEP + GENIE_ENDPOINT_RN); - odlToGenieMap.put(ENDPOINT_L3_RN, GENIE_EPR_L3_ROOT + PolicyUri.POLICY_URI_SEP + GENIE_ENDPOINT_L3_RN); - odlToGenieMap.put(TENANTS_RN, GENIE_TENANTS_RN); - odlToGenieMap.put(TENANT_RN, GENIE_TENANT_RN); - odlToGenieMap.put(EPG_RN, GENIE_EPG_RN); - odlToGenieMap.put(CONTRACT_RN, GENIE_CONTRACT_RN); - odlToGenieMap.put(SUBJECT_RN, GENIE_SUBJECT_RN); - odlToGenieMap.put(RULE_RN, GENIE_RULE_RN); - odlToGenieMap.put(CLAUSE_RN, ""); - odlToGenieMap.put(CLASSIFIER_REF_RN, GENIE_CLASSIFIER_RN); - odlToGenieMap.put(L2_FLOOD_DOMAIN_RN, GENIE_FLOOD_DOMAIN_RN); - odlToGenieMap.put(L2_BRIDGE_DOMAIN_RN, GENIE_BRIDGE_DOMAIN_RN); - odlToGenieMap.put(SUBNET_RN, GENIE_SUBNETS_RN + PolicyUri.POLICY_URI_SEP + GENIE_SUBNET_NAME_DEFAULT - + PolicyUri.POLICY_URI_SEP + GENIE_SUBNET_RN); - odlToGenieMap.put(L3_CONTEXT_RN, GENIE_ROUTING_DOMAIN_RN); - - genieToOdlMap = new ConcurrentHashMap(); - genieToOdlMap.put(GENIE_ENDPOINT_RN, ENDPOINT_RN); - genieToOdlMap.put(GENIE_ENDPOINT_L3_RN, ENDPOINT_L3_RN); - genieToOdlMap.put(GENIE_TENANTS_RN, TENANTS_RN); - genieToOdlMap.put(GENIE_TENANT_RN, TENANT_RN); - genieToOdlMap.put(GENIE_EPG_RN, EPG_RN); - genieToOdlMap.put(GENIE_CONTRACT_RN, CONTRACT_RN); - genieToOdlMap.put(GENIE_SUBJECT_RN, SUBJECT_RN); - genieToOdlMap.put(GENIE_RULE_RN, RULE_RN); - genieToOdlMap.put(GENIE_CLASSIFIER_RN, CLASSIFIER_REF_RN); - genieToOdlMap.put(GENIE_FLOOD_DOMAIN_RN, L2_FLOOD_DOMAIN_RN); - genieToOdlMap.put(GENIE_BRIDGE_DOMAIN_RN, L2_BRIDGE_DOMAIN_RN); - genieToOdlMap.put(GENIE_SUBNETS_RN, ""); - genieToOdlMap.put(GENIE_SUBNET_RN, SUBNET_RN); - genieToOdlMap.put(GENIE_ROUTING_DOMAIN_RN, L3_CONTEXT_RN); - genieToOdlMap.put(GENIE_EPR_L2_ROOT, ENDPOINTS_RN); - genieToOdlMap.put(GENIE_EPR_L3_ROOT, ENDPOINTS_RN); - - } - - private static BigInteger intToBigInt(int i) { - return new BigInteger(Integer.toString(i)); - } - - public static void setOpflexLib(MitLib opflexLib) { - lib = opflexLib; - } - - public static PolicyUri parseUri(String uri) { - PolicyUri u = new PolicyUri(uri); - if (u.valid()) - return u; - return null; - } - - /* - * Until I clean this up, this is going to accept the Genie URI. The format - * for these URIs is: - * - * /PolicyUniverse/PolicySpace/[name] - */ - public static String getTenantFromUri(String uri) { - PolicyUri genieUri = odlUriToGenieUri(new PolicyUri(uri)); - if (genieUri.totalElements() >= 3) - return genieUri.getElement(2); - return null; - } - - /* - * Until I clean this up, this is going to be the Genie URI. The format for - * these URIs is: - * - * /PolicyUniverse/PolicySpace/[name]/GbpEpGroup/[name] - * - * Where [name] is the tenant and ID for the EPG - */ - public static String getEndpointGroupFromUri(String uri) { - PolicyUri genieUri = odlUriToGenieUri(new PolicyUri(uri)); - PolicyUri pu = new PolicyUri(genieUri.toString()); - if (!pu.contains(GENIE_EPG_RN)) { - return null; - } - int epgIdx = pu.whichElement(GENIE_EPG_RN); - /* - * subtract 1 to compare between total elements and an array index; it's - * an EPG URI if it's the second to the last element - */ - if (epgIdx == pu.totalElements() - 1 - 1) { - return pu.getElement(epgIdx + 1); - } - return null; - } - - public static String getContextFromUri(String uri) { - PolicyUri genieUri = odlUriToGenieUri(new PolicyUri(uri)); - PolicyUri pu = new PolicyUri(genieUri.toString()); - - if (!pu.contains(GENIE_EPG_RN)) { - return null; - } - int epgIdx = pu.whichElement(GENIE_EPG_RN); - /* - * subtract 1 to compare between total elements and an array index; it's - * an EPG URI if it's the second to the last element - */ - if (epgIdx == pu.totalElements() - 1 - 1) { - return pu.getElement(epgIdx + 2); - } - return null; - } - - public static String createEpgUri(String tenantId, String epgId) { - return GENIE_TENANT_PREFIX + tenantId + PolicyUri.POLICY_URI_SEP + GENIE_EPG_RN + PolicyUri.POLICY_URI_SEP - + epgId; - } - - public static boolean hasEpg(String uri) { - return new PolicyUri(uri).contains(GENIE_EPG_RN); - } - - public static boolean isEpgUri(String uri) { - PolicyUri pu = new PolicyUri(uri); - if (!pu.contains(GENIE_EPG_RN)) { - return false; - } - int epgIdx = pu.whichElement(GENIE_EPG_RN); - /* - * subtract 1 to compare between total elements and an array index; it's - * an EPG URI if it's the second to the last element - */ - return (epgIdx == pu.totalElements() - 1 - 1); - } - - /** - * Check to see if the given URI is already in genie format - * - * @param uri - * @return - */ - public static boolean isGenieUri(Uri uri) { - PolicyUri puri = new PolicyUri(uri.toString()); - List genieRoot = Arrays.asList("PolicyUniverse", "EprL2Universe", "EprL3Universe"); - - if (genieRoot.contains(puri.getElement(0))) - return true; - - return false; - - } - - /** - * Check to see if the given URI is already in ODL format - * - * @param uri - * @return - */ - public static boolean isOdlUri(Uri uri) { - PolicyUri puri = new PolicyUri(uri.toString()); - List odlRoot = Arrays.asList("tenants", "endpoints"); - - if (odlRoot.contains(puri.getElement(0))) - return true; - - return false; - } - - /** - * Iterator for URIs. Provides iteration, along with identification of key - * values needed for URI translation. - * - * @author tbachman - */ - public static class UriIterator implements Iterator { - - private final PolicyUri uri; - private int index; - private int keyCount; - private final Map keyMap; - - public UriIterator(PolicyUri uri, ConcurrentMap keyMap) { - this.uri = uri; - this.index = 0; - this.keyCount = 0; - this.keyMap = keyMap; - } - - public boolean isKey() { - if (keyCount > 0) - return true; - return false; - } - - public String getElement() { - if (this.index >= this.uri.totalElements()) - return null; - return this.uri.getElement(index); - } - - @Override - public boolean hasNext() { - if (this.index < this.uri.totalElements()) - return true; - - return false; - } - - @Override - public String next() { - /* - * Check to see if the subsequent elements are keys, and if so, set - * the number of keys - */ - if (keyCount > 0) { - keyCount -= 1; - } - if (keyCount == 0 && keyMap.containsKey(this.getElement())) { - keyCount = keyMap.get(this.getElement()); - } - - this.index += 1; - - if (this.index >= this.uri.totalElements()) - return null; - - return this.uri.getElement(index); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - } - - /** - * Convert ODL URI to a Genie URI. The ODL names are unique, so we are able - * to provide a conversion based solely on name. - * This only maps URIs from the following roots: - * /endpoint /policy - * - * @param odlUri - * @return - */ - public static PolicyUri odlUriToGenieUri(PolicyUri odlUri) { - - PolicyUri genieUri = new PolicyUri(); - - /* - * If it's already a genie URI, do nothing - */ - if (isGenieUri(new Uri(odlUri.toString()))) { - return odlUri; - } - - UriIterator it = new UriIterator(odlUri, odlKeys); - while (it.getElement() != null) { - - /* - * Get the converted element, then make the following checks: - * - * o element is key - push the element directly onto the stack - * without translation - * o no corresponding genie element - return -- - * we're done - * o genie element, but result is null - don't push - * anything on the stack; continue - * o regular element - convert the - * element and push it on the stack - */ - String element = it.getElement(); - String genieElement = odlToGenieMap.get(element); - - if (it.isKey()) { - genieUri.push(it.getElement()); - it.next(); - continue; - } else if (genieElement == null) - break; - else if (genieElement.equals("")) { - it.next(); - continue; - } - - genieUri.push(genieElement); - it.next(); - } - - return genieUri; - } - - public static PolicyUri genieUriToOdlUri(PolicyUri genieUri) { - - PolicyUri odlUri = new PolicyUri(); - - /* - * If it's already a genie URI, do nothing - */ - if (isOdlUri(new Uri(genieUri.toString()))) { - return genieUri; - } - - UriIterator it = new UriIterator(genieUri, genieKeys); - while (it.getElement() != null) { - - /* - * Get the converted element, then make the following checks: - * - * o element is key - push the element directly onto the stack - * without translation - * o no corresponding genie element - return -- - * we're done - * o genie element, but result is null - don't push - * anything on the stack; continue - * o regular element - convert the - * element and push it on the stack - */ - String element = it.getElement(); - String odlElement = genieToOdlMap.get(element); - - if (it.isKey()) { - odlUri.push(it.getElement()); - it.next(); - continue; - } else if (odlElement == null) - break; - else if (odlElement.equals("")) { - it.next(); - continue; - } - - odlUri.push(odlElement); - it.next(); - } - - return odlUri; - - } - - private static void setParentFields(PolicyUri current, PolicyObjectInstance poi, String parentRelation, - boolean hasId) { - PolicyUri uriCopy = new PolicyUri(current); - - // Pop off the subject name and class to get to parent - uriCopy.pop(); - uriCopy.pop(); - PolicyUri parent = new PolicyUri(uriCopy); - - // remove parent ID to get to parent subject - if (hasId) { - uriCopy.pop(); - } - String parentSubject = uriCopy.pop(); - poi.setParent(parent.getUri()); - poi.setParentSubject(parentSubject); - poi.setParentRelation(parentRelation); - } - - public static List getSubjectMo(PolicyUri current, Subject s, RuleGroup rg, IndexedTenant it) { - if (s == null) - return null; - - // Convert to Genie URI - PolicyUri convertedUri = odlUriToGenieUri(current); - - String prefix = convertedUri.toString(); - - ManagedObject mo = new ManagedObject(); - List mol = new ArrayList(); - List childrenUris = new ArrayList(); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_SUBJECT_RN); - if (pci == null) - return null; - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_SUBJECT_RN, true); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_SUBJECT_NAME) && s.getName() != null) { - poi.setString(ppi.getPropId(), s.getName().getValue()); - } else if (ppi.getPropName().equals(GENIE_RULE_RN) && s.getRule() != null) { - /* - * Each subject has a set of resolved rules. Add those as - * children. - */ - - for (Rule r : rg.getRules()) { - PolicyUri uri = new PolicyUri(prefix); - uri.push(GENIE_RULE_RN); - uri.push(r.getName().getValue()); - childrenUris.add(uri.getUri()); - poi.addChild(uri.getUri()); // TODO: remove? - mol.addAll(MessageUtils.getRuleMo(uri, r, rg, it)); - } - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setChildren(childrenUris); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_SUBJECT_RN); - mo.setUri(convertedUri.getUri()); - mol.add(mo); - - return mol; - } - - public static List getRuleMo(PolicyUri current, Rule r, RuleGroup rg, IndexedTenant it) { - if (r == null) - return null; - - // Convert to Genie URI - PolicyUri convertedUri = odlUriToGenieUri(current); - - String prefix = convertedUri.toString(); - - ManagedObject mo = new ManagedObject(); - List mol = new ArrayList(); - List childrenUris = new ArrayList(); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_RULE_RN); - if (pci == null) - return null; - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_RULE_RN, true); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_RULE_NAME) && r.getName() != null) { - poi.setString(ppi.getPropId(), r.getName().getValue()); - } else if (ppi.getPropName().equals(GENIE_RULE_ORDER) && r.getOrder() != null) { - poi.setUint64(ppi.getPropId(), intToBigInt(r.getOrder().intValue())); - } else if (ppi.getPropName().equals(GENIE_CLASSIFIER_REF_RN) && r.getClassifierRef() != null) { - for (ClassifierRef cr : r.getClassifierRef()) { - ClassifierInstance ci = it.getClassifier(cr.getName()); - if (ci != null) { - PolicyUri uri = new PolicyUri(prefix); - uri.push(GENIE_CLASSIFIER_REF_RN); - uri.push(cr.getName().getValue()); - mol.addAll(MessageUtils.getClassifierRefMo(uri, ci, cr, rg, it)); - childrenUris.add(uri.getUri()); - poi.addChild(uri.getUri()); // TODO: remove? - } - } - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setChildren(childrenUris); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_RULE_RN); - mo.setUri(convertedUri.getUri()); - - mol.add(mo); - - return mol; - } - - /** - * Convert a Contract to the equivalent Genie MO - * - * @param c - * @return - */ - public static List getContractAndSubMos(List cmol, PolicyUri current, Contract c, - RuleGroup rg, IndexedTenant it) { - if (c == null) - return null; - - ManagedObject mo = new ManagedObject(); - List mol = new ArrayList(); - List childrenUris = new ArrayList(); - - PolicyUri convertedUri = odlUriToGenieUri(current); - - String prefix = convertedUri.toString(); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_CONTRACT_RN); - if (pci == null) - return null; - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_CONTRACT_RN, true); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - if (c.getSubject() == null) - LOG.warn("subject is NULL"); - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_CONTRACT_NAME) && c.getId() != null) { - poi.setString(ppi.getPropId(), c.getId().getValue()); - } else if (ppi.getPropName().equals(GENIE_SUBJECT_RN) && c.getSubject() != null) { - - LOG.warn("related subject is {}", rg.getRelatedSubject()); - /* - * Get the subject in scope for this contract (NB: there could - * be more than one -- we get multiple subjects for a single - * contract in multiple RuleGroup objects). - */ - SubjectName sn = rg.getRelatedSubject(); - if (sn == null) - continue; - - /* Find the related subject object */ - for (Subject s : c.getSubject()) { - LOG.warn("subject is {}", s.getName()); - - if (s.getName().getValue().equals(sn.getValue())) { - - PolicyUri uri = new PolicyUri(prefix); - uri.push(GENIE_SUBJECT_RN); - uri.push(s.getName().getValue()); - - mol.addAll(MessageUtils.getSubjectMo(uri, s, rg, it)); - childrenUris.add(uri.getUri()); - poi.addChild(uri.getUri()); // TODO: needed? - break; - } - } - } - } - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setChildren(childrenUris); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_CONTRACT_RN); - mo.setUri(convertedUri.getUri()); - cmol.add(mo); - - return mol; - } - - public static ManagedObject getConsumerNamedSelectorMo(PolicyUri current, Contract c) { - if (c == null) - return null; - - ManagedObject mo = new ManagedObject(); - - PolicyUri convertedUri = odlUriToGenieUri(current); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_CONSUMER_CONTRACT_REF_RN); - if (pci == null) - return null; - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_CONSUMER_CONTRACT_REF_RN, true); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_CONSUMER_CONTRACT_TARGET)) { - PolicyUri uri = new PolicyUri(convertedUri); - // Go up to the EPG - uri.pop(); - uri.pop(); - uri.push(GENIE_CONSUMER_CONTRACT_REF_RN); - uri.push(c.getId().getValue()); - String newUri = odlUriToGenieUri(uri).toString(); - PolicyReference pr = new PolicyReference(pci.getClassId(), new Uri(newUri)); - poi.setReference(ppi.getPropId(), pr); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_CONSUMER_CONTRACT_REF_RN); - mo.setUri(convertedUri.getUri()); - - return mo; - } - - public static ManagedObject getProviderNamedSelectorMo(PolicyUri current, Contract c) { - if (c == null) - return null; - ManagedObject mo = new ManagedObject(); - - PolicyUri convertedUri = odlUriToGenieUri(current); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_PROVIDER_CONTRACT_REF_RN); - if (pci == null) - return null; - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_PROVIDER_CONTRACT_REF_RN, true); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_PROVIDER_CONTRACT_TARGET)) { - PolicyUri uri = new PolicyUri(convertedUri); - // Go up to the EPG - uri.pop(); - uri.pop(); - uri.push(GENIE_CONTRACT_RN); - uri.push(c.getId().getValue()); - String newUri = odlUriToGenieUri(uri).toString(); - PolicyReference pr = new PolicyReference(pci.getClassId(), new Uri(newUri)); - // TODO: should we chase the contracts? - poi.setReference(ppi.getPropId(), pr); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_PROVIDER_CONTRACT_REF_RN); - mo.setUri(convertedUri.getUri()); - - return mo; - - } - - private static List getParamList(HashMap> hm, String type) { - List pvl = hm.get(type); - if (pvl == null) { - pvl = new ArrayList<>(); - hm.put(type, pvl); - } - return pvl; - } - - private static final Integer TCP_PROTO = 6; - private static final Integer UDP_PROTO = 17; - - /** - * Build up a set of possible parameter values using the classifier - * instance. - * - * @param ci - * @param cr - * @return - */ - private static Map> buildParameterValues(ClassifierInstance ci, ClassifierRef cr) { - HashMap> pmap = new HashMap<>(); - List pvl = null; - - /* - * Create the map of classifier types/values - */ - for (ParameterValue pv : ci.getParameterValue()) { - /* - * The parameter-value name tells us the type of classifier - * involved: "type": EtherType/L2 "proto": IP/L3 - * "sourceport"/"destport": TCP/UDP/L4 - */ - if (pv.getName().getValue().equals("type")) { - if (pv.getIntValue() != null) { - switch (pv.getIntValue().intValue()) { - case 0x0806: - case 0x8906: - case 0x0800: - case 0x86DD: - case 0x88E5: - case 0x8847: - case 0x22F3: - - pvl = getParamList(pmap, GENIE_CLASSIFIER_ETHERT); - pvl.add(intToBigInt(pv.getIntValue().intValue())); - break; - - default: - break; - } - } else if (pv.getStringValue() != null) { - if (pv.getStringValue().equals("TCP")) { - pvl = getParamList(pmap, GENIE_CLASSIFIER_PROT); - pvl.add(intToBigInt(TCP_PROTO.intValue())); - } else if (pv.getStringValue().equals("UDP")) { - pvl = getParamList(pmap, GENIE_CLASSIFIER_PROT); - pvl.add(intToBigInt(UDP_PROTO.intValue())); - } - } - } - if (pv.getName().getValue().equals("proto")) { - pvl = getParamList(pmap, GENIE_CLASSIFIER_ARP_OPC); - pvl.add(intToBigInt(pv.getIntValue().intValue())); - - } - if (pv.getName().getValue().equals("sourceport")) { - if (cr.getDirection().equals(Direction.In)) { - pvl = getParamList(pmap, GENIE_CLASSIFIER_STO_PORT); - pvl.add(intToBigInt(pv.getIntValue().intValue())); - } else if (cr.getDirection().equals(Direction.Out)) { - pvl = getParamList(pmap, GENIE_CLASSIFIER_SFROM_PORT); - pvl.add(intToBigInt(pv.getIntValue().intValue())); - } else { - pvl = getParamList(pmap, GENIE_CLASSIFIER_STO_PORT); - pvl.add(intToBigInt(pv.getIntValue().intValue())); - pvl = getParamList(pmap, GENIE_CLASSIFIER_SFROM_PORT); - pvl.add(intToBigInt(pv.getIntValue().intValue())); - } - } - if (pv.getName().getValue().equals("destport")) { - if (cr.getDirection().equals(Direction.In)) { - pvl = getParamList(pmap, GENIE_CLASSIFIER_DTO_PORT); - pvl.add(intToBigInt(pv.getIntValue().intValue())); - } else if (cr.getDirection().equals(Direction.Out)) { - pvl = getParamList(pmap, GENIE_CLASSIFIER_DFROM_PORT); - pvl.add(intToBigInt(pv.getIntValue().intValue())); - } else { - pvl = getParamList(pmap, GENIE_CLASSIFIER_DTO_PORT); - pvl.add(intToBigInt(pv.getIntValue().intValue())); - pvl = getParamList(pmap, GENIE_CLASSIFIER_DFROM_PORT); - pvl.add(intToBigInt(pv.getIntValue().intValue())); - - } - } - } - - return pmap; - - } - - public static List getClassifierRefMo(PolicyUri current, ClassifierInstance ci, ClassifierRef cr, - RuleGroup rg, IndexedTenant it) { - - List mol = new ArrayList(); - ManagedObject mo = new ManagedObject(); - - PolicyUri convertedUri = odlUriToGenieUri(current); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_CLASSIFIER_REF_RN); - if (pci == null) - return null; - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_CLASSIFIER_REF_RN, false); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_CLASSIFIER_REF_TARGET)) { - - PolicyUri uri = new PolicyUri(GENIE_POLICY_ROOT); - uri.push(GENIE_TENANT_RN); - uri.push(rg.getContractTenant().getId().getValue()); - uri.push(GENIE_CLASSIFIER_RN); - uri.push(ci.getName().getValue()); - ManagedObject clMo = getClassifierInstanceMo(uri, ci, cr, rg, it); - if (clMo != null) { - mol.add(clMo); - } - - PolicyReference pr = new PolicyReference(pci.getClassId(), uri.getUri()); - poi.setReference(ppi.getPropId(), pr); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_CLASSIFIER_REF_RN); - mo.setUri(convertedUri.getUri()); - mol.add(mo); - - return mol; - } - - /** - * Create the Genie Classifier Instance MO. We need to use fields from both - * the ClassifierRef and the ClassifierInstance in the ODL model. - * - * @param current - * @param ci - * @param cr - * @param rg - * @param it - * @return - */ - public static ManagedObject getClassifierInstanceMo(PolicyUri current, ClassifierInstance ci, ClassifierRef cr, - RuleGroup rg, IndexedTenant it) { - if (ci == null) - return null; - - // Convert to Genie URI - PolicyUri convertedUri = odlUriToGenieUri(current); - - if (ci.getParameterValue() == null) - return null; - - Map> pmap = buildParameterValues(ci, cr); - - ManagedObject mo = new ManagedObject(); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_CLASSIFIER_RN); - if (pci == null) - return null; - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_CLASSIFIER_RN, true); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - String prefix = convertedUri.toString(); - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_CLASSIFIER_NAME) && cr.getName() != null) { - poi.setString(ppi.getPropId(), cr.getName().getValue()); - Uri child = new Uri(prefix + GENIE_CLASSIFIER_NAME + cr.getName().getValue()); - poi.setUri(child); - } else if (ppi.getPropName().equals(GENIE_CLASSIFIER_DIRECTION) && cr.getDirection() != null) { - // initialize with bogus values for placeholders, then replace - // with real ones - List odl2genie = new ArrayList(Arrays.asList(1, 2, 3)); - odl2genie.set(0, 1); - odl2genie.set(1, 2); - odl2genie.set(2, 0); - - /* - * The direction enums are different between the ODL and Genie - * models: - * - * Value: | ODL | Genie --------------+-----+-------- - * bidirectional | 2 | 0 in | 0 | 1 out | 1 | 2 - */ - Integer genieDirection = odl2genie.get(cr.getDirection().getIntValue()); - poi.setUint64(ppi.getPropId(), new BigInteger(genieDirection.toString())); - } else if (ppi.getPropName().equals(GENIE_CLASSIFIER_CONNECTION_TRACKING) - && cr.getConnectionTracking() != null) { - poi.setUint64(ppi.getPropId(), intToBigInt(cr.getConnectionTracking().getIntValue())); - } else if (ppi.getPropName().equals(GENIE_CLASSIFIER_ARP_OPC) && pmap.get(GENIE_CLASSIFIER_ARP_OPC) != null) { - poi.setUint64(ppi.getPropId(), pmap.get(GENIE_CLASSIFIER_ARP_OPC).get(0)); - } else if (ppi.getPropName().equals(GENIE_CLASSIFIER_ETHERT) && pmap.get(GENIE_CLASSIFIER_ETHERT) != null) { - poi.setUint64(ppi.getPropId(), pmap.get(GENIE_CLASSIFIER_ETHERT).get(0)); - } else if (ppi.getPropName().equals(GENIE_CLASSIFIER_DFROM_PORT) - && pmap.get(GENIE_CLASSIFIER_DFROM_PORT) != null) { - poi.setUint64(ppi.getPropId(), pmap.get(GENIE_CLASSIFIER_DFROM_PORT).get(0)); - } else if (ppi.getPropName().equals(GENIE_CLASSIFIER_DTO_PORT) - && pmap.get(GENIE_CLASSIFIER_DTO_PORT) != null) { - poi.setUint64(ppi.getPropId(), pmap.get(GENIE_CLASSIFIER_DTO_PORT).get(0)); - } else if (ppi.getPropName().equals(GENIE_CLASSIFIER_SFROM_PORT) - && pmap.get(GENIE_CLASSIFIER_SFROM_PORT) != null) { - poi.setUint64(ppi.getPropId(), pmap.get(GENIE_CLASSIFIER_SFROM_PORT).get(0)); - } else if (ppi.getPropName().equals(GENIE_CLASSIFIER_STO_PORT) - && pmap.get(GENIE_CLASSIFIER_STO_PORT) != null) { - poi.setUint64(ppi.getPropId(), pmap.get(GENIE_CLASSIFIER_STO_PORT).get(0)); - } else if (ppi.getPropName().equals(GENIE_CLASSIFIER_PROT) && pmap.get(GENIE_CLASSIFIER_PROT) != null) { - poi.setUint64(ppi.getPropId(), pmap.get(GENIE_CLASSIFIER_PROT).get(0)); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_CLASSIFIER_RN); - mo.setUri(convertedUri.getUri()); - - return mo; - } - - public static class Ipv4PlusSubnet { - - private String prefix; - private final String mask; - - public Ipv4PlusSubnet(String ipAndMask) { - String[] parts = ipAndMask.split("/"); - this.mask = parts[1]; - this.prefix = ""; - - int ip = 0; - int index = 0; - for (String s : parts[0].split("\\.")) { - ip |= (Integer.parseInt(s) & 0xff) << (24 - 8 * index); - index += 1; - } - - int msk = -1 << (32 - Integer.parseInt(parts[1])); - int sub = ip & msk; - for (int i = 0; i < 3; i++) { - this.prefix = this.prefix + String.valueOf((sub >> (24 - 8 * i)) & 0xff) + "."; - } - this.prefix = this.prefix + String.valueOf(sub & 0xff); - } - - public String getPrefixAsString() { - return this.prefix; - } - - public String getMaskAsString() { - return this.mask; - } - - public int getMaskAsInt() { - return Integer.parseInt(this.mask); - } - - public BigInteger getMaskAsBigInt() { - return new BigInteger(this.mask); - } - - } - - public static ManagedObject getSubnetMo(PolicyUri current, Subnet s, Tenant t) { - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_SUBNET_RN); - if (pci == null) - return null; - - // Convert to Genie URI - PolicyUri convertedUri = odlUriToGenieUri(current); - - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_SUBNET_RN, true); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - // convert this once - we'll use it below - Ipv4PlusSubnet ipv4 = new Ipv4PlusSubnet(s.getIpPrefix().getIpv4Prefix().getValue()); - - for (PolicyPropertyInfo ppi : ppil) { - - // use the subnet ID for the subnets (plural) ID - if (ppi.getPropName().equals(GENIE_SUBNET_NAME) && s.getId() != null) { - poi.setString(ppi.getPropId(), GENIE_SUBNET_NAME_DEFAULT); - } - if (ppi.getPropName().equals(GENIE_SUBNET_ADDRESS) && s.getIpPrefix() != null) { - /* - * We need to strip off the subnet delimiter - */ - poi.setString(ppi.getPropId(), ipv4.getPrefixAsString()); - } - if (ppi.getPropName().equals(GENIE_SUBNET_PREFIX_LEN) && s.getIpPrefix() != null) { - poi.setUint64(ppi.getPropId(), ipv4.getMaskAsBigInt()); - } - if (ppi.getPropName().equals(GENIE_SUBNET_VIRTUAL_ROUTER_IP) && s.getVirtualRouterIp() != null) { - poi.setString(ppi.getPropId(), s.getVirtualRouterIp().getIpv4Address().getValue()); - } - } - - ManagedObject mo = new ManagedObject(); - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_SUBNET_RN); - mo.setUri(convertedUri.getUri()); - - return mo; - } - - public static List getSubnetNetworkRefMo(PolicyUri current, NetworkDomainId ndid, Tenant t) { - if (ndid == null) - return null; - - List mol = new ArrayList(); - ManagedObject mo = new ManagedObject(); - - PolicyUri convertedUri = odlUriToGenieUri(current); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_SUBNETS_TO_NETWORK_RN); - if (pci == null) - return null; - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_SUBNETS_TO_NETWORK_RN, false); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_SUBNETS_TO_NETWORK_DOMAIN_TARGET)) { - - PolicyUri uri = new PolicyUri(convertedUri); - uri.pop(); - uri.pop(); - uri.push(GENIE_FLOOD_DOMAIN_RN); - uri.push(ndid.getValue()); - mol = getL2FloodDomainMo(uri, ndid, t); - if (mol == null) { - uri.pop(); - uri.pop(); - uri.push(GENIE_BRIDGE_DOMAIN_RN); - uri.push(ndid.getValue()); - mol = getL2BridgeDomainMo(uri, ndid, t); - } - if (mol == null) { - uri.pop(); - uri.pop(); - uri.push(GENIE_ROUTING_DOMAIN_RN); - uri.push(ndid.getValue()); - mol = new ArrayList(); - ManagedObject l3cmo = getL3ContextMo(uri, ndid, t); - if (l3cmo != null) { - mol.add(l3cmo); - } - } - /* - * We default to this being a routing domain reference if the - * actual reference can't be resolved. - */ - PolicyReference pr = new PolicyReference(pci.getClassId(), uri.getUri()); - poi.setReference(ppi.getPropId(), pr); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_SUBNETS_TO_NETWORK_RN); - mo.setUri(convertedUri.getUri()); - mol.add(mo); - - return mol; - } - - public static List getSubnetsMo(PolicyUri current, NetworkDomainId nid, Tenant t) { - if (nid == null) - return null; - List mol = new ArrayList(); - - Subnet subnetMatch = null; - List sl = t.getSubnet(); - if (sl != null) { - for (Subnet s : sl) { - if (s.getId().getValue().equals(nid.getValue())) { - subnetMatch = s; - break; - } - } - } - if (subnetMatch == null) - return null; - - ManagedObject mo = new ManagedObject(); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_SUBNETS_RN); - if (pci == null) - return null; - List childrenUris = new ArrayList(); - - // Convert to Genie URI - PolicyUri convertedUri = odlUriToGenieUri(current); - String prefix = convertedUri.toString(); - - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_SUBNETS_RN, true); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - // use the subnet ID for the subnets (plural) ID - if (ppi.getPropName().equals(GENIE_SUBNETS_NAME) && subnetMatch.getId() != null) { - poi.setString(ppi.getPropId(), subnetMatch.getId().getValue()); - } - if (ppi.getPropName().equals(GENIE_SUBNET_RN) && subnetMatch.getId() != null) { - PolicyUri child = new PolicyUri(prefix); - child.push(GENIE_SUBNET_RN); - child.push(GENIE_SUBNET_NAME_DEFAULT); - ManagedObject snetMo = getSubnetMo(child, subnetMatch, t); - if (snetMo != null) { - mol.add(snetMo); - } - childrenUris.add(child.getUri()); - } - if (ppi.getPropName().equals(GENIE_SUBNETS_TO_NETWORK_RN) && subnetMatch.getParent() != null) { - PolicyUri child = new PolicyUri(prefix); - child.push(GENIE_SUBNETS_TO_NETWORK_RN); - mol = getSubnetNetworkRefMo(child, subnetMatch.getParent(), t); - childrenUris.add(child.getUri()); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setChildren(childrenUris); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_SUBNETS_RN); - mo.setUri(convertedUri.getUri()); - - mol.add(mo); - - return mol; - } - - public static List getL2FloodDomainRefMo(PolicyUri current, NetworkDomainId ndid, Tenant t) { - if (ndid == null) - return null; - List mol = new ArrayList(); - ManagedObject mo = new ManagedObject(); - - PolicyUri convertedUri = odlUriToGenieUri(current); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_FLOOD_DOMAIN_TO_NETWORK_RN); - if (pci == null) - return null; - - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_FLOOD_DOMAIN_TO_NETWORK_RN, false); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_EPG_TO_NETWORK_DOMAIN_TARGET)) { - - /* - * We have to move back to the tenant, since all of the - * references are relative to the tenant - */ - PolicyUri uri = new PolicyUri(GENIE_POLICY_ROOT); - uri.push(GENIE_TENANT_RN); - uri.push(t.getId().getValue()); - uri.push(GENIE_BRIDGE_DOMAIN_RN); - uri.push(ndid.getValue()); - - /* - * Go chase the network domain references. Look for the - * reference in the bridge domain list. - */ - mol = getL2BridgeDomainMo(uri, ndid, t); - if (mol == null) { - uri.pop(); - uri.pop(); - uri.push(GENIE_ROUTING_DOMAIN_RN); - uri.push(ndid.getValue()); - mol = new ArrayList(); - ManagedObject l3cmo = getL3ContextMo(uri, ndid, t); - if (l3cmo != null) { - mol.add(l3cmo); - } - } - /* - * We default to this being a routing domain reference if the - * actual reference can't be resolved. - */ - PolicyReference pr = new PolicyReference(pci.getClassId(), uri.getUri()); - poi.setReference(ppi.getPropId(), pr); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_FLOOD_DOMAIN_TO_NETWORK_RN); - mo.setUri(convertedUri.getUri()); - mol.add(mo); - - return mol; - } - - public static List getL2FloodDomainMo(PolicyUri current, NetworkDomainId ndid, Tenant t) { - if (ndid == null) - return null; - - // Convert to Genie URI - PolicyUri convertedUri = odlUriToGenieUri(current); - String prefix = convertedUri.toString(); - L2FloodDomain l2fdMatch = null; - - List l2fdl = t.getL2FloodDomain(); - if (l2fdl != null) { - for (L2FloodDomain l2fd : l2fdl) { - if (l2fd.getId().getValue().equals(ndid.getValue())) { - l2fdMatch = l2fd; - break; - } - } - } - - if (l2fdMatch == null) - return null; - - List mol = new ArrayList(); - List childrenUris = new ArrayList(); - ManagedObject mo = new ManagedObject(); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_FLOOD_DOMAIN_RN); - if (pci == null) - return null; - - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_FLOOD_DOMAIN_RN, true); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_FLOOD_DOMAIN_NAME)) { - poi.setString(ppi.getPropId(), l2fdMatch.getId().getValue()); - } - if (ppi.getPropName().equals(GENIE_FLOOD_DOMAIN_TO_NETWORK_RN) && l2fdMatch.getParent() != null) { - /* - * Add as a child, not a property, and get the child - */ - PolicyUri child = new PolicyUri(prefix); - child.push(GENIE_FLOOD_DOMAIN_TO_NETWORK_RN); - mol.addAll(getL2FloodDomainRefMo(child, l2fdMatch.getParent(), t)); - childrenUris.add(child.getUri()); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setChildren(childrenUris); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_FLOOD_DOMAIN_RN); - mo.setUri(convertedUri.getUri()); - mol.add(mo); - - return mol; - } - - public static List getL2BridgeDomainRefMo(PolicyUri current, NetworkDomainId ndid, Tenant t) { - if (ndid == null) - return null; - - List mol = new ArrayList(); - ManagedObject mo = new ManagedObject(); - - PolicyUri convertedUri = odlUriToGenieUri(current); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_BRIDGE_DOMAIN_TO_NETWORK_RN); - if (pci == null) - return null; - - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_BRIDGE_DOMAIN_TO_NETWORK_RN, false); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_BRIDGE_DOMAIN_TO_NETWORK_DOMAIN_TARGET)) { - - /* - * We have to move back to the tenant, since all of the - * references are relative to the tenant - */ - PolicyUri uri = new PolicyUri(GENIE_POLICY_ROOT); - uri.push(GENIE_TENANT_RN); - uri.push(t.getId().getValue()); - uri.push(GENIE_ROUTING_DOMAIN_RN); - uri.push(ndid.getValue()); - mol = new ArrayList(); - ManagedObject l3cmo = getL3ContextMo(uri, ndid, t); - if (l3cmo != null) { - mol.add(l3cmo); - } - - /* - * We default to this being a routing domain reference if the - * actual reference can't be resolved. - */ - PolicyReference pr = new PolicyReference(pci.getClassId(), uri.getUri()); - poi.setReference(ppi.getPropId(), pr); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_BRIDGE_DOMAIN_TO_NETWORK_RN); - mo.setUri(convertedUri.getUri()); - - mol.add(mo); - - return mol; - } - - public static List getL2BridgeDomainMo(PolicyUri current, NetworkDomainId ndid, Tenant t) { - List l2bdl = t.getL2BridgeDomain(); - if (ndid == null || l2bdl == null) - return null; - - // Convert to Genie URI - PolicyUri convertedUri = odlUriToGenieUri(current); - String prefix = convertedUri.toString(); - - L2BridgeDomain l2bdMatch = null; - for (L2BridgeDomain l2bd : l2bdl) { - if (l2bd.getId().getValue().equals(ndid.getValue())) { - l2bdMatch = l2bd; - break; - } - } - - if (l2bdMatch == null) - return null; - - List mol = new ArrayList(); - List childrenUris = new ArrayList(); - ManagedObject mo = new ManagedObject(); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_BRIDGE_DOMAIN_RN); - if (pci == null) - return null; - - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_BRIDGE_DOMAIN_RN, true); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_BRIDGE_DOMAIN_NAME)) { - poi.setString(ppi.getPropId(), l2bdMatch.getId().getValue()); - } - if (ppi.getPropName().equals(GENIE_BRIDGE_DOMAIN_TO_NETWORK_RN) && l2bdMatch.getParent() != null) { - /* - * Add as a child, not a property, and get the child - */ - PolicyUri child = new PolicyUri(prefix); - child.push(GENIE_BRIDGE_DOMAIN_TO_NETWORK_RN); - mol.addAll(getL2BridgeDomainRefMo(child, l2bdMatch.getParent(), t)); - childrenUris.add(child.getUri()); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setChildren(childrenUris); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_BRIDGE_DOMAIN_RN); - mo.setUri(convertedUri.getUri()); - mol.add(mo); - - return mol; - } - - public static ManagedObject getL3ContextMo(PolicyUri current, NetworkDomainId ndid, Tenant t) { - List l3cl = t.getL3Context(); - if (ndid == null || l3cl == null) - return null; - - // Convert to Genie URI - PolicyUri convertedUri = odlUriToGenieUri(current); - - L3Context l3cMatch = null; - for (L3Context l3c : l3cl) { - if (l3c.getId().getValue().equals(ndid.getValue())) { - l3cMatch = l3c; - break; - } - } - - if (l3cMatch == null) - return null; - - ManagedObject mo = new ManagedObject(); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_ROUTING_DOMAIN_RN); - if (pci == null) - return null; - - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_ROUTING_DOMAIN_RN, true); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_ROUTING_DOMAIN_NAME)) { - poi.setString(ppi.getPropId(), l3cMatch.getId().getValue()); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_ROUTING_DOMAIN_RN); - mo.setUri(convertedUri.getUri()); - return mo; - } - - /** - * This is the equivalent of a network reference object in the Genie MIT. We - * chase the reference to get any other objects in a network hierarchy. - * - * @param current - * @param ndid - * @param t - * @return - */ - public static List getNetwokDomainRefMo(PolicyUri current, NetworkDomainId ndid, Tenant t) { - if (ndid == null) - return null; - List mol = new ArrayList(); - ManagedObject mo = new ManagedObject(); - - PolicyUri convertedUri = odlUriToGenieUri(current); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_EPG_TO_NETWORK_DOMAIN_RN); - if (pci == null) - return null; - - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_EPG_TO_NETWORK_DOMAIN_RN, false); - poi.setUri(convertedUri.getUri()); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_EPG_TO_NETWORK_DOMAIN_TARGET)) { - - /* - * We have to move back to the tenant, since all of the - * references are relative to the tenant - */ - PolicyUri uri = new PolicyUri(GENIE_POLICY_ROOT); - uri.push(GENIE_TENANT_RN); - uri.push(t.getId().getValue()); - uri.push(GENIE_SUBNETS_RN); - uri.push(ndid.getValue()); - - /* - * Go chase the network domain references. Look first for the - * reference in the subnets list. - */ - mol = getSubnetsMo(uri, ndid, t); - if (mol == null) { - uri.pop(); - uri.pop(); - uri.push(GENIE_FLOOD_DOMAIN_RN); - uri.push(ndid.getValue()); - mol = getL2FloodDomainMo(uri, ndid, t); - } - if (mol == null) { - uri.pop(); - uri.pop(); - uri.push(GENIE_BRIDGE_DOMAIN_RN); - uri.push(ndid.getValue()); - mol = getL2BridgeDomainMo(uri, ndid, t); - } - if (mol == null) { - uri.pop(); - uri.pop(); - uri.push(GENIE_ROUTING_DOMAIN_RN); - uri.push(ndid.getValue()); - mol = new ArrayList(); - ManagedObject l3cmo = getL3ContextMo(uri, ndid, t); - if (l3cmo != null) { - mol.add(l3cmo); - } - } - /* - * We default to this being a routing domain reference if the - * actual reference can't be resolved. - */ - PolicyReference pr = new PolicyReference(pci.getClassId(), uri.getUri()); - poi.setReference(ppi.getPropId(), pr); - } - } - - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_EPG_TO_NETWORK_DOMAIN_RN); - mo.setUri(convertedUri.getUri()); - mol.add(mo); - - return mol; - - } - - public static Set getEndpointGroupMo(ManagedObject epgMo, PolicyUri current, EndpointGroup epg, - RuleGroup rg) { - if (epg == null) - return null; - - // Convert to Genie URI - PolicyUri convertedUri = odlUriToGenieUri(current); - - String prefix = convertedUri.toString(); - - // Arrays for MOs that follow - List mol = new ArrayList(); - List childrenUris = new ArrayList(); - - /* - * Build up the equivalent Genie object - */ - PolicyClassInfo pci = mit.getClass(GENIE_EPG_RN); - if (pci == null) - return null; - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - setParentFields(convertedUri, poi, GENIE_EPG_RN, true); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - // Use the name to set the URI of this object - poi.setUri(convertedUri.getUri()); - - Contract c = rg.getRelatedContract(); - for (PolicyPropertyInfo ppi : ppil) { - if (ppi.getPropName().equals(GENIE_ENDPOINT_GROUP_NAME) && epg.getId() != null) { - poi.setString(ppi.getPropId(), epg.getId().getValue()); - } - if (ppi.getPropName().equals(GENIE_INTRA_EPG_RN) && epg.getIntraGroupPolicy() != null) { - poi.setUint64(ppi.getPropId(), intToBigInt(epg.getIntraGroupPolicy().getIntValue())); - } - - // TODO: the following only maps named selectors. What about target - // selectors? - if (ppi.getPropName().equals(GENIE_CONSUMER_CONTRACT_REF_RN) && epg.getConsumerNamedSelector() != null) { - // TODO: this does all the selectors -- should we just do those - // that are in scope? - for (ConsumerNamedSelector cns : epg.getConsumerNamedSelector()) { - for (ContractId cid : cns.getContract()) { - if (!cid.getValue().equals(c.getId().getValue())) { - PolicyUri child = new PolicyUri(prefix); - child.push(GENIE_CONSUMER_CONTRACT_REF_RN); - child.push(cns.getName().getValue()); - ManagedObject conMo = getConsumerNamedSelectorMo(child, c); - if (conMo != null) { - mol.add(conMo); - } - childrenUris.add(child.getUri()); - } - } - } - } - - // TODO: the following only maps named selectors. What about target - // selectors? - if (ppi.getPropName().equals(GENIE_PROVIDER_CONTRACT_REF_RN) && epg.getProviderNamedSelector() != null) { - // TODO: this does all the selectors -- should we just do those - // that are in scope? - for (ProviderNamedSelector pns : epg.getProviderNamedSelector()) { - for (ContractId cid : pns.getContract()) { - if (cid.getValue().equals(c.getId().getValue())) { - PolicyUri child = new PolicyUri(prefix); - child.push(GENIE_PROVIDER_CONTRACT_REF_RN); - child.push(pns.getName().getValue()); - ManagedObject provMo = getProviderNamedSelectorMo(child, c); - if (provMo != null) { - mol.add(provMo); - } - childrenUris.add(child.getUri()); - } - } - } - } - /* - * Don't bother getting network references if we have them already - */ - if (ppi.getPropName().equals(GENIE_EPG_TO_NETWORK_DOMAIN_RN) && epg.getNetworkDomain() != null) { - PolicyUri child = new PolicyUri(prefix); - child.push(GENIE_EPG_TO_NETWORK_DOMAIN_RN); - mol.addAll(MessageUtils.getNetwokDomainRefMo(child, epg.getNetworkDomain(), rg.getContractTenant())); - childrenUris.add(child.getUri()); - } - - } - - lib.serializeMoProperties(pci, poi, epgMo, mit); - - epgMo.setChildren(childrenUris); - - epgMo.setParent_uri(poi.getParent()); - epgMo.setParent_subject(poi.getParentSubject()); - epgMo.setParent_relation(poi.getParentRelation()); - epgMo.setSubject(GENIE_EPG_RN); - epgMo.setUri(convertedUri.getUri()); - - return Sets.newHashSet(mol); - } - - /** - * Deserialize the MO properties, convert them to objects that are used in - * the ODL tree, and return them as a list of objects. - * - * @param mo - * @return - */ - public static EprOperation getEprOpFromEpMo(ManagedObject mo, int prr, String agentId) { - MacAddress mac = null; - EndpointGroupId epgid = null; - L2BridgeDomainId l2bdid = null; - L3ContextId l3cid = null; - IpAddress ip = null; - EprOperation op = null; - TenantId tid = null; - List l3al = new ArrayList(); - - if (mo.getProperties() == null) - return null; - - // Deserialize the MO properties - PolicyObjectInstance poi = lib.deserializeMoProperties(mo, mit); - if (poi == null) - return null; - - PolicyClassInfo pci = mit.getClass(poi.getClassId()); - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - /* - * We want to extract the properties we need to map to the corresponding - * ODL MIT. We have to roll through the list of properties that were - * present and map each of them independently. We know what type of - * Endpoint we're mapping by the "subject" field of the MO. - */ - // TODO: add support for vector values - for (PolicyPropertyInfo ppi : ppil) { - if (poi.isSet(ppi.getPropId(), ppi.getType(), ppi.getPropCardinality())) { - switch (ppi.getPropName()) { - case GENIE_ENDPOINT_MAC: - mac = poi.getMacAddress(ppi.getPropId()); - break; - case GENIE_ENDPOINT_EPG: - /* - * This must be a full URI of the EPG -- otherwise, it can't - * be uniquely resolved. - */ - String epg = poi.getString(ppi.getPropId()); - epgid = new EndpointGroupId(epg); - break; - case GENIE_ENDPOINT_CONTEXT: - /* - * It seems like this should be scoped by tenant as well, - * which means it would have to be a full URI. If that's the - * case, then the code below needs fixing. - */ - if (mo.getSubject().equals(GENIE_ENDPOINT_RN)) { - l2bdid = new L2BridgeDomainId(poi.getString(ppi.getPropId())); - } else if (mo.getSubject().equals(GENIE_ENDPOINT_L3_RN)) { - l3cid = new L3ContextId(poi.getString(ppi.getPropId())); - } - break; - case GENIE_ENDPOINT_UUID: - String uuid = poi.getString(ppi.getPropId()); - tid = new TenantId(uuid); - break; - case GENIE_ENDPOINT_IP: - // TODO: support v6 - Ipv4Address ipv4 = new Ipv4Address(poi.getString(ppi.getPropId())); - ip = new IpAddress(ipv4); - break; - default: - break; - } - } - - } - - if (ip != null && l3cid != null) { - L3AddressBuilder l3ab = new L3AddressBuilder(); - l3ab.setIpAddress(ip); - l3ab.setL3Context(l3cid); - l3al.add(l3ab.build()); - } - - String epType = mo.getSubject(); - if (epType.equals(GENIE_ENDPOINT_RN)) { - L2EprOperation l2eo = new L2EprOperation(prr); - l2eo.setAgentId(agentId); - l2eo.setContextId(l2bdid); - l2eo.setEndpointGroupId(epgid); - l2eo.setL3AddressList(l3al); - l2eo.setMacAddress(mac); - l2eo.setTenantId(tid); - op = l2eo; - } else if (epType.equals(GENIE_ENDPOINT_L3_RN)) { - L3EprOperation l3eo = new L3EprOperation(prr); - l3eo.setAgentId(agentId); - l3eo.setContextId(l3cid); - l3eo.setEndpointGroupId(epgid); - l3eo.setIpAddress(ip); - l3eo.setL3AddressList(l3al); - l3eo.setMacAddress(mac); - l3eo.setTenantId(tid); - op = l3eo; - } - - return op; - } - - /** - * Get the Endpoint Registry Operation from the Genie URI. The Genie URI - * must be a URI for an Endpoint in the EPR. - * - * @param uri - * @param subject - * @return - */ - public static EprOperation getEprOpFromUri(Uri uri, String subject) { - PolicyUri convertedUri = genieUriToOdlUri(new PolicyUri(uri.getValue())); - String convertedSubject = genieToOdlMap.get(subject); - - /* - * Get the objects that are common to all EPs - */ - EprOperation op = null; - String identifier = convertedUri.pop(); - String context = convertedUri.pop(); - Identity id = new Identity(identifier); - id.setContext(context); - - /* - * Determine if it's an L2 or L3 EPR Op, and get the EP-specific objects - */ - - if (convertedSubject.equals(ENDPOINT_RN)) { - L2EprOperation l2eo = new L2EprOperation(); - l2eo.setContextId(new L2BridgeDomainId(context)); - l2eo.setMacAddress(new MacAddress(identifier)); - - op = l2eo; - } else if (convertedSubject.equals(ENDPOINT_L3_RN)) { - L3EprOperation l3eo = new L3EprOperation(); - l3eo.setContextId(new L3ContextId(context)); - Ipv4Address ipv4 = new Ipv4Address(identifier); - l3eo.setIpAddress(new IpAddress(ipv4)); - - op = l3eo; - } - - return op; - } - - public static EprOperation getEprOpFromEpId(EndpointIdentity eid, String subject) { - EprOperation op = null; - Uri uri = eid.getContext(); - String rn = eid.getIdentifier(); - - PolicyUri convertedUri = genieUriToOdlUri(new PolicyUri(uri.getValue())); - String convertedSubject = genieToOdlMap.get(subject); - - /* - * It's not clear if the identifier contains both of the keys for an EP - * (e.g. context + MAC/IP), or if it's just the last identifier - * (MAC/IP). From the description in the RFC, it seems to be just the - * last identifer, so we'll start with that. - */ - String context = convertedUri.pop(); - Identity id = new Identity(rn); - id.setContext(context); - - /* - * Determine if it's an L2 or L3 EPR Op, and get the EP-specific objects - */ - - if (convertedSubject.equals(ENDPOINT_RN)) { - L2EprOperation l2eo = new L2EprOperation(); - l2eo.setContextId(new L2BridgeDomainId(context)); - l2eo.setMacAddress(new MacAddress(rn)); - - op = l2eo; - } else if (convertedSubject.equals(ENDPOINT_L3_RN)) { - L3EprOperation l3eo = new L3EprOperation(); - l3eo.setContextId(new L3ContextId(context)); - Ipv4Address ipv4 = new Ipv4Address(rn); - l3eo.setIpAddress(new IpAddress(ipv4)); - - op = l3eo; - } - - return op; - } - - public static ManagedObject getMoFromEp(DataObject obj) { - MacAddress mac = null; - EndpointGroupId epgid = null; - String context = null; - String uuid = null; - IpAddress ip = null; - PolicyUri uri = new PolicyUri(); - - ManagedObject mo = new ManagedObject(); - String className = null; - PolicyClassInfo pci = null; - PolicyObjectInstance poi = null; - - if (obj instanceof Endpoint) { - Endpoint ep = (Endpoint) obj; - epgid = ep.getEndpointGroup(); - mac = ep.getMacAddress(); - uuid = ep.getTenant().getValue(); - context = ep.getL2Context().getValue(); - className = GENIE_ENDPOINT_RN; - pci = mit.getClass(className); - poi = new PolicyObjectInstance(pci.getClassId()); - uri.push(GENIE_EPR_L2_ROOT); - uri.push(GENIE_ENDPOINT_RN); - uri.push(ep.getL2Context().getValue()); - uri.push(ep.getMacAddress().getValue()); - setParentFields(uri, poi, GENIE_ENDPOINT_RN, true); - } else if (obj instanceof EndpointL3) { - EndpointL3 ep = (EndpointL3) obj; - epgid = ep.getEndpointGroup(); - mac = ep.getMacAddress(); - uuid = ep.getTenant().getValue(); - ip = ep.getIpAddress(); - context = ep.getL3Context().getValue(); - className = GENIE_ENDPOINT_L3_RN; - pci = mit.getClass(className); - poi = new PolicyObjectInstance(pci.getClassId()); - uri.push(GENIE_EPR_L3_ROOT); - uri.push(GENIE_ENDPOINT_L3_RN); - uri.push(ep.getL3Context().getValue()); - uri.push(ep.getIpAddress().getIpv4Address().getValue()); - setParentFields(uri, poi, GENIE_ENDPOINT_L3_RN, true); - } else { - return null; - } - - mo.setSubject(className); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - /* - * Set all the properties based on the EP - */ - // TODO: add support for vector values - for (PolicyPropertyInfo ppi : ppil) { - switch (ppi.getPropName()) { - case GENIE_ENDPOINT_MAC: - poi.setMacAddress(ppi.getPropId(), mac); - break; - case GENIE_ENDPOINT_EPG: - poi.setString(ppi.getPropId(), epgid.getValue()); - break; - case GENIE_ENDPOINT_CONTEXT: - poi.setString(ppi.getPropId(), context); - break; - case GENIE_ENDPOINT_IP: - // TODO: support v6 - poi.setString(ppi.getPropId(), ip.toString()); - break; - case GENIE_ENDPOINT_UUID: - poi.setString(ppi.getPropId(), uuid); - break; - default: - break; - - } - } - lib.serializeMoProperties(pci, poi, mo, mit); - - mo.setParent_uri(poi.getParent()); - mo.setParent_subject(poi.getParentSubject()); - mo.setParent_relation(poi.getParentRelation()); - mo.setSubject(GENIE_EPG_TO_NETWORK_DOMAIN_RN); - mo.setUri(uri.getUri()); - - return mo; - } - - public static ManagedObject getMoFromOp(EprOperation op) { - MacAddress mac = null; - EndpointGroupId epgid = null; - String context = null; - // String uuid = null; - IpAddress ip = null; - - ManagedObject mo = new ManagedObject(); - String className = null; - PolicyClassInfo pci = null; - PolicyObjectInstance poi = null; - - /* - * The problem is that the op can return different types of things - - * Endpoint, EndpointL3. I guess I need to return the individual pieces - * from the op, and use those to construct the MO - */ - if (op instanceof L2EprOperation) { - L2EprOperation l2eo = (L2EprOperation) op; - Endpoint ep = l2eo.getEp(); - if (ep == null) - return null; - epgid = ep.getEndpointGroup(); - mac = ep.getMacAddress(); - context = ep.getL2Context().getValue(); - className = GENIE_ENDPOINT_RN; - - } else if (op instanceof L3EprOperation) { - L3EprOperation l3eo = (L3EprOperation) op; - EndpointL3 ep = l3eo.getEp(); - if (ep == null) - return null; - - epgid = ep.getEndpointGroup(); - mac = ep.getMacAddress(); - ip = ep.getIpAddress(); - context = ep.getL3Context().getValue(); - className = GENIE_ENDPOINT_L3_RN; - } - pci = mit.getClass(className); - poi = new PolicyObjectInstance(pci.getClassId()); - - mo.setSubject(className); - - List ppil = pci.getProperties(); - if (ppil == null) - return null; - - /* - * Set all the properties based on the EP - */ - // TODO: add support for vector values - for (PolicyPropertyInfo ppi : ppil) { - switch (ppi.getPropName()) { - case GENIE_ENDPOINT_MAC: - poi.setMacAddress(ppi.getPropId(), mac); - break; - case GENIE_ENDPOINT_EPG: - poi.setString(ppi.getPropId(), epgid.getValue()); - break; - case GENIE_ENDPOINT_CONTEXT: - poi.setString(ppi.getPropId(), context); - break; - case GENIE_ENDPOINT_IP: - // TODO: support v6 - poi.setString(ppi.getPropId(), ip.toString()); - break; - case GENIE_ENDPOINT_UUID: - default: - break; - - } - } - lib.serializeMoProperties(pci, poi, mo, mit); - - return mo; - } - - /** - * Merge the contents of two {@link ManagedObject} objects that represent - * the same MO. The contents of mo2 are merged into the contents of mo1 - * - * @param mo1 - * @param mo2 - */ - public static void mergeMos(ManagedObject mo1, ManagedObject mo2) { - - /* - * Some sanity checks, to make sure we're dealing with the same MO - */ - if (!mo1.getSubject().equals(mo2.getSubject()) || !mo1.getUri().getValue().equals(mo2.getUri().getValue())) { - return; - } - - /* - * The only things that need merging are the children URIs and the - * properties. - */ - List mo1Props = mo1.getProperties(); - List mo2Props = mo2.getProperties(); - if (mo2Props != null) { - if (mo1Props == null) { - mo1.setProperties(mo2Props); - } else { - for (Property prop : mo2Props) { - if (!mo1Props.contains(prop)) { - mo1Props.add(prop); - } - } - } - } - - List mo1Children = mo1.getChildren(); - List mo2Children = mo2.getChildren(); - if (mo2Children != null) { - if (mo1Children == null) { - mo1.setChildren(mo2Children); - } else { - for (Uri child : mo2Children) { - if (!mo1Children.contains(child)) { - mo1Children.add(child); - } - } - } - } - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/OpflexRenderer.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/OpflexRenderer.java deleted file mode 100644 index d91f0ce72..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/OpflexRenderer.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexConnectionService; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.AgentOvsMit; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.MitLib; -import org.opendaylight.groupbasedpolicy.resolver.PolicyResolver; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Renderer that uses OpFlex to implement an overlay network - * using Open vSwitch. - * - * @author tbachman - */ -public class OpflexRenderer implements AutoCloseable { - - private static final Logger LOG = LoggerFactory.getLogger(OpflexRenderer.class); - - private final PolicyResolver policyResolver; - private final EndpointManager endpointManager; - private final PolicyManager policyManager; - private final OpflexConnectionService connectionService; - private final MitLib mitLibrary; - private final ScheduledExecutorService executor; - - ListenerRegistration configReg; - - public OpflexRenderer(DataBroker dataProvider, RpcProviderRegistry rpcRegistry) { - super(); - - int numCPU = Runtime.getRuntime().availableProcessors(); - executor = Executors.newScheduledThreadPool(numCPU * 2); - - mitLibrary = new MitLib(); - MessageUtils.setOpflexLib(mitLibrary); - MessageUtils.init(); - MessageUtils.setMit(new AgentOvsMit()); - - connectionService = new OpflexConnectionService(dataProvider, executor); - - endpointManager = new EndpointManager(dataProvider, rpcRegistry, executor, connectionService, mitLibrary); - policyResolver = new PolicyResolver(dataProvider, executor); - - policyManager = new PolicyManager(policyResolver, connectionService, executor, mitLibrary); - - LOG.info("Initialized OpFlex renderer"); - } - - // ************* - // AutoCloseable - // ************* - - @Override - public void close() throws Exception { - executor.shutdownNow(); - if (configReg != null) - configReg.close(); - if (policyResolver != null) - policyResolver.close(); - if (policyManager != null) - policyManager.close(); - if (connectionService != null) - connectionService.close(); - if (endpointManager != null) - endpointManager.close(); - } - - // ************** - // Implementation - // ************** -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/PolicyManager.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/PolicyManager.java deleted file mode 100644 index 097254c7a..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/PolicyManager.java +++ /dev/null @@ -1,518 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ScheduledExecutorService; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcEndpoint; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcBroker; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessageMap; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexAgent; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexConnectionService; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.Role; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.ManagedObject; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.OpflexError; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyResolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyResolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUnresolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUnresolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUpdateRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.MitLib; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyUri; -import org.opendaylight.groupbasedpolicy.resolver.ConditionGroup; -import org.opendaylight.groupbasedpolicy.resolver.EgKey; -import org.opendaylight.groupbasedpolicy.resolver.IndexedTenant; -import org.opendaylight.groupbasedpolicy.resolver.Policy; -import org.opendaylight.groupbasedpolicy.resolver.PolicyInfo; -import org.opendaylight.groupbasedpolicy.resolver.PolicyListener; -import org.opendaylight.groupbasedpolicy.resolver.PolicyResolver; -import org.opendaylight.groupbasedpolicy.resolver.PolicyScope; -import org.opendaylight.groupbasedpolicy.resolver.RuleGroup; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ConditionName; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.Contract; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -/** - * Manage policies on agents by subscribing to updates from the - * policy resolver and information about endpoints from the endpoint - * registry - * - * @author tbachman - */ -public class PolicyManager implements PolicyListener, RpcBroker.RpcCallback, AutoCloseable { - - private static final Logger LOG = LoggerFactory.getLogger(PolicyManager.class); - - private static final String UKNOWN_POLICY = "unknown policy name"; - - /* - * The tables below are used to look up Managed Objects (MOs) - * that have been subscribed to. The table is indexed as - * - */ - final PolicyResolver policyResolver; - final OpflexConnectionService connectionService; - final ScheduledExecutorService executor; - private final MitLib mitLibrary; - private final PolicyScope policyScope; - - private final ConcurrentHashMap> epgSubscriptions = new ConcurrentHashMap<>(); - private RpcMessageMap messageMap = null; - - public PolicyManager(PolicyResolver policyResolver, OpflexConnectionService connectionService, - ScheduledExecutorService executor, MitLib mitLibrary) { - super(); - this.executor = executor; - this.policyResolver = policyResolver; - this.connectionService = connectionService; - this.mitLibrary = mitLibrary; - - /* Subscribe to PR messages */ - messageMap = new RpcMessageMap(); - List messages = Role.POLICY_REPOSITORY.getMessages(); - messageMap.addList(messages); - for (RpcMessage msg : messages) { - this.connectionService.subscribe(msg, this); - } - - policyScope = policyResolver.registerListener(this); - - LOG.debug("Initialized OpFlex policy manager"); - } - - /** - * Shut down the {@link PolicyManager}. Implemented from the - * AutoCloseable interface. - */ - @Override - public void close() throws ExecutionException, InterruptedException { - - } - - // ************** - // PolicyListener - // ************** - - @Override - public void policyUpdated(Set updatedConsumers) { - - sendPolicyUpdates(updatedConsumers); - } - - // ************** - // Implementation - // ************** - - /** - * Update all policy on all agents as needed. Note that this will block - * one of the threads on the executor. - * - * @author tbachman - */ - private void sendPolicyUpdates(Set updatedConsumers) { - Map> agentMap = new HashMap>(); - - PolicyInfo info = policyResolver.getCurrentPolicy(); - if (info == null) - return; - - /* - * First build a per-agent set of EPGs that need updating - */ - for (EgKey cepg : updatedConsumers) { - - /* - * Find the set of agents that have subscribed to - * updates for this EPG - */ - for (String agentId : epgSubscriptions.get(cepg)) { - Set egSet = agentMap.get(agentId); - if (egSet == null) { - egSet = Collections.newSetFromMap(new ConcurrentHashMap()); - agentMap.put(agentId, egSet); - } - egSet.add(cepg); - } - } - - /* - * Go through each agent and provide a single update for all EPGs - */ - for (Map.Entry> entry : agentMap.entrySet()) { - OpflexAgent agent = connectionService.getOpflexAgent(entry.getKey()); - if (agent == null) - continue; - - sendPolicyUpdate(agent.getEndpoint(), entry.getValue(), info); - - } - } - - /** - * This implements Runnable, which allows the {@link ScheduledExecutorService} to execute the - * run() method to implement the update - * - * @author tbachman - */ - private class PolicyUpdate implements Runnable { - - private final JsonRpcEndpoint agent; - private final Set epgSet; - private final PolicyInfo info; - - PolicyUpdate(JsonRpcEndpoint agent, Set epgSet, PolicyInfo info) { - this.agent = agent; - this.epgSet = epgSet; - this.info = info; - } - - @Override - public void run() { - List subtrees = new ArrayList(); - - PolicyUpdateRequest request = new PolicyUpdateRequest(); - List paramsList = new ArrayList<>(); - PolicyUpdateRequest.Params params = new PolicyUpdateRequest.Params(); - - /* - * We may need to optimize this in the future. Currently - * we send down the EPG MOs and all the related policy - * that's in scope from the PolicyResolver. If we want - * to optimize this in the future to only send the policy - * objects that changed, we'd either have to change the - * PolicyResolver to provide this delta, or we'd have to - * keep cached state for each node. - */ - for (EgKey epg : epgSet) { - /* - * Get EPGs from the IndexedTenant, as the EPGs from - * the IndexedTenenat alread has collapsed the EPGs - * (i.e. inheritance accounted for) - * - * TODO: needed? - */ - - IndexedTenant it = policyResolver.getTenant(epg.getTenantId()); - List relatedMos = getPolicy(epg, info, it); - subtrees.addAll(relatedMos); - } - - /* - * Currently not using delete URI or merge_children MOs - */ - params.setDelete_uri(new ArrayList()); - params.setMerge_children(new ArrayList()); - params.setReplace(subtrees); - paramsList.add(params); - request.setParams(paramsList); - try { - agent.sendRequest(request); - } catch (Exception e) { - - } - } - } - - void sendPolicyUpdate(JsonRpcEndpoint agent, Set epgSet, PolicyInfo info) { - executor.execute(new PolicyUpdate(agent, epgSet, info)); - } - - /** - * This method creates {@link ManagedObject} POJOs for all of the - * policy objects that need to be sent as a result of policy - * resolution for the given EPG. - * - * @param epg The Endpoint Group that was resolved - * @param policySnapshot A snapshot of the current resolved policy - */ - private List getPolicy(EgKey epg, PolicyInfo policySnapshot, IndexedTenant it) { - if (policySnapshot == null) - return null; - - Set policyMos = Sets.newHashSet(); - Set peers = policySnapshot.getPeers(epg); - - if (peers == null || peers.size() <= 0) - return null; - - // Allocate an MO for the requested EPG - ManagedObject epgMo = new ManagedObject(); - for (EgKey depg : peers) { - /* - * Construct the base URI, so that we can - * continue adding on to create child MOs. - * We use the peer EPG for getting the policy - */ - PolicyUri uri = new PolicyUri(); - uri.push(MessageUtils.TENANTS_RN); - uri.push(MessageUtils.TENANT_RN); - uri.push(depg.getTenantId().getValue()); - - Policy policy = policySnapshot.getPolicy(epg, depg); - if (policy == null || policy == Policy.EMPTY) - continue; - - /* - * We now have a policy that we need to send to the agent. - * Provide empty condition lists for now - need to be - * an actual empty list, instead of null - * - * TODO: get actual condition groups - */ - List conds = new ArrayList(); - ConditionGroup cgSrc = policySnapshot.getEgCondGroup(epg, conds); - ConditionGroup cgDst = policySnapshot.getEgCondGroup(depg, conds); - List rgl = policy.getRules(cgSrc, cgDst); - - /* - * RuleGroups can refer to the same contract. As result, - * we need to keep track of contracts returned and merge - * the results into a single ManagedObject - */ - Map contracts = new ConcurrentHashMap(); - - for (RuleGroup rg : rgl) { - - /* - * Construct a new URI for the EPG requested. - * In this case, we want the requested EPG, not - * the peer EPG - */ - PolicyUri puri = new PolicyUri(); - puri.push(MessageUtils.TENANTS_RN); - puri.push(MessageUtils.TENANT_RN); - puri.push(epg.getTenantId().getValue()); - puri.push(MessageUtils.EPG_RN); - puri.push(epg.getEgId().getValue()); - Set epgMos = MessageUtils.getEndpointGroupMo(epgMo, puri, - it.getEndpointGroup(epg.getEgId()), rg); - if (epgMos != null) { - policyMos.addAll(epgMos); - } - - Contract c = rg.getRelatedContract(); - /* - * This cmol list is used as a container to pass - * an out parameter for the contract MO. This MO - * is returned separately from the others because - * may require merging -- different RuleGroup - * objects can refer to the same contract - */ - List cmol = new ArrayList<>(); - - uri.push(MessageUtils.CONTRACT_RN); - uri.push(c.getId().getValue()); - List mol = MessageUtils.getContractAndSubMos(cmol, uri, c, rg, it); - if (mol == null) - continue; - - // walk back to the tenant for next contract URI - uri.pop(); - uri.pop(); - - if (contracts.get(c) != null) { - /* - * Aggregate the child URIs and properties. - */ - MessageUtils.mergeMos(contracts.get(c), cmol.remove(0)); - } else { - contracts.put(c, cmol.remove(0)); - } - policyMos.addAll(mol); - } - // add in the EPG - policyMos.add(epgMo); - // add in the contracts - policyMos.addAll(contracts.values()); - } - return Lists.newArrayList(policyMos); - } - - private void addPolicySubscription(JsonRpcEndpoint endpoint, EgKey epgId) { - policyScope.addToScope(epgId.getTenantId(), epgId.getEgId()); - - Set agents = epgSubscriptions.get(epgId); - if (agents == null) { - agents = Collections.newSetFromMap(new ConcurrentHashMap()); - Set result = epgSubscriptions.putIfAbsent(epgId, agents); - if (result != null) { - agents = result; - } - } - agents.add(endpoint.getIdentifier()); - - } - - private void removePolicySubscription(JsonRpcEndpoint endpoint, EgKey epgId) { - Set agents = epgSubscriptions.get(epgId); - if (agents != null) { - agents.remove(endpoint.getIdentifier()); - } - policyScope.removeFromScope(epgId.getTenantId(), epgId.getEgId()); - } - - @Override - public void callback(JsonRpcEndpoint endpoint, RpcMessage request) { - - if (messageMap.get(request.getMethod()) == null) { - LOG.warn("message {} was not subscribed to, but was delivered.", request); - return; - } - - RpcMessage response = null; - - if (request instanceof PolicyResolveRequest) { - PolicyResolveRequest req = (PolicyResolveRequest) request; - PolicyResolveResponse msg = new PolicyResolveResponse(); - PolicyResolveResponse.Result result = new PolicyResolveResponse.Result(); - msg.setId(request.getId()); - - if (!req.valid()) { - LOG.warn("Invalid resolve request: {}", req); - OpflexError error = new OpflexError(); - error.setCode(OpflexError.ErrorCode.ERROR.toString()); - // error.setData(data); - // error.setMessage(message); - // error.setTrace(trace); - msg.setError(error); - } - - List mol = new ArrayList<>(); - - for (PolicyResolveRequest.Params p : req.getParams()) { - - // Skip this if we already have an error - if (msg.getError() != null) - break; - - /* - * Only Policy Identity or Policy URI is present. - * Convert Policy Identities to a URI that we can use - */ - Uri policyUri = p.getPolicy_uri(); - if (policyUri == null) { - Uri rn = p.getPolicy_ident().getContext(); - String name = p.getPolicy_ident().getName(); - PolicyUri puri = new PolicyUri(rn.getValue()); - puri.push(name); - policyUri = puri.getUri(); - } - - // See if the request has an EPG in the URI - if (MessageUtils.hasEpg(policyUri.getValue())) { - /* - * Keep track of EPGs requested by agents. - */ - EndpointGroupId egid = new EndpointGroupId( - MessageUtils.getEndpointGroupFromUri(policyUri.getValue())); - TenantId tid = new TenantId(MessageUtils.getTenantFromUri(policyUri.getValue())); - EgKey epgId = new EgKey(tid, egid); - - addPolicySubscription(endpoint, epgId); - - IndexedTenant it = policyResolver.getTenant(tid); - if (it != null) { - List relatedMos = getPolicy(epgId, policyResolver.getCurrentPolicy(), it); - if (relatedMos != null) { - mol.addAll(relatedMos); - } - } - } else { - OpflexError error = new OpflexError(); - error.setMessage(UKNOWN_POLICY); - error.setCode(OpflexError.ErrorCode.EUNSUPPORTED.toString()); - // error.setData(data); - // error.setTrace(trace); - msg.setError(error); - } - - } - result.setPolicy(mol); - msg.setResult(result); - response = msg; - } else if (request instanceof PolicyUnresolveRequest) { - PolicyUnresolveRequest req = (PolicyUnresolveRequest) request; - PolicyUnresolveResponse msg = new PolicyUnresolveResponse(); - msg.setId(request.getId()); - Uri policyUri; - - if (!req.valid()) { - OpflexError error = new OpflexError(); - error.setCode(OpflexError.ErrorCode.ERROR.toString()); - // error.setData(data); - // error.setMessage(message); - // error.setTrace(trace); - msg.setError(error); - } - - for (PolicyUnresolveRequest.Params p : req.getParams()) { - - // Skip this if we already have an error - if (msg.getError() != null) - break; - - /* - * Only Policy Identity or Policy URI is present. - * Convert to a URI that we'll use - */ - policyUri = p.getPolicy_uri(); - if (policyUri == null) { - // Convert the RN/name to DN - Uri rn = p.getPolicy_ident().getContext(); - String name = p.getPolicy_ident().getName(); - PolicyUri puri = new PolicyUri(rn.getValue()); - puri.push(name); - policyUri = puri.getUri(); - } - - if (MessageUtils.hasEpg(policyUri.getValue())) { - /* - * Keep track of EPGs requested by agents. - */ - EndpointGroupId egid = new EndpointGroupId( - MessageUtils.getEndpointGroupFromUri(policyUri.getValue())); - TenantId tid = new TenantId(MessageUtils.getTenantFromUri(policyUri.getValue())); - EgKey epgId = new EgKey(tid, egid); - - removePolicySubscription(endpoint, epgId); - } else { - OpflexError error = new OpflexError(); - error.setMessage(UKNOWN_POLICY); - msg.setError(error); - } - } - response = msg; - - } - if (response != null) { - try { - endpoint.sendResponse(response); - } catch (Exception e) { - LOG.warn("Error sending response {}", e); - } - } - - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/ConnectionService.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/ConnectionService.java deleted file mode 100644 index 1a7468d49..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/ConnectionService.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - - -/** - * An interface to provide notifications when connections are - * established or closed. The connection notifications - * use {@link JsonRpcEndpoint} objects; as connections come and go, - * the {@link JsonRpcEndpoint} objects associated with the connections - * can be long-lived - * - * @author tbachman - */ -public interface ConnectionService { - /** - * - * Indication that a new connections was established with - * the {@link JsonRpcEndpoint} - * - * @param endpoint The endpoint that added the connection. - */ - public void addConnection(JsonRpcEndpoint endpoint); - - /** - * - * Indication that a connections with the {@link JsonRpcEndpoint} - * was closed. - * - * @param endpoint The endpoint that closed the connection. - */ - public void channelClosed(JsonRpcEndpoint endpoint) throws Exception; -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/ExceptionHandler.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/ExceptionHandler.java deleted file mode 100644 index 32a7b9c3d..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/ExceptionHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2013 EBay Software Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Ashwin Raveendran - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import io.netty.channel.ChannelHandlerAdapter; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.TooLongFrameException; - -public class ExceptionHandler extends ChannelHandlerAdapter { - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - if ((cause instanceof InvalidEncodingException) - || (cause instanceof TooLongFrameException)) { - - ctx.channel().disconnect(); - } - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/InvalidEncodingException.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/InvalidEncodingException.java deleted file mode 100644 index 053991c8a..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/InvalidEncodingException.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2013 EBay Software Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Ashwin Raveendran, Madhu Venugopal - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -public class InvalidEncodingException extends RuntimeException { - - private static final long serialVersionUID = -2241512201890075052L; - private final String actual; - - public InvalidEncodingException(String actual, String message) { - super(message); - this.actual = actual; - } - - public String getActual() { - return actual; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpc10Response.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpc10Response.java deleted file mode 100644 index 63c95f2e3..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpc10Response.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2013 EBay Software Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Ashwin Raveendran, Madhu Venugopal - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import java.util.List; - -import com.google.common.collect.Lists; - -public class JsonRpc10Response { - - String id; - String error; - List result = Lists.newArrayList(); - - public JsonRpc10Response() { - } - - public JsonRpc10Response(String id) { - setId(id); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - - public List getResult() { - return result; - } - - public void setResult(List result) { - this.result = result; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcDecoder.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcDecoder.java deleted file mode 100644 index ad350ca54..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcDecoder.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2013 EBay Software Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Ashwin Raveendran, Madhu Venugopal, Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufInputStream; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageDecoder; -import io.netty.handler.codec.TooLongFrameException; - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.core.JsonEncoding; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.io.IOContext; -import com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper; -import com.fasterxml.jackson.core.util.BufferRecycler; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.MappingJsonFactory; - -/** - * JSON RPC 1.0 compatible decoder capable of decoding JSON messages from a TCP stream. - * The stream is framed first by inspecting the json for valid end marker (left curly) - * and is passed to a Json parser (jackson) for converting into an object model. - * - * There are no JSON parsers that I am aware of that does non blocking parsing. - * This approach avoids having to run json parser over and over again on the entire - * stream waiting for input. Parser is invoked only when we know of a full JSON message - * in the stream. - */ -public class JsonRpcDecoder extends ByteToMessageDecoder { - - protected static final Logger logger = LoggerFactory.getLogger(JsonRpcDecoder.class); - - private final int maxFrameLength; - - private final JsonFactory jacksonJsonFactory = new MappingJsonFactory(); - - private final IOContext jacksonIOContext = new IOContext(new BufferRecycler(), null, false); - - // context for the previously read incomplete records - private int lastRecordBytes = 0; - private int leftCurlies = 0; - private int rightCurlies = 0; - private boolean inS = false; - - private int recordsRead; - - public JsonRpcDecoder(int maxFrameLength) { - this.maxFrameLength = maxFrameLength; - } - - @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List out) throws Exception { - - logger.trace("readable bytes {}, records read {}, incomplete record bytes {}", - buf.readableBytes(), recordsRead, lastRecordBytes); - - if (lastRecordBytes == 0) { - if (buf.readableBytes() < 4) { - return; //wait for more data - } - - skipSpaces(buf); - - byte[] buff = new byte[4]; - buf.getBytes(buf.readerIndex(), buff); - ByteSourceJsonBootstrapper strapper = new ByteSourceJsonBootstrapper(jacksonIOContext, buff, 0, 4); - JsonEncoding jsonEncoding = strapper.detectEncoding(); - if (!JsonEncoding.UTF8.equals(jsonEncoding)) { - throw new InvalidEncodingException(jsonEncoding.getJavaName(), "currently only UTF-8 is supported"); - } - } - - int i = lastRecordBytes + buf.readerIndex(); - - for (; i < buf.writerIndex(); i++) { - switch (buf.getByte(i)) { - case '{': - if (!inS) leftCurlies++; - break; - case '}': - if (!inS) rightCurlies++; - break; - case '"': { - if (buf.getByte(i - 1) != '\\') inS = !inS; - break; - } - default: - break; - } - - if (leftCurlies != 0 && leftCurlies == rightCurlies && !inS) { - ByteBuf slice = buf.readSlice(1 + i - buf.readerIndex()); - JsonParser jp = jacksonJsonFactory.createParser(new ByteBufInputStream(slice)); - JsonNode root = jp.readValueAsTree(); - out.add(root); - leftCurlies = rightCurlies = lastRecordBytes = 0; - recordsRead++; - break; - } - - if (isEom(buf.getByte(i) & 0xFF)) { - // Dump up to this point in the buffer - buf.readerIndex(1 + i); - leftCurlies = rightCurlies = lastRecordBytes = 0; - ctx.fireChannelReadComplete(); - } - else if (i - buf.readerIndex() >= maxFrameLength) { - fail(ctx, i - buf.readerIndex()); - } - } - - // end of stream, save the incomplete record index to avoid reexamining the whole on next run - if (i >= buf.writerIndex()) { - lastRecordBytes = buf.readableBytes(); - return; - } - } - - public int getRecordsRead() { - return recordsRead; - } - - private static boolean isEom(int ch) { - if (ch == '\0') { - return true; - } - return false; - } - - private static void skipSpaces(ByteBuf b) { - while (b.isReadable()) { - int ch = b.getByte(b.readerIndex()) & 0xFF; - if (!(ch == ' ' || ch == '\r' || ch == '\n' || ch == '\t' || ch == '\0')) { - return; - } - b.readByte(); //move the read index - } - } - - // copied from Netty decoder - private void fail(ChannelHandlerContext ctx, long frameLength) { - if (frameLength > 0) { - ctx.fireExceptionCaught( - new TooLongFrameException( - "frame length exceeds " + maxFrameLength + - ": " + frameLength + " - discarded")); - } else { - ctx.fireExceptionCaught( - new TooLongFrameException( - "frame length exceeds " + maxFrameLength + - " - discarding")); - } - } -} - diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEncoder.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEncoder.java deleted file mode 100644 index 6c606983f..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEncoder.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2013 EBay Software Foundation - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Ashwin Raveendran, Madhu Venugopal, Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToMessageEncoder; - -import java.util.List; - -public class JsonRpcEncoder extends MessageToMessageEncoder { - @Override - protected void encode(ChannelHandlerContext ctx, Object msg, List out) throws Exception { - - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEndpoint.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEndpoint.java deleted file mode 100644 index 4f661ef12..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEndpoint.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2013 EBay Software Foundation - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Ashwin Raveendran, Madhu Venugopal, Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; - -import java.util.Map; -import java.util.UUID; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.Maps; -import com.google.common.util.concurrent.SettableFuture; - -/** - * - * This represents a JSONRPC connection between a {@link RpcServer} - * and some client. The clients may connect and disconnect, so one - * possible role that the JSONRPC endpoint can serve is to keep a long-lived - * notion of a client, while maintaining connectivity as it comes and goes. - * - * TODO: The current implementation uses Jackson Full data binding serialization, - * using JSON that has already been parsed using Jackson's Tree Model. - * This will be changed to streaming-mode serialization later. - * - * @author tbachman - * - */ -public class JsonRpcEndpoint implements ChannelFutureListener { - - protected static final Logger logger = LoggerFactory.getLogger(JsonRpcEndpoint.class); - - private static class CallContext { - private final String method; - private final SettableFuture future; - - public CallContext(String method, SettableFuture future) { - this.method = method; - this.future = future; - } - - public String getMethod() { - return method; - } - - public SettableFuture getFuture() { - return future; - } - } - - private final String identifier; - private Object context; - private final ObjectMapper objectMapper; - private final Channel nettyChannel; - private final Map methodContext = Maps.newHashMap(); - private final RpcMessageMap messageMap; - private final RpcBroker broker; - private final ConnectionService connectionService; - - public String getIdentifier() { - return identifier; - } - - public Object getContext() { - return context; - } - - public void setContext(Object context) { - this.context = context; - } - - public Channel getChannel() { - return nettyChannel; - } - - public JsonRpcEndpoint(String identifier, ConnectionService connectionService, - ObjectMapper objectMapper, Channel channel, - RpcMessageMap messageMap, RpcBroker broker) { - this.identifier = identifier; - this.connectionService = connectionService; - this.objectMapper = objectMapper; - this.nettyChannel = channel; - this.messageMap = messageMap; - this.broker = broker; - } - - /** - * - * Send a concrete {@link RpcMessage} to the RPC endpoint. - * - * @param message The concrete {@link RpcMessage} to send - * @return SettableFuture<Object> The caller can use the returned - * object to wait for the response (currently no timeout) - * @throws Exception The concrete message couldn't be serialized and sent - */ - public SettableFuture sendRequest(RpcMessage message) throws Exception { - if (messageMap.get(message.getName()) == null) { - return null; - } - JsonNode jn = objectMapper.getNodeFactory().textNode(UUID.randomUUID().toString()); - message.setId(jn); - - String s = objectMapper.writeValueAsString(message) + "\0"; - logger.trace("invoke: {}", s); - - SettableFuture sf = SettableFuture.create(); - methodContext.put(message.getId().asText(), new CallContext(message.getName(), sf)); - - nettyChannel.writeAndFlush(s); - - return sf; - } - - /** - * - * Send a response to a previous {@link RpcMessage}request - * - * @param message The concrete {@link RpcMessage} - * @throws Exception The concrete message couldn't be serialized and sent - */ - public void sendResponse (RpcMessage message) throws Exception { - - String s = objectMapper.writeValueAsString(message) + "\0"; - logger.trace("sendResponse: {}", s); - - nettyChannel.writeAndFlush(s); - } - - /** - * - * Handle an {@link RpcMessage} response from the peer. - * - * @param response A fully parsed Jackson Tree-Mode JsonNode - * @throws NoSuchMethodException Internal error - */ - public void processResult(JsonNode response) throws NoSuchMethodException { - - logger.trace("Response : {}", response.toString()); - CallContext returnCtxt = methodContext.get(response.get("id").asText()); - if (returnCtxt == null) return; - RpcMessage message = messageMap.get(returnCtxt.getMethod()); - if (message != null) { - try { - RpcMessage handler = objectMapper.treeToValue(response, message.getClass()); - - JsonNode error = response.get("error"); - if (error != null && !error.isNull()) { - logger.error("Error : {}", error.toString()); - } - - returnCtxt.getFuture().set(handler); - } catch (JsonProcessingException e) { - logger.error("Unable to handle " + returnCtxt.getMethod(), e); - } - } else { - throw new RuntimeException("The response to " + returnCtxt.getMethod() + - "sent is unsupported"); - } - } - - /** - * - * Handle incoming {@link RpcMessage} requests. The supported messages - * are defined by the endpoint's message map. - * - * @param requestJson A Jackson JsonNode that has had full Tree-Mode parsing - */ - public void processRequest(JsonNode requestJson) { - RpcMessage message; - RpcMessage callback = messageMap.get(requestJson.get("method").asText()); - if (callback != null) { - try { - logger.trace("Request : {} {}", requestJson.get("method"), requestJson.get("params")); - - message = objectMapper.treeToValue(requestJson, callback.getClass()); - message.setId(requestJson.get("id")); - - broker.publish(this, message); - } catch (JsonProcessingException e) { - logger.error("Unable to invoke callback " + callback.getName(), e); - } - return; - } - - // Echo dont need any special processing. hence handling it internally. - - if (requestJson.get("method").asText().equals("echo")) { - JsonRpc10Response response = new JsonRpc10Response(requestJson.get("id").asText()); - response.setError(null); - String s = null; - try { - s = objectMapper.writeValueAsString(response) + "\0"; - nettyChannel.writeAndFlush(s); - } catch (JsonProcessingException e) { - logger.error("Exception while processing JSON string " + s, e ); - } - return; - } - - logger.error("No handler for Request : {}",requestJson.toString()); - } - - @Override - public void operationComplete(ChannelFuture arg0) throws Exception { - connectionService.channelClosed(this); - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcServiceBinderHandler.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcServiceBinderHandler.java deleted file mode 100644 index f9d18bda1..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcServiceBinderHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2013 EBay Software Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Ashwin Raveendran, Madhu Venugopal, Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import com.fasterxml.jackson.databind.JsonNode; - -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class JsonRpcServiceBinderHandler extends ChannelInboundHandlerAdapter { - protected static final Logger logger = LoggerFactory.getLogger(JsonRpcServiceBinderHandler.class); - JsonRpcEndpoint endpoint = null; - - public JsonRpcServiceBinderHandler(JsonRpcEndpoint endpoint) { - this.endpoint = endpoint; - } - - // Setter to facilitate unit testing - public void setEndpoint(JsonRpcEndpoint endpoint) { - this.endpoint = endpoint; - } - - @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { - - if (msg instanceof JsonNode) { - JsonNode jsonNode = (JsonNode) msg; - - if (jsonNode.has("result")) { - endpoint.processResult(jsonNode); - } else if (jsonNode.hasNonNull("method")) { - if (jsonNode.has("id") && (jsonNode.get("id") != null)) { - endpoint.processRequest(jsonNode); - } - } - - return; - } - - ctx.channel().close(); - } - - @Override - public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { - ctx.flush(); - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcBroker.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcBroker.java deleted file mode 100644 index 95ccf7d36..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcBroker.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -/** - * The {@link RpcBroker} provides a content-based pub/sub per RpcMessage - * type. This allows clients to register for the messages they are interested - * in. - * - * @author tbachman - */ -public interface RpcBroker { - - /** - * The {@link RpcCallback} provides a callback interface for the - * {@link RpcBroker}. When the broker needs to publish a new - * {@link RpcMessage}, it invokes the callbacks that were - * registered for that message. - * - * @author tbachman - */ - public interface RpcCallback { - - /** - * Callback that's invoked when the {@link RpcMessage} - * request message is received - * - * @param endpoint The endpoint that received the messgae - * @param message The concrete {@link RpcMessage} received - */ - public void callback(JsonRpcEndpoint endpoint, RpcMessage message); - - } - - /** - * - * Subscribe to a concrete {@link RpcMessage} - * - * @param message The concrete {@link RpcMessage} message to subscribe to - * @param callback The callback to invoke when the message is published - * - */ - public void subscribe(RpcMessage message, RpcCallback callback); - - /** - * Notification to call when a new {@link RpcMessage} request - * is received - * - * @param endpoint The endpoint that received this message - * @param message the concrete {@link RpcMessage} - */ - public void publish(JsonRpcEndpoint endpoint, RpcMessage message); - - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcMessage.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcMessage.java deleted file mode 100644 index db873ed39..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcMessage.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import com.fasterxml.jackson.databind.JsonNode; - - -/** - * The abstract {@link RpcMessage} is used for creating application - * specific RPC messages that can be used by the RPC library. The RPC - * library uses these for serialization and deserialization of messages. - * - *

The class provides notifiers for request and response messages, - * and provides for sending new requests. - * - *

The class should be used to store the - * - * @author tbachman - */ -public abstract class RpcMessage { - - public abstract String getName(); - public abstract void setName(String name); - public abstract JsonNode getId(); - public abstract void setId(JsonNode id); - public abstract String getMethod(); - public abstract void setMethod(String method); - public abstract boolean valid(); -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcMessageMap.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcMessageMap.java deleted file mode 100644 index 36583522f..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcMessageMap.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - - -public class RpcMessageMap { - private final Map messageMap = new ConcurrentHashMap<>(); - - public RpcMessage get(String messageName) { - return messageMap.get(messageName); - } - - public void add(RpcMessage message) { - messageMap.put(message.getName(), message); - } - - public void addList(List messages) { - for ( RpcMessage msg : messages ) { - this.add(msg); - } - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcServer.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcServer.java deleted file mode 100644 index c4f67b20a..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcServer.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.AdaptiveRecvByteBufAllocator; -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOption; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioServerSocketChannel; -import io.netty.handler.codec.string.StringEncoder; -import io.netty.handler.logging.LogLevel; -import io.netty.handler.logging.LoggingHandler; -import io.netty.util.CharsetUtil; - -import java.net.InetAddress; -import java.util.List; -import java.util.concurrent.ExecutionException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -/** - * A (soon-to-be) generic RPC server. It creates {@link JsonRpcEndpoint} objects - * for each new connection. The RpcServer has a set of {@link RpcMessage} - * types that it supports, and it passes on these supported messages - * to the {@link JsonRpcEndpoint} objects that it creates. - * - * TODO: add serialization type, and refactor so serialization determines - * concrete RpcEndpoint object (only JsonRpcEndpoint right now). - * TODO: This and other classes are tightly coupled to netty -- make abstraction? - */ -public class RpcServer { - protected static final Logger logger = - LoggerFactory.getLogger(RpcServer.class); - - final String identity; - final int listenPort; - Channel channel; - Object context; - private final RpcMessageMap messageMap = new RpcMessageMap(); - ConnectionService connectionService; - RpcBroker broker; - - public RpcServer(String identity, int port) { - this.listenPort = port; - this.identity = identity; - } - - public Object getContext() { - return context; - } - - public void setContext(Object context) { - this.context = context; - } - - public void addMessage(RpcMessage message) { - this.messageMap.add(message); - } - - public void addMessageList(List messageList) { - this.messageMap.addList(messageList); - } - - public void setConnectionService(ConnectionService connectionService) { - this.connectionService = connectionService; - } - - public void setRpcBroker(RpcBroker broker) { - this.broker = broker; - } - - public void setChannel(Channel channel) { - this.channel = channel; - } - - public Channel getChannel() { - return this.channel; - } - - void handleNewConnection(String identifier, Channel newChannel) - throws InterruptedException, ExecutionException { - - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.configure( - DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); - - JsonRpcEndpoint endpoint = new JsonRpcEndpoint(identifier, connectionService, - objectMapper, newChannel, messageMap, broker); - endpoint.setContext(context); - JsonRpcServiceBinderHandler binderHandler = - new JsonRpcServiceBinderHandler(endpoint); - newChannel.pipeline().addLast(binderHandler); - - connectionService.addConnection(endpoint); - - ChannelFuture closeFuture = newChannel.closeFuture(); - closeFuture.addListener(endpoint); - } - - public void start() { - EventLoopGroup bossGroup = new NioEventLoopGroup(); - EventLoopGroup workerGroup = new NioEventLoopGroup(); - try { - ServerBootstrap b = new ServerBootstrap(); - b.group(bossGroup, workerGroup) - .channel(NioServerSocketChannel.class) - .option(ChannelOption.SO_BACKLOG, 100) - .handler(new LoggingHandler(LogLevel.INFO)) - .childHandler(new ChannelInitializer() { - @Override - public void initChannel(SocketChannel ch) - throws Exception { - logger.debug("New Passive channel created : " - + ch.toString()); - InetAddress address = ch.remoteAddress() - .getAddress(); - int port = ch.remoteAddress().getPort(); - String identifier = address.getHostAddress() + ":" - + port; - ch.pipeline().addLast( - new LoggingHandler(LogLevel.INFO), - new JsonRpcDecoder(100000), - new StringEncoder(CharsetUtil.UTF_8)); - - handleNewConnection(identifier, ch); - logger.trace("Connected Node : " + identifier); - } - }); - b.option(ChannelOption.TCP_NODELAY, true); - b.option(ChannelOption.RCVBUF_ALLOCATOR, - new AdaptiveRecvByteBufAllocator(65535, 65535, 65535)); - // Start the server. - ChannelFuture f = b.bind(identity, listenPort).sync(); - String id = f.channel().localAddress().toString(); - logger.trace("Connected Node : " + id); - - this.channel = f.channel(); - - // Wait until the server socket is closed. - f.channel().closeFuture().sync(); - } catch (InterruptedException e) { - logger.error("Thread interrupted", e); - } finally { - // Shut down all event loops to terminate all threads. - bossGroup.shutdownGracefully(); - workerGroup.shutdownGracefully(); - } - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexAgent.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexAgent.java deleted file mode 100644 index 2f67dd5a3..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexAgent.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcEndpoint; - -/** - * Represents a participant in an OpFlex domain. It - * contains references to the {@link OpflexRpcServer} that - * it communicates with (i.e. peer), and indicates the roles - * for that server. - * - * @author tbachman - */ -public class OpflexAgent { - - String identity; - String domain; - List roles; - JsonRpcEndpoint endpoint; - OpflexRpcServer opflexServer; - - public OpflexAgent() {} - - /** - * Get the OpFlex administrative domain for this agent - * - * @return - */ - public String getDomain() { - return domain; - } - - /** - * Set the OpFlex administrative domain for this agent - * - * @param domain - */ - public void setDomain(String domain) { - this.domain = domain; - } - - /** - * Get the identity for this agent, as a String - * - * @return - */ - public String getIdentity() { - return identity; - } - - /** - * Set the identity for the agent. - * - * @param identity - */ - public void setIdentity(String identity) { - this.identity = identity; - } - - /** - * Associate an {@link OpflexRpcServer} with this agent. - * - * @return - */ - public OpflexRpcServer getOpflexServer() { - return opflexServer; - } - - /** - * Get the {@link OpflexRpcServer} associated with this agent - * - * @param server - */ - public void setOpflexServer(OpflexRpcServer server) { - this.opflexServer = server; - } - - /** - * Get the roles for this agent - * - * @return - */ - public List getRoles() { - return roles; - } - - /** - * Set the list of roles for this agent - * - * @param roles - */ - public void setRoles(List roles) { - this.roles = roles; - } - - /** - * Get the {@link JsonRpcEndpoint} for this agent - * - * @return - */ - public JsonRpcEndpoint getEndpoint() { - return endpoint; - } - - /** - * Set the {@link JsonRpcEndpoint} for this agent - * - * @param endpoint - */ - public void setEndpoint(JsonRpcEndpoint endpoint) { - this.endpoint = endpoint; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexConnectionService.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexConnectionService.java deleted file mode 100644 index 1f16bf5b0..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexConnectionService.java +++ /dev/null @@ -1,741 +0,0 @@ -/* - * Copyright (C) 2013 Red Hat, Inc. Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Madhu Venugopal, Brent Salisbury, Evan Zeller, Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ScheduledExecutorService; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.ConnectionService; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcEndpoint; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcBroker; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessageMap; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.OpflexError; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.DiscoveryDefinitions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.DiscoveryDefinitionsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.EndpointRegistry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.EndpointRegistryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.Observer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.ObserverBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.PolicyRepository; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.PolicyRepositoryBuilder; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Manages the different OpFlex entity connections. It does this on behalf of - * each logical OpFlex entity: o Policy Repositories o Endpoint Registries o - * Observers - * Each OpFlex entity defines the JSON RPC methods supported, and manages their - * connection/discovery using dedicated servers. Servers and connections are - * maintained in dedicated client and server maps. - * - * @author tbachman - */ -public class OpflexConnectionService implements ConnectionService, RpcBroker, RpcBroker.RpcCallback, - DataChangeListener, AutoCloseable { - - protected static final Logger logger = LoggerFactory.getLogger(OpflexConnectionService.class); - - public static final String OPFLEX_DOMAIN = "default"; - static final String INVALID_DOMAIN = "Domain mismatch"; - // Properties that can be set in config.ini - public static final String OPFLEX_LISTENPORT = "opflex.listenPort"; - private static final Integer defaultOpflexPort = 6670; - public static final String OPFLEX_LISTENIP = "opflex.listenIp"; - private static final String defaultOpflexIp = "0.0.0.0"; - - private Integer opflexListenPort = defaultOpflexPort; - private String opflexListenIp = defaultOpflexIp; - - private final ScheduledExecutorService executor; - private final ListenerRegistration dataListener; - - String domain; - private final Map opflexAgents = new ConcurrentHashMap<>(); - private final Map opflexServers = new ConcurrentHashMap<>(); - private ConcurrentMap> brokerMap = null; - - private DiscoveryDefinitions currentIdentities; - private final DataBroker dataProvider; - private final RpcMessageMap messageMap = new RpcMessageMap(); - - public static final InstanceIdentifier DISCOVERY_IID = InstanceIdentifier.builder( - DiscoveryDefinitions.class).build(); - - public OpflexConnectionService(DataBroker salDataProvider, ScheduledExecutorService executor) { - this.dataProvider = salDataProvider; - this.executor = executor; - - createBroker(); - - /* Subscribe to Discovery messages */ - List messages = Role.DISCOVERY.getMessages(); - this.messageMap.addList(messages); - for (RpcMessage msg : messages) { - this.subscribe(msg, this); - } - - /* - * Check configuration to see which listeners we should be creating - */ - int listenPort = defaultOpflexPort; - String portString = System.getProperty(OPFLEX_LISTENPORT); - if (portString != null) { - listenPort = Integer.decode(portString).intValue(); - } - this.opflexListenPort = listenPort; - String listenIp = defaultOpflexIp; - String ipString = System.getProperty(OPFLEX_LISTENIP); - if (ipString != null) { - listenIp = ipString; - } - this.opflexListenIp = listenIp; - - initializeServers(); - - this.dataListener = dataProvider.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, - OpflexConnectionService.DISCOVERY_IID, this, DataChangeScope.SUBTREE); - } - - private List setDefaultIdentities() { - - /* - * Create a single server, filling all roles - */ - String identity = opflexListenIp + ":" + opflexListenPort.toString(); - List srvList = new ArrayList(); - List roles = new ArrayList(); - roles.add(Role.POLICY_REPOSITORY); - roles.add(Role.ENDPOINT_REGISTRY); - roles.add(Role.OBSERVER); - - OpflexRpcServer srv = new OpflexRpcServer(domain, identity, roles); - srv.setConnectionService(this); - srv.setRpcBroker(this); - srvList.add(srv); - return srvList; - - } - - private List createServerList(DiscoveryDefinitions identities) { - - if (identities != null) { - Map servers = new ConcurrentHashMap(); - List addList = getPolicyRepositories(identities.getPolicyRepository()); - addServerList(servers, addList, Role.POLICY_REPOSITORY); - addList = getEndpointRegistries(identities.getEndpointRegistry()); - addServerList(servers, addList, Role.ENDPOINT_REGISTRY); - addList = getObservers(identities.getObserver()); - addServerList(servers, addList, Role.OBSERVER); - return (new ArrayList(servers.values())); - } - return null; - } - - private void initializeServers() { - /* - * Get the configured identities, if any. If lists are empty, set up a - * single instance of each, using the default interface, all inside a - * default domain - */ - domain = OPFLEX_DOMAIN; - readConfig(); - - } - - private List getPolicyRepositories(List repositories) { - List identityList = new ArrayList(); - if (repositories == null) - return null; - for (PolicyRepository pr : repositories) { - String identity = pr.getId() + ":" + pr.getPort().toString(); - identityList.add(identity); - } - return identityList; - } - - private List getEndpointRegistries(List registries) { - List identityList = new ArrayList(); - if (registries == null) - return null; - for (EndpointRegistry epr : registries) { - String identity = epr.getId() + ":" + epr.getPort().toString(); - identityList.add(identity); - } - return identityList; - } - - private List getObservers(List observers) { - List identityList = new ArrayList(); - if (observers == null) - return null; - for (Observer o : observers) { - String identity = o.getId() + ":" + o.getPort().toString(); - identityList.add(identity); - } - return identityList; - } - - private void addServerList(Map servers, List idList, Role role) { - if (idList == null || idList.size() <= 0) - return; - - for (String id : idList) { - List roles = new ArrayList(); - OpflexRpcServer srv = servers.get(id); - if (srv != null) { - roles = srv.getRoles(); - servers.remove(id); - } - - roles.add(role); - srv = new OpflexRpcServer(domain, id, roles); - srv.setConnectionService(this); - srv.setRpcBroker(this); - servers.put(id, srv); - } - - } - - /** - * Find the {@link OpflexAgent} that owns this {@link JsonRpcEndpoint}. - * - * @param endpoint - * The endpoint to look up - * @return The OpflexConnection that owns this endpoint - * TODO: should throw an exception of there is no OpflexConnection - * that contains this endpoint - */ - public OpflexAgent getOpflexConnection(JsonRpcEndpoint endpoint) { - - return getOpflexAgent(endpoint.getIdentifier()); - } - - /** - * Get the OpflexRpcServer that spawned this endpoint. - * - * @param endpoint - * The endpoint to look up - * @return The OpflexRpcServer that owns this endpoint, or null if the - * server no longer exists - * TODO: exception if the endpoint is owned by anything - */ - public OpflexRpcServer getOpflexServer(JsonRpcEndpoint endpoint) { - if (endpoint.getContext() instanceof OpflexRpcServer) { - return (OpflexRpcServer) endpoint.getContext(); - } - logger.warn("Couldn't find OpflexConnection for endpoint {}", endpoint.getIdentifier()); - return null; - } - - /** - * Start the {@link OpflexConnectionService} - */ - public synchronized void createBroker() { - brokerMap = new ConcurrentHashMap>(); - } - - public Map getOpflexAgents() { - return opflexAgents; - } - - public Map getOpflexServers() { - return opflexServers; - } - - public void removeOpflexAgent(OpflexAgent agent) { - opflexAgents.remove(agent.getIdentity()); - } - - public void removeOpflexServer(OpflexRpcServer server) { - opflexServers.remove(server.getId()); - } - - public List getOpflexServerList() { - return new ArrayList(opflexServers.values()); - } - - /** - * Clean up all the entities contained by this domain. The connection - * service also owns these references, so we provide notifications to the - * connection service so that it can clean up as well. - */ - public void cleanup() { - List agents = new ArrayList(opflexAgents.keySet()); - List servers = new ArrayList(opflexServers.keySet()); - for (String agent : agents) { - OpflexAgent conn = opflexAgents.remove(agent); - conn.getEndpoint().getChannel().disconnect(); - } - for (String srv : servers) { - OpflexRpcServer server = opflexServers.get(srv); - if (server.getRpcServer().getChannel() != null) { - server.getRpcServer().getChannel().disconnect(); - } - } - } - - /** - * Add an {@link OpflexAgent} to the domain - * - * @param agent - * The agent to add - */ - public void addOpflexAgent(OpflexAgent agent) { - opflexAgents.put(agent.getIdentity(), agent); - } - - /** - * Return the {@link OpflexAgent} associated with this identity - * - * @param identity - * A string representing the connections identity - * @return The connection represented by that key, or null if not found - */ - public OpflexAgent getOpflexAgent(String identity) { - return opflexAgents.get(identity); - } - - /** - * Add the List of servers to the domain - * - * @param serverList - * List of new servers to start - */ - public void addServers(List serverList) { - - if (serverList == null) - return; - - /* - * Check to see if there's already a server with this identity, and if - * so, close it and replace it with this one. - */ - for (OpflexRpcServer srv : serverList) { - OpflexRpcServer server = opflexServers.get(srv.getId()); - if (server != null) { - if (!server.sameServer(srv)) { - OpflexRpcServer oldServer = opflexServers.remove(srv.getId()); - if (oldServer != null && oldServer.getRpcServer() != null - && oldServer.getRpcServer().getChannel() != null) { - oldServer.getRpcServer().getChannel().disconnect(); - } - opflexServers.put(srv.getId(), srv); - srv.start(); - } - } else { - opflexServers.put(srv.getId(), srv); - srv.start(); - } - } - } - - /** - * Drop the list of servers from the domain - * - * @param oldServers - * The list of servers to drop - * TODO: Should we provide notifications to or close the - * connections that were spawned by the deleted servers? - */ - public void dropServers(List oldServers) { - OpflexRpcServer server; - - /* - * Check to see if there's a server with this identity, and if so, close - * it - */ - for (String srv : oldServers) { - if (opflexServers.containsKey(srv)) { - server = opflexServers.remove(srv); - server.getRpcServer().getChannel().disconnect(); - } - } - } - - /** - * Check the new configuration of the servers against the existing, and if - * different, delete the old server and replace it with a new server running - * the updated parameters. - * - * @param serverList - * The new server configurations - */ - public void updateServers(List serverList) { - /* Get the new list of configured servers in this domain */ - List updateServers = new ArrayList(); - List newServers = new ArrayList(); - List newList = new ArrayList(); - - for (OpflexRpcServer srv : serverList) { - newList.add(srv.getId()); - } - - /* Get the list of currently configured servers in this domain */ - List currentList = new ArrayList(opflexServers.keySet()); - - /* Make the add/drop/update lists */ - List addList = new ArrayList(newList); - List dropList = new ArrayList(currentList); - List updateList = new ArrayList(newList); - - addList.removeAll(currentList); - dropList.removeAll(newList); - updateList.removeAll(addList); - - /* - * Create add and update lists - */ - for (OpflexRpcServer srv : serverList) { - if (updateList.contains(srv.getId())) { - updateServers.add(srv); - } - if (addList.contains(srv.getId())) { - newServers.add(srv); - } - } - - dropServers(dropList); - addServers(newServers); - addServers(updateServers); - } - - private void readConfig() { - ListenableFuture> dao = dataProvider.newReadOnlyTransaction().read( - LogicalDatastoreType.CONFIGURATION, DISCOVERY_IID); - Futures.addCallback(dao, new FutureCallback>() { - - @Override - public void onSuccess(final Optional result) { - getNewConfig(result); - } - - @Override - public void onFailure(Throwable t) { - logger.error("Failed to read configuration", t); - } - }, executor); - } - - void getNewConfig(final Optional result) { - /* - * Get the new list of discovery definitions from the configuration - * store, and convert to a list for manipulation - */ - if (!result.isPresent()) { - domain = OPFLEX_DOMAIN; - if (currentIdentities != null) { - dropServers(new ArrayList(opflexServers.keySet())); - } - List defaults = setDefaultIdentities(); - addServers(defaults); - commitDefaultConfiguration(defaults); - - return; - } - - currentIdentities = result.get(); - if (currentIdentities == null) { - dropServers(new ArrayList(opflexServers.keySet())); - List defaults = setDefaultIdentities(); - addServers(defaults); - commitDefaultConfiguration(defaults); - } else { - domain = currentIdentities.getDomain(); - // TODO: what to do about existing agents? keep the same domain? - if (domain == null) - domain = OPFLEX_DOMAIN; - - updateServers(createServerList(currentIdentities)); - } - } - - private void commitDefaultConfiguration(List servers) { - EndpointRegistryBuilder erb = new EndpointRegistryBuilder(); - PolicyRepositoryBuilder prb = new PolicyRepositoryBuilder(); - ObserverBuilder ob = new ObserverBuilder(); - DiscoveryDefinitionsBuilder ddb = new DiscoveryDefinitionsBuilder(); - for (OpflexRpcServer srv : servers) { - if (srv.getRoles().contains(Role.ENDPOINT_REGISTRY)) { - erb.setId(srv.getAddress()); - erb.setPort(srv.getPort()); - } - if (srv.getRoles().contains(Role.POLICY_REPOSITORY)) { - prb.setId(srv.getAddress()); - prb.setPort(srv.getPort()); - } - if (srv.getRoles().contains(Role.OBSERVER)) { - ob.setId(srv.getAddress()); - ob.setPort(srv.getPort()); - } - - } - List erl = new ArrayList(); - List prl = new ArrayList(); - List ol = new ArrayList(); - erl.add(erb.build()); - prl.add(prb.build()); - ol.add(ob.build()); - - ddb.setEndpointRegistry(erl); - ddb.setObserver(ol); - ddb.setPolicyRepository(prl); - ddb.setDomain(domain); - DiscoveryDefinitions identities = ddb.build(); - WriteTransaction wt = dataProvider.newWriteOnlyTransaction(); - wt.put(LogicalDatastoreType.CONFIGURATION, DISCOVERY_IID, identities); - wt.submit(); - } - - // ****************** - // DataChangeListener - // ****************** - - @Override - public void onDataChanged(final AsyncDataChangeEvent, DataObject> change) { - - readConfig(); - } - - /** - * Close the connection service. Implemented from the AutoCloseable - * interface. - */ - @Override - public void close() throws ExecutionException, InterruptedException { - cleanup(); - dataListener.close(); - } - - /** - * Subscribe to a given {@link RpcMessage}. We synchronize this method to - * ensure consistency, and because subscriptions aren't a frequent event. - * The list is a copy on write list to ensure that anyone using a list has a - * usable copy - */ - @Override - public synchronized void subscribe(RpcMessage message, RpcCallback callback) { - - /* - * Create a new list, replacing the old - */ - List cbList = brokerMap.get(message.getName()); - if (cbList == null) { - cbList = new CopyOnWriteArrayList(); - cbList.add(callback); - brokerMap.put(message.getName(), cbList); - } else if (!cbList.contains(callback)) { - cbList.add(callback); - brokerMap.replace(message.getName(), cbList); - } - } - - /** - * Publish the {@link RpcMessage} to all subscribers. - */ - @Override - public synchronized void publish(JsonRpcEndpoint endpoint, RpcMessage message) { - List cbList = brokerMap.get(message.getName()); - if (cbList == null) { - logger.warn("Unhandled Message name is " + message.getName()); - return; - } - - for (RpcCallback cb : cbList) { - cb.callback(endpoint, message); - } - } - - /** - * This notification handles the OpFlex Identity request messages. - */ - @Override - public void callback(JsonRpcEndpoint endpoint, RpcMessage message) { - - if (!(message instanceof IdentityRequest)) { - logger.warn("message is not identity request {}", message); - return; - } - OpflexRpcServer srv = getOpflexServer(endpoint); - if (srv == null) - return; - - IdentityRequest request = (IdentityRequest) message; - IdentityResponse.Result result = new IdentityResponse.Result(); - - List peers = new ArrayList(); - - IdentityResponse response = new IdentityResponse(); - - /* - * We inherit our role from the server that spawned the connection. - */ - List myRoles = new ArrayList(); - List roles = srv.getRoles(); - if (roles != null) { - for (Role r : roles) { - myRoles.add(r.toString()); - } - } - result.setMy_role(myRoles); - - /* - * The peers field contains the identifiers other than my_role - */ - if (request.getParams() == null || request.getParams().size() <= 0) { - return; - } - if (request.getParams() == null || request.getParams().get(0) == null - || !request.getParams().get(0).getDomain().equals(domain)) { - OpflexError error = new OpflexError(); - error.setMessage(INVALID_DOMAIN); - response.setError(error); - /* send domain mismatch */ - } else { - for (OpflexRpcServer server : getOpflexServerList()) { - /* Skip our server -- reported in my_role */ - // if ( Objects.equals(server.getId(), srv.getId())) - // continue; - roles = server.getRoles(); - if (roles != null) { - IdentityResponse.Peer peer = new IdentityResponse.Peer(); - peer.setConnectivity_info(server.getId()); - List stringRoles = new ArrayList(); - for (Role r : roles) { - stringRoles.add(r.toString()); - } - peer.setRole(stringRoles); - peers.add(peer); - } - } - result.setPeers(peers); - result.setName(srv.getId()); - result.setDomain(domain); - response.setResult(result); - } - response.setId(message.getId()); - - /* - * Collect the set of severs and send in the response - */ - try { - endpoint.sendResponse(response); - } catch (Exception e) { - logger.error("Exception for sending {}, {}", message, e); - } - } - - /** - * This is the notification when a new endpoint has been created. Since the - * endpoint is new, we don't have a OpflexConnection for it yet. We create - * the OpflexConnection, then retrieve the OpflexRpcServer that created this - * connections to inherit some of the fields we need (domain, server). - */ - @Override - public void addConnection(JsonRpcEndpoint endpoint) { - - /* - * When the connection is added, we only have the JsonRpcEndpoint. We - * use the JsonRpcEndpoint's context field to store the server object - * that created this connection, and can look up things like the domain, - * etc. to create the containing connection object. - */ - if (!(endpoint.getContext() instanceof OpflexRpcServer)) { - logger.error("Connection for endpoint {} invalid", endpoint.getIdentifier()); - // TODO: close connection? - return; - } - - OpflexRpcServer server = (OpflexRpcServer) endpoint.getContext(); - - /* - * The OpFlex domain is the same as the server that the agent connected - * to. Look up the OpFlex RPC server using the server socket. - * - * It's possible that the server was closed or changed between the - * connection establishment and now (race condition). Treat that as a - * failure, closing the connection. - */ - OpflexAgent oc = new OpflexAgent(); - oc.setEndpoint(endpoint); - oc.setIdentity(endpoint.getIdentifier()); - oc.setDomain(domain); - oc.setOpflexServer(server); - oc.setRoles(server.getRoles()); - - logger.trace("Adding agent {}", endpoint.getIdentifier()); - addOpflexAgent(oc); - - /* - * Send an Identity Request - */ - IdentityRequest ourId = new IdentityRequest(); - IdentityRequest.Params params = new IdentityRequest.Params(); - List paramList = new ArrayList(); - List myRoles = new ArrayList(); - List roles = server.getRoles(); - if (roles != null) { - for (Role r : roles) { - myRoles.add(r.toString()); - } - } - params.setMy_role(myRoles); - params.setDomain(server.getDomain()); - params.setName(server.getId()); - paramList.add(params); - ourId.setParams(paramList); - - try { - endpoint.sendRequest(ourId); - } catch (Exception e) { - logger.error("Couldn't send Identity {}", e); - } - } - - /** - * This is the notification we receive when a connection is closed. Retrieve - * the domain from the {@link JsonRpcEndpoint}'s context field to get the - * {@link OpflexRpcServer}, which contains the OpFlex domain for this - * connection, then use the identity from the {@link JsonRpcEndpoint} and - * domain to remove the {@link OpflexAgent} from the domain - */ - @Override - public void channelClosed(JsonRpcEndpoint endpoint) throws Exception { - logger.trace("Connection to Node : {} closed", endpoint.getIdentifier()); - OpflexAgent agent = getOpflexConnection(endpoint); - if (agent != null) { - removeOpflexAgent(agent); - } - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexRpcServer.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexRpcServer.java deleted file mode 100644 index 6ca2e36d0..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexRpcServer.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.ConnectionService; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcBroker; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcServer; - -/** - * The {@link OpflexRpcServer}s respond to OpFlex clients - * which create {@link OpflexAgent} objects when they - * are established. The servers don't own the connections, - * which allows the clients to continue operation even if - * the server is closed - * - * @author tbachman - */ -public class OpflexRpcServer { - - private String identity; - private final String domain; - private final List roles; - private final RpcServer rpcServer; - private ConnectionService connectionService; - private RpcBroker rpcBroker; - - private String address; - private int port; - - private void parseAndSetIdentity(String id) { - if (id.split(":").length == 2) { - this.identity = id; - this.address = id.split(":")[0]; - this.port = Integer.parseInt(id.split(":")[1]); - } - } - - public OpflexRpcServer(String domain, String identity, List roles) { - this.domain = domain; - this.roles = roles; - parseAndSetIdentity(identity); - rpcServer = new RpcServer(address, port); - rpcServer.setContext(this); - } - - public String getDomain() { - return domain; - } - - public String getId() { - return this.identity; - } - - public RpcServer getRpcServer() { - return rpcServer; - } - - public ConnectionService getConnectionService() { - return connectionService; - } - - public void setConnectionService(ConnectionService service) { - this.connectionService = service; - } - - public String getAddress() { - return address; - } - - public int getPort() { - return port; - } - - public RpcBroker getRpcBroker() { - return this.rpcBroker; - } - - public void setRpcBroker(RpcBroker rpcBroker) { - this.rpcBroker = rpcBroker; - } - - public List getRoles() { - return this.roles; - } - - /** - * Start the {@link OpflexRpcServer}. This adds the supported - * messages to the server, based on the roles that were - * configured. It creates an {@link RpcServer} object, - * passes it the context owned by the {@link OpflexRpcServer}, - * and starts the server in its own thread. - * TODO: should use executor service instead? - */ - public void start() { - rpcServer.setConnectionService(connectionService); - rpcServer.setRpcBroker(rpcBroker); - - for (Role role : roles) { - rpcServer.addMessageList(role.getMessages()); - } - /* - * All servers get Discovery messages - */ - rpcServer.addMessageList(Role.DISCOVERY.getMessages()); - - new Thread() { - - private RpcServer server; - - public Thread initializeServerParams(RpcServer srv) { - this.server = srv; - return this; - } - - @Override - public void run() { - try { - server.start(); - } catch (Exception e) { - } - } - }.initializeServerParams(rpcServer).start(); - - } - - /** - * Check to see if two servers are the same. They - * need to be in the same Opflex Domain, have the same - * identity, and the same roles, or they can be - * identical objects. Note that it purposely does - * not compare the RpcServer, as the purpose for - * this method is to see if there is already a server - * fulfilling this configuration (which is the reason - * it's a new method, instead of overriding toString). - * - * @param srv The server to compare against - * @return true if they are equivalent - */ - public boolean sameServer(OpflexRpcServer srv) { - if (this == srv) - return true; - if (srv == null) - return false; - if (!this.identity.equals(srv.identity)) - return false; - if (this.domain == null || !this.domain.equals(srv.getDomain())) - return false; - if (this.roles == null && srv.roles == null) - return true; - if (this.roles == null || srv.roles == null) - return false; - if (this.roles.size() == srv.roles.size() && this.roles.containsAll(srv.roles)) - return true; - return false; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/Role.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/Role.java deleted file mode 100644 index c362be34c..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/Role.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib; - -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUndeclareRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUnresolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUnresolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUpdateRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUpdateResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyResolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyResolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUnresolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUnresolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUpdateRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUpdateResponse; - -/** - * Enum for OpFlex roles and their supported messages - * - * @author tbachman - */ -public enum Role { - DISCOVERY("discovery"), POLICY_REPOSITORY("policy_repository"), ENDPOINT_REGISTRY("endpoint_registry"), OBSERVER( - "observer"), POLICY_ELEMENT("policy_element"); - - static final IdentityRequest idReq = new IdentityRequest(); - static final IdentityResponse idRsp = new IdentityResponse(); - static final EndpointDeclareRequest epDeclReq = new EndpointDeclareRequest(); - static final EndpointDeclareResponse epDeclRsp = new EndpointDeclareResponse(); - static final EndpointUndeclareRequest epUndeclReq = new EndpointUndeclareRequest(); - static final EndpointResolveRequest epReqReq = new EndpointResolveRequest(); - static final EndpointResolveResponse epReqRsp = new EndpointResolveResponse(); - static final EndpointUnresolveRequest epUnreqReq = new EndpointUnresolveRequest(); - static final EndpointUnresolveResponse epUnreqRsp = new EndpointUnresolveResponse(); - static final EndpointUpdateRequest epPolUpdReq = new EndpointUpdateRequest(); - static final EndpointUpdateResponse epPolUpdRsp = new EndpointUpdateResponse(); - static final PolicyResolveRequest polReq = new PolicyResolveRequest(); - static final PolicyResolveResponse polRsp = new PolicyResolveResponse(); - static final PolicyUpdateRequest polUpdReq = new PolicyUpdateRequest(); - static final PolicyUpdateResponse polUpdRsp = new PolicyUpdateResponse(); - static final PolicyUnresolveRequest polUnReq = new PolicyUnresolveRequest(); - static final PolicyUnresolveResponse polUnRsp = new PolicyUnresolveResponse(); - - private final String role; - - Role(String role) { - this.role = role; - } - - /** - * Get the {@link RpcMessage}s supported by this Role - * - * @return List of RpcMessages supported for this Role - */ - public List getMessages() { - if (role.equals(DISCOVERY.toString())) { - List msgList = new ArrayList(); - msgList.add(idReq); - msgList.add(idRsp); - return msgList; - } else if (role.equals(POLICY_REPOSITORY.toString())) { - List msgList = new ArrayList(); - msgList.add(polReq); - msgList.add(polUpdReq); - msgList.add(polUpdRsp); - msgList.add(polUnReq); - msgList.add(polUnRsp); - return msgList; - } else if (role.equals(ENDPOINT_REGISTRY.toString())) { - List msgList = new ArrayList(); - msgList.add(epDeclReq); - msgList.add(epUndeclReq); - msgList.add(epReqReq); - msgList.add(epUnreqReq); - msgList.add(epPolUpdReq); - msgList.add(epPolUpdRsp); - return msgList; - } else if (role.equals(OBSERVER.toString())) { - List msgList = new ArrayList(); - return msgList; - } - return null; - } - - @Override - public String toString() { - return this.role; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointDeclareRequest.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointDeclareRequest.java deleted file mode 100644 index adfb0df5e..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointDeclareRequest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class EndpointDeclareRequest extends RpcMessage { - - public static final String DECLARE_MESSAGE = "endpoint_declare"; - - static public class Params { - - private List endpoint; - private int prr; - - public List getEndpoint() { - return endpoint; - } - - public void setEndpoint(List endpoint) { - this.endpoint = endpoint; - } - - public int getPrr() { - return prr; - } - - public void setPrr(int prr) { - this.prr = prr; - } - } - - private JsonNode id; - private String method; - private List params; - - @JsonIgnore - private String name; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - - public List getParams() { - return this.params; - } - - public void setParams(List params) { - this.params = params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public EndpointDeclareRequest(String name) { - this.name = name; - } - - public EndpointDeclareRequest() { - this.name = DECLARE_MESSAGE; - this.method = DECLARE_MESSAGE; - } - - /** - * Minimal check on validity of message - * - * @return true if message has passed validity check - */ - @JsonIgnore - @Override - public boolean valid() { - if (params == null) - return false; - if (params.get(0) == null) - return false; - - return true; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointDeclareResponse.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointDeclareResponse.java deleted file mode 100644 index 0b6f39099..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointDeclareResponse.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class EndpointDeclareResponse extends RpcMessage { - - public static final String ENDPOINT_DECLARE_RESPONSE = "endpoint_declare_response"; - - static public class Result { - } - - private JsonNode id; - private Result result; - private OpflexError error; - - @JsonIgnore - private String name; - @JsonIgnore - private String method; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - public OpflexError getError() { - return error; - } - - public void setError(OpflexError error) { - this.error = error; - } - - @Override - public String getMethod() { - return null; - } - - @Override - public void setMethod(String method) {} - - public Result getResult() { - return this.result; - } - - public void setResult(Result result) { - this.result = result; - } - - public EndpointDeclareResponse(String name) { - this.name = name; - } - - public EndpointDeclareResponse() { - this.name = ENDPOINT_DECLARE_RESPONSE; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @JsonIgnore - @Override - public boolean valid() { - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointIdentity.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointIdentity.java deleted file mode 100644 index bf5ecaea7..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointIdentity.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -public class EndpointIdentity { - - private String identifier; - private Uri context; - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public Uri getContext() { - return context; - } - - public void setContext(Uri context) { - this.context = context; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointResolveRequest.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointResolveRequest.java deleted file mode 100644 index e910ada32..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointResolveRequest.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class EndpointResolveRequest extends RpcMessage { - - public static final String EP_RESOLVE_REQUEST_MESSAGE = "endpoint_resolve"; - - static public class Params { - - private String subject; - private Uri endpoint_uri; - private EndpointIdentity endpoint_ident; - private int prr; - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public Uri getEndpoint_uri() { - return endpoint_uri; - } - - public void setEndpoint_uri(Uri endpoint_uri) { - this.endpoint_uri = endpoint_uri; - } - - public EndpointIdentity getEndpoint_ident() { - return endpoint_ident; - } - - public void setEndpoint_ident(EndpointIdentity endpoint_ident) { - this.endpoint_ident = endpoint_ident; - } - - public int getPrr() { - return prr; - } - - public void setPrr(int prr) { - this.prr = prr; - } - } - - private JsonNode id; - private String method; - private List params; - - @JsonIgnore - private String name; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - - public List getParams() { - return this.params; - } - - public void setParams(List params) { - this.params = params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public EndpointResolveRequest(String name) { - this.name = name; - } - - public EndpointResolveRequest() { - this.name = EP_RESOLVE_REQUEST_MESSAGE; - } - - /** - * Minimal check on validity of message - * - * @return true if message has passed validity check - */ - @JsonIgnore - @Override - public boolean valid() { - if (params == null) - return false; - if (params.get(0) == null) - return false; - return true; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointResolveResponse.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointResolveResponse.java deleted file mode 100644 index 9c6c979a4..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointResolveResponse.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class EndpointResolveResponse extends RpcMessage { - - public static final String EPP_RESOLVE_MESSAGE_RESPONSE = "endpoint_resolve_response"; - - static public class Result { - - List endpoint; - - public List getEndpoint() { - return endpoint; - } - - public void setEndpoint(List endpoint) { - this.endpoint = endpoint; - } - } - - private JsonNode id; - private Result result; - private OpflexError error; - - @JsonIgnore - private String name; - @JsonIgnore - private String method; - - @Override - public JsonNode getId() { - return this.id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - public OpflexError getError() { - return error; - } - - public void setError(OpflexError error) { - this.error = error; - } - - @Override - public String getMethod() { - return null; - } - - @Override - public void setMethod(String method) {} - - public Result getResult() { - return this.result; - } - - public void setResult(Result result) { - this.result = result; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public EndpointResolveResponse(String name) { - this.name = name; - } - - public EndpointResolveResponse() { - this.name = EPP_RESOLVE_MESSAGE_RESPONSE; - } - - @JsonIgnore - @Override - public boolean valid() { - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUndeclareRequest.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUndeclareRequest.java deleted file mode 100644 index 8ab3d1c37..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUndeclareRequest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; - -public class EndpointUndeclareRequest extends RpcMessage { - - public static final String UNDECLARE_MESSAGE = "endpoint_undeclare"; - - static public class Params { - - private String subject; - private Uri endpoint_uri; - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public Uri getEndpoint_uri() { - return endpoint_uri; - } - - public void setEndpoint_uri(Uri endpoint_uri) { - this.endpoint_uri = endpoint_uri; - } - } - - private JsonNode id; - private String method; - private List params; - - @JsonIgnore - private String name; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - - public List getParams() { - return this.params; - } - - public void setParams(List params) { - this.params = params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public EndpointUndeclareRequest(String name) { - this.name = name; - } - - public EndpointUndeclareRequest() { - this.name = UNDECLARE_MESSAGE; - this.method = UNDECLARE_MESSAGE; - } - - /** - * Minimal check on validity of message - * - * @return true if message has passed validity check - */ - @JsonIgnore - @Override - public boolean valid() { - if (params == null) - return false; - if (params.get(0) == null) - return false; - - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUndeclareResponse.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUndeclareResponse.java deleted file mode 100644 index 985f2bbf6..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUndeclareResponse.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class EndpointUndeclareResponse extends RpcMessage { - - public static final String ENDPOINT_UNDECLARE_RESPONSE = "endpoint_undeclare_response"; - - static public class Result { - } - - private JsonNode id; - private Result result; - private OpflexError error; - - @JsonIgnore - private String name; - @JsonIgnore - private String method; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - public OpflexError getError() { - return error; - } - - public void setError(OpflexError error) { - this.error = error; - } - - @Override - public String getMethod() { - return null; - } - - @Override - public void setMethod(String method) {} - - public Result getResult() { - return this.result; - } - - public void setResult(Result result) { - this.result = result; - } - - public EndpointUndeclareResponse(String name) { - this.name = name; - } - - public EndpointUndeclareResponse() { - this.name = ENDPOINT_UNDECLARE_RESPONSE; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @JsonIgnore - @Override - public boolean valid() { - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUnresolveRequest.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUnresolveRequest.java deleted file mode 100644 index 3f865d11d..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUnresolveRequest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class EndpointUnresolveRequest extends RpcMessage { - - public static final String EP_UNRESOLVE_REQUEST_MESSAGE = "endpoint_unresolve"; - - static public class Params { - - private String subject; - private Uri endpoint_uri; - private EndpointIdentity endpoint_ident; - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public Uri getEndpoint_uri() { - return endpoint_uri; - } - - public void setEndpoint_uri(Uri endpoint_uri) { - this.endpoint_uri = endpoint_uri; - } - - public EndpointIdentity getEndpoint_ident() { - return endpoint_ident; - } - - public void setEndpoint_ident(EndpointIdentity endpoint_ident) { - this.endpoint_ident = endpoint_ident; - } - } - - private JsonNode id; - private String method; - private List params; - - @JsonIgnore - private String name; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - - public List getParams() { - return this.params; - } - - public void setParams(List params) { - this.params = params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public EndpointUnresolveRequest(String name) { - this.name = name; - } - - public EndpointUnresolveRequest() { - this.name = EP_UNRESOLVE_REQUEST_MESSAGE; - } - - /** - * Minimal check on validity of message - * - * @return true if message has passed validity check - */ - @JsonIgnore - @Override - public boolean valid() { - if (params == null) - return false; - if (params.get(0) == null) - return false; - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUnresolveResponse.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUnresolveResponse.java deleted file mode 100644 index 7a982aa13..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUnresolveResponse.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class EndpointUnresolveResponse extends RpcMessage { - - public static final String EPP_UNRESOLVE_MESSAGE_RESPONSE = "endpoint_unresolve_response"; - - static public class Result { - } - - private JsonNode id; - private Result result; - private OpflexError error; - - @JsonIgnore - private String name; - @JsonIgnore - private String method; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - public OpflexError getError() { - return error; - } - - public void setError(OpflexError error) { - this.error = error; - } - - @Override - public String getMethod() { - return null; - } - - @Override - public void setMethod(String method) {} - - public Result getResult() { - return this.result; - } - - public void setResult(Result result) { - this.result = result; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public EndpointUnresolveResponse(String name) { - this.name = name; - } - - public EndpointUnresolveResponse() { - this.name = EPP_UNRESOLVE_MESSAGE_RESPONSE; - } - - @JsonIgnore - @Override - public boolean valid() { - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUpdateRequest.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUpdateRequest.java deleted file mode 100644 index 18116f313..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUpdateRequest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class EndpointUpdateRequest extends RpcMessage { - - public static final String EP_UPDATE_MESSAGE = "endpoint_update"; - - static public class Params { - - private List replace; - private List delete_uri; - - public List getReplace() { - return replace; - } - - public void setReplace(List replace) { - this.replace = replace; - } - - public List getDelete_uri() { - return delete_uri; - } - - public void setDelete_uri(List delete_uri) { - this.delete_uri = delete_uri; - } - } - - private JsonNode id; - private String method; - private List params; - - @JsonIgnore - private String name; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - - public List getParams() { - return this.params; - } - - public void setParams(List params) { - this.params = params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public EndpointUpdateRequest(String name) { - this.name = name; - } - - public EndpointUpdateRequest() { - this.name = EP_UPDATE_MESSAGE; - this.method = EP_UPDATE_MESSAGE; - } - - /** - * Minimal check on validity of message - * - * @return true if message has passed validity check - */ - @JsonIgnore - @Override - public boolean valid() { - if (params == null) - return false; - if (params.get(0) == null) - return false; - return true; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUpdateResponse.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUpdateResponse.java deleted file mode 100644 index 5a5a45ee8..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/EndpointUpdateResponse.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class EndpointUpdateResponse extends RpcMessage { - - public static final String EP_UPDATE_MESSAGE_RESPONSE = "endpoint_update_response"; - - static public class Result { - } - - private JsonNode id; - private Result result; - private OpflexError error; - - @JsonIgnore - private String name; - @JsonIgnore - private String method; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - public OpflexError getError() { - return error; - } - - public void setError(OpflexError error) { - this.error = error; - } - - @Override - public String getMethod() { - return null; - } - - @Override - public void setMethod(String method) {} - - public Result getResult() { - return this.result; - } - - public void setResult(Result result) { - this.result = result; - } - - public EndpointUpdateResponse(String name) { - this.name = name; - } - - public EndpointUpdateResponse() { - this.name = EP_UPDATE_MESSAGE_RESPONSE; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @JsonIgnore - @Override - public boolean valid() { - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/IdentityRequest.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/IdentityRequest.java deleted file mode 100644 index 7b2e6f924..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/IdentityRequest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class IdentityRequest extends RpcMessage { - - public static final String IDENTITY_MESSAGE = "send_identity"; - public static final String OPFLEX_PROTOCOL_VERSION = "1.0"; - - static public class Params { - - private final String proto_version; - private String name; - private String domain; - private List my_role; - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public Params() { - this.proto_version = OPFLEX_PROTOCOL_VERSION; - my_role = new ArrayList(); - } - - public String getProto_version() { - return proto_version; - } - - public String getDomain() { - return domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - public List getMy_role() { - return my_role; - } - - public void setMy_role(List my_role) { - this.my_role = my_role; - } - - } - - private JsonNode id; - private String method; - private List params; - - @JsonIgnore - private String name; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - - public List getParams() { - return this.params; - } - - public void setParams(List params) { - this.params = params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public IdentityRequest(String name) { - this.name = name; - } - - public IdentityRequest() { - this.name = IDENTITY_MESSAGE; - this.method = IDENTITY_MESSAGE; - } - - /** - * Minimal check on validity of message - * - * @return true if message has passed validity check - */ - @JsonIgnore - @Override - public boolean valid() { - if (params == null) - return false; - if (params.get(0) == null) - return false; - return true; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/IdentityResponse.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/IdentityResponse.java deleted file mode 100644 index 6e347ec57..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/IdentityResponse.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class IdentityResponse extends RpcMessage { - - public static final String IDENTITY_MESSAGE_RESPONSE = "send_identity_response"; - - static public class Peer { - - private List role; - private String connectivity_info; - - public List getRole() { - return role; - } - - public void setRole(List role) { - this.role = role; - } - - public String getConnectivity_info() { - return connectivity_info; - } - - public void setConnectivity_info(String connectivity_info) { - this.connectivity_info = connectivity_info; - } - - public Peer() {} - } - - static public class Result { - - private String name; - private String domain; - private List my_role; - private List peers; - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public Result() { - my_role = new ArrayList(); - } - - public String getDomain() { - return domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - public List getMy_role() { - return my_role; - } - - public void setMy_role(List my_role) { - this.my_role = my_role; - } - - public List getPeers() { - return peers; - } - - public void setPeers(List peers) { - this.peers = peers; - } - - } - - private JsonNode id; - private Result result; - private OpflexError error; - - @JsonIgnore - private String name; - @JsonIgnore - private String method; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - public OpflexError getError() { - return error; - } - - public void setError(OpflexError error) { - this.error = error; - } - - @Override - public String getMethod() { - return null; - } - - @Override - public void setMethod(String method) {} - - public Result getResult() { - return this.result; - } - - public void setResult(Result result) { - this.result = result; - } - - public IdentityResponse(String name) { - this.name = name; - } - - public IdentityResponse() { - this.name = IDENTITY_MESSAGE_RESPONSE; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @JsonIgnore - @Override - public boolean valid() { - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/ManagedObject.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/ManagedObject.java deleted file mode 100644 index f3e861a99..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/ManagedObject.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class ManagedObject { - - public static class Property { - - private String name; - private JsonNode data; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public JsonNode getData() { - return data; - } - - public void setData(JsonNode data) { - this.data = data; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((data == null) ? 0 : data.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Property other = (Property) obj; - if (data == null) { - if (other.data != null) - return false; - } else if (!data.asText().equals(other.getData().asText())) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - - } - - private String subject; - private Uri uri; - private List properties; - private String parent_subject; - private Uri parent_uri; - private String parent_relation; - private List children; - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public Uri getUri() { - return uri; - } - - public void setUri(Uri uri) { - this.uri = uri; - } - - public List getProperties() { - return properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - public String getParent_subject() { - return parent_subject; - } - - public void setParent_subject(String parent_subject) { - this.parent_subject = parent_subject; - } - - public Uri getParent_uri() { - return parent_uri; - } - - public void setParent_uri(Uri parent_uri) { - this.parent_uri = parent_uri; - } - - public String getParent_relation() { - return parent_relation; - } - - public void setParent_relation(String parent_relation) { - this.parent_relation = parent_relation; - } - - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((children == null) ? 0 : children.hashCode()); - result = prime * result + ((parent_relation == null) ? 0 : parent_relation.hashCode()); - result = prime * result + ((parent_subject == null) ? 0 : parent_subject.hashCode()); - result = prime * result + ((parent_uri == null) ? 0 : parent_uri.hashCode()); - result = prime * result + ((properties == null) ? 0 : properties.hashCode()); - result = prime * result + ((subject == null) ? 0 : subject.hashCode()); - result = prime * result + ((uri == null) ? 0 : uri.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ManagedObject other = (ManagedObject) obj; - if (children == null) { - if (other.children != null) - return false; - } else if (!children.equals(other.children)) - return false; - if (parent_relation == null) { - if (other.parent_relation != null) - return false; - } else if (!parent_relation.equals(other.parent_relation)) - return false; - if (parent_subject == null) { - if (other.parent_subject != null) - return false; - } else if (!parent_subject.equals(other.parent_subject)) - return false; - if (parent_uri == null) { - if (other.parent_uri != null) - return false; - } else if (!parent_uri.equals(other.parent_uri)) - return false; - if (properties == null) { - if (other.properties != null) - return false; - } else if (!properties.equals(other.properties)) - return false; - if (subject == null) { - if (other.subject != null) - return false; - } else if (!subject.equals(other.subject)) - return false; - if (uri == null) { - if (other.uri != null) - return false; - } else if (!uri.equals(other.uri)) - return false; - return true; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/OpflexError.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/OpflexError.java deleted file mode 100644 index 92dcaeb2a..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/OpflexError.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -public class OpflexError { - - public static enum ErrorCode { - ERROR("ERROR"), EUNSUPPORTED("EUNSUPPORTED"), ESTATE("ESTATE"), EPROTO("EPROTO"), EDOMAIN("EDOMAIN"); - - private final String errorCode; - - ErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - @Override - public String toString() { - return this.errorCode; - } - } - - private String code; - private String message; - private String trace; - private String data; - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getTrace() { - return trace; - } - - public void setTrace(String trace) { - this.trace = trace; - } - - public String getData() { - return data; - } - - public void setData(String data) { - this.data = data; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyIdentity.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyIdentity.java deleted file mode 100644 index 61801e10e..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyIdentity.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -public class PolicyIdentity { - - private String name; - private Uri context; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Uri getContext() { - return context; - } - - public void setContext(Uri context) { - this.context = context; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyResolveRequest.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyResolveRequest.java deleted file mode 100644 index d9b30474a..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyResolveRequest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class PolicyResolveRequest extends RpcMessage { - - public static final String RESOLVE_MESSAGE = "policy_resolve"; - - static public class Params { - - private String subject; - private Uri policy_uri; - private PolicyIdentity policy_ident; - private String data; - private int prr; - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public Uri getPolicy_uri() { - return policy_uri; - } - - public void setPolicy_uri(Uri policy_uri) { - this.policy_uri = policy_uri; - } - - public PolicyIdentity getPolicy_ident() { - return policy_ident; - } - - public void setPolicy_ident(PolicyIdentity policy_ident) { - this.policy_ident = policy_ident; - } - - public String getData() { - return data; - } - - public void setData(String data) { - this.data = data; - } - - public int getPrr() { - return prr; - } - - public void setPrr(int prr) { - this.prr = prr; - } - } - - private JsonNode id; - private String method; - private List params; - - @JsonIgnore - private String name; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - - public List getParams() { - return this.params; - } - - public void setParams(List params) { - this.params = params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public PolicyResolveRequest(String name) { - this.name = name; - } - - public PolicyResolveRequest() { - this.name = RESOLVE_MESSAGE; - this.method = RESOLVE_MESSAGE; - } - - /** - * Minimal check on validity of message - * - * @return true if message has passed validity check - */ - @JsonIgnore - @Override - public boolean valid() { - if (params == null) - return false; - if (params.get(0) == null) - return false; - return true; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyResolveResponse.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyResolveResponse.java deleted file mode 100644 index 135fbba7b..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyResolveResponse.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class PolicyResolveResponse extends RpcMessage { - - public static final String POLICY_MESSAGE_RESPONSE = "policy_resolve_response"; - - static public class Result { - - private List policy; - - public List getPolicy() { - return policy; - } - - public void setPolicy(List policy) { - this.policy = policy; - } - } - - private JsonNode id; - private Result result; - private OpflexError error; - - @JsonIgnore - private String name; - @JsonIgnore - private String method; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - public OpflexError getError() { - return error; - } - - public void setError(OpflexError error) { - this.error = error; - } - - @Override - public String getMethod() { - return null; - } - - @Override - public void setMethod(String method) {} - - public Result getResult() { - return this.result; - } - - public void setResult(Result result) { - this.result = result; - } - - public PolicyResolveResponse(String name) { - this.name = name; - } - - public PolicyResolveResponse() { - this.name = POLICY_MESSAGE_RESPONSE; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @JsonIgnore - @Override - public boolean valid() { - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUnresolveRequest.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUnresolveRequest.java deleted file mode 100644 index 947b0ee48..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUnresolveRequest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class PolicyUnresolveRequest extends RpcMessage { - - public static final String UNRESOLVE_MESSAGE = "policy_unresolve"; - - static public class Params { - - private String subject; - private Uri policy_uri; - private PolicyIdentity policy_ident; - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public Uri getPolicy_uri() { - return policy_uri; - } - - public void setPolicy_uri(Uri policy_uri) { - this.policy_uri = policy_uri; - } - - public PolicyIdentity getPolicy_ident() { - return policy_ident; - } - - public void setPolicy_ident(PolicyIdentity policy_ident) { - this.policy_ident = policy_ident; - } - } - - private JsonNode id; - private String method; - private List params; - - @JsonIgnore - private String name; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - - public List getParams() { - return this.params; - } - - public void setParams(List params) { - this.params = params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public PolicyUnresolveRequest(String name) { - this.name = name; - } - - public PolicyUnresolveRequest() { - this.name = UNRESOLVE_MESSAGE; - this.method = UNRESOLVE_MESSAGE; - } - - /** - * Minimal check on validity of message - * - * @return true if message has passed validity check - */ - @JsonIgnore - @Override - public boolean valid() { - if (params == null) - return false; - if (params.get(0) == null) - return false; - return true; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUnresolveResponse.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUnresolveResponse.java deleted file mode 100644 index 97d273ffa..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUnresolveResponse.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class PolicyUnresolveResponse extends RpcMessage { - - public static final String UNRESOLVE_MESSAGE_RESPONSE = "policy_unresolve_response"; - - static public class Result { - } - - private JsonNode id; - private Result result; - private OpflexError error; - - @JsonIgnore - private String name; - @JsonIgnore - private String method; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - public OpflexError getError() { - return error; - } - - public void setError(OpflexError error) { - this.error = error; - } - - @Override - public String getMethod() { - return null; - } - - @Override - public void setMethod(String method) {} - - public Result getResult() { - return this.result; - } - - public void setResult(Result result) { - this.result = result; - } - - public PolicyUnresolveResponse(String name) { - this.name = name; - } - - public PolicyUnresolveResponse() { - this.name = UNRESOLVE_MESSAGE_RESPONSE; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @JsonIgnore - @Override - public boolean valid() { - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUpdateRequest.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUpdateRequest.java deleted file mode 100644 index c1f2ae692..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUpdateRequest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class PolicyUpdateRequest extends RpcMessage { - - public static final String UPDATE_MESSAGE = "policy_update"; - - static public class Params { - - private List replace; - private List merge_children; - private List delete_uri; - - public List getReplace() { - return replace; - } - - public void setReplace(List replace) { - this.replace = replace; - } - - public List getMerge_children() { - return merge_children; - } - - public void setMerge_children(List merge_children) { - this.merge_children = merge_children; - } - - public List getDelete_uri() { - return delete_uri; - } - - public void setDelete_uri(List delete_uri) { - this.delete_uri = delete_uri; - } - } - - private JsonNode id; - private String method; - private List params; - - @JsonIgnore - private String name; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - - public List getParams() { - return this.params; - } - - public void setParams(List params) { - this.params = params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public PolicyUpdateRequest(String name) { - this.name = name; - } - - public PolicyUpdateRequest() { - this.name = UPDATE_MESSAGE; - this.method = UPDATE_MESSAGE; - } - - /** - * Minimal check on validity of message - * - * @return true if message has passed validity check - */ - @JsonIgnore - @Override - public boolean valid() { - if (params == null) - return false; - if (params.get(0) == null) - return false; - return true; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUpdateResponse.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUpdateResponse.java deleted file mode 100644 index dff9ec561..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/PolicyUpdateResponse.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class PolicyUpdateResponse extends RpcMessage { - - public static final String UPDATE_MESSAGE_RESPONSE = "policy_update_response"; - - static public class Result { - } - - private JsonNode id; - private Result result; - private OpflexError error; - - @JsonIgnore - private String name; - @JsonIgnore - private String method; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - public OpflexError getError() { - return error; - } - - public void setError(OpflexError error) { - this.error = error; - } - - @Override - public String getMethod() { - return null; - } - - @Override - public void setMethod(String method) {} - - public Result getResult() { - return this.result; - } - - public void setResult(Result result) { - this.result = result; - } - - public PolicyUpdateResponse(String name) { - this.name = name; - } - - public PolicyUpdateResponse() { - this.name = UPDATE_MESSAGE_RESPONSE; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @JsonIgnore - @Override - public boolean valid() { - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/StateReportRequest.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/StateReportRequest.java deleted file mode 100644 index 4eae0c428..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/StateReportRequest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class StateReportRequest extends RpcMessage { - - public static final String STATE_MESSAGE = "report_state"; - - static public class Params { - - private Uri object; - private List observable; - - public Uri getObject() { - return object; - } - - public void setObject(Uri object) { - this.object = object; - } - - public List getObservable() { - return observable; - } - - public void setObservable(List observable) { - this.observable = observable; - } - } - - private JsonNode id; - private String method; - private List params; - - @JsonIgnore - private String name; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - - public List getParams() { - return this.params; - } - - public void setParams(List params) { - this.params = params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - public StateReportRequest(String name) { - this.name = name; - } - - public StateReportRequest() { - this.name = STATE_MESSAGE; - this.method = STATE_MESSAGE; - } - - /** - * Minimal check on validity of message - * - * @return true if message has passed validity check - */ - @JsonIgnore - @Override - public boolean valid() { - if (params == null) - return false; - if (params.get(0) == null) - return false; - return true; - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/StateReportResponse.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/StateReportResponse.java deleted file mode 100644 index e4b7f79a4..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/StateReportResponse.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonSerialize -@JsonDeserialize -public class StateReportResponse extends RpcMessage { - - public static final String REPORT_MESSAGE_RESPONSE = "trigger_policy_response"; - - static public class Result { - } - - private JsonNode id; - private Result result; - private OpflexError error; - - @JsonIgnore - private String name; - @JsonIgnore - private String method; - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - public OpflexError getError() { - return error; - } - - public void setError(OpflexError error) { - this.error = error; - } - - @Override - public String getMethod() { - return null; - } - - @Override - public void setMethod(String method) {} - - public Result getResult() { - return this.result; - } - - public void setResult(Result result) { - this.result = result; - } - - public StateReportResponse(String name) { - this.name = name; - } - - public StateReportResponse() { - this.name = REPORT_MESSAGE_RESPONSE; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @JsonIgnore - @Override - public boolean valid() { - return true; - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/AgentOvsMit.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/AgentOvsMit.java deleted file mode 100644 index 3560f5f78..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/AgentOvsMit.java +++ /dev/null @@ -1,3696 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.EnumInfo.EnumInfoBuilder; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyClassInfo.PolicyClassInfoBuilder; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyId; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyInfoBuilder; - -/** - * This class represents the schema used with the OpFlex Agent - * reference design for Open vSwitch. - * - * @author tbachman - */ -public class AgentOvsMit implements OpflexMit { - - private Map metaDataMap = null; - private Map classIdToStringMap = null; - - public AgentOvsMit() { - Map metaData = new HashMap(); - Map classIdToString = new HashMap(); - - /* - * Construct the MIT - */ - EnumInfo ei; - PolicyPropertyInfo ppi; - PolicyClassInfo pci; - EnumInfoBuilder eib; - PolicyPropertyInfoBuilder ppib; - PolicyClassInfoBuilder pcib; - List ppil; - List classKeys; - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147516423l)) - .setPropName("RelatorUniverse") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(7l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147516436l)) - .setPropName("GbpeTunnelEpUniverse") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(20l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147516439l)) - .setPropName("DomainConfig") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(23l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147516467l)) - .setPropName("EpdrL2Discovered") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(51l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147516468l)) - .setPropName("EpdrL3Discovered") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(52l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147516471l)) - .setPropName("EprL2Universe") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(55l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147516474l)) - .setPropName("EprL3Universe") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(58l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147516518l)) - .setPropName("ObserverEpStatUniverse") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(102l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147516531l)) - .setPropName("PolicyUniverse") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(115l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(1) - .setClassName("DmtreeRoot") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713057l)) - .setPropName("DomainConfigToConfigRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(33l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713058l)) - .setPropName("GbpeEpgMappingCtxToEpgMappingRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(34l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713070l)) - .setPropName("SpanLocalEpToEpRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(46l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713083l)) - .setPropName("SpanMemberToRefRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(59l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713093l)) - .setPropName("GbpRuleToClassifierRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(69l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713094l)) - .setPropName("EpdrEndPointToGroupRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(70l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713105l)) - .setPropName("GbpSubnetsToNetworkRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(81l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713108l)) - .setPropName("GbpEpGroupToNetworkRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(84l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713113l)) - .setPropName("GbpEpGroupToProvContractRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(89l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713116l)) - .setPropName("GbpEpGroupToConsContractRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(92l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713120l)) - .setPropName("GbpBridgeDomainToNetworkRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(96l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147713124l)) - .setPropName("GbpFloodDomainToNetworkRRes") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(100l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(7) - .setClassName("RelatorUniverse") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("GbpeEncapTypeT"); - eib.setEnumValue("unknown", new BigInteger(String.valueOf(0))); - eib.setEnumValue("vlan", new BigInteger(String.valueOf(1))); - eib.setEnumValue("vxlan", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(294914l)) - .setPropName("encapType") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("PlatformSwitchingModeT"); - eib.setEnumValue("hairpin", new BigInteger(String.valueOf(1))); - eib.setEnumValue("intra_bd", new BigInteger(String.valueOf(3))); - eib.setEnumValue("intra_epg", new BigInteger(String.valueOf(2))); - eib.setEnumValue("intra_rd", new BigInteger(String.valueOf(4))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(294915l)) - .setPropName("mode") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(294916l)) - .setPropName("multicastGroupIP") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(294913l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147778571l)) - .setPropName("CdpConfig") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(11l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147778575l)) - .setPropName("DfwConfig") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(15l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147778582l)) - .setPropName("L2Config") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(22l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147778584l)) - .setPropName("LacpConfig") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(24l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147778585l)) - .setPropName("LldpConfig") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(25l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147778586l)) - .setPropName("StpConfig") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(26l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147778592l)) - .setPropName("DomainConfigFromConfigRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(32l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147778601l)) - .setPropName("SpanSrcGrp") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(41l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147778602l)) - .setPropName("SpanDstGrp") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(42l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147778603l)) - .setPropName("SpanLocalEp") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(43l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(9) - .setClassName("PlatformConfig") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(327682l)) - .setPropName("defaultGroup") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(327681l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147811359l)) - .setPropName("GbpeEpgMappingCtxFromEpgMappingRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(31l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(10) - .setClassName("GbpeEpgMapping") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(360449l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("PlatformAdminStateT"); - eib.setEnumValue("off", new BigInteger(String.valueOf(0))); - eib.setEnumValue("on", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(360450l)) - .setPropName("state") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(11) - .setClassName("CdpConfig") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(393217l)) - .setPropName("classid") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(393218l)) - .setPropName("encapId") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(393219l)) - .setPropName("multicastGroupIP") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(12) - .setClassName("GbpeInstContext") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2147909659l)) - .setPropName("GbpeEpgMappingCtxToEpgMappingRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(27l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(13) - .setClassName("GbpeEpgMappingCtx") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(491521l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("PlatformAdminStateT"); - eib.setEnumValue("off", new BigInteger(String.valueOf(0))); - eib.setEnumValue("on", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(491522l)) - .setPropName("state") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(15) - .setClassName("DfwConfig") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(524290l)) - .setPropName("rxDrop") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(524291l)) - .setPropName("txDrop") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(524289l)) - .setPropName("uuid") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(16) - .setClassName("DfwEpCounter") - .setPolicyType(PolicyClassInfo.PolicyClassType.OBSERVABLE) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(557057l)) - .setPropName("multicastGroupIP") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(17) - .setClassName("GbpeFloodContext") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("ArpOpcodeT"); - eib.setEnumValue("reply", new BigInteger(String.valueOf(2))); - eib.setEnumValue("request", new BigInteger(String.valueOf(1))); - eib.setEnumValue("unspecified", new BigInteger(String.valueOf(0))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589829l)) - .setPropName("arpOpc") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("GbpConnTrackT"); - eib.setEnumValue("normal", new BigInteger(String.valueOf(0))); - eib.setEnumValue("reflexive", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589827l)) - .setPropName("connectionTracking") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589834l)) - .setPropName("dFromPort") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589835l)) - .setPropName("dToPort") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("GbpDirectionT"); - eib.setEnumValue("bidirectional", new BigInteger(String.valueOf(0))); - eib.setEnumValue("in", new BigInteger(String.valueOf(1))); - eib.setEnumValue("out", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589828l)) - .setPropName("direction") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("L2EtherTypeT"); - eib.setEnumValue("arp", new BigInteger(String.valueOf(0x0806))); - eib.setEnumValue("fcoe", new BigInteger(String.valueOf(0x8906))); - eib.setEnumValue("ipv4", new BigInteger(String.valueOf(0x0800))); - eib.setEnumValue("ipv6", new BigInteger(String.valueOf(0x86DD))); - eib.setEnumValue("mac_security", new BigInteger(String.valueOf(0x88E5))); - eib.setEnumValue("mpls_ucast", new BigInteger(String.valueOf(0x8847))); - eib.setEnumValue("trill", new BigInteger(String.valueOf(0x22F3))); - eib.setEnumValue("unspecified", new BigInteger(String.valueOf(0))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589830l)) - .setPropName("etherT") - .setType(PolicyPropertyInfo.PropertyType.ENUM16) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589825l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589826l)) - .setPropName("order") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589831l)) - .setPropName("prot") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589832l)) - .setPropName("sFromPort") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(589833l)) - .setPropName("sToPort") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148073540l)) - .setPropName("GbpRuleFromClassifierRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(68l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(18) - .setClassName("GbpeL24Classifier") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622600l)) - .setPropName("rxBroadcast") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622604l)) - .setPropName("rxBytes") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622596l)) - .setPropName("rxDrop") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622598l)) - .setPropName("rxMulticast") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622594l)) - .setPropName("rxPackets") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622602l)) - .setPropName("rxUnicast") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622601l)) - .setPropName("txBroadcast") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622605l)) - .setPropName("txBytes") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622597l)) - .setPropName("txDrop") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622599l)) - .setPropName("txMulticast") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622595l)) - .setPropName("txPackets") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622603l)) - .setPropName("txUnicast") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(622593l)) - .setPropName("uuid") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(19) - .setClassName("GbpeEpCounter") - .setPolicyType(PolicyClassInfo.PolicyClassType.OBSERVABLE) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148139029l)) - .setPropName("GbpeTunnelEp") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(21l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(20) - .setClassName("GbpeTunnelEpUniverse") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(688133l)) - .setPropName("encapId") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("GbpeEncapTypeT"); - eib.setEnumValue("unknown", new BigInteger(String.valueOf(0))); - eib.setEnumValue("vlan", new BigInteger(String.valueOf(1))); - eib.setEnumValue("vxlan", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(688132l)) - .setPropName("encapType") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(688131l)) - .setPropName("mac") - .setType(PolicyPropertyInfo.PropertyType.MAC) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(688130l)) - .setPropName("terminatorIp") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(688129l)) - .setPropName("uuid") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(21) - .setClassName("GbpeTunnelEp") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ENDPOINT) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(720897l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(720898l)) - .setPropName("state") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(22) - .setClassName("L2Config") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148237340l)) - .setPropName("DomainConfigToConfigRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(28l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(23) - .setClassName("DomainConfig") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("LacpControlBitsT"); - eib.setEnumValue("fast-select-hot-standby", new BigInteger(String.valueOf(8))); - eib.setEnumValue("graceful-convergence", new BigInteger(String.valueOf(2))); - eib.setEnumValue("load-defer", new BigInteger(String.valueOf(4))); - eib.setEnumValue("suspend-invididual-port", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(786437l)) - .setPropName("controlBits") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(786435l)) - .setPropName("maxLinks") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(786434l)) - .setPropName("minLinks") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("LacpModeT"); - eib.setEnumValue("active", new BigInteger(String.valueOf(1))); - eib.setEnumValue("mac-pin", new BigInteger(String.valueOf(3))); - eib.setEnumValue("off", new BigInteger(String.valueOf(0))); - eib.setEnumValue("passive", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(786436l)) - .setPropName("mode") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(786433l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(24) - .setClassName("LacpConfig") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(819201l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("PlatformAdminStateT"); - eib.setEnumValue("off", new BigInteger(String.valueOf(0))); - eib.setEnumValue("on", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(819202l)) - .setPropName("rx") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("PlatformAdminStateT"); - eib.setEnumValue("off", new BigInteger(String.valueOf(0))); - eib.setEnumValue("on", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(819203l)) - .setPropName("tx") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(25) - .setClassName("LldpConfig") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("PlatformAdminStateT"); - eib.setEnumValue("off", new BigInteger(String.valueOf(0))); - eib.setEnumValue("on", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(851971l)) - .setPropName("bpduFilter") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("PlatformAdminStateT"); - eib.setEnumValue("off", new BigInteger(String.valueOf(0))); - eib.setEnumValue("on", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(851970l)) - .setPropName("bpduGuard") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(851969l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(26) - .setClassName("StpConfig") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(884739l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(27) - .setClassName("GbpeEpgMappingCtxToEpgMappingRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(917507l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(28) - .setClassName("DomainConfigToConfigRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1015810l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1015811l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1015809l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(31) - .setClassName("GbpeEpgMappingCtxFromEpgMappingRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1048578l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1048579l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1048577l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(32) - .setClassName("DomainConfigFromConfigRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1081346l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1081345l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(33) - .setClassName("DomainConfigToConfigRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1114114l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1114113l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(34) - .setClassName("GbpeEpgMappingCtxToEpgMappingRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1245188l)) - .setPropName("context") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1245187l)) - .setPropName("group") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1245186l)) - .setPropName("mac") - .setType(PolicyPropertyInfo.PropertyType.MAC) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1245185l)) - .setPropName("uuid") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148728871l)) - .setPropName("EprL3Net") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(39l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148728877l)) - .setPropName("SpanLocalEpFromEpRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(45l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(38) - .setClassName("EprL2Ep") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ENDPOINT) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1277953l)) - .setPropName("ip") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(39) - .setClassName("EprL3Net") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ENDPOINT) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1343491l)) - .setPropName("label") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1343489l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("PlatformAdminStateT"); - eib.setEnumValue("off", new BigInteger(String.valueOf(0))); - eib.setEnumValue("on", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1343490l)) - .setPropName("state") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148827196l)) - .setPropName("SpanSrcMember") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(60l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148827197l)) - .setPropName("SpanDstMember") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(61l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(41) - .setClassName("SpanSrcGrp") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1376257l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148859964l)) - .setPropName("SpanSrcMember") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(60l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148859965l)) - .setPropName("SpanDstMember") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(61l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(42) - .setClassName("SpanDstGrp") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1409025l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1409026l)) - .setPropName("nic") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148892716l)) - .setPropName("SpanLocalEpToEpRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(44l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2148892722l)) - .setPropName("SpanMemberFromRefRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(50l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(43) - .setClassName("SpanLocalEp") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1441795l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(44) - .setClassName("SpanLocalEpToEpRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1474562l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1474563l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1474561l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(45) - .setClassName("SpanLocalEpFromEpRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1507330l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1507329l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(46) - .setClassName("SpanLocalEpToEpRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1540101l)) - .setPropName("context") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1540099l)) - .setPropName("group") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1540100l)) - .setPropName("ip") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1540098l)) - .setPropName("mac") - .setType(PolicyPropertyInfo.PropertyType.MAC) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1540097l)) - .setPropName("uuid") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149023789l)) - .setPropName("SpanLocalEpFromEpRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(45l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(47) - .setClassName("EprL3Ep") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ENDPOINT) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1605635l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(49) - .setClassName("SpanMemberToRefRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1638402l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1638403l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1638401l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(50) - .setClassName("SpanMemberFromRefRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149154887l)) - .setPropName("EpdrLocalL2Ep") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(71l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(51) - .setClassName("EpdrL2Discovered") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149187656l)) - .setPropName("EpdrLocalL3Ep") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(72l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(52) - .setClassName("EpdrL3Discovered") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149285926l)) - .setPropName("EprL2Ep") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(38l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(55) - .setClassName("EprL2Universe") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1835011l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(56) - .setClassName("EpdrEndPointToGroupRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1867778l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1867779l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1867777l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(57) - .setClassName("EpdrEndPointFromGroupRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149384239l)) - .setPropName("EprL3Ep") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(47l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(58) - .setClassName("EprL3Universe") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1933314l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1933313l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(59) - .setClassName("SpanMemberToRefRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("SpanDirectionT"); - eib.setEnumValue("both", new BigInteger(String.valueOf(3))); - eib.setEnumValue("in", new BigInteger(String.valueOf(1))); - eib.setEnumValue("out", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1966082l)) - .setPropName("dir") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1966081l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149449777l)) - .setPropName("SpanMemberToRefRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(49l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(60) - .setClassName("SpanSrcMember") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(1998849l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149482545l)) - .setPropName("SpanMemberToRefRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(49l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149482558l)) - .setPropName("SpanDstSummary") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(62l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(61) - .setClassName("SpanDstMember") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2031617l)) - .setPropName("dest") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2031624l)) - .setPropName("dscp") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2031620l)) - .setPropName("flowId") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("SpanErspanDestModeT"); - eib.setEnumValue("notVisible", new BigInteger(String.valueOf(2))); - eib.setEnumValue("visible", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2031625l)) - .setPropName("mode") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2031623l)) - .setPropName("mtu") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2031618l)) - .setPropName("srcPrefix") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2031621l)) - .setPropName("ttl") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("SpanErspanVersionT"); - eib.setEnumValue("v1", new BigInteger(String.valueOf(1))); - eib.setEnumValue("v2", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2031619l)) - .setPropName("version") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2031622l)) - .setPropName("vrfName") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(62) - .setClassName("SpanDstSummary") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2097153l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149580865l)) - .setPropName("GbpSubject") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(65l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149580886l)) - .setPropName("GbpEpGroupFromProvContractRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(86l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149580891l)) - .setPropName("GbpEpGroupFromConsContractRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(91l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(64) - .setClassName("GbpContract") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2129921l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149613634l)) - .setPropName("GbpRule") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(66l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(65) - .setClassName("GbpSubject") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2162689l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2162690l)) - .setPropName("order") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149646403l)) - .setPropName("GbpRuleToClassifierRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(67l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(66) - .setClassName("GbpRule") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2195459l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(67) - .setClassName("GbpRuleToClassifierRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2228226l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2228227l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2228225l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(68) - .setClassName("GbpRuleFromClassifierRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2260994l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2260993l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(69) - .setClassName("GbpRuleToClassifierRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2293762l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2293761l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(70) - .setClassName("EpdrEndPointToGroupRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2326530l)) - .setPropName("mac") - .setType(PolicyPropertyInfo.PropertyType.MAC) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2326529l)) - .setPropName("uuid") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149810189l)) - .setPropName("GbpeEpgMappingCtx") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(13l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149810232l)) - .setPropName("EpdrEndPointToGroupRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(56l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(71) - .setClassName("EpdrLocalL2Ep") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2359299l)) - .setPropName("ip") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2359298l)) - .setPropName("mac") - .setType(PolicyPropertyInfo.PropertyType.MAC) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2359297l)) - .setPropName("uuid") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149842957l)) - .setPropName("GbpeEpgMappingCtx") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(13l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149843000l)) - .setPropName("EpdrEndPointToGroupRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(56l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(72) - .setClassName("EpdrLocalL3Ep") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2424834l)) - .setPropName("ipv6Autoconfig") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2424833l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149908492l)) - .setPropName("GbpeInstContext") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(12l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149908560l)) - .setPropName("GbpSubnetsFromNetworkRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(80l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149908563l)) - .setPropName("GbpEpGroupFromNetworkRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(83l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149908575l)) - .setPropName("GbpBridgeDomainFromNetworkRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(95l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(74) - .setClassName("GbpRoutingDomain") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2457602l)) - .setPropName("address") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2457606l)) - .setPropName("ipv6AdvAutonomousFlag") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2457607l)) - .setPropName("ipv6AdvPreferredLifetime") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2457605l)) - .setPropName("ipv6AdvValidLifetime") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2457601l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2457603l)) - .setPropName("prefixLen") - .setType(PolicyPropertyInfo.PropertyType.U64) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2457604l)) - .setPropName("virtualRouterIp") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(75) - .setClassName("GbpSubnet") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("GbpIntraGroupPolicyT"); - eib.setEnumValue("allow", new BigInteger(String.valueOf(0))); - eib.setEnumValue("require-contract", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2490370l)) - .setPropName("intraGroupPolicy") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2490369l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149974028l)) - .setPropName("GbpeInstContext") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(12l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149974066l)) - .setPropName("SpanMemberFromRefRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(50l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149974073l)) - .setPropName("EpdrEndPointFromGroupRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(57l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149974098l)) - .setPropName("GbpEpGroupToNetworkRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(82l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149974101l)) - .setPropName("GbpEpGroupToProvContractRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(85l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2149974106l)) - .setPropName("GbpEpGroupToConsContractRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(90l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(76) - .setClassName("GbpEpGroup") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2555905l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150039627l)) - .setPropName("GbpSubnet") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(75l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150039631l)) - .setPropName("GbpSubnetsToNetworkRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(79l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150039635l)) - .setPropName("GbpEpGroupFromNetworkRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(83l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(78) - .setClassName("GbpSubnets") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2588675l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(79) - .setClassName("GbpSubnetsToNetworkRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2621442l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2621443l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2621441l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(80) - .setClassName("GbpSubnetsFromNetworkRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2654210l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2654209l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(81) - .setClassName("GbpSubnetsToNetworkRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2686979l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(82) - .setClassName("GbpEpGroupToNetworkRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2719746l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2719747l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2719745l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(83) - .setClassName("GbpEpGroupFromNetworkRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2752514l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2752513l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(84) - .setClassName("GbpEpGroupToNetworkRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2785283l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(85) - .setClassName("GbpEpGroupToProvContractRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2818050l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2818051l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2818049l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(86) - .setClassName("GbpEpGroupFromProvContractRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2850817l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150334476l)) - .setPropName("GbpeInstContext") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(12l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150334544l)) - .setPropName("GbpSubnetsFromNetworkRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(80l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150334547l)) - .setPropName("GbpEpGroupFromNetworkRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(83l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150334552l)) - .setPropName("GbpBridgeDomainToNetworkRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(88l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150334563l)) - .setPropName("GbpFloodDomainFromNetworkRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(99l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(87) - .setClassName("GbpBridgeDomain") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2883587l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(88) - .setClassName("GbpBridgeDomainToNetworkRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2916354l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2916353l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(89) - .setClassName("GbpEpGroupToProvContractRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2949123l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(90) - .setClassName("GbpEpGroupToConsContractRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2981890l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2981891l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2981889l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(91) - .setClassName("GbpEpGroupFromConsContractRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3014658l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3014657l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(92) - .setClassName("GbpEpGroupToConsContractRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3112962l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3112963l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3112961l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(95) - .setClassName("GbpBridgeDomainFromNetworkRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3145730l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3145729l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(96) - .setClassName("GbpBridgeDomainToNetworkRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("GbpAddressResModeT"); - eib.setEnumValue("drop", new BigInteger(String.valueOf(2))); - eib.setEnumValue("flood", new BigInteger(String.valueOf(1))); - eib.setEnumValue("unicast", new BigInteger(String.valueOf(0))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3178498l)) - .setPropName("arpMode") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3178497l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("GbpAddressResModeT"); - eib.setEnumValue("drop", new BigInteger(String.valueOf(2))); - eib.setEnumValue("flood", new BigInteger(String.valueOf(1))); - eib.setEnumValue("unicast", new BigInteger(String.valueOf(0))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3178499l)) - .setPropName("neighborDiscMode") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("GbpUnknownFloodModeT"); - eib.setEnumValue("drop", new BigInteger(String.valueOf(0))); - eib.setEnumValue("flood", new BigInteger(String.valueOf(1))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3178500l)) - .setPropName("unknownFloodMode") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150662161l)) - .setPropName("GbpeFloodContext") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(17l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150662224l)) - .setPropName("GbpSubnetsFromNetworkRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(80l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150662227l)) - .setPropName("GbpEpGroupFromNetworkRTgt") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(83l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150662242l)) - .setPropName("GbpFloodDomainToNetworkRSrc") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(98l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(97) - .setClassName("GbpFloodDomain") - .setPolicyType(PolicyClassInfo.PolicyClassType.POLICY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3211267l)) - .setPropName("target") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(98) - .setClassName("GbpFloodDomainToNetworkRSrc") - .setPolicyType(PolicyClassInfo.PolicyClassType.RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3244034l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3244035l)) - .setPropName("source") - .setType(PolicyPropertyInfo.PropertyType.REFERENCE) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3244033l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(99) - .setClassName("GbpFloodDomainFromNetworkRTgt") - .setPolicyType(PolicyClassInfo.PolicyClassType.REVERSE_RELATIONSHIP) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - eib = new EnumInfoBuilder(); - eib.setName("RelatorRoleT"); - eib.setEnumValue("resolver", new BigInteger(String.valueOf(4))); - eib.setEnumValue("source", new BigInteger(String.valueOf(1))); - eib.setEnumValue("target", new BigInteger(String.valueOf(2))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3276802l)) - .setPropName("role") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName("RelatorTypeT"); - eib.setEnumValue("direct-association", new BigInteger(String.valueOf(1))); - eib.setEnumValue("direct-dependency", new BigInteger(String.valueOf(3))); - eib.setEnumValue("named-association", new BigInteger(String.valueOf(2))); - eib.setEnumValue("named-dependency", new BigInteger(String.valueOf(4))); - eib.setEnumValue("reference", new BigInteger(String.valueOf(8))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3276801l)) - .setPropName("type") - .setType(PolicyPropertyInfo.PropertyType.ENUM8) - .setEnumInfo(ei) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(100) - .setClassName("GbpFloodDomainToNetworkRRes") - .setPolicyType(PolicyClassInfo.PolicyClassType.RESOLVER) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150826000l)) - .setPropName("DfwEpCounter") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(16l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2150826003l)) - .setPropName("GbpeEpCounter") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(19l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(102) - .setClassName("ObserverEpStatUniverse") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2151251977l)) - .setPropName("PlatformConfig") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(9l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2151251978l)) - .setPropName("GbpeEpgMapping") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(10l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2151252084l)) - .setPropName("PolicySpace") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(116l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(115) - .setClassName("PolicyUniverse") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(3801089l)) - .setPropName("name") - .setType(PolicyPropertyInfo.PropertyType.STRING) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2151284754l)) - .setPropName("GbpeL24Classifier") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(18l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2151284800l)) - .setPropName("GbpContract") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(64l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2151284810l)) - .setPropName("GbpRoutingDomain") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(74l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2151284812l)) - .setPropName("GbpEpGroup") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(76l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2151284814l)) - .setPropName("GbpSubnets") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(78l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2151284823l)) - .setPropName("GbpBridgeDomain") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(87l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(2151284833l)) - .setPropName("GbpFloodDomain") - .setType(PolicyPropertyInfo.PropertyType.COMPOSITE) - .setClassId(97l) - .setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(116) - .setClassName("PolicySpace") - .setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY) - .setProperty(ppil) - .setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIdToString.put(Long.valueOf(pci.getClassId()), pci.getClassName()); - - metaDataMap = Collections.unmodifiableMap(metaData); - classIdToStringMap = Collections.unmodifiableMap(classIdToString); - } - - @Override - public PolicyClassInfo getClass(String name) { - return metaDataMap.get(name); - } - - @Override - public PolicyClassInfo getClass(Long classId) { - String className = classIdToStringMap.get(classId); - if (className == null) - return null; - return metaDataMap.get(className); - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/EnumInfo.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/EnumInfo.java deleted file mode 100644 index 1de78c9e1..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/EnumInfo.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Map; - -/** - * An object that represents an enum in the MIT's - * PropertyInfo object map - * - * @author tbachman - */ -public interface EnumInfo { - - /** - * Get the name of the enum as it appears in the MIT's - * PropertyInfo map. - * - * @return - */ - public String getName(); - - /** - * Get the Integer representation of the value by name - * for the enum - * - * @param name - * @return - */ - public BigInteger getEnumValue(String name); - - public String getEnumValue(BigInteger value); - - /** - * Class for building immutable EnumInfo objects - * - * @author tbachman - */ - public static class EnumInfoBuilder { - - private String name; - private final Map enumValuesByString = new HashMap<>(); - private final Map enumValuesByInt = new HashMap<>(); - - public EnumInfoBuilder() { - } - - /** - * Set the name of the EnumInfo object - * - * @param name - * @return - */ - public EnumInfoBuilder setName(String name) { - this.name = name; - return this; - } - - /** - * Add a name/value pair to the enum, where - * value is an Integer object - * - * @param name - * @param value - * @return - */ - public EnumInfoBuilder setEnumValue(String name, BigInteger value) { - this.enumValuesByString.put(name, value); - this.enumValuesByInt.put(value, name); - return this; - } - - public EnumInfo build() { - return new EnumInfoImpl(this); - } - - public static class EnumInfoImpl implements EnumInfo { - - private final String name; - private final Map enumValuesByString; - private final Map enumValuesByInt; - - public EnumInfoImpl(EnumInfoBuilder builder) { - this.name = builder.name; - this.enumValuesByString = builder.enumValuesByString; - this.enumValuesByInt = builder.enumValuesByInt; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public BigInteger getEnumValue(String name) { - return this.enumValuesByString.get(name); - } - - @Override - public String getEnumValue(BigInteger value) { - return this.enumValuesByInt.get(value); - } - } - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/MitLib.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/MitLib.java deleted file mode 100644 index 714c1cf0d..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/MitLib.java +++ /dev/null @@ -1,475 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.ManagedObject; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class MitLib { - - protected static final Logger LOG = LoggerFactory.getLogger(MitLib.class); - private final ObjectMapper objectMapper; - private final JsonNodeFactory jnf; - - @JsonSerialize - public static class Reference { - - String subject; - String reference_uri; - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public String getReference_uri() { - return reference_uri; - } - - public void setReference_uri(String reference_uri) { - this.reference_uri = reference_uri; - } - - } - - public MitLib() { - objectMapper = new ObjectMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - jnf = objectMapper.getNodeFactory(); - } - - public static final String REFERENCE_SUBJECT = "subject"; - public static final String REFERENCE_URI = "reference_uri"; - - public BigInteger deserializeMoPropertyEnum(JsonNode node, PolicyPropertyInfo ppi) { - - EnumInfo ei = ppi.getEnumInfo(); - return ei.getEnumValue(node.asText()); - } - - public String serializeMoPropertyEnum(PolicyPropertyInfo ppi, PolicyObjectInstance poi) { - - EnumInfo ei = ppi.getEnumInfo(); - return ei.getEnumValue(poi.getUint64(ppi.getPropId())); - } - - /** - * Deserialize a REFERENCE property - * - * @param node - * @return - */ - public PolicyObjectInstance.PolicyReference deserializeMoPropertyRef(JsonNode node, OpflexMit mit) { - - JsonNode sn = node.findValue(REFERENCE_SUBJECT); - if (sn == null) - return null; - JsonNode un = node.findValue(REFERENCE_URI); - if (un == null) - return null; - - PolicyClassInfo pci = mit.getClass(sn.asText()); - if (pci == null) - return null; - - return new PolicyObjectInstance.PolicyReference(pci.getClassId(), new Uri(un.asText())); - - } - - /** - * Serialize a REFERENCE property - * - * @param reference - * @param mit - * @return - */ - public ObjectNode serializeMoPropertyRef(PolicyObjectInstance.PolicyReference reference, OpflexMit mit) { - - ObjectNode on = jnf.objectNode(); - PolicyClassInfo pci = mit.getClass(reference.getClassId()); - if (pci == null) - return null; - PolicyUri puri = new PolicyUri(reference.getUri().getValue()); - // walk our way up until we find a valid class - String identifier = puri.pop(); - while (mit.getClass(identifier) == null) { - identifier = puri.pop(); - } - on.put(REFERENCE_SUBJECT, identifier); - on.put(REFERENCE_URI, reference.getUri().getValue()); - return on; - } - - /** - * Take the {@link ManagedObject} and deserialize the properties - * into a concrete type to be used by the renderer. It also - * adds URIs for any children that are referenced in the - * properties to the MO's "children" array. - * - * @param mo - */ - public PolicyObjectInstance deserializeMoProperties(ManagedObject mo, OpflexMit mit) { - - /* - * The subject gives us the class to use for the schema - */ - PolicyClassInfo pci = mit.getClass(mo.getSubject()); - - // sanity checks - if (pci == null) - return null; - - PolicyObjectInstance poi = new PolicyObjectInstance(pci.getClassId()); - - if (mo.getProperties() == null) - return poi; - - for (ManagedObject.Property prop : mo.getProperties()) { - PolicyPropertyInfo ppi = pci.getProperty(prop.getName()); - if ((ppi == null) || (prop.getData() == null)) - continue; - - JsonNode node = prop.getData(); - - boolean vectored = false; - if (ppi.getPropCardinality().equals(PolicyPropertyInfo.PropertyCardinality.VECTOR)) { - vectored = true; - } - switch (ppi.getType()) { - case STRING: - if (vectored) { - if (!node.isArray()) - continue; - - List sl = new ArrayList(); - for (int i = 0; i < node.size(); i++) { - JsonNode jn = node.get(i); - if (!jn.isTextual()) - continue; - - sl.add(jn.asText()); - } - poi.setString(ppi.getPropId(), sl); - } else { - if (!node.isTextual()) - continue; - - poi.setString(ppi.getPropId(), node.asText()); - } - break; - - case U64: - if (vectored) { - if (!node.isArray()) - continue; - - List bil = new ArrayList(); - - for (int i = 0; i < node.size(); i++) { - JsonNode jn = node.get(i); - if (!jn.isBigInteger()) - continue; - - bil.add(new BigInteger(jn.asText())); - } - poi.setUint64(ppi.getPropId(), bil); - } else { - if (!node.isBigInteger()) - continue; - - poi.setUint64(ppi.getPropId(), new BigInteger(node.asText())); - } - break; - - case S64: - if (vectored) { - if (!node.isArray()) - continue; - - List ll = new ArrayList(); - - for (int i = 0; i < node.size(); i++) { - JsonNode jn = node.get(i); - - if (!jn.isBigInteger()) - continue; - - ll.add(jn.asLong()); - } - poi.setInt64(ppi.getPropId(), ll); - } else { - if (!node.isBigInteger()) - continue; - - poi.setInt64(ppi.getPropId(), node.asLong()); - } - break; - - case REFERENCE: - if (vectored) { - if (!node.isArray()) - continue; - - List prl = new ArrayList(); - - for (int i = 0; i < node.size(); i++) { - JsonNode jn = node.get(i); - PolicyObjectInstance.PolicyReference pr = deserializeMoPropertyRef(jn, mit); - if (pr == null) - continue; - - prl.add(pr); - } - poi.setReference(ppi.getPropId(), prl); - } else { - PolicyObjectInstance.PolicyReference pr = deserializeMoPropertyRef(node, mit); - if (pr == null) - continue; - - poi.setReference(ppi.getPropId(), pr); - } - break; - - case ENUM8: - case ENUM16: - case ENUM32: - case ENUM64: - if (vectored) { - if (!node.isArray()) - continue; - - List bil = new ArrayList(); - - for (int i = 0; i < node.size(); i++) { - JsonNode jn = node.get(i); - if (!jn.isTextual()) - continue; - BigInteger bi = deserializeMoPropertyEnum(node, ppi); - - bil.add(bi); - } - poi.setUint64(ppi.getPropId(), bil); - } else { - if (!node.isTextual()) - continue; - - BigInteger bi = deserializeMoPropertyEnum(node, ppi); - poi.setUint64(ppi.getPropId(), bi); - } - break; - - case MAC: - if (vectored) { - if (!node.isArray()) - continue; - - List ml = new ArrayList(); - - for (int i = 0; i < node.size(); i++) { - JsonNode jn = node.get(i); - - if (!jn.isTextual()) - continue; - - ml.add(new MacAddress(jn.asText())); - } - poi.setMacAddress(ppi.getPropId(), ml); - } else { - if (!node.isTextual()) - continue; - - poi.setMacAddress(ppi.getPropId(), new MacAddress(node.asText())); - } - break; - - case COMPOSITE: - - } - - } - - return poi; - } - - /** - * Serialize the properties contained in the {@link PolicyObjectInstance} into the properties - * field of the {@link ManagedObject} - * - * @param pci - * @param poi - * @param mo - * @param mit - */ - public void serializeMoProperties(PolicyClassInfo pci, PolicyObjectInstance poi, ManagedObject mo, OpflexMit mit) { - - List ppil = pci.getProperties(); - if (ppil == null) - return; - - List pl = new ArrayList(); - - /* - * For serialization of values, we can cheat a bit, - * as the native "toString" method gives us exactly - * the formatting we need (including vectors). - */ - for (PolicyPropertyInfo ppi : ppil) { - /* - * Skip any properties that aren't populated for this - * object instance - */ - if (ppi.getType() != PolicyPropertyInfo.PropertyType.COMPOSITE - && !poi.isSet(ppi.getPropId(), ppi.getType(), ppi.getPropCardinality())) { - continue; - } - ManagedObject.Property p = null; - boolean scalar = true; - - if (ppi.getPropCardinality() == PolicyPropertyInfo.PropertyCardinality.VECTOR) { - scalar = false; - } - - switch (ppi.getType()) { - case STRING: - p = new ManagedObject.Property(); - p.setName(ppi.getPropName()); - if (scalar) { - JsonNode jn = jnf.textNode(poi.getString(ppi.getPropId())); - p.setData(jn); - } else { - int len = poi.getStringSize(ppi.getPropId()); - ArrayNode an = jnf.arrayNode(); - for (int i = 0; i < len; i++) { - an.add(poi.getString(ppi.getPropId(), i)); - } - p.setData(an); - } - break; - - case S64: - p = new ManagedObject.Property(); - p.setName(ppi.getPropName()); - if (scalar) { - JsonNode jn = jnf.numberNode(poi.getInt64(ppi.getPropId())); - p.setData(jn); - } else { - int len = poi.getInt64Size(ppi.getPropId()); - ArrayNode an = jnf.arrayNode(); - for (int i = 0; i < len; i++) { - an.add(Long.valueOf(poi.getInt64(ppi.getPropId(), i))); - } - p.setData(an); - } - break; - - case ENUM8: - case ENUM16: - case ENUM32: - case ENUM64: - p = new ManagedObject.Property(); - p.setName(ppi.getPropName()); - if (scalar) { - JsonNode jn = jnf.textNode(serializeMoPropertyEnum(ppi, poi)); - p.setData(jn); - } else { - int len = poi.getUint64Size(ppi.getPropId()); - ArrayNode an = jnf.arrayNode(); - for (int i = 0; i < len; i++) { - an.add(serializeMoPropertyEnum(ppi, poi)); - } - p.setData(an); - } - break; - - case U64: - p = new ManagedObject.Property(); - p.setName(ppi.getPropName()); - if (scalar) { - JsonNode jn = jnf.numberNode(poi.getUint64(ppi.getPropId())); - p.setData(jn); - } else { - int len = poi.getUint64Size(ppi.getPropId()); - ArrayNode an = jnf.arrayNode(); - for (int i = 0; i < len; i++) { - an.numberNode(poi.getUint64(ppi.getPropId())); - } - p.setData(an); - } - break; - - case MAC: - p = new ManagedObject.Property(); - p.setName(ppi.getPropName()); - if (scalar) { - MacAddress mac = poi.getMacAddress(ppi.getPropId()); - JsonNode jn = jnf.textNode(mac.getValue()); - p.setData(jn); - } else { - int len = poi.getMacAddressSize(ppi.getPropId()); - ArrayNode an = jnf.arrayNode(); - for (int i = 0; i < len; i++) { - MacAddress mac = poi.getMacAddress(ppi.getPropId()); - an.add(mac.getValue()); - } - p.setData(an); - } - break; - - case REFERENCE: - p = new ManagedObject.Property(); - p.setName(ppi.getPropName()); - if (scalar) { - ObjectNode on = serializeMoPropertyRef(poi.getReference(ppi.getPropId()), mit); - p.setData(on); - } else { - int len = poi.getReferenceSize(ppi.getPropId()); - ArrayNode an = jnf.arrayNode(); - for (int i = 0; i < len; i++) { - ObjectNode on = serializeMoPropertyRef(poi.getReference(ppi.getPropId(), i), mit); - an.add(on); - } - p.setData(an); - } - break; - - case COMPOSITE: - /* - * Get the URI to add to the list of children - */ - break; - - default: - - } - if (p != null) { - pl.add(p); - } - } - - mo.setProperties(pl); - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/OpflexMit.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/OpflexMit.java deleted file mode 100644 index 756264b2b..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/OpflexMit.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -/** - * Interface for interacting with the MIT, regardless of the - * nature of the actual MIT. - * - * @author tbachman - */ -public interface OpflexMit { - - /** - * Get a ClassInfo object from the MIT by name - * - * @param name - * @return - */ - public PolicyClassInfo getClass(String name); - - /** - * Get a ClassInfo object from the MIT by class ID - * - * @param classId - * @return - */ - public PolicyClassInfo getClass(Long classId); - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyClassInfo.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyClassInfo.java deleted file mode 100644 index a81c9f5fe..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyClassInfo.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyId; - -/** - * Class that provides Managed Object metadata. The {@link PolicyClassInfo} object contains metadata - * about - * the Managed Object, while the {@link PolicyPropertyInfo} list - * contained by this object provides the metadata about the - * Managed Object properties. - * This data must be kept consistent with the agents. - * - * @author tbachman - */ -public interface PolicyClassInfo { - - static public enum PolicyClassType { - POLICY("policy"), REMOTE_ENDPOINT("remote_endpoint"), LOCAL_ENDPOINT("local_endpoint"), OBSERVABLE("observable"), LOCAL_ONLY( - "local_only"), RESOLVER("resolver"), RELATIONSHIP("relationship"), REVERSE_RELATIONSHIP( - "reverse_relationship"); - - private final String type; - - PolicyClassType(String type) { - this.type = type; - } - - @Override - public String toString() { - return this.type; - } - } - - /** - * Get the ID for the class - * - * @return - */ - public int getClassId(); - - /** - * Get the type for the class - * - * @return - */ - public PolicyClassType getPolicyType(); - - /** - * Get the name for the class - * - * @return - */ - public String getClassName(); - - /** - * Get a {@link PolicyPropertyInfo} object by name - * from the class. - * - * @param name - * @return - */ - public PolicyPropertyInfo getProperty(String name); - - /** - * Return the entire list of {@link PolicyPropertyInfo} objects for this class. - * - * @return - */ - public List getProperties(); - - /** - * Get a list of {@link PolicyPropertyId} objects, - * which are the keys to the {@link PolicyPropertyInfo} objects for this class. - * - * @return - */ - public List getKeys(); - - /** - * A builder class for create immutable instances of {@link PolicyClassInfo} objects. - * - * @author tbachman - */ - public static class PolicyClassInfoBuilder { - - private int classId; - private PolicyClassType policyType; - private String className; - private final Map properties = new HashMap<>(); - private final List keys = new ArrayList<>(); - - public PolicyClassInfoBuilder() { - } - - public int getClassId() { - return classId; - } - - public PolicyClassInfoBuilder setClassId(int classId) { - this.classId = classId; - return this; - } - - public PolicyClassType getPolicyType() { - return policyType; - } - - public PolicyClassInfoBuilder setPolicyType(PolicyClassType policyType) { - this.policyType = policyType; - return this; - } - - public String getClassName() { - return className; - } - - public PolicyClassInfoBuilder setClassName(String className) { - this.className = className; - return this; - } - - public PolicyClassInfoBuilder setProperty(List ppil) { - for (PolicyPropertyInfo ppi : ppil) { - this.properties.put(ppi.getPropName(), ppi); - } - return this; - } - - public PolicyClassInfoBuilder setKey(List pidl) { - this.keys.addAll(pidl); - return this; - } - - public PolicyClassInfo build() { - return new PolicyClassInfoImpl(this); - } - - private static final class PolicyClassInfoImpl implements PolicyClassInfo { - - private final int classId; - private final PolicyClassType policyType; - private final String className; - private final Map properties; - private final List keys; - - private PolicyClassInfoImpl(PolicyClassInfoBuilder builder) { - this.classId = builder.classId; - this.policyType = builder.policyType; - this.className = builder.className; - this.properties = builder.properties; - this.keys = builder.keys; - } - - @Override - public int getClassId() { - return classId; - } - - @Override - public PolicyClassType getPolicyType() { - return policyType; - } - - @Override - public String getClassName() { - return className; - } - - @Override - public PolicyPropertyInfo getProperty(String name) { - return properties.get(name); - } - - @Override - public List getProperties() { - return new ArrayList(properties.values()); - } - - @Override - public List getKeys() { - return keys; - } - } - } - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyObjectInstance.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyObjectInstance.java deleted file mode 100644 index 7e1cf3adc..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyObjectInstance.java +++ /dev/null @@ -1,791 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyId; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; - -/** - * This is a policy object instance, used to provide an abstraction - * between OpFlex messaging and the back-end policy. - * - * @author tbachman - */ -public class PolicyObjectInstance { - - /** - * An object used as a key for the property hash map. It - * consists of the tuple: { {@link PolicyPropertyId}, {@link PolicyPropertyInfo.PropertyType}, - * {@link PolicyPropertyInfo.PropertyCardinality} - * - * @author tbachman - */ - public static class PropertyKey { - - private final PolicyPropertyId propId; - private final PolicyPropertyInfo.PropertyType type; - private final PolicyPropertyInfo.PropertyCardinality cardinality; - - public PropertyKey(PolicyPropertyId propId, PolicyPropertyInfo.PropertyType type, - PolicyPropertyInfo.PropertyCardinality cardinality) { - this.propId = propId; - this.type = type; - this.cardinality = cardinality; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cardinality == null) ? 0 : cardinality.hashCode()); - result = prime * result + ((propId == null) ? 0 : propId.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PropertyKey other = (PropertyKey) obj; - if (cardinality != other.cardinality) - return false; - if (propId == null) { - if (other.propId != null) - return false; - } else if (!propId.equals(other.propId)) - return false; - if (type != other.type) - return false; - return true; - } - - } - - /** - * Class that contains a value held by the {@link PolicyObjectInstance}. - * The value can be scalar or vector in nature. - * - * @author tbachman - */ - public static class Value { - - private Object v; - private List vl; - private PolicyPropertyInfo.PropertyType type; - private PolicyPropertyInfo.PropertyCardinality cardinality; - - public void setPropertyType(PolicyPropertyInfo.PropertyType type) { - this.type = type; - } - - public void setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality cardinality) { - this.cardinality = cardinality; - } - - public void setValue(Object v) { - this.v = v; - } - - public void setValue(List vl) { - this.vl = vl; - } - - public Object getValue(int index) { - if (this.cardinality == PolicyPropertyInfo.PropertyCardinality.VECTOR) { - return this.vl.get(index); - } else { - return this.v; - } - } - - public PolicyPropertyInfo.PropertyType getType() { - return this.type; - } - } - - /** - * Class used as a reference to another PolicyObject. - * - * @author tbachman - */ - public static class PolicyReference { - - private final Uri uri; - private final long classId; - - public PolicyReference(long classId, Uri uri) { - this.uri = uri; - this.classId = classId; - } - - public Uri getUri() { - return this.uri; - } - - public long getClassId() { - return this.classId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (classId ^ (classId >>> 32)); - result = prime * result + ((uri == null) ? 0 : uri.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PolicyReference other = (PolicyReference) obj; - if (classId != other.classId) - return false; - if (uri == null) { - if (other.uri != null) - return false; - } else if (!uri.equals(other.uri)) - return false; - return true; - } - - } - - private final long classId; - private Uri uri; - private Uri parentUri; - private String parentSubject; - private String parentRelation; - private final List children = new ArrayList<>(); - private final Map propertyMap = new HashMap<>(); - - private PolicyPropertyInfo.PropertyType normalize(PolicyPropertyInfo.PropertyType type) { - switch (type) { - case ENUM8: - case ENUM16: - case ENUM32: - case ENUM64: - return PolicyPropertyInfo.PropertyType.U64; - default: - return type; - } - } - - public PolicyObjectInstance(long classId) { - this.classId = classId; - } - - /** - * Get the class ID for this object instance. - * - * @return the class ID - */ - public long getClassId() { - return this.classId; - } - - public Uri getUri() { - return uri; - } - - public void setUri(Uri uri) { - this.uri = uri; - } - - public void addChild(Uri childUri) { - children.add(childUri); - } - - public List getChildren() { - return this.children; - } - - public void setParent(Uri uri) { - this.parentUri = uri; - } - - public Uri getParent() { - return this.parentUri; - } - - public void setParentSubject(String subject) { - this.parentSubject = subject; - } - - public String getParentSubject() { - return this.parentSubject; - } - - public void setParentRelation(String relation) { - this.parentRelation = relation; - } - - public String getParentRelation() { - return this.parentRelation; - } - - /** - * Check whether the given property is set. If the property is - * vector-valued, this will return false if the vector is zero length - * - * @param propId - * @param type - * @param cardinality - * @return true if set, false if not set or zero length vector - */ - public boolean isSet(PolicyPropertyInfo.PolicyPropertyId propId, PolicyPropertyInfo.PropertyType type, - PolicyPropertyInfo.PropertyCardinality cardinality) { - type = normalize(type); - PropertyKey key = new PropertyKey(propId, type, cardinality); - return propertyMap.containsKey(key); - } - - /** - * Unset the given property. If it's a vector, the vector is - * emptied. If its a scalar, the scalar is unset. - * - * @param propId - * @param type - * @param cardinality - * @return true if the property was alread set before - */ - public boolean unset(PolicyPropertyInfo.PolicyPropertyId propId, PolicyPropertyInfo.PropertyType type, - PolicyPropertyInfo.PropertyCardinality cardinality) { - type = normalize(type); - PropertyKey key = new PropertyKey(propId, type, cardinality); - Value v = propertyMap.remove(key); - if (v == null) - return false; - return true; - } - - // getters - - /** - * Get the unsigned 64-bit valued property for prop_name. - * - * @param id - * @return null if not present or {@link BigInteger} - */ - public BigInteger getUint64(PolicyPropertyInfo.PolicyPropertyId id) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64, - PolicyPropertyInfo.PropertyCardinality.SCALAR); - return (BigInteger) propertyMap.get(key).getValue(0); - } - - /** - * For a vector-valued 64-bit unsigned property, get the specified - * property value at the specified index - * - * @param id - * @param index - * @return the property value - */ - public BigInteger getUint64(PolicyPropertyInfo.PolicyPropertyId id, int index) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - return (BigInteger) propertyMap.get(key).getValue(index); - } - - /** - * Get the number of unsigned 64-bit values for the specified - * property - * - * @param id - * @return the number of elements - */ - public int getUint64Size(PolicyPropertyInfo.PolicyPropertyId id) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - return v.vl.size(); - } - - /** - * Get the signed 64-bit valued property for prop_name. - * - * @param id - * @return the property value - */ - public long getInt64(PolicyPropertyInfo.PolicyPropertyId id) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64, - PolicyPropertyInfo.PropertyCardinality.SCALAR); - return (long) propertyMap.get(key).getValue(0); - } - - /** - * For a vector-valued 64-bit signed property, get the specified - * property value at the specified index - * - * @param id - * @param index - * @return the property value - */ - public long getInt64(PolicyPropertyInfo.PolicyPropertyId id, int index) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - return (long) propertyMap.get(key).getValue(index); - } - - /** - * Get the number of signed 64-bit values for the specified - * property - * - * @param id - * @return the number of elements - */ - public int getInt64Size(PolicyPropertyInfo.PolicyPropertyId id) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - return v.vl.size(); - } - - /** - * Get the string-valued property for prop_name. - * - * @param id - * @return the property value - */ - public String getString(PolicyPropertyInfo.PolicyPropertyId id) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING, - PolicyPropertyInfo.PropertyCardinality.SCALAR); - return (String) propertyMap.get(key).getValue(0); - } - - /** - * For a vector-valued string property, get the specified property - * value at the specified index - * - * @param id - * @param index - * @return the property value - */ - public String getString(PolicyPropertyInfo.PolicyPropertyId id, int index) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - return (String) propertyMap.get(key).getValue(index); - } - - /** - * Get the number of string values for the specified property - * - * @param id - * @return the number of elements - */ - public int getStringSize(PolicyPropertyInfo.PolicyPropertyId id) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - return v.vl.size(); - } - - /** - * Get the reference-valued property for prop_name. - * - * @param id - * @return the property value - */ - public PolicyReference getReference(PolicyPropertyInfo.PolicyPropertyId id) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE, - PolicyPropertyInfo.PropertyCardinality.SCALAR); - return (PolicyReference) propertyMap.get(key).getValue(0); - } - - /** - * For a vector-valued reference property, get the specified property - * value at the specified index - * - * @param id - * @param index - * @return the property value - */ - public PolicyReference getReference(PolicyPropertyInfo.PolicyPropertyId id, int index) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - return (PolicyReference) propertyMap.get(key).getValue(index); - } - - /** - * Get the number of reference values for the specified property - * - * @param id - * @return the number of elements - */ - public int getReferenceSize(PolicyPropertyInfo.PolicyPropertyId id) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - return v.vl.size(); - } - - /** - * Get the MAC-address-valued property for prop_name. - * - * @param id - * @return the property value - */ - public MacAddress getMacAddress(PolicyPropertyInfo.PolicyPropertyId id) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC, - PolicyPropertyInfo.PropertyCardinality.SCALAR); - return (MacAddress) propertyMap.get(key).getValue(0); - } - - /** - * For a vector-valued MAC address property, get the specified - * property value at the specified index - * - * @param id - * @param index - * @return the property value - */ - public MacAddress getMacAddress(PolicyPropertyInfo.PolicyPropertyId id, int index) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - return (MacAddress) propertyMap.get(key).getValue(index); - } - - /** - * Get the number of MAC address values for the specified - * property - * - * @param id - * @return the number of elements - */ - public int getMacAddressSize(PolicyPropertyInfo.PolicyPropertyId id) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - return v.vl.size(); - } - - // setters - /** - * Set the uint64-valued parameter to the specified value. - * - * @param id - * @param bi - */ - public void setUint64(PolicyPropertyInfo.PolicyPropertyId id, BigInteger bi) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64, - PolicyPropertyInfo.PropertyCardinality.SCALAR); - Value v = propertyMap.get(key); - if (v == null) - v = new Value(); - propertyMap.put(key, v); - - v.setPropertyType(PolicyPropertyInfo.PropertyType.U64); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - v.setValue(bi); - } - - /** - * Set the uint64-vector-valued parameter to the specified value. - * - * @param id - * @param bil - */ - public void setUint64(PolicyPropertyInfo.PolicyPropertyId id, List bil) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - if (v == null) - v = new Value(); - propertyMap.put(key, v); - - v.setPropertyType(PolicyPropertyInfo.PropertyType.U64); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - v.setValue(bil); - - } - - /** - * Set the int64-valued parameter to the specified value. - * - * @param id - * @param li - */ - public void setInt64(PolicyPropertyInfo.PolicyPropertyId id, long li) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64, - PolicyPropertyInfo.PropertyCardinality.SCALAR); - Value v = propertyMap.get(key); - if (v == null) - v = new Value(); - propertyMap.put(key, v); - - v.setPropertyType(PolicyPropertyInfo.PropertyType.S64); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - v.setValue(li); - - } - - /** - * Set the int64-vector-valued parameter to the specified value. - * - * @param id - * @param ll - */ - public void setInt64(PolicyPropertyInfo.PolicyPropertyId id, List ll) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - if (v == null) - v = new Value(); - propertyMap.put(key, v); - - v.setPropertyType(PolicyPropertyInfo.PropertyType.S64); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - v.setValue(ll); - - } - - /** - * Set the string-valued parameter to the specified value. - * - * @param id - * @param s - */ - public void setString(PolicyPropertyInfo.PolicyPropertyId id, String s) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING, - PolicyPropertyInfo.PropertyCardinality.SCALAR); - Value v = propertyMap.get(key); - if (v == null) - v = new Value(); - propertyMap.put(key, v); - - v.setPropertyType(PolicyPropertyInfo.PropertyType.STRING); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - v.setValue(s); - - } - - /** - * Set the string-vector-valued parameter to the specified vector. - * - * @param id - * @param sl - */ - public void setString(PolicyPropertyInfo.PolicyPropertyId id, List sl) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - if (v == null) - v = new Value(); - propertyMap.put(key, v); - - v.setPropertyType(PolicyPropertyInfo.PropertyType.STRING); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - v.setValue(sl); - - } - - /** - * Set the reference-valued parameter to the specified value. - * - * @param id - * @param pr - */ - public void setReference(PolicyPropertyInfo.PolicyPropertyId id, PolicyReference pr) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE, - PolicyPropertyInfo.PropertyCardinality.SCALAR); - Value v = propertyMap.get(key); - if (v == null) - v = new Value(); - propertyMap.put(key, v); - - v.setPropertyType(PolicyPropertyInfo.PropertyType.REFERENCE); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - v.setValue(pr); - - } - - /** - * Set the reference-vector-valued parameter to the specified - * vector. - * - * @param id - * @param prl - */ - public void setReference(PolicyPropertyInfo.PolicyPropertyId id, List prl) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - if (v == null) - v = new Value(); - propertyMap.put(key, v); - - v.setPropertyType(PolicyPropertyInfo.PropertyType.REFERENCE); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - v.setValue(prl); - - } - - /** - * Set the MAC address-valued parameter to the specified value. - * - * @param id - * @param mac - */ - public void setMacAddress(PolicyPropertyInfo.PolicyPropertyId id, MacAddress mac) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC, - PolicyPropertyInfo.PropertyCardinality.SCALAR); - Value v = propertyMap.get(key); - if (v == null) - v = new Value(); - propertyMap.put(key, v); - - v.setPropertyType(PolicyPropertyInfo.PropertyType.MAC); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - v.setValue(mac); - - } - - /** - * Set the MAC address-vector-valued parameter to the specified value. - * - * @param id - * @param macList - */ - public void setMacAddress(PolicyPropertyInfo.PolicyPropertyId id, List macList) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - if (v == null) - v = new Value(); - propertyMap.put(key, v); - - v.setPropertyType(PolicyPropertyInfo.PropertyType.MAC); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - v.setValue(macList); - - } - - /** - * Add a value to a the specified unsigned 64-bit vector. - * - * @param id - * @param bi - */ - public void addUint64(PolicyPropertyInfo.PolicyPropertyId id, BigInteger bi) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.U64, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - if (v == null) { - v = new Value(); - v.setPropertyType(PolicyPropertyInfo.PropertyType.U64); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - List bil = new ArrayList(); - v.setValue(bil); - propertyMap.put(key, v); - } - v.vl.add(bi); - } - - /** - * Add a value to a the specified signed 64-bit vector. - * - * @param id - * @param li - */ - public void addInt64(PolicyPropertyInfo.PolicyPropertyId id, long li) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.S64, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - if (v == null) { - v = new Value(); - v.setPropertyType(PolicyPropertyInfo.PropertyType.U64); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - List ll = new ArrayList(); - v.setValue(ll); - propertyMap.put(key, v); - } - v.vl.add(li); - } - - /** - * Add a value to a the specified string vector. - * - * @param id - * @param s - */ - public void addString(PolicyPropertyInfo.PolicyPropertyId id, String s) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.STRING, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - if (v == null) { - v = new Value(); - v.setPropertyType(PolicyPropertyInfo.PropertyType.STRING); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - List sl = new ArrayList(); - v.setValue(sl); - propertyMap.put(key, v); - } - v.vl.add(s); - } - - /** - * Add a value to a the specified reference vector. - * - * @param id - * @param pr - */ - public void addReference(PolicyPropertyInfo.PolicyPropertyId id, PolicyReference pr) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.REFERENCE, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - if (v == null) { - v = new Value(); - v.setPropertyType(PolicyPropertyInfo.PropertyType.REFERENCE); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - List prl = new ArrayList(); - v.setValue(prl); - propertyMap.put(key, v); - } - v.vl.add(pr); - - } - - /** - * Add a value to a the specified MAC address vector. - * - * @param id - * @param mac - */ - public void addMacAddress(PolicyPropertyInfo.PolicyPropertyId id, MacAddress mac) { - PropertyKey key = new PropertyKey(id, PolicyPropertyInfo.PropertyType.MAC, - PolicyPropertyInfo.PropertyCardinality.VECTOR); - Value v = propertyMap.get(key); - if (v == null) { - v = new Value(); - v.setPropertyType(PolicyPropertyInfo.PropertyType.MAC); - v.setPropertyCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - List ml = new ArrayList(); - v.setValue(ml); - propertyMap.put(key, v); - } - v.vl.add(mac); - - } -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyPropertyInfo.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyPropertyInfo.java deleted file mode 100644 index 7b7fa2353..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyPropertyInfo.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -/** - * Class containing metadata used to describe - * properties contained by an OpFlex Managed Object - * - * @author tbachman - */ -public interface PolicyPropertyInfo { - - /** - * enum that represents possible Property types - * - * @author tbachman - */ - static public enum PropertyType { - COMPOSITE("composite"), REFERENCE("reference"), STRING("string"), S64("s64"), U64("u64"), MAC("mac"), ENUM8( - "enum8"), ENUM16("enum16"), ENUM32("enum32"), ENUM64("enum64"); - - private final String type; - - PropertyType(String type) { - this.type = type; - } - - @Override - public String toString() { - return this.type; - } - } - - /** - * enum that represents the possible cardinalities of a Property - * - * @author tbachman - */ - static public enum PropertyCardinality { - SCALAR("scalar"), VECTOR("vector"); - - private final String cardinality; - - PropertyCardinality(String cardinality) { - this.cardinality = cardinality; - } - - @Override - public String toString() { - return this.cardinality; - } - } - - /** - * The unique local ID assigned to this Property - * - * @author tbachman - */ - static public class PolicyPropertyId { - - private final long propertyId; - - public PolicyPropertyId(long propertyId) { - this.propertyId = propertyId; - } - - public long getPropertyId() { - return propertyId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (propertyId ^ (propertyId >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PolicyPropertyId other = (PolicyPropertyId) obj; - if (propertyId != other.propertyId) - return false; - return true; - } - - } - - public static class PolicyPropertyInfoBuilder { - - private long classId; - private PropertyType type; - private PolicyPropertyId propId; - private PropertyCardinality propCardinality; - private String propName; - private EnumInfo enumInfo; - - public PolicyPropertyInfoBuilder setClassId(long classId) { - this.classId = classId; - return this; - } - - public PolicyPropertyInfoBuilder setType(PropertyType type) { - this.type = type; - return this; - } - - public PolicyPropertyInfoBuilder setPropId(PolicyPropertyId propId) { - this.propId = propId; - return this; - } - - public PolicyPropertyInfoBuilder setPropCardinality(PropertyCardinality propCardinality) { - this.propCardinality = propCardinality; - return this; - } - - public PolicyPropertyInfoBuilder setPropName(String propName) { - this.propName = propName; - return this; - } - - public PolicyPropertyInfoBuilder setEnumInfo(EnumInfo enumInfo) { - this.enumInfo = enumInfo; - return this; - } - - public PolicyPropertyInfo build() { - return new PolicyPropertyInfoImpl(this); - } - - private static final class PolicyPropertyInfoImpl implements PolicyPropertyInfo { - - /* - * The classId is only used in COMPOSITE properties - */ - private final long classId; - private final PropertyType type; - private final PolicyPropertyId propId; - private final PropertyCardinality propCardinality; - private final String propName; - private final EnumInfo enumInfo; - - public PolicyPropertyInfoImpl(PolicyPropertyInfoBuilder builder) { - this.classId = builder.classId; - this.type = builder.type; - this.propId = builder.propId; - this.propCardinality = builder.propCardinality; - this.propName = builder.propName; - this.enumInfo = builder.enumInfo; - - } - - @Override - public long getClassId() { - return classId; - } - - @Override - public PropertyType getType() { - return type; - } - - @Override - public PolicyPropertyId getPropId() { - return propId; - } - - @Override - public PropertyCardinality getPropCardinality() { - return propCardinality; - } - - @Override - public String getPropName() { - return propName; - } - - @Override - public EnumInfo getEnumInfo() { - return enumInfo; - } - } - - } - - /** - * Get the class of the {@link PolicyPropertyInfo} object - * - * @return - */ - public long getClassId(); - - /** - * Get the type of the {@link PolicyPropertyInfo} object - * - * @return - */ - public PropertyType getType(); - - /** - * Get the ID of the {@link PolicyPropertyInfo} object - * - * @return - */ - public PolicyPropertyId getPropId(); - - /** - * Get the cardinality of the {@link PolicyPropertyInfo} object - * - * @return - */ - public PropertyCardinality getPropCardinality(); - - /** - * Get the name of the {@link PolicyPropertyInfo} object - * - * @return - */ - public String getPropName(); - - /** - * Get the {@link EnumInfo} object for the {@link PolicyPropertyInfo} object, if present - * - * @return - */ - public EnumInfo getEnumInfo(); - -} diff --git a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyUri.java b/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyUri.java deleted file mode 100644 index 672dd3458..000000000 --- a/renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyUri.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; - -/** - * Class used for building and extending URIs - * Returning the URI could be optimized by building this - * as we go, rather than building it when requested. - * This counts and levels used in this class are for - * the level of hierarchy, and do not include any - * separator characters ("/"). For example, the following - * URI: - * /tenants/tenant/51134b1e-6047-4d51-8d07-4135afd3672f - * has 3 levels. - * - * @author tbachman - */ -public class PolicyUri { - - public final static String POLICY_URI_SEP = "/"; - - private List uri; - - public PolicyUri() { - uri = new ArrayList(); - } - - /** - * Copy Constructor - * - * @param policyUri - */ - public PolicyUri(PolicyUri policyUri) { - this.uri = new ArrayList(policyUri.uri); - } - - /** - * Constructor using a full string, which gets split - * into it's elements. - * - * @param uri - */ - public PolicyUri(String uri) { - String[] tmpUri = uri.split(PolicyUri.POLICY_URI_SEP); - if (tmpUri.length > 0) { - this.uri = new ArrayList(); - // gets rid of leading empty element - for (int i = 1; i < tmpUri.length; i++) { - this.push(tmpUri[i]); - } - } else { - this.uri = null; - } - } - - /** - * Constructor using a list of URI elements, which - * excludes separator characters - * - * @param tokens - */ - public PolicyUri(List tokens) { - if (tokens.size() > 0) { - this.uri = new ArrayList(); - for (String t : tokens) { - this.push(t); - } - } - } - - /** - * Return the URI as a Uri object, including - * separator characters - * - * @return - */ - public Uri getUri() { - return new Uri(this.toString()); - } - - /** - * Push a new leaf on to the URI - * - * @param leaf - */ - public void push(String leaf) { - uri.add(POLICY_URI_SEP); - uri.add(leaf); - } - - /** - * Returns the String representation of parent object URI - * - * @return - */ - public String getParent() { - if (uri.size() == 0) - return null; - - PolicyUri parentUri = new PolicyUri(this); - parentUri.pop(); - return parentUri.toString(); - - } - - /** - * Remove (and return) the leaf of the URI. - * Never pop off the "/" root element. - * - * @return - */ - public String pop() { - if (uri.size() <= 0) { - return null; - } else { - // remove the node - String s = uri.remove(uri.size() - 1); - // remove the separator - uri.remove(uri.size() - 1); - // return just the node - return s; - } - } - - /** - * Determine if the URI is valid. - * - * @return - */ - public boolean valid() { - if (uri.size() > 0) { - return true; - } - return false; - } - - /** - * Get the element at depth "level". Returns - * null if level exceeds the hierarchy depth. - * - * @param level - * @return - */ - public String getElement(int level) { - if ((level * 2 + 1) > this.uri.size()) - return null; - - return this.uri.get(level * 2 + 1); - } - - /** - * Return the index of the first instance - * where the named element is found in the URI, - * starting the search from the root - * - * @param needle - * @return - */ - public int whichElement(String needle) { - return (this.uri.indexOf(needle) / 2); - } - - /** - * Return the number of levels in the parsed URI - * hierarchy - * - * @return - */ - public int totalElements() { - return (this.uri.size() / 2); - } - - /** - * Check to see if the parsed URI contains - * the named element in the hierarchy - * - * @param needle - * @return - */ - public boolean contains(String needle) { - return this.uri.contains(needle); - } - - public String originalPath() { - return this.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((uri == null) ? 0 : uri.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PolicyUri other = (PolicyUri) obj; - if (uri == null) { - if (other.uri != null) - return false; - } else if (!uri.equals(other.uri)) - return false; - return true; - } - - @Override - public String toString() { - if (uri.size() == 0) - return ""; - StringBuilder sb = new StringBuilder(); - - for (String s : uri) { - sb.append(s); - } - return sb.toString(); - } -} diff --git a/renderers/opflex/src/main/yang/opflex-provider-impl.yang b/renderers/opflex/src/main/yang/opflex-provider-impl.yang deleted file mode 100644 index 501ec10e7..000000000 --- a/renderers/opflex/src/main/yang/opflex-provider-impl.yang +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -module opflex-provider-impl { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:config:opflex-provider:impl"; - prefix "opflex-provider-impl"; - - import config { prefix config; revision-date 2013-04-05; } - import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } - - - description - "This module contains the base YANG definitions for - opflex-provider impl implementation."; - - revision "2014-06-11" { - description - "Initial revision."; - } - - identity opflex-provider-impl { - base "config:module-type"; - - config:java-name-prefix OpflexProvider; - } - - // Augments the 'configuration' choice node under modules/module. - augment "/config:modules/config:module/config:configuration" { - case opflex-provider-impl { - when "/config:modules/config:module/config:type = 'opflex-provider-impl'"; - - //wires in the data-broker service - container data-broker { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-async-data-broker; - } - } - } - // RPC Registry - container rpc-registry { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-rpc-registry; - } - } - } - } - } -} diff --git a/renderers/opflex/src/main/yang/opflex-provider.yang b/renderers/opflex/src/main/yang/opflex-provider.yang deleted file mode 100644 index a2d38c52c..000000000 --- a/renderers/opflex/src/main/yang/opflex-provider.yang +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -module opflex-provider { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:config:opflex-provider"; - prefix "opflex-provider"; - - import config { prefix config; revision-date 2013-04-05; } - - description - "This module contains the base YANG definitions for - opflex-provider services."; - - revision "2014-04-21" { - description - "Initial revision."; - } - - identity opflex-provider { - base "config:service-type"; - config:java-class "org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexData"; - } -} diff --git a/renderers/opflex/src/main/yang/opflex.yang b/renderers/opflex/src/main/yang/opflex.yang deleted file mode 100644 index 9ab38a384..000000000 --- a/renderers/opflex/src/main/yang/opflex.yang +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -module opflex { - yang-version 1; - - namespace "urn:opendaylight:groupbasedpolicy:opflex"; - prefix "opflex"; - - import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; } - - import yang-ext {prefix ext; revision-date "2013-07-09";} - import gbp-common {prefix gbp-common;} - import endpoint {prefix endpoint;} - - description - "This module defines the group-based policy OpFlex renderer model."; - - revision "2014-05-28" { - description - "Initial revision."; - } - - typedef serialization { - description - "The serialization to use for OpFlex messages."; - - type enumeration { - enum json { - description - "JSON 1.0 serialization."; - } - enum xml { - description - "XML serialization."; - } - enum binary { - description - "OpFlex binary serialization."; - } - } - } - - container discovery-definitions { - description - "The nodes that any OpFlex agent needs to communicate - with in an OpFlex policy fabric."; - - config true; - - leaf domain { - description - "The OpFlex administrative domain."; - - config true; - - type string; - } - - list policy-repository { - description - "A repository that the OpFlex agent can use for resolving - policies."; - - key "id"; - - leaf id { - description - "The id for the policy repository."; - type string; - } - leaf port { - description - "The port number to use for the connection"; - type int32; - } - leaf serialization-type { - description - "The serialization to use for this connection."; - type serialization; - } - } - - list endpoint-registry { - description - "A repository that the OpFlex agent can use for registration - and lookup of endpoints."; - - key "id"; - - leaf id { - description - "The id for the endpoint registry."; - type string; - } - leaf port { - description - "The port number to use for the connection"; - type int32; - } - leaf serialization-type { - description - "The serialization to use for this connection."; - type serialization; - } - } - - list observer { - description - "A repository that the OpFlex agent can send State Report - messages to."; - - key "id"; - - leaf id { - description - "The id for the Observer."; - type string; - } - leaf port { - description - "The port number to use for the connection"; - type int32; - } - leaf serialization-type { - description - "The serialization to use for this connection."; - type serialization; - } - } - } - - grouping endpoint-location { - description - "The location for this endpoint in the overlay network"; - - leaf location-type { - default internal; - - type enumeration { - enum internal { - description - "The endpoint is located on a port that is part of - the overlay network. You must include the node - ID and port number for this endpoint."; - } - enum external { - description "This endpoint is not inside the overlay."; - } - } - } - leaf agent-id { - description - "The OpFlex agent where the endpoing is located. Must be included - for all internal endpoints. The format is the agent identifier, - which is an IP address or DNS name ':' port number."; - type string; - } - leaf agent-ep-location { - description - "The location of the endpoint on the OpFlex agent. The format of - this is dependent on the renderer used by the agent."; - type string; - } - } - - augment "/endpoint:endpoints/endpoint:endpoint" { - ext:augment-identifier "opflex-overlay-context"; - uses endpoint-location; - } - - augment "/endpoint:register-endpoint/endpoint:input" { - ext:augment-identifier "opflex-overlay-context-input"; - uses endpoint-location; - } - - augment "/endpoint:endpoints/endpoint:endpoint-l3" { - ext:augment-identifier "opflex-overlay-context-l3"; - uses endpoint-location; - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointManagerTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointManagerTest.java deleted file mode 100644 index 8fd89ef4e..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointManagerTest.java +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ScheduledExecutorService; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcEndpoint; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexConnectionService; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointIdentity; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUndeclareRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUnresolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.MitLib; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyUri; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2BridgeDomainId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.EndpointService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.OpflexOverlayContext; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; - - - -/** - * - */ -public class EndpointManagerTest implements DataChangeListener { - protected static final Logger logger = LoggerFactory.getLogger(EndpointManagerTest.class); - private static final String TEST_CONTEXT = "3de31df2-5a65-4d5a-b42b-01fa3bdd82ea"; - private static final int TEST_PRR = 1000; - private static final String TEST_IDENTIFIER = "00:11:22:33:44:55"; - private static final String TEST_AGENT_ID = "192.168.194.132:6742"; - private static final String TEST_EP_URI = "/EprL2Universe/EprL2Ep/3de31df2-5a65-4d5a-b42b-01fa3bdd82ea/00:11:22:33:44:55"; - private static final String TEST_SUBJECT = "EprL2Ep"; - - @Mock - private JsonNode TEST_MSG_ID; - @Mock - private DataBroker mockBroker; - @Mock - private RpcProviderRegistry mockRpcRegistry; - @Mock - private ScheduledExecutorService mockExecutor; - @Mock - private OpflexConnectionService mockConnService; - @Mock - private ListenerRegistration mockListener; - @Mock - private ListenerRegistration mockL3Listener; - @Mock - private JsonRpcEndpoint mockAgent; - @Mock - private EndpointDeclareRequest mockRpcMessage; - @Mock - private BindingAwareBroker.RpcRegistration mockRpcRegistration; - @Mock - private WriteTransaction mockWriteTransaction; - @Mock - private ReadOnlyTransaction mockReadTransaction; - @Mock - private CheckedFuture mockWriteFuture; - @Mock - private CheckedFuture,ReadFailedException> mockReadFuture; - @Mock - private AsyncDataChangeEvent, DataObject> mockChange; - @Mock - private Map, DataObject> mockDaoMap; - @Mock - private Set> mockDaoSet; - @Mock - private DataObject mockDao; - @Mock - private InstanceIdentifier mockIid; - @Mock - private MitLib mockOpflexLib; - - private EndpointIdentity testIdentity; - private EndpointManager epManager; - - - @Override - public void onDataChanged(AsyncDataChangeEvent, DataObject> change) { - } - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - when(mockBroker.registerDataChangeListener(Matchers.any(), - Matchers.>any(), Matchers.any(), - Matchers.any())) - .thenReturn(mockListener); - - // The following is needed to satisfy the AbstractEndpointRegistry - when(mockRpcRegistry.addRpcImplementation(Matchers.>any(), - Matchers.any())).thenReturn(mockRpcRegistration); - when(mockBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction); - when(mockBroker.newReadOnlyTransaction()).thenReturn(mockReadTransaction); - when(mockReadTransaction.read(Matchers.any(), - Matchers.>any())).thenReturn(mockReadFuture); - when(mockWriteTransaction.submit()).thenReturn(mockWriteFuture); - epManager = new EndpointManager(mockBroker, - mockRpcRegistry, mockExecutor, mockConnService, mockOpflexLib); - MessageUtils.init(); - PolicyUri puri = new PolicyUri(TEST_EP_URI); - testIdentity = new EndpointIdentity(); - testIdentity.setIdentifier(puri.pop()); - testIdentity.setContext(puri.getUri()); - } - - - @Test - public void testConstructor() throws Exception { - verify(mockBroker, times(2)).registerDataChangeListener(Matchers.any(), - Matchers.>any(), Matchers.any(), - Matchers.any()); - } - - @Test - public void testCallbackEpDeclare() throws Exception { - JsonRpcEndpoint agent = mock(JsonRpcEndpoint.class); - EndpointDeclareRequest mockReq = - mock(EndpointDeclareRequest.class); - EndpointDeclareRequest.Params mockParams = - mock(EndpointDeclareRequest.Params.class); - List paramList = - new ArrayList(); - paramList.add(mockParams); - List idList = - new ArrayList(); - idList.add(TEST_IDENTIFIER); - - when(mockReq.valid()).thenReturn(true); - when(mockReq.getId()).thenReturn(TEST_MSG_ID); - when(mockReq.getMethod()).thenReturn(EndpointDeclareRequest.DECLARE_MESSAGE); - when(mockReq.getParams()).thenReturn(paramList); - when(mockParams.getEndpoint()).thenReturn(null); - when(mockParams.getPrr()).thenReturn(TEST_PRR); - epManager.callback(agent, mockReq); - verify(mockParams).getEndpoint(); - - } - - @Test - public void testCallbackEpUndeclare() throws Exception { - JsonRpcEndpoint agent = mock(JsonRpcEndpoint.class); - EndpointUndeclareRequest mockReq = - mock(EndpointUndeclareRequest.class); - EndpointUndeclareRequest.Params mockParams = - mock(EndpointUndeclareRequest.Params.class); - List paramList = - new ArrayList(); - paramList.add(mockParams); - List idList = - new ArrayList(); - idList.add(TEST_IDENTIFIER); - - when(mockReq.valid()).thenReturn(true); - when(mockReq.getId()).thenReturn(TEST_MSG_ID); - when(mockReq.getMethod()).thenReturn(EndpointUndeclareRequest.UNDECLARE_MESSAGE); - when(mockReq.getParams()).thenReturn(paramList); - when(mockParams.getEndpoint_uri()).thenReturn(null); - when(mockParams.getSubject()).thenReturn(TEST_SUBJECT); - epManager.callback(agent, mockReq); - verify(mockParams).getEndpoint_uri(); - - } - - @Test - public void testCallbackEpResolve1() throws Exception { - JsonRpcEndpoint mockRpcEp = mock(JsonRpcEndpoint.class); - EndpointResolveRequest mockReq = - mock(EndpointResolveRequest.class); - EndpointResolveRequest.Params mockParams = - mock(EndpointResolveRequest.Params.class); - List paramList = - new ArrayList(); - paramList.add(mockParams); - - when(mockRpcEp.getIdentifier()).thenReturn(TEST_IDENTIFIER); - when(mockReq.valid()).thenReturn(true); - when(mockReq.getId()).thenReturn(TEST_MSG_ID); - when(mockReq.getMethod()).thenReturn(EndpointResolveRequest.EP_RESOLVE_REQUEST_MESSAGE); - when(mockReq.getParams()).thenReturn(paramList); - when(mockParams.getEndpoint_ident()).thenReturn(null); - when(mockParams.getEndpoint_uri()).thenReturn(new Uri(TEST_EP_URI)); - when(mockParams.getSubject()).thenReturn(TEST_SUBJECT); - epManager.callback(mockRpcEp, mockReq); - verify(mockParams, times(3)).getEndpoint_uri(); - } - - @Test - public void testCallbackEpResolve2() throws Exception { - JsonRpcEndpoint mockRpcEp = mock(JsonRpcEndpoint.class); - EndpointResolveRequest mockReq = - mock(EndpointResolveRequest.class); - EndpointResolveRequest.Params mockParams = - mock(EndpointResolveRequest.Params.class); - List paramList = - new ArrayList(); - paramList.add(mockParams); - - when(mockRpcEp.getIdentifier()).thenReturn(TEST_IDENTIFIER); - when(mockReq.valid()).thenReturn(true); - when(mockReq.getId()).thenReturn(TEST_MSG_ID); - when(mockReq.getMethod()).thenReturn(EndpointResolveRequest.EP_RESOLVE_REQUEST_MESSAGE); - when(mockReq.getParams()).thenReturn(paramList); - when(mockParams.getEndpoint_ident()).thenReturn(testIdentity); - when(mockParams.getEndpoint_uri()).thenReturn(null); - when(mockParams.getSubject()).thenReturn(TEST_SUBJECT); - epManager.callback(mockRpcEp, mockReq); - verify(mockParams, times(3)).getEndpoint_ident(); - } - - @Test - public void testCallbackEpUnresolve1() throws Exception { - JsonRpcEndpoint mockRpcEp = mock(JsonRpcEndpoint.class); - EndpointUnresolveRequest mockReq = - mock(EndpointUnresolveRequest.class); - EndpointUnresolveRequest.Params mockParams = - mock(EndpointUnresolveRequest.Params.class); - List paramList = - new ArrayList(); - paramList.add(mockParams); - - when(mockRpcEp.getIdentifier()).thenReturn(TEST_IDENTIFIER); - when(mockReq.valid()).thenReturn(true); - when(mockReq.getId()).thenReturn(TEST_MSG_ID); - when(mockReq.getMethod()).thenReturn(EndpointUnresolveRequest.EP_UNRESOLVE_REQUEST_MESSAGE); - when(mockReq.getParams()).thenReturn(paramList); - when(mockParams.getEndpoint_ident()).thenReturn(null); - when(mockParams.getEndpoint_uri()).thenReturn(new Uri(TEST_EP_URI)); - when(mockParams.getSubject()).thenReturn(TEST_SUBJECT); - epManager.callback(mockRpcEp, mockReq); - verify(mockParams, times(2)).getEndpoint_uri(); - - } - - @Test - public void testCallbackEpUnresolve2() throws Exception { - JsonRpcEndpoint mockRpcEp = mock(JsonRpcEndpoint.class); - EndpointUnresolveRequest mockReq = - mock(EndpointUnresolveRequest.class); - EndpointUnresolveRequest.Params mockParams = - mock(EndpointUnresolveRequest.Params.class); - List paramList = - new ArrayList(); - paramList.add(mockParams); - - when(mockRpcEp.getIdentifier()).thenReturn(TEST_IDENTIFIER); - when(mockReq.valid()).thenReturn(true); - when(mockReq.getId()).thenReturn(TEST_MSG_ID); - when(mockReq.getMethod()).thenReturn(EndpointUnresolveRequest.EP_UNRESOLVE_REQUEST_MESSAGE); - when(mockReq.getParams()).thenReturn(paramList); - when(mockParams.getEndpoint_ident()).thenReturn(testIdentity); - when(mockParams.getEndpoint_uri()).thenReturn(null); - when(mockParams.getSubject()).thenReturn(TEST_SUBJECT); - epManager.callback(mockRpcEp, mockReq); - verify(mockParams, times(2)).getEndpoint_ident(); - - } - - @Test - public void testOnDataChangedCreated() throws Exception { - List daoList = - new ArrayList(); - Endpoint mockEp = mock(Endpoint.class); - EndpointGroupId mockEpgId = mock(EndpointGroupId.class); - TenantId mockTid = mock(TenantId.class); - L2BridgeDomainId mockBdId = mock(L2BridgeDomainId.class); - MacAddress mockMac = mock(MacAddress.class); - OpflexOverlayContext mockCtx = mock(OpflexOverlayContext.class); - Set> emptySet = - Collections.emptySet(); - Map,DataObject> emptyMap = - new ConcurrentHashMap, DataObject>(); - - daoList.add(mockEp); - when(mockEp.getEndpointGroup()).thenReturn(mockEpgId); - when(mockEp.getTenant()).thenReturn(mockTid); - when(mockEp.getL2Context()).thenReturn(mockBdId); - when(mockBdId.getValue()).thenReturn(TEST_CONTEXT); - when(mockEp.getMacAddress()).thenReturn(mockMac); - when(mockEp.getAugmentation(OpflexOverlayContext.class)).thenReturn(mockCtx); - when(mockCtx.getAgentId()).thenReturn(TEST_AGENT_ID); - when(mockMac.getValue()).thenReturn(TEST_IDENTIFIER); - - when(mockChange.getCreatedData()).thenReturn(mockDaoMap); - when(mockDaoMap.values()).thenReturn(daoList); - when(mockChange.getRemovedPaths()).thenReturn(emptySet); - when(mockChange.getUpdatedData()).thenReturn(emptyMap); - epManager.onDataChanged(mockChange); - verify(mockChange).getCreatedData(); - } - - @Test - public void testOnDataChangedRemoved() throws Exception { - List daoList = - new ArrayList(); - Endpoint mockEp = mock(Endpoint.class); - EndpointGroupId mockEpgId = mock(EndpointGroupId.class); - TenantId mockTid = mock(TenantId.class); - L2BridgeDomainId mockBdId = mock(L2BridgeDomainId.class); - MacAddress mockMac = mock(MacAddress.class); - OpflexOverlayContext mockCtx = mock(OpflexOverlayContext.class); - Map,DataObject> emptyMap = - new ConcurrentHashMap, DataObject>(); - Map,Boolean> dummyMap = - new ConcurrentHashMap, Boolean>(); - Set> dummySet = - Collections.newSetFromMap(dummyMap); - dummySet.add(mockIid); - daoList.add(mockEp); - when(mockEp.getEndpointGroup()).thenReturn(mockEpgId); - when(mockEp.getTenant()).thenReturn(mockTid); - when(mockEp.getL2Context()).thenReturn(mockBdId); - when(mockBdId.getValue()).thenReturn(TEST_CONTEXT); - when(mockEp.getMacAddress()).thenReturn(mockMac); - when(mockEp.getAugmentation(OpflexOverlayContext.class)).thenReturn(mockCtx); - when(mockCtx.getAgentId()).thenReturn(TEST_AGENT_ID); - when(mockMac.getValue()).thenReturn(TEST_IDENTIFIER); - - when(mockChange.getCreatedData()).thenReturn(emptyMap); - when(mockChange.getRemovedPaths()).thenReturn(dummySet); - when(mockChange.getOriginalData()).thenReturn(mockDaoMap); - when(mockChange.getUpdatedData()).thenReturn(emptyMap); - when(mockDaoMap.get(Matchers.>any())).thenReturn(mockEp); - - epManager.onDataChanged(mockChange); - verify(mockChange).getOriginalData(); - } - - @Test - public void testOnDataChangedUpdated() throws Exception { - List daoList = - new ArrayList(); - Endpoint mockEp = mock(Endpoint.class); - EndpointGroupId mockEpgId = mock(EndpointGroupId.class); - TenantId mockTid = mock(TenantId.class); - L2BridgeDomainId mockBdId = mock(L2BridgeDomainId.class); - MacAddress mockMac = mock(MacAddress.class); - OpflexOverlayContext mockCtx = mock(OpflexOverlayContext.class); - Set> emptySet = - Collections.emptySet(); - Map,DataObject> emptyMap = - new ConcurrentHashMap, DataObject>(); - Map,DataObject> dummyMap = - new ConcurrentHashMap, DataObject>(); - dummyMap.put(mockIid, mockEp); - - daoList.add(mockEp); - when(mockEp.getEndpointGroup()).thenReturn(mockEpgId); - when(mockEp.getTenant()).thenReturn(mockTid); - when(mockEp.getL2Context()).thenReturn(mockBdId); - when(mockEp.getMacAddress()).thenReturn(mockMac); - when(mockEp.getAugmentation(OpflexOverlayContext.class)).thenReturn(mockCtx); - when(mockCtx.getAgentId()).thenReturn(TEST_AGENT_ID); - when(mockMac.getValue()).thenReturn(TEST_IDENTIFIER); - - when(mockChange.getCreatedData()).thenReturn(emptyMap); - when(mockChange.getRemovedPaths()).thenReturn(emptySet); - when(mockChange.getUpdatedData()).thenReturn(dummyMap); - when(mockChange.getOriginalData()).thenReturn(mockDaoMap); - when(mockDaoMap.get(Matchers.>any())).thenReturn(mockEp); - - when(mockDaoMap.values()).thenReturn(daoList); - epManager.onDataChanged(mockChange); - verify(mockChange).getOriginalData(); - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprContextTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprContextTest.java deleted file mode 100644 index e5fe06545..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EprContextTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.util.concurrent.CheckedFuture; - - - -/** - * - */ -public class EprContextTest implements EprContext.EprCtxCallback { - protected static final Logger logger = LoggerFactory.getLogger(L2EprOperationTest.class); - - @Mock - private WriteTransaction mockWriter; - @Mock - private DataBroker mockDataProvider; - @Mock - private EprOperation mockOperation; - @Mock - private WriteTransaction mockWriteTransaction; - @Mock - private ReadOnlyTransaction mockReadTransaction; - @Mock - CheckedFuture mockFuture; - - private ScheduledExecutorService executor; - private EprContext ec; - private int callbacks; - - - @Override - public void callback(EprContext ctx) { - this.callbacks += 1; - } - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - executor = Executors.newScheduledThreadPool(1); - - ec = new EprContext(null, null, mockDataProvider, executor); - ec.addOperation(mockOperation); - } - - @Test - public void testCreate() throws Exception { - when(mockDataProvider.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction); - when(mockWriteTransaction.submit()).thenReturn(mockFuture); - ec.createEp(); - verify(mockOperation).put(mockWriteTransaction); - verify(mockFuture).addListener(ec, executor); - } - - @Test - public void testDelete() throws Exception { - when(mockDataProvider.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction); - when(mockWriteTransaction.submit()).thenReturn(mockFuture); - ec.deleteEp(); - verify(mockOperation).delete(mockWriteTransaction); - verify(mockFuture).addListener(ec, executor); - - } - - @Test - public void testLookup() throws Exception { - when(mockDataProvider.newReadOnlyTransaction()).thenReturn(mockReadTransaction); - ec.lookupEndpoint(); - verify(mockOperation).setCallback(ec); - verify(mockOperation).read(mockReadTransaction, executor); - - } - - @Test - public void testCallback() throws Exception { - List ops = new ArrayList(); - - EprOperation op1 = mock(EprOperation.class); - EprOperation op2 = mock(EprOperation.class); - EprOperation op3 = mock(EprOperation.class); - EprOperation op4 = mock(EprOperation.class); - - ops.add(op1); - ops.add(op2); - ops.add(op3); - ops.add(op4); - - when(mockDataProvider.newReadOnlyTransaction()).thenReturn(mockReadTransaction); - - this.callbacks = 0; - ec.setCallback(this); - - for (EprOperation op: ops) { - ec.addOperation(op); - } - assertTrue(this.callbacks == 0); - - ec.lookupEndpoint(); - - for (EprOperation op: ops) { - ec.callback(op); - } - assertTrue(this.callbacks == 0); - ec.callback(mockOperation); - assertTrue(this.callbacks == 1); - - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/IdentityTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/IdentityTest.java deleted file mode 100644 index f2c5e5a71..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/IdentityTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.MockitoAnnotations; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * - */ -public class IdentityTest { - protected static final Logger logger = LoggerFactory.getLogger(IdentityTest.class); - - Identity id; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - } - - private static final String TEST_IP = "192.168.194.132"; - private static final String TEST_MAC2 = "11:22:33:44:55:66"; - private static final String TEST_CONTEXT = "9AC3DB0E-C47A-4409-B1AD-BDE647A29440"; - - @Test - public void testL3Identity() throws Exception { - id = new Identity(TEST_IP); - id.setContext(TEST_CONTEXT); - assertTrue(id.identityAsString().equals(TEST_IP)); - assertTrue(id.getL3Context().getValue().equals(TEST_CONTEXT)); - List lid = id.getL3Addresses(); - assertTrue(lid.size() == 1); - for (L3Address l3addr : lid) { - assertTrue(l3addr.getIpAddress().equals(id.getL3Identity())); - assertTrue(l3addr.getL3Context().getValue().equals(TEST_CONTEXT)); - } - //L2BridgeDomainId l2bdid = id.getL2Context(); - //assertTrue(l2bdid.getValue().equals(TEST_CONTEXT)); - } - - @Test - public void testL2Identity() throws Exception { - id = new Identity(TEST_MAC2); - id.setContext(TEST_CONTEXT); - assertTrue(id.identityAsString().equals(TEST_MAC2)); - assertTrue(id.getL2Identity().getValue().equals(TEST_MAC2)); - - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L2EprOperationTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L2EprOperationTest.java deleted file mode 100644 index 2648d93dc..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L2EprOperationTest.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2BridgeDomainId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3AddressBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; - - - -/** - * - */ -public class L2EprOperationTest implements EprOperation.EprOpCallback { - protected static final Logger logger = LoggerFactory.getLogger(L2EprOperationTest.class); - - private static final int TEST_SIZE = 1; - L2EprOperation op = null; - private int callbacks; - - @Mock - private WriteTransaction mockWriter; - @Mock - private ReadOnlyTransaction mockReader; - @Mock - private Identity mockId; - @Mock - private L2BridgeDomainId mockL2Context; - @Mock - private MacAddress mockMac; - @Mock - private CheckedFuture,ReadFailedException> mockFuture; - @Mock - private Optional mockOption; - @Mock - private Endpoint mockEp; - @Mock - private List mockIdentityList; - private ScheduledExecutorService executor; - - private static final String TEST_TENANT_ID = "e9fbd015-df23-4749-abec-8ba63bc0e738"; - private static final String TEST_EPG_ID = "8e359239-a253-42c3-9858-9acc039f1913"; - private static final String TEST_BD_ID = "badac187-2f98-416b-a931-2d0ee58be6b9"; - private static final String TEST_CONTEXT = "eef1f1de-18f8-4adc-910d-2141bf3e6699"; - private static final String TEST_IP1 = "192.168.194.131"; - private static final String TEST_IP2 = "192.168.194.132"; - private static final String TEST_IP3 = "192.168.194.133"; - private static final String TEST_MAC = "de:ad:be:ef:00:ba"; - private static final int TEST_PRR = 100; - - private static Ipv4Address TEST_IPV4_1, TEST_IPV4_2, TEST_IPV4_3; - private static TenantId tid; - private static EndpointGroupId egid; - private static L2BridgeDomainId l2bdid; - private static L3ContextId l3cid; - private static MacAddress mac; - private static List l3List; - private static Long prr; - - - @Override - public void callback(EprOperation op) { - this.callbacks += 1; - - } - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - TEST_IPV4_1 = new Ipv4Address(TEST_IP1); - TEST_IPV4_2 = new Ipv4Address(TEST_IP2); - TEST_IPV4_3 = new Ipv4Address(TEST_IP3); - op = new L2EprOperation(TEST_PRR); - op.setCallback(this); - - tid = new TenantId(TEST_TENANT_ID); - egid = new EndpointGroupId(TEST_EPG_ID); - l3cid = new L3ContextId(TEST_CONTEXT); - mac = new MacAddress(TEST_MAC); - prr = new Long(TEST_PRR); - l2bdid = new L2BridgeDomainId(TEST_BD_ID); - - op.setTenantId(tid); - op.setEndpointGroupId(egid); - op.setContextId(l2bdid); - op.setMacAddress(mac); - - // Add 3 contexts - L3AddressBuilder l3ab = new L3AddressBuilder(); - l3ab.setL3Context(l3cid); - l3ab.setIpAddress(new IpAddress(TEST_IPV4_1)); - l3List = new ArrayList(); - l3List.add(l3ab.build()); - l3ab.setIpAddress(new IpAddress(TEST_IPV4_2)); - l3List.add(l3ab.build()); - l3ab.setIpAddress(new IpAddress(TEST_IPV4_3)); - l3List.add(l3ab.build()); - op.setL3AddressList(l3List); - } - - @Test - public void testEpPut() throws Exception { - - op.put(mockWriter); - verify(mockWriter).put(eq(LogicalDatastoreType.OPERATIONAL), - Matchers.>any(), Matchers.any()); - Endpoint ep = op.getEp(); - assertTrue(ep != null); - assertTrue(ep.getEndpointGroup().equals(egid)); - assertTrue(ep.getTenant().equals(tid)); - assertTrue(ep.getL3Address().equals(l3List)); - assertTrue(ep.getMacAddress().equals(mac)); - assertTrue(ep.getTimestamp().equals(prr)); - - - } - - @Test - public void testEpDelete() throws Exception { - op.delete(mockWriter); - verify(mockWriter).delete(eq(LogicalDatastoreType.OPERATIONAL), - Matchers.>any()); - - } - - @Test - public void testRead() throws Exception { - executor = Executors.newScheduledThreadPool(1); - assertTrue(executor != null); - when(mockReader.read(eq(LogicalDatastoreType.OPERATIONAL), - Matchers.>any())).thenReturn(mockFuture); - op.read(mockReader, executor); - verify(mockReader).read(eq(LogicalDatastoreType.OPERATIONAL), - Matchers.>any()); - Endpoint ep = op.getEp(); - assertTrue(ep != null); - assertTrue(ep.getEndpointGroup().equals(egid)); - assertTrue(ep.getTenant().equals(tid)); - assertTrue(ep.getL3Address().equals(l3List)); - assertTrue(ep.getMacAddress().equals(mac)); - assertTrue(ep.getTimestamp().equals(prr)); - } - - @Test - public void testCallback() throws Exception { - this.callbacks = 0; - - // pre-seed the EP - op.setEp(op.buildEp()); - - when(mockOption.isPresent()).thenReturn(true); - when(mockOption.get()).thenReturn(op.getEp()); - - op.onSuccess(mockOption); - Endpoint ep = op.getEp(); - assertTrue(ep != null); - assertTrue(ep.getEndpointGroup().equals(egid)); - assertTrue(ep.getTenant().equals(tid)); - assertTrue(ep.getL3Address().equals(l3List)); - assertTrue(ep.getMacAddress().equals(mac)); - assertTrue(ep.getTimestamp().equals(prr)); - assertTrue(this.callbacks == TEST_SIZE); - - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L3EprOperationTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L3EprOperationTest.java deleted file mode 100644 index c10bfd3e5..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L3EprOperationTest.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3AddressBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; - - - -/** - * - */ -public class L3EprOperationTest implements EprOperation.EprOpCallback { - protected static final Logger logger = LoggerFactory.getLogger(L3EprOperationTest.class); - - private static final int TEST_SIZE = 1; - L3EprOperation op = null; - private int callbacks; - @Mock - private WriteTransaction mockWriter; - @Mock - private ReadOnlyTransaction mockReader; - @Mock - private Identity mockId; - @Mock - private L3ContextId mockL3Context; - @Mock - private IpAddress mockIp; - @Mock - private List mockAddresses; - @Mock - private CheckedFuture,ReadFailedException> mockFuture; - @Mock - private Optional mockOption; - @Mock - private EndpointL3 mockEp; - @Mock - private List mockIdentityList; - private ScheduledExecutorService executor; - - private static final String TEST_TENANT_ID = "e9fbd015-df23-4749-abec-8ba63bc0e738"; - private static final String TEST_EPG_ID = "8e359239-a253-42c3-9858-9acc039f1913"; - private static final String TEST_CONTEXT = "4ac7e31a-5775-46ac-b228-f40cdfeeabe7"; - private static final String TEST_IP1 = "192.168.194.131"; - private static final String TEST_IP2 = "192.168.194.132"; - private static final String TEST_IP3 = "192.168.194.133"; - private static final String TEST_MAC = "de:ad:be:ef:00:ba"; - private static final int TEST_PRR = 100; - - private static Ipv4Address TEST_IPV4_1, TEST_IPV4_2, TEST_IPV4_3; - private static TenantId tid; - private static EndpointGroupId egid; - private static L3ContextId l3cid; - private static MacAddress mac; - private static List l3List; - private static IpAddress ip; - private static Long prr; - - @Override - public void callback(EprOperation op) { - this.callbacks += 1; - - } - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - TEST_IPV4_1 = new Ipv4Address(TEST_IP1); - TEST_IPV4_2 = new Ipv4Address(TEST_IP2); - TEST_IPV4_3 = new Ipv4Address(TEST_IP3); - op = new L3EprOperation(TEST_PRR); - op.setCallback(this); - - tid = new TenantId(TEST_TENANT_ID); - egid = new EndpointGroupId(TEST_EPG_ID); - l3cid = new L3ContextId(TEST_CONTEXT); - mac = new MacAddress(TEST_MAC); - ip = new IpAddress(TEST_IPV4_1); - prr = new Long(TEST_PRR); - - op.setTenantId(tid); - op.setEndpointGroupId(egid); - op.setIpAddress(new IpAddress(TEST_IPV4_1)); - op.setContextId(l3cid); - op.setMacAddress(mac); - - // Add 3 contexts - L3AddressBuilder l3ab = new L3AddressBuilder(); - l3ab.setL3Context(l3cid); - l3ab.setIpAddress(new IpAddress(TEST_IPV4_1)); - l3List = new ArrayList(); - l3List.add(l3ab.build()); - l3ab.setIpAddress(new IpAddress(TEST_IPV4_2)); - l3List.add(l3ab.build()); - l3ab.setIpAddress(new IpAddress(TEST_IPV4_3)); - l3List.add(l3ab.build()); - op.setL3AddressList(l3List); - } - - - @Test - public void testEpPut() throws Exception { - - op.put(mockWriter); - verify(mockWriter).put(eq(LogicalDatastoreType.OPERATIONAL), - Matchers.>any(), Matchers.any()); - EndpointL3 epl3 = op.getEp(); - assertTrue(epl3 != null); - assertTrue(epl3.getEndpointGroup().equals(egid)); - assertTrue(epl3.getTenant().equals(tid)); - assertTrue(epl3.getIpAddress().equals(ip)); - assertTrue(epl3.getL3Address().equals(l3List)); - assertTrue(epl3.getMacAddress().equals(mac)); - assertTrue(epl3.getTimestamp().equals(prr)); - assertTrue(epl3.getL3Context().equals(l3cid)); - - } - - - @Test - public void testEpDelete() throws Exception { - op.delete(mockWriter); - verify(mockWriter).delete(eq(LogicalDatastoreType.OPERATIONAL), - Matchers.>any()); - - } - - @Test - public void testEpRead() throws Exception { - executor = Executors.newScheduledThreadPool(1); - assertTrue(executor != null); - when(mockReader.read(eq(LogicalDatastoreType.OPERATIONAL), - Matchers.>any())).thenReturn(mockFuture); - op.read(mockReader, executor); - verify(mockReader).read(eq(LogicalDatastoreType.OPERATIONAL), - Matchers.>any()); - EndpointL3 epl3 = op.getEp(); - assertTrue(epl3 != null); - assertTrue(epl3.getEndpointGroup().equals(egid)); - assertTrue(epl3.getTenant().equals(tid)); - assertTrue(epl3.getIpAddress().equals(ip)); - assertTrue(epl3.getL3Address().equals(l3List)); - assertTrue(epl3.getMacAddress().equals(mac)); - assertTrue(epl3.getTimestamp().equals(prr)); - assertTrue(epl3.getL3Context().equals(l3cid)); - - } - - @Test - public void testCallback() throws Exception { - this.callbacks = 0; - - // pre-seed the EP - op.setEp(op.buildEp()); - - when(mockOption.isPresent()).thenReturn(true); - when(mockOption.get()).thenReturn(op.getEp()); - - op.onSuccess(mockOption); - EndpointL3 epl3 = op.getEp(); - assertTrue(epl3 != null); - assertTrue(epl3.getEndpointGroup().equals(egid)); - assertTrue(epl3.getTenant().equals(tid)); - assertTrue(epl3.getIpAddress().equals(ip)); - assertTrue(epl3.getL3Address().equals(l3List)); - assertTrue(epl3.getMacAddress().equals(mac)); - assertTrue(epl3.getTimestamp().equals(prr)); - assertTrue(epl3.getL3Context().equals(l3cid)); - assertTrue(this.callbacks == TEST_SIZE); - } - - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/MessageUtilsTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/MessageUtilsTest.java deleted file mode 100644 index e2a064a4f..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/MessageUtilsTest.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.MockitoAnnotations; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.ManagedObject; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.AgentOvsMit; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.MitLib; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyUri; -import org.opendaylight.groupbasedpolicy.resolver.RuleGroup; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContractId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Name; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.NetworkDomainId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SelectorName; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.Tenant; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.TenantBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.EndpointGroup; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.EndpointGroup.IntraGroupPolicy; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.EndpointGroupBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.endpoint.group.ConsumerNamedSelector; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.endpoint.group.ConsumerNamedSelectorBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.endpoint.group.ProviderNamedSelector; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.endpoint.group.ProviderNamedSelectorBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * - */ -public class MessageUtilsTest { - protected static final Logger logger = LoggerFactory.getLogger(MessageUtilsTest.class); - public static final String SEP = "/"; - public static final String TENANT_PREFIX = "/PolicyUniverse/PolicySpace"; - public static final String CONTRACT_RN = "contract"; - public static final String EPG_RN = "GbpEpGroup"; - public static final String TENANT_UUID = "8ca978fa-05bc-4120-b037-f74802d18396"; - public static final String EPG_UUID = "420c5855-0578-4ca5-b3d2-3057e640e55a"; - public static final String EPG_NAME = "webFarm1"; - - public static final String TEST_TARGET_NAME1 = "target1"; - public static final String TEST_TARGET_NAME2 = "target2"; - public static final String TEST_CONTRACT_ID1 = "bcef4a60-ce45-4eb2-9a47-5d93bf6877bc"; - public static final String TEST_CONTRACT_ID2 = "e8de1a72-6d0b-45e4-9980-a425b2b4a40d"; - public static final Integer TEST_RULE_ORDER = 1; - public static final String TEST_RULE_NAME1 = "rule1"; - public static final String TEST_ACTION_NAME1 = "action1"; - public static final String TEST_ACTION_NAME2 = "action2"; - public static final Integer TEST_ACTION_ORDER1 = 1; - public static final Integer TEST_ACTION_ORDER2 = 2; - public static final String TEST_CLASSIFIER_NAME1 = "classifier1"; - public static final String TEST_CLASSIFIER_NAME2 = "classifier2"; - public static final String TEST_CLASSIFIER_INSTANCE_NAME1 = "classifierInstance1"; - public static final String TEST_CLASSIFIER_INSTANCE_NAME2 = "classifierInstance2"; - private static final String TEST_URI1 = TENANT_PREFIX + PolicyUri.POLICY_URI_SEP + TENANT_UUID + SEP + EPG_RN + SEP + EPG_UUID; - private static final String TEST_SELECTOR_NAME1 = "selector1"; - private static final String TEST_NETWORK_DOMAIN_ID = "9AF7B4EF-1C5B-4FA9-A769-F368F781C4E6"; - - private static final String TEST_IP_SUBNET_1 = "10.0.2.23/24"; - private static final String TEST_IP_SUBNET_2 = "192.168.194.1/24"; - private static final String TEST_IP_SUBNET_3 = "192.168.195.23/23"; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - MessageUtils.init(); - MessageUtils.setMit(new AgentOvsMit()); - MessageUtils.setOpflexLib(new MitLib()); - } - - - @Test - public void testUri() throws Exception { - - PolicyUri uri = MessageUtils.parseUri(TEST_URI1); - assertTrue(uri != null); - int index = 0; - String element = uri.getElement(index++); - while (element != null) { - System.out.println("Element: " + element); - element = uri.getElement(index++); - } - assertTrue(uri.contains(EPG_RN)); - index = uri.whichElement(EPG_UUID); - assertTrue(index == uri.totalElements()-1); - - assertTrue(MessageUtils.hasEpg(TEST_URI1)); - assertTrue(MessageUtils.isEpgUri(TEST_URI1)); - - } - - - private List getTestConsumerNamedSelectorList() { - List cns = new ArrayList(); - - ConsumerNamedSelectorBuilder cnsb = new ConsumerNamedSelectorBuilder(); - cnsb.setContract(getTestContractIdList()); - cnsb.setName(new SelectorName(TEST_SELECTOR_NAME1)); - cns.add(cnsb.build()); - - return cns; - } - - - private List getTestContractIdList() { - List cid = new ArrayList(); - - cid.add(new ContractId(TEST_CONTRACT_ID1)); - cid.add(new ContractId(TEST_CONTRACT_ID2)); - - return cid; - } - - private List getTestProviderNamedSelectorList() { - List pns = new ArrayList(); - - ProviderNamedSelectorBuilder pnsb = new ProviderNamedSelectorBuilder(); - pnsb.setContract(getTestContractIdList()); - pnsb.setName(new SelectorName(TEST_SELECTOR_NAME1)); - - pns.add(pnsb.build()); - - return pns; - } - - - private void printMos(Set mol) { - for (ManagedObject mo: mol) { - if (mo == null) return; - - if (mo.getProperties() != null) { - for (ManagedObject.Property p : mo.getProperties()) { - assertTrue(p != null); - System.out.println("\t" + p.getName() + ": " + p.getData()); - } - } - if (mo.getChildren() == null) return; - - for (Uri children: mo.getChildren()) { - assertTrue(children != null); - } - } - } - - @Test - public void testIsGenieUri() throws Exception { - PolicyUri uri = new PolicyUri(); - uri.push("PolicyUniverse"); - uri.push("PolicySpace"); - uri.push(TENANT_UUID); - uri.push("GbpEpGroup"); - assertTrue(MessageUtils.isGenieUri(new Uri(uri.toString()))); - } - - private static final String TEST_URI_1 = - "/endpoints/endpoint/e60dec20-ff2c-4b10-90a3-e8c27ce9fd08/00:11:22:33:44:55"; - private static final String TEST_URI_2 = - "/endpoints/endpoint-l3/e60dec20-ff2c-4b10-90a3-e8c27ce9fd08/192.168.10.3"; - private static final String TEST_URI_3 = "/tenants/tenant/51134b1e-6047-4d51-8d07-4135afd3672f"; - private static final String TEST_URI_4 = - TEST_URI_3 + "/contract/81cb5b9f-b443-4d85-9da2-dfe2b3e5f7a3"; - private static final String TEST_URI_5 = - TEST_URI_4 + "/subject/HTTP"; - private static final String TEST_URI_6 = - TEST_URI_5 + "/rule/block"; - private static final String TEST_URI_7 = - TEST_URI_3 + "/l2-flood-domain/e2168e8d-856c-4927-9695-156ed567d6a8"; - private static final String TEST_URI_8 = - TEST_URI_3 + "/l2-bridge-domain/1d148938-38e3-41e5-a6dc-4b35541a498b"; - private static final String TEST_URI_9 = - TEST_URI_3 + "/subnet/99693e3c-a5e1-4229-a3b6-9aae9cf69b61"; - private static final String TEST_URI_10 = - TEST_URI_3 + "/l3-context/bf11bd5b-7a45-412d-bff3-c9c1f1770023"; - - -// private static final String TEST_GENIE_URI_1 = -// "/EprL2Universe/EprL2Ep/e60dec20-ff2c-4b10-90a3-e8c27ce9fd08/00:11:22:33:44:55"; -// private static final String TEST_GENIE_URI_2 = -// "/EprL3Universe/EprL3Ep/e60dec20-ff2c-4b10-90a3-e8c27ce9fd08/192.168.10.3"; - - //@Test - public void testOdlUriIterator() throws Exception { - PolicyUri uri = new PolicyUri(TEST_URI_1); - MessageUtils.UriIterator it = new MessageUtils.UriIterator(uri, MessageUtils.getOdlKeys()); - - while (it.hasNext()) { - if (it.isKey()) { - System.out.println("Key is " + it.getElement()); - } - else { - System.out.println("Element is " + it.getElement()); - } - it.next(); - } - uri = new PolicyUri(TEST_URI_2); - it = new MessageUtils.UriIterator(uri, MessageUtils.getOdlKeys()); - while (it.hasNext()) { - if (it.isKey()) { - System.out.println("Key is " + it.getElement()); - } - else { - System.out.println("Element is " + it.getElement()); - } - it.next(); - } - } - - //@Test - public void testOdlUritoGenieUri() throws Exception { - PolicyUri guri = MessageUtils.odlUriToGenieUri(new PolicyUri(TEST_URI_1)); - System.out.println(guri.originalPath()); - guri = MessageUtils.odlUriToGenieUri(new PolicyUri(TEST_URI_2)); - System.out.println(guri.originalPath()); - guri = MessageUtils.odlUriToGenieUri(new PolicyUri(TEST_URI_3)); - System.out.println(guri.originalPath()); - guri = MessageUtils.odlUriToGenieUri(new PolicyUri(TEST_URI_4)); - System.out.println(guri.originalPath()); - guri = MessageUtils.odlUriToGenieUri(new PolicyUri(TEST_URI_5)); - System.out.println(guri.originalPath()); - guri = MessageUtils.odlUriToGenieUri(new PolicyUri(TEST_URI_6)); - System.out.println(guri.originalPath()); - guri = MessageUtils.odlUriToGenieUri(new PolicyUri(TEST_URI_7)); - System.out.println(guri.originalPath()); - guri = MessageUtils.odlUriToGenieUri(new PolicyUri(TEST_URI_8)); - System.out.println(guri.originalPath()); - guri = MessageUtils.odlUriToGenieUri(new PolicyUri(TEST_URI_9)); - System.out.println(guri.originalPath()); - guri = MessageUtils.odlUriToGenieUri(new PolicyUri(TEST_URI_10)); - System.out.println(guri.originalPath()); - } - - //@Test - public void testGetEndpointGroup() throws Exception { - TenantBuilder tb = new TenantBuilder(); - tb.setId(new TenantId(TENANT_UUID)); - Tenant t = tb.build(); - ManagedObject epgMo = new ManagedObject(); - - RuleGroup rg = new RuleGroup(null, 0, t, null, null); - - EndpointGroupBuilder epgb = new EndpointGroupBuilder(); - epgb.setConsumerNamedSelector(getTestConsumerNamedSelectorList()); - epgb.setProviderNamedSelector(getTestProviderNamedSelectorList()); - - epgb.setIntraGroupPolicy(IntraGroupPolicy.Allow); - epgb.setNetworkDomain(new NetworkDomainId(TEST_NETWORK_DOMAIN_ID)); - epgb.setName(new Name(EPG_NAME)); - epgb.setId(new EndpointGroupId(EPG_UUID)); - - EndpointGroup epg = epgb.build(); - assertTrue(epg != null); - PolicyUri uri = new PolicyUri(); - uri.push("PolicyUniverse"); - uri.push("PolicySpace"); - uri.push(TENANT_UUID); - uri.push("GbpEpGroup"); - uri.push(epg.getId().getValue()); - Set children = MessageUtils.getEndpointGroupMo(epgMo, uri, epg, rg); - printMos(children); - } - - //@Test - public void testIpv4PlusSubnet() throws Exception { - MessageUtils.Ipv4PlusSubnet ipv4 = new MessageUtils.Ipv4PlusSubnet(TEST_IP_SUBNET_1); - System.out.println("Prefix is " + ipv4.getPrefixAsString() + ", Mask is " + ipv4.getMaskAsString()); - ipv4 = new MessageUtils.Ipv4PlusSubnet(TEST_IP_SUBNET_2); - System.out.println("Prefix is " + ipv4.getPrefixAsString() + ", Mask is " + ipv4.getMaskAsString()); - ipv4 = new MessageUtils.Ipv4PlusSubnet(TEST_IP_SUBNET_3); - System.out.println("Prefix is " + ipv4.getPrefixAsString() + ", Mask is " + ipv4.getMaskAsString()); - } -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/PolicyManagerTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/PolicyManagerTest.java deleted file mode 100644 index 145fa2b75..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/PolicyManagerTest.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex; - -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; - -import org.junit.Before; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcEndpoint; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessageMap; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexAgent; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexConnectionService; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyResolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.MitLib; -import org.opendaylight.groupbasedpolicy.resolver.EgKey; -import org.opendaylight.groupbasedpolicy.resolver.Policy; -import org.opendaylight.groupbasedpolicy.resolver.PolicyInfo; -import org.opendaylight.groupbasedpolicy.resolver.PolicyListener; -import org.opendaylight.groupbasedpolicy.resolver.PolicyResolver; -import org.opendaylight.groupbasedpolicy.resolver.PolicyScope; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.EndpointService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.util.concurrent.CheckedFuture; - - - -/** - * - */ -public class PolicyManagerTest implements DataChangeListener { - protected static final Logger logger = LoggerFactory.getLogger(PolicyManagerTest.class); - private static final String TEST_AGENT_ID = "192.168.194.11:6723"; - private static final int TEST_TIMEOUT = 500; - private static final String TEST_POLICY = "foo-boo"; - - @Mock - private JsonNode TEST_MSG_ID; - @Mock - private PolicyResolver mockResolver; - @Mock - private OpflexConnectionService mockConnService; - @Mock - private ListenerRegistration mockListener; - @Mock - private ListenerRegistration mockL3Listener; - @Mock - private EndpointDeclareRequest mockRpcMessage; - @Mock - private BindingAwareBroker.RpcRegistration mockRpcRegistration; - @Mock - private WriteTransaction mockWriteTransaction; - @Mock - private CheckedFuture mockFuture; - @Mock - private PolicyInfo mockPolicyInfo; - @Mock - private OpflexAgent mockAgent; - @Mock - private PolicyScope mockScope; - @Mock - private List mockParamsList; - @Mock - private MitLib mockOpflexLib; - - - private JsonRpcEndpoint dummyEndpoint; - - private PolicyManager policyManager; - private ScheduledExecutorService executor; - - @Override - public void onDataChanged(AsyncDataChangeEvent, DataObject> change) { - } - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - int numCPU = Runtime.getRuntime().availableProcessors(); - executor = Executors.newScheduledThreadPool(numCPU * 2); - dummyEndpoint = - new JsonRpcEndpoint(null, null, - null, null, new RpcMessageMap(), null); - when(mockResolver - .registerListener(Matchers.any())).thenReturn(mockScope); - - policyManager = new PolicyManager(mockResolver, - mockConnService, executor, mockOpflexLib); - } - - - //@Test - public void testPolicyUpdated() throws Exception { - EgKey sepgKey = mock(EgKey.class); - EgKey depgKey = mock(EgKey.class); - Policy mockPolicy = mock(Policy.class); - - Set degKeySet = Collections. - newSetFromMap(new ConcurrentHashMap()); - degKeySet.add(depgKey); - Set segKeySet = Collections. - newSetFromMap(new ConcurrentHashMap()); - segKeySet.add(sepgKey); - - when(mockResolver.getCurrentPolicy()).thenReturn(mockPolicyInfo); - when(mockConnService.getOpflexAgent(anyString())).thenReturn(mockAgent); - when(mockPolicyInfo.getPeers(sepgKey)).thenReturn(degKeySet); - when(mockPolicyInfo.getPolicy(sepgKey, depgKey)).thenReturn(mockPolicy); - when(mockAgent.getEndpoint()).thenReturn(dummyEndpoint); - - /* - * Add some EPGs to enable messaging - */ - //policyManager.dirty.get().addEndpointGroup(sepgKey); - //policyManager.dirty.get().addEndpointGroup(depgKey); - - /* - * Add a single agent - */ - //policyManager.dirty.get().addAgent(TEST_AGENT_ID); - - policyManager.policyUpdated(segKeySet); - - verify(mockAgent, timeout(TEST_TIMEOUT)).getEndpoint(); - - } - - //@Test - public void testGroupEndpointUpdated() throws Exception { - EgKey sepgKey = mock(EgKey.class); - EgKey depgKey = mock(EgKey.class); - Policy mockPolicy = mock(Policy.class); - TenantId tId = mock(TenantId.class); - EndpointGroupId epgId = mock(EndpointGroupId.class); - - Set egKeySet = Collections. - newSetFromMap(new ConcurrentHashMap()); - egKeySet.add(depgKey); - - when(mockResolver.getCurrentPolicy()).thenReturn(mockPolicyInfo); - when(mockConnService.getOpflexAgent(anyString())).thenReturn(mockAgent); - when(mockPolicyInfo.getPeers(sepgKey)).thenReturn(egKeySet); - when(mockPolicyInfo.getPolicy(sepgKey, depgKey)).thenReturn(mockPolicy); - when(mockAgent.getEndpoint()).thenReturn(dummyEndpoint); - when(sepgKey.getTenantId()).thenReturn(tId); - when(sepgKey.getEgId()).thenReturn(epgId); - - /* - * Add some EPGs to enable messaging - */ - //policyManager.dirty.get().addEndpointGroup(sepgKey); - //policyManager.dirty.get().addEndpointGroup(depgKey); - - /* - * Add a single agent - */ - //policyManager.dirty.get().addAgent(TEST_AGENT_ID); - - //policyManager.groupEndpointUpdated(sepgKey, epKey); - - verify(mockAgent, timeout(TEST_TIMEOUT)).getEndpoint(); - - } - - - //@Test - public void testCallback() throws Exception { - JsonRpcEndpoint mockEp = mock(JsonRpcEndpoint.class); - PolicyResolveRequest request = - mock(PolicyResolveRequest.class); - PolicyResolveRequest.Params mockParams = - mock(PolicyResolveRequest.Params.class); - - when(request.getId()).thenReturn(TEST_MSG_ID); - when(request.valid()).thenReturn(true); - when(request.getMethod()).thenReturn(PolicyResolveRequest.RESOLVE_MESSAGE); - when(request.getParams()).thenReturn(mockParamsList); - when(mockParamsList.get(0)).thenReturn(mockParams); - when(mockParams.getPolicy_uri()).thenReturn(new Uri(TEST_POLICY)); - when(mockEp.getIdentifier()).thenReturn(TEST_AGENT_ID); - - policyManager.callback(mockEp, request); - - verify(mockEp, timeout(TEST_TIMEOUT).times(2)).getIdentifier(); - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcDecoderTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcDecoderTest.java deleted file mode 100644 index b473f87ce..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcDecoderTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Dave Tucker - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import static io.netty.buffer.Unpooled.copiedBuffer; - -import static org.junit.Assert.assertEquals; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; - -import io.netty.channel.embedded.EmbeddedChannel; -import io.netty.handler.codec.DecoderException; -import io.netty.handler.codec.TooLongFrameException; -import io.netty.util.CharsetUtil; - -import java.net.URL; - -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcDecoder; - -public class JsonRpcDecoderTest { - static int testJson_BYTES = 179; - String testJson; - String prettyTestJson; - static final String PREAMBLE = " "; - static final String PARTIAL_START = "{\"foo\":"; - static final String PARTIAL_END = "{\"bar\":\"baz\"}}"; - - JsonRpcDecoder decoder; - EmbeddedChannel ch; - - @Before - public void setUp() throws Exception { - decoder = new JsonRpcDecoder(1000); - ch = new EmbeddedChannel(decoder); - - URL testJsonUrl = Resources.getResource(JsonRpcDecoderTest.class, "test.json"); - testJson = Resources.toString(testJsonUrl, Charsets.UTF_8); - URL prettyTestJsoUrl = Resources.getResource(JsonRpcDecoderTest.class, "pretty-test.json"); - prettyTestJson = Resources.toString(prettyTestJsoUrl, Charsets.UTF_8); - } - - @Test - public void testDecode() throws Exception { - for (int i = 0; i < 10; i++) { - ch.writeInbound(copiedBuffer(testJson, CharsetUtil.UTF_8)); - } - ch.readInbound(); - assertEquals(10, decoder.getRecordsRead()); - ch.finish(); - } - - @Test - public void testDecodePrettyJson() throws Exception { - ch.writeInbound(copiedBuffer(prettyTestJson, CharsetUtil.UTF_8)); - ch.readInbound(); - assertEquals(1, decoder.getRecordsRead()); - ch.finish(); - } - - @Test - public void testDecodeSkipSpaces() throws Exception { - ch.writeInbound(copiedBuffer(PREAMBLE + testJson + PREAMBLE + testJson, CharsetUtil.UTF_8)); - ch.readInbound(); - assertEquals(2, decoder.getRecordsRead()); - ch.finish(); - } - - @Test - public void testDecodePartial() throws Exception { - ch.writeInbound(copiedBuffer(PARTIAL_START, CharsetUtil.UTF_8)); - ch.readInbound(); - Thread.sleep(10); - ch.writeInbound(copiedBuffer(PARTIAL_END, CharsetUtil.UTF_8)); - ch.readInbound(); - assertEquals(1, decoder.getRecordsRead()); - ch.finish(); - } - - @Test(expected= DecoderException.class) - public void testDecodeInvalidEncoding() throws Exception { - ch.writeInbound(copiedBuffer(testJson, CharsetUtil.UTF_16)); - ch.finish(); - } - - @Test(expected=TooLongFrameException.class) - public void testDecodeFrameLengthExceed() { - decoder = new JsonRpcDecoder(testJson_BYTES -1); - ch = new EmbeddedChannel(decoder); - ch.writeInbound(copiedBuffer(testJson, CharsetUtil.UTF_8)); - ch.finish(); - } -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEndpointTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEndpointTest.java deleted file mode 100644 index 40f083631..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcEndpointTest.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import static io.netty.buffer.Unpooled.copiedBuffer; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import io.netty.channel.embedded.EmbeddedChannel; -import io.netty.util.CharsetUtil; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.google.common.util.concurrent.ListenableFuture; - -public class JsonRpcEndpointTest implements RpcBroker, RpcBroker.RpcCallback { - protected static final Logger logger = LoggerFactory.getLogger(JsonRpcEndpoint.class); - - static final String TEST_JSON_CLASS_NAME = "send_identity"; - // Used for message generation, single property - static final String simpleMessage = "{\"otherstuff\": \"foobar\"}"; - // Used for testing valid incoming JSONRPC request messages - static final String testRequest = - "{ \"id\":\"2da9e3d7-0bbe-4099-b343-12783777452f\"," + - "\"method\":" + "\"" + TEST_JSON_CLASS_NAME + "\",\"params\":null}"; - // Used for testing invalid incoming JSONRPC request messages - static final String testBadRequest = - "{ \"id\":\"2da9e3d7-0bbe-4099-b343-12783777452f\"," + - "\"method\":\"foobar\",\"params\":[]}"; - // Used for testing valid incoming JSONRPC echo request messages - static final String testEchoRequest = - "{ \"id\":\"2da9e3d7-0bbe-4099-b343-12783777452f\"," + - "\"method\":\"echo\",\"params\":[]}"; - // Used for testing invalid incoming JSONRPC response messages - static final String unknownResponse = - "{ \"id\":\"2da9e3d7-0bbe-4099-b343-12783777452f\"," + - "\"result\":\"foobar\",\"error\":null}"; - static final String opflexIdentityRequest = - "{ \"id\":\"2da9e3d7-0bbe-4099-b343-12783777452f\"," + - "\"method\":" + "\"" + TEST_JSON_CLASS_NAME + "\",\"params\": [ {" + - "\"name\": \"will\", \"domain\": \"robinson\"," + - "\"my_role\": [\"policy_element\", \"policy_repository\"]} ] }"; - - - private JsonRpcDecoder decoder; - private EmbeddedChannel channel; - private JsonRpcEndpoint endpoint; - private RpcMessageMap messageMap; - private boolean testTriggerFlag; - - @Override - public void subscribe(RpcMessage message, RpcCallback callback) { - } - - @Override - public void publish(JsonRpcEndpoint ep, RpcMessage message) { - testTriggerFlag = true; - callback(ep, message); - } - - @JsonDeserialize - static final public class Params { - private String name; - private String domain; - private List my_role; - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public String getDomain() { - return domain; - } - public void setDomain(String domain) { - this.domain = domain; - } - public List getMy_role() { - return my_role; - } - public void setMy_role(List my_role) { - this.my_role = my_role; - } - public Params() { - my_role = new ArrayList(); - } - } - - @JsonDeserialize - static final class OpflexTest extends RpcMessage { - - private JsonNode id; - private String method; - - private List params; - private String otherstuff; - @JsonIgnore - private String name; - - public OpflexTest() { - this.name = TEST_JSON_CLASS_NAME; - } - - public void setOtherstuff ( String otherstuff ) { - this.otherstuff = otherstuff; - } - public String getOtherstuff() { - return this.otherstuff; - } - - public void setParams(List params) { - this.params = params; - } - - public List getParams() { - return params; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @Override - public JsonNode getId() { - return id; - } - - @Override - public void setId(JsonNode id) { - this.id = id; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public void setMethod(String method) { - this.method = method; - } - @JsonIgnore - @Override - public boolean valid() { - return true; - } - } - - @Override - public void callback(JsonRpcEndpoint ep, RpcMessage message) { - - if (message != null && message instanceof JsonRpcEndpointTest.OpflexTest) { - JsonRpcEndpointTest.OpflexTest msg = (JsonRpcEndpointTest.OpflexTest)message; - if ( msg.getParams() == null) { - return; - } - } - } - - - @Before - public void setUp() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - /* - * Create the message map, populating with just our test message - */ - messageMap = new RpcMessageMap(); - JsonRpcEndpointTest.OpflexTest rpcMethod = - new JsonRpcEndpointTest.OpflexTest(); - rpcMethod.setName(TEST_JSON_CLASS_NAME); - messageMap.add(rpcMethod); - - decoder = new JsonRpcDecoder(1000); - JsonRpcServiceBinderHandler binderHandler = - new JsonRpcServiceBinderHandler(null); - channel = new EmbeddedChannel(decoder, binderHandler); - - endpoint = new JsonRpcEndpoint(channel.localAddress().toString(), null, - objectMapper, channel, messageMap, this); - binderHandler.setEndpoint(endpoint); - } - - - @Test - public void testOutbound() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - JsonRpcEndpointTest.OpflexTest testRpc = objectMapper. - readValue(simpleMessage, JsonRpcEndpointTest.OpflexTest.class); - testRpc.setName(TEST_JSON_CLASS_NAME); - try { - endpoint.sendRequest(testRpc); - Object result = channel.readOutbound(); - assertTrue(result != null); - assertTrue(result.toString().contains("id")); - assertTrue(result.toString().contains("method")); - assertTrue(result.toString().contains("params")); - channel.finish(); - } catch ( Exception e ) { - fail(); - } - } - - @Test - public void testInboundRequestMatch() throws Exception { - testTriggerFlag = false; - channel.writeInbound(copiedBuffer(testRequest, CharsetUtil.UTF_8)); - assertTrue(testTriggerFlag); - channel.finish(); - } - - @Test - public void testInboundRequestNoMatch() throws Exception { - testTriggerFlag = false; - channel.writeInbound(copiedBuffer(testBadRequest, CharsetUtil.UTF_8)); - assertFalse(testTriggerFlag); - channel.finish(); - } - - @Test - public void testInboundResponseNoMatch() throws Exception { - testTriggerFlag = false; - channel.writeInbound(copiedBuffer(unknownResponse, CharsetUtil.UTF_8)); - assertFalse(testTriggerFlag); - channel.finish(); - } - - @Test - public void testInboundResponseMatch() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - JsonRpcEndpointTest.OpflexTest testRpc = objectMapper. - readValue(simpleMessage, JsonRpcEndpointTest.OpflexTest.class); - testRpc.setName(TEST_JSON_CLASS_NAME); - - try { - ListenableFuture lf = endpoint.sendRequest(testRpc); - String result = channel.readOutbound().toString(); - JsonNode node = objectMapper.readValue(result, JsonNode.class); - String idValue = node.path("id").textValue(); - String foo = "{ \"id\":\"" + idValue + - "\",\"result\":\"foobar\",\"error\":null}"; - testTriggerFlag = false; - channel.writeInbound(copiedBuffer(foo, CharsetUtil.UTF_8)); - Object tmp = lf.get(); - assertTrue(tmp instanceof JsonRpcEndpointTest.OpflexTest); - channel.finish(); - } catch ( Exception e ) { - fail(); - } - } - - @Test - public void testInboundEchoRequest() throws Exception { - channel.writeInbound(copiedBuffer(testEchoRequest, CharsetUtil.UTF_8)); - Object result = channel.readOutbound(); - assertTrue(result != null); - assertTrue(result.toString().contains("id")); - assertTrue(result.toString().contains("result")); - assertTrue(result.toString().contains("error")); - channel.finish(); - } - - @Test - public void testOpflexIdentityRequest() throws Exception { - testTriggerFlag = false; - System.out.println("OpflexIdentity Test"); - channel.writeInbound(copiedBuffer(opflexIdentityRequest, CharsetUtil.UTF_8)); - channel.finish(); - assertTrue(testTriggerFlag); - } -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcServiceBinderHandlerTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcServiceBinderHandlerTest.java deleted file mode 100644 index c5bf6b635..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/JsonRpcServiceBinderHandlerTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - -import static io.netty.buffer.Unpooled.copiedBuffer; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import io.netty.channel.embedded.EmbeddedChannel; -import io.netty.util.CharsetUtil; - -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.databind.JsonNode; - -public class JsonRpcServiceBinderHandlerTest { - protected static final Logger logger = LoggerFactory.getLogger(JsonRpcEndpoint.class); - - // Used for testing incoming JSONRPC request messages - static final String testRequest = - "{ \"id\":\"2da9e3d7-0bbe-4099-b343-12783777452f\"," + - "\"method\": \"test_foo\",\"params\":null}"; - // Used for testing incoming JSONRPC response messages - static final String testResponse = - "{ \"id\":\"2da9e3d7-0bbe-4099-b343-12783777452f\"," + - "\"result\":\"foobar\",\"error\":null}"; - - private JsonRpcEndpoint mockEndpoint; - private JsonRpcServiceBinderHandler binderHandler; - private JsonRpcDecoder decoder; - private EmbeddedChannel channel; - - @Before - public void setUp() throws Exception { - - mockEndpoint = mock(JsonRpcEndpoint.class); - decoder = new JsonRpcDecoder(1000); - binderHandler = new JsonRpcServiceBinderHandler(mockEndpoint); - channel = new EmbeddedChannel(decoder, binderHandler); - } - - - @Test - public void testRequest() throws Exception { - channel.writeInbound(copiedBuffer(testRequest, CharsetUtil.UTF_8)); - channel.finish(); - verify(mockEndpoint).processRequest((JsonNode)anyObject()); - } - - @Test - public void testResponse() throws Exception { - channel.writeInbound(copiedBuffer(testResponse, CharsetUtil.UTF_8)); - channel.finish(); - verify(mockEndpoint).processResult((JsonNode)anyObject()); - - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcServerTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcServerTest.java deleted file mode 100644 index 9356531ff..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/RpcServerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc; - - -import org.junit.Before; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RpcServerTest implements ConnectionService, RpcBroker { - protected static final Logger logger = LoggerFactory.getLogger(JsonRpcEndpoint.class); - - private static final String TEST_IP = "127.0.0.1"; - private static final int TEST_PORT = 53670; - - - @Override - public void addConnection(JsonRpcEndpoint endpoint) { - } - - @Override - public void channelClosed(JsonRpcEndpoint peer) throws Exception { - } - - @Override - public void publish(JsonRpcEndpoint endpoint, RpcMessage message) { - } - - @Override - public void subscribe(RpcMessage message, RpcCallback callback) { - } - - @Before - public void setUp() throws Exception { - - RpcServer server = new RpcServer(TEST_IP, TEST_PORT); - server.setConnectionService(this); - server.setRpcBroker(this); - - } - - - //@Test - public void testStartup() throws Exception { - - } - - //@Test - public void testShutdown() throws Exception { - - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexConnectionServiceTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexConnectionServiceTest.java deleted file mode 100644 index 61cc4c500..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexConnectionServiceTest.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib; - -import static io.netty.buffer.Unpooled.copiedBuffer; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import io.netty.channel.embedded.EmbeddedChannel; -import io.netty.util.CharsetUtil; - -import java.io.IOException; -import java.net.ServerSocket; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcDecoder; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcEndpoint; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcServiceBinderHandler; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessageMap; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcServer; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexAgent; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexConnectionService; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexRpcServer; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.Role; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.OpflexMessageTest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.DiscoveryDefinitions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.DiscoveryDefinitionsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.EndpointRegistry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.EndpointRegistryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.Observer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.ObserverBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.PolicyRepository; -import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.opflex.rev140528.discovery.definitions.PolicyRepositoryBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; - -/** - * - * Test the serialization and deserialization of RPC Messages, - * and check against expected structure and values. - */ -public class OpflexConnectionServiceTest { - protected static final Logger logger = LoggerFactory.getLogger(OpflexMessageTest.class); - - static private final String TEST_EP_UUID = "85d53c32-47af-4eaf-82fd-ced653ff74da"; - static public final String TEST_IP = "127.0.0.1"; - - static private final String ID_UUID = "2da9e3d7-0bbe-4099-b343-12783777452f"; - static private final String SEND_IDENTITY = "send_identity"; - static private final String DOMAIN_UUID = "default"; - static private final String NAME = "vm1"; - static private final String IDENTITY = "192.168.0.1:56732"; - static private final String opflexIdentityRequest = - "{ \"id\": \"" + ID_UUID + "\"," + - " \"method\": \"" + SEND_IDENTITY + "\"," + - " \"params\": [ {" + - " \"name\": \"" + NAME + "\"," + - " \"domain\": \"" + DOMAIN_UUID + "\"," + - " \"my_role\": [\"" + Role.POLICY_ELEMENT.toString() + "\"]" + - " }] }"; - - @Mock - private DataBroker mockDataBroker; - private DiscoveryDefinitionsBuilder discoveryBuilder; - private EndpointRegistryBuilder eprBuilder; - private PolicyRepositoryBuilder prBuilder; - private ObserverBuilder oBuilder; - private DiscoveryDefinitions dummyDefinitions; - private List registries; - private List repositories; - private List observers; - private OpflexConnectionService opflexService; - @Mock - private EmbeddedChannel mockChannel; - @Mock - private JsonRpcEndpoint mockEp; - private JsonRpcDecoder decoder; - @Mock - private ReadOnlyTransaction mockRead; - @Mock - private WriteTransaction mockWrite; - @Mock - private CheckedFuture, ReadFailedException> mockOption; - @Mock - CheckedFuture mockStatus; - @Mock - private Optional mockDao; - @Mock - private OpflexRpcServer mockOpflexServer; - @Mock - private OpflexAgent mockAgent; - - private ScheduledExecutorService executor; - - @Mock - private OpflexRpcServer mockServer; - @Mock - private RpcServer mockRpcServer; - - private ServerSocket create(int[] ports) throws IOException { - for (int port : ports) { - try { - return new ServerSocket(port); - } catch (IOException ex) { - continue; // try next port - } - } - - // if the program gets here, no port in the range was found - throw new IOException("no free port found"); - } - - private int getAvailableServerPort() { - try { - int freePort; - ServerSocket s = create(new int[] - { 6670, 6671, 6672, 6673, 6674, 6675, 6676, 6677, 6678 }); - freePort = s.getLocalPort(); - s.close(); - return freePort; - } catch (IOException ex) { - return 0; - } - } - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - int numCPU = Runtime.getRuntime().availableProcessors(); - executor = Executors.newScheduledThreadPool(numCPU * 2); - - /* - * Mocks - */ - when(mockDataBroker.newReadOnlyTransaction()).thenReturn(mockRead); - when(mockDataBroker.newWriteOnlyTransaction()).thenReturn(mockWrite); - when(mockWrite.submit()).thenReturn(mockStatus); - when(mockRead.read(LogicalDatastoreType.CONFIGURATION, - OpflexConnectionService.DISCOVERY_IID)).thenReturn(mockOption); - when(mockOption.get()).thenReturn(mockDao); - when(mockDao.get()).thenReturn(dummyDefinitions); - - /* - * Builders for creating our own discovery definitions - */ - discoveryBuilder = new DiscoveryDefinitionsBuilder(); - eprBuilder = new EndpointRegistryBuilder(); - prBuilder = new PolicyRepositoryBuilder(); - oBuilder = new ObserverBuilder(); - - int testPort = getAvailableServerPort(); - if ( testPort == 0) { - assertTrue(1==0); - } - System.setProperty(OpflexConnectionService.OPFLEX_LISTENPORT, Integer.toString(testPort)); - System.setProperty(OpflexConnectionService.OPFLEX_LISTENIP, TEST_IP); - } - - @Test - public void testNoDefinitions() throws Exception { - - opflexService = new OpflexConnectionService(mockDataBroker, executor); - verify(mockDataBroker).newReadOnlyTransaction(); - } - - @Test - public void testInitialSet() throws Exception { - registries = new ArrayList(); - repositories = new ArrayList(); - observers = new ArrayList(); - int serverPort = getAvailableServerPort(); - EndpointRegistry epr = eprBuilder.setId(TEST_IP) - .setPort(serverPort).build(); - PolicyRepository pr = prBuilder.setId(TEST_IP) - .setPort(serverPort).build(); - Observer o = oBuilder.setId(TEST_IP) - .setPort(serverPort).build(); - registries.add(epr); - repositories.add(pr); - observers.add(o); - dummyDefinitions = discoveryBuilder.setObserver(observers) - .setEndpointRegistry(registries) - .setPolicyRepository(repositories).build(); - opflexService = new OpflexConnectionService(mockDataBroker, executor); - - verify(mockDataBroker).newReadOnlyTransaction(); - - } - - @Test - public void testAddConnection() throws Exception { - when(mockEp.getIdentifier()).thenReturn(TEST_EP_UUID); - when(mockEp.getContext()).thenReturn(mockOpflexServer); - when(mockOpflexServer.getDomain()).thenReturn(DOMAIN_UUID); - - opflexService = new OpflexConnectionService(mockDataBroker, executor); - opflexService.addConnection(mockEp); - verify(mockEp, Mockito.times(2)).getIdentifier(); - } - - @Test - public void testChannelClosed() throws Exception { - when(mockEp.getIdentifier()).thenReturn(TEST_EP_UUID); - when(mockEp.getContext()).thenReturn(mockOpflexServer); - - opflexService = new OpflexConnectionService(mockDataBroker, executor); - when(mockOpflexServer.getDomain()). - thenReturn(OpflexConnectionService.OPFLEX_DOMAIN); - opflexService.addConnection(mockEp); - - verify(mockEp, Mockito.times(2)).getIdentifier(); - - assertTrue(opflexService.getOpflexAgents().size() > 0); - when(mockAgent.getIdentity()).thenReturn(TEST_EP_UUID); - opflexService.channelClosed(mockEp); - assertTrue(opflexService.getOpflexAgents().size() <=0); - } - - @Test - public void testPublishSubscribeCallback() throws Exception { - - List testRoles = new ArrayList(); - testRoles.add(Role.POLICY_REPOSITORY); - testRoles.add(Role.ENDPOINT_REGISTRY); - testRoles.add(Role.OBSERVER); - - /* - * This is *far* from UT, but worthwhile for now - */ - opflexService = new OpflexConnectionService(mockDataBroker, executor); - - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - decoder = new JsonRpcDecoder(1000); - JsonRpcServiceBinderHandler binderHandler = - new JsonRpcServiceBinderHandler(null); - EmbeddedChannel channel = new EmbeddedChannel(decoder, binderHandler); - - RpcMessageMap messageMap = new RpcMessageMap(); - messageMap.addList(Role.DISCOVERY.getMessages()); - - JsonRpcEndpoint ep = new JsonRpcEndpoint(IDENTITY , opflexService, - objectMapper, channel, messageMap, opflexService); - ep.setContext(mockOpflexServer); - binderHandler.setEndpoint(ep); - - when(mockOpflexServer.getRoles()).thenReturn(testRoles); - when(mockOpflexServer.getDomain()). - thenReturn(OpflexConnectionService.OPFLEX_DOMAIN); - opflexService.addConnection(ep); - channel.writeInbound(copiedBuffer(opflexIdentityRequest, CharsetUtil.UTF_8)); - Object result = channel.readOutbound(); - result = channel.readOutbound(); - assertTrue(result != null); - IdentityResponse resp = objectMapper.readValue(result.toString(), IdentityResponse.class); - assertTrue(resp != null); - assertTrue(resp.getResult().getMy_role() - .contains(Role.ENDPOINT_REGISTRY.toString())); - assertTrue(resp.getResult().getMy_role() - .contains(Role.POLICY_REPOSITORY.toString())); - assertTrue(resp.getResult().getMy_role() - .contains(Role.OBSERVER.toString())); - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexRpcServerTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexRpcServerTest.java deleted file mode 100644 index 4cf425d5f..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/OpflexRpcServerTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.ConnectionService; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.JsonRpcEndpoint; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcServer; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexConnectionService; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.OpflexRpcServer; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.Role; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.OpflexMessageTest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - - -/** - * - */ -public class OpflexRpcServerTest implements ConnectionService { - protected static final Logger logger = LoggerFactory.getLogger(OpflexMessageTest.class); - private static final String TEST_IDENTITY = "localhost:6671"; - private static final String TEST_IDENTITY2 = "localhost:6672"; - private static final String TEST_DOMAIN = "default"; - - private OpflexRpcServer testServer = null; - private OpflexRpcServer ts1 = null; - private OpflexRpcServer ts2 = null; - private OpflexRpcServer ts3 = null; - private List roles = null; - - @Mock - private RpcServer mockServer; - @Mock - private OpflexConnectionService mockService; - - @Override - public void addConnection(JsonRpcEndpoint endpoint) { - } - - @Override - public void channelClosed(JsonRpcEndpoint endpoint) throws Exception { - } - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - roles = new ArrayList(); - roles.add(Role.POLICY_REPOSITORY); - - testServer = - new OpflexRpcServer(TEST_DOMAIN, TEST_IDENTITY, roles); - testServer.setRpcBroker(mockService); - testServer.setConnectionService(mockService); - - ts1 = new OpflexRpcServer(TEST_DOMAIN, TEST_IDENTITY, roles); - ts2 = new OpflexRpcServer(TEST_DOMAIN, TEST_IDENTITY2, roles); - roles = new ArrayList(); - roles.add(Role.POLICY_ELEMENT); - ts3 = new OpflexRpcServer(TEST_DOMAIN, TEST_IDENTITY2, roles); - } - - - @Test - public void testStart() throws Exception { - testServer.start(); - assertTrue(testServer.getRpcServer() != null); - } - - @Test - public void testSameServer() throws Exception { - assertTrue(testServer.sameServer(ts1)); - assertFalse(testServer.sameServer(ts2)); - assertFalse(testServer.sameServer(ts3)); - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/RoleTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/RoleTest.java deleted file mode 100644 index dc1b49bce..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/RoleTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib; - -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.Role; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyResolveRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * - */ -public class RoleTest { - protected static final Logger logger = LoggerFactory.getLogger(RoleTest.class); - - private boolean idReq; - private boolean idRsp; - private boolean polReq; - private boolean epDeclReq; - private boolean epReqReq; - - - @Before - public void setUp() throws Exception { - } - @Test - public void testDiscovery() throws Exception { - idReq = false; - idRsp = false; - - List messages = Role.DISCOVERY.getMessages(); - for (RpcMessage msg : messages) { - if (msg instanceof IdentityRequest) { - idReq = true; - } - if (msg instanceof IdentityResponse) { - idRsp = true; - } - } - assertTrue(idReq == true); - assertTrue(idRsp == true); - } - - - @Test - public void testPolicyRepository() throws Exception { - polReq = false; - - List messages = Role.POLICY_REPOSITORY.getMessages(); - for (RpcMessage msg : messages) { - if (msg instanceof PolicyResolveRequest) { - polReq = true; - } - } - assertTrue(polReq == true); - } - - @Test - public void testEndpointRegistry() throws Exception { - epDeclReq = false; - epReqReq = false; - - List messages = Role.ENDPOINT_REGISTRY.getMessages(); - for (RpcMessage msg : messages) { - if (msg instanceof EndpointDeclareRequest) { - epDeclReq = true; - } - if (msg instanceof EndpointResolveRequest) { - epReqReq = true; - } - } - assertTrue(epDeclReq == true); - assertTrue(epReqReq == true); - } - - //@Test -// public void testObserver() throws Exception { -// -// List messages = Role.OBSERVER.getMessages(); -// for (RpcMessage msg : messages) { -// } -// } - -} \ No newline at end of file diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/OpflexMessageTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/OpflexMessageTest.java deleted file mode 100644 index 16f7a03b3..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/lib/messages/OpflexMessageTest.java +++ /dev/null @@ -1,1048 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : Thomas Bachman - */ - -package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages; - -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.Role; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointDeclareResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUndeclareRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUndeclareResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUnresolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUnresolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUpdateRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointUpdateResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.EndpointResolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.IdentityResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyResolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyResolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUnresolveRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUnresolveResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUpdateRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.PolicyUpdateResponse; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.StateReportRequest; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.StateReportResponse; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * - * Test the serialization and deserialization of RPC Messages, - * and check against expected structure and values. - */ -public class OpflexMessageTest { - protected static final Logger logger = LoggerFactory.getLogger(OpflexMessageTest.class); - -// private enum Role { -// POLICY_REPOSITORY("policy_repository"), -// ENDPOINT_REGISTRY("endpoint_registry"), -// OBSERVER("observer"), -// POLICY_ELEMENT("policy_element"); -// -// private String role; -// Role(String role) { -// this.role = role; -// } -// @Override -// public String toString() { -// return this.role; -// } -// } - - // TODO: should just import these from somewhere? - /* - * common JSON definitions - */ - private static final String JSON_OBJECT_OPEN = "{"; - private static final String JSON_OBJECT_CLOSE = "}"; - private static final String JSON_ARRAY_OPEN = "["; - private static final String JSON_ARRAY_CLOSE = "]"; - - /* - * common JSON-RPC definitions - */ - // Just use the same UUID for all IDs - private static final String ID_UUID = "2da9e3d7-0bbe-4099-b343-12783777452f"; - private static final String JSONRPC_ID = "\"id\": [\"send_itentity\", \"" + ID_UUID + "\"],"; - private static final String JSONRPC_METHOD = " \"method\":"; - private static final String JSONRPC_PARAMS_OPEN = "\"params\": " + JSON_ARRAY_OPEN; - private static final String JSONRPC_PARAMS_CLOSE = JSON_ARRAY_CLOSE; - private static final String JSONRPC_RESULT_OPEN = "\"result\": " + JSON_OBJECT_OPEN; - private static final String JSONRPC_RESULT_CLOSE = JSON_OBJECT_CLOSE; - private static final String JSONRPC_ERROR_OPEN = "\"error\": " + JSON_OBJECT_OPEN; - private static final String JSONRPC_ERROR_CLOSE = JSON_OBJECT_CLOSE; - - /* - * Common OpFlex message definitions - */ - public static final String SUBJECT = "\"subject\":"; - - /* - * Identity message-specific definitions - */ - private static final String DOMAIN_UUID = "75caaff2-cb4f-4509-b45e-47b447cb35a9"; - private static final String TEST_NAME = "vm1"; - private static final String IDENTITY = "192.168.0.1:56732"; - // Use the same protocol version for all test messages - private static final String OPFLEX_PROTO_VERSION = "1.0"; - private static final String PROTO_VERSION = "\"proto_version\": \"" + OPFLEX_PROTO_VERSION + "\","; - private static final String MY_ROLE_OPEN = "\"my_role\": " + JSON_ARRAY_OPEN; - private static final String MY_ROLE_CLOSE = JSON_ARRAY_CLOSE; - private static final String PEERS_OPEN = "\"peers\":" + JSON_ARRAY_OPEN + JSON_OBJECT_OPEN; - private static final String PEERS_CLOSE = JSON_OBJECT_CLOSE + JSON_ARRAY_CLOSE; - private static final String OPFLEX_ROLE_OPEN = "\"role\":" + JSON_ARRAY_OPEN; - private static final String OPFLEX_ROLE_CLOSE = JSON_ARRAY_CLOSE; - // Use the same test name for all OpFlex name fields - private static final String OPFLEX_NAME = "\"name\": \"" + TEST_NAME + "\","; - // Use the same Domain for all test messages - private static final String OPFLEX_DOMAIN = "\"domain\": \"" + DOMAIN_UUID + "\","; - - /* - * Identity messages - */ - private static final String opflexIdentityRequest = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + IdentityRequest.IDENTITY_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + JSON_OBJECT_OPEN + - PROTO_VERSION + - OPFLEX_NAME + - OPFLEX_DOMAIN + - MY_ROLE_OPEN + - "\"" + Role.POLICY_ELEMENT.toString() + "\"" + - MY_ROLE_CLOSE + - JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - private static final String opflexIdentityResponse = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_ERROR_OPEN + - JSONRPC_ERROR_CLOSE + "," + - JSONRPC_RESULT_OPEN + - OPFLEX_NAME + - OPFLEX_DOMAIN + - MY_ROLE_OPEN + - "\"" + Role.POLICY_REPOSITORY.toString() + "\"" + - MY_ROLE_CLOSE + "," + - PEERS_OPEN + - OPFLEX_ROLE_OPEN + - "\"" + Role.ENDPOINT_REGISTRY.toString() + "\"," + - "\"" + Role.OBSERVER.toString() + "\"" + - OPFLEX_ROLE_CLOSE + "," + - "\"connectivity_info\": \"" + IDENTITY + "\"" + - PEERS_CLOSE + - JSONRPC_RESULT_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Policy message-specific definitions - */ - public static final String POLICY_URI = "\"policy_uri\":"; - public static final String DATA = "\"data\":"; - public static final String PRR = "\"prr\":"; - public static final String POLICY_IDENT_OPEN = "\"policy_ident\":" + JSON_OBJECT_OPEN; - public static final String POLICY_IDENT_CLOSE = JSON_OBJECT_CLOSE; - public static final String POLICY_IDENT_CONTEXT = "\"context\":"; - public static final String POLICY_IDENT_NAME = "\"name\":"; - - public static final Uri POLICY_IDENT_CONTEXT_VALUE = - new Uri("/PolicyUniverse/PolicySpace/f4d908bd-2911-43d4-9f22-a09f36ed3ddb"); - public static final Uri POLICY_URI_VALUE = - new Uri("/PolicyUniverse/PolicySpace/f4d908bd-2911-43d4-9f22-a09f36ed3ddb" + - "/GbpContract/b3506f37-b324-4092-80dd-f8a63bd193db"); - public static final String POLICY_CONTEXT = "Contract"; - public static final String PROP_NAME = "subject"; - public static final String PROP_DATA = "http"; - public static final Uri URI_NAME = new Uri("/foo/bar/t/robot"); - public static final Uri PARENT_URI_NAME = new Uri("/foo/bar/t"); - public static final String SUBJECT_NAME = "webFarmContract"; - public static final String PARENT_RELATION_NAME = "fooboo"; - public static final String PARENT_SUBJECT_NAME = "webFarmContractParent"; - public static final String POLICY_IDENT_URI = "ef130684-ac17-4118-ad36-8dea0babc7b2"; - public static final String DATA_NAME = "condition:notAuthorized"; - public static final String PRR_VALUE = "100"; - - /* - * Policy Request using URI - */ - private static final String opflexPolicyResolve1 = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + PolicyResolveRequest.RESOLVE_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + JSON_OBJECT_OPEN + - SUBJECT + "\"" + SUBJECT_NAME + "\"," + - POLICY_URI + "\"" + POLICY_URI_VALUE.getValue() + "\"," + - POLICY_IDENT_OPEN + - POLICY_IDENT_NAME + "\"\"," + - POLICY_IDENT_CONTEXT + "\"\"" + - POLICY_IDENT_CLOSE + "," + - DATA + "\"" + DATA_NAME + "\"," + - PRR + "\"" + PRR_VALUE + "\"" + - JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Policy Request using policy identity - */ - private static final String opflexPolicyResolve2 = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + PolicyResolveRequest.RESOLVE_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + JSON_OBJECT_OPEN + - SUBJECT + "\"" + SUBJECT_NAME + "\"," + - POLICY_URI + "\"\"," + - POLICY_IDENT_OPEN + - POLICY_IDENT_NAME + "\"" + POLICY_IDENT_URI + "\"," + - POLICY_IDENT_CONTEXT + "\"" + POLICY_IDENT_CONTEXT_VALUE.getValue() + "\"" + - POLICY_IDENT_CLOSE + "," + - DATA + "\"" + DATA_NAME + "\"," + - PRR + "\"" + PRR_VALUE + "\"" + - JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Managed Object definitions - */ - private static final String URI = " \"uri\":"; - private static final String PROPERTIES_OPEN = "\"properties\":" + JSON_ARRAY_OPEN; - private static final String PROPERTIES_CLOSE = JSON_ARRAY_CLOSE; - private static final String PROPERTY_NAME = "\"name\":"; - private static final String PROPERTY_DATA = "\"data\":"; - private static final String PARENT_SUBJECT = "\"parent_subject\":"; - private static final String PARENT_URI = "\"parent_uri\":"; - private static final String PARENT_RELATION = "\"parent_relation\":"; - private static final String CHILDREN = "\"children\":"; - private static final String POLICY_OPEN = "\"policy\":" + JSON_ARRAY_OPEN; - private static final String POLICY_CLOSE = JSON_ARRAY_CLOSE; - - private static final String managedObject = - SUBJECT + "\"" + SUBJECT_NAME + "\"," + - URI + "\"" + URI_NAME.getValue() + "\"," + - PROPERTIES_OPEN + - JSON_OBJECT_OPEN + - PROPERTY_NAME + "\"" + PROP_NAME + "\", " + - PROPERTY_DATA + "\"" + PROP_DATA + "\"" + - JSON_OBJECT_CLOSE + - PROPERTIES_CLOSE + ", " + - PARENT_SUBJECT + "\"" + PARENT_SUBJECT_NAME + "\"," + - PARENT_URI + "\"" + PARENT_URI_NAME.getValue() + "\"," + - PARENT_RELATION + "\"" + PARENT_RELATION_NAME + "\"," + - CHILDREN + JSON_ARRAY_OPEN + JSON_ARRAY_CLOSE; - - private static final String opflexPolicyResponse = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_ERROR_OPEN + - JSONRPC_ERROR_CLOSE + "," + - JSONRPC_RESULT_OPEN + - POLICY_OPEN + - JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE + - POLICY_CLOSE + - JSONRPC_RESULT_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Policy Unresolve message-specific definitions - */ - private static final String opflexPolicyUnresolveRequest = - JSON_OBJECT_OPEN + JSONRPC_ID + - JSONRPC_METHOD + "\"" + PolicyUnresolveRequest.UNRESOLVE_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + JSON_OBJECT_OPEN + - SUBJECT + "\"" + SUBJECT_NAME + "\"," + - POLICY_URI + "\"\"," + - POLICY_IDENT_OPEN + - POLICY_IDENT_NAME + "\"" + POLICY_IDENT_URI + "\"," + - POLICY_IDENT_CONTEXT + "\"" + POLICY_IDENT_CONTEXT_VALUE.getValue() + "\"" + - POLICY_IDENT_CLOSE + - JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - private static final String opflexPolicyUnresolveResponse = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_ERROR_OPEN + - JSONRPC_ERROR_CLOSE + "," + - JSONRPC_RESULT_OPEN + - JSONRPC_RESULT_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Pollicy Update message-specific definitions - */ - private static final String REPLACE_OPEN = "\"replace\":" + JSON_ARRAY_OPEN; - private static final String REPLACE_CLOSE = JSON_ARRAY_CLOSE; - private static final String MERGE_CHILDREN_OPEN = "\"merge_children\":" + JSON_ARRAY_OPEN; - private static final String MERGE_CHILDREN_CLOSE = JSON_ARRAY_CLOSE; - private static final String DELETE_URI_OPEN = "\"delete_uri\":" + JSON_ARRAY_OPEN; - private static final String DELETE_URI_CLOSE = JSON_ARRAY_CLOSE; - - private static final String opflexUpdateRequest = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + PolicyUpdateRequest.UPDATE_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + - JSON_OBJECT_OPEN + - REPLACE_OPEN + - JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE + - REPLACE_CLOSE + "," + - MERGE_CHILDREN_OPEN + - JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE + - MERGE_CHILDREN_CLOSE + "," + - DELETE_URI_OPEN + "\"" + POLICY_URI_VALUE.getValue() + "\"" + DELETE_URI_CLOSE + - JSON_OBJECT_CLOSE + - JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - private static final String opflexUpdateResponse = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_ERROR_OPEN + - JSONRPC_ERROR_CLOSE + "," + - JSONRPC_RESULT_OPEN + - JSONRPC_RESULT_CLOSE + - JSON_OBJECT_CLOSE; - - - /* - * Endoint Declare message-specific definitions - */ - private static final String ENDPOINT_OPEN = "\"endpoint\":" + JSON_ARRAY_OPEN; - private static final String ENDPOINT_CLOSE = JSON_ARRAY_CLOSE; - - - private static final String opflexEpDeclareRequest = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + EndpointDeclareRequest.DECLARE_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + - JSON_OBJECT_OPEN + - ENDPOINT_OPEN + - JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE + - ENDPOINT_CLOSE + "," + - PRR + "\"" + PRR_VALUE + "\"" + - JSON_OBJECT_CLOSE + - JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - private static final String opflexEpDeclareResponse = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_ERROR_OPEN + - JSONRPC_ERROR_CLOSE + "," + - JSONRPC_RESULT_OPEN + - JSONRPC_RESULT_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Endpoint Resolve message-specific definitions - */ - public static final String ENDPOINT_IDENT_OPEN = "\"endpoint_ident\":" + JSON_OBJECT_OPEN; - public static final String ENDPOINT_IDENT_CLOSE = JSON_OBJECT_CLOSE; - public static final String ENDPOINT_IDENT_CONTEXT = "\"context\":"; - public static final String ENDPOINT_IDENT_NAME = "\"identifier\":"; - public static final Uri ENDPOINT_IDENT_CONTEXT_VALUE = - new Uri("/EprL2Universe/EprL2Ep/f4d908bd-2911-43d4-9f22-a09f36ed3ddb"); - public static final Uri ENDPOINT_URI_VALUE = - new Uri("/EprL2Universe/EprL2Ep/f4d908bd-2911-43d4-9f22-a09f36ed3ddb/b3506f37-b324-4092-80dd-f8a63bd193db"); - public static final String ENDPOINT_IDENT_URI = "ef130684-ac17-4118-ad36-8dea0babc7b2"; - public static final String ENDPOINT = "\"endpoint\":"; - - - /* - * Endpoint Undeclare message-specific definitions - */ - private static final String ENDPOINT_URI = "\"endpoint_uri\":"; - private static final String opflexEpUndeclareRequest = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + EndpointUndeclareRequest.UNDECLARE_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + - JSON_OBJECT_OPEN + - SUBJECT + "\"" + SUBJECT_NAME + "\"," + - ENDPOINT_URI + "\"" + ENDPOINT_URI_VALUE.getValue() + "\"" + - JSON_OBJECT_CLOSE + - JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - private static final String opflexEpUndeclareResponse = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_ERROR_OPEN + - JSONRPC_ERROR_CLOSE + "," + - JSONRPC_RESULT_OPEN + - JSONRPC_RESULT_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Endpoint Resolve using URI - */ - private static final String opflexEpResolveRequest1 = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + EndpointResolveRequest.EP_RESOLVE_REQUEST_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + - JSON_OBJECT_OPEN + - SUBJECT + "\"" + SUBJECT_NAME + "\"," + - ENDPOINT_URI + "\"" + ENDPOINT_URI_VALUE.getValue() + "\"," + - ENDPOINT_IDENT_OPEN + - ENDPOINT_IDENT_CLOSE + "," + - PRR + "\"" + PRR_VALUE + "\"" + - JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Endpoint Resolve using Identity - */ - private static final String opflexEpResolveRequest2 = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + EndpointResolveRequest.EP_RESOLVE_REQUEST_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + - JSON_OBJECT_OPEN + - SUBJECT + "\"" + SUBJECT_NAME + "\"," + - ENDPOINT_URI + "\"\"," + - ENDPOINT_IDENT_OPEN + - ENDPOINT_IDENT_NAME + "\"" + ENDPOINT_IDENT_URI + "\"," + - ENDPOINT_IDENT_CONTEXT + "\"" + ENDPOINT_IDENT_CONTEXT_VALUE.getValue() + "\"" + - ENDPOINT_IDENT_CLOSE + "," + - PRR + "\"" + PRR_VALUE + "\"" + - JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - private static final String opflexEpResponse = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_ERROR_OPEN + - JSONRPC_ERROR_CLOSE + "," + - JSONRPC_RESULT_OPEN + - ENDPOINT + - JSON_ARRAY_OPEN + JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE + JSON_ARRAY_CLOSE + - JSONRPC_RESULT_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Endpoint Unresolve message-specific defines - */ - - /* - * Endpoint Unresolve using URI - */ - private static final String opflexEpUnresolveRequest1 = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + EndpointUnresolveRequest.EP_UNRESOLVE_REQUEST_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + - JSON_OBJECT_OPEN + - SUBJECT + "\"" + SUBJECT_NAME + "\"," + - ENDPOINT_URI + "\"" + ENDPOINT_URI_VALUE.getValue() + "\"," + - ENDPOINT_IDENT_OPEN + - ENDPOINT_IDENT_CLOSE + - JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Endpoint Unresolve using Identity - */ - private static final String opflexEpUnresolveRequest2 = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + EndpointUnresolveRequest.EP_UNRESOLVE_REQUEST_MESSAGE+ "\"," + - JSONRPC_PARAMS_OPEN + - JSON_OBJECT_OPEN + - SUBJECT + "\"" + SUBJECT_NAME + "\"," + - ENDPOINT_URI + "\"\"," + - ENDPOINT_IDENT_OPEN + - ENDPOINT_IDENT_NAME + "\"" + ENDPOINT_IDENT_URI + "\"," + - ENDPOINT_IDENT_CONTEXT + "\"" + ENDPOINT_IDENT_CONTEXT_VALUE.getValue() + "\"" + - ENDPOINT_IDENT_CLOSE + - JSON_OBJECT_CLOSE + JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - private static final String opflexEpUnresolveResponse = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_ERROR_OPEN + - JSONRPC_ERROR_CLOSE + "," + - JSONRPC_RESULT_OPEN + - JSONRPC_RESULT_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * Endpoint Update message-specific definitions - */ - - - private static final String opflexEpUpdateRequest = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + EndpointUpdateRequest.EP_UPDATE_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + - JSON_OBJECT_OPEN + - REPLACE_OPEN + - JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE + - REPLACE_CLOSE + "," + - DELETE_URI_OPEN + "\"" + POLICY_URI_VALUE.getValue() + "\"" + DELETE_URI_CLOSE + - JSON_OBJECT_CLOSE + - JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - private static final String opflexEpUpdateResponse = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_ERROR_OPEN + - JSONRPC_ERROR_CLOSE + "," + - JSONRPC_RESULT_OPEN + - JSONRPC_RESULT_CLOSE + - JSON_OBJECT_CLOSE; - - /* - * State Report message-specific definitions - */ - private static final String OBJECT = "\"object\":"; - private static final Uri OBJECT_VALUE = - new Uri("/EprL2Universe/EprL2Ep/f4d908bd-2911-43d4-9f22-a09f36ed3ddb"); - private static final String OBSERVABLE = "\"observable\":"; - private static final String opflexStateRequest = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_METHOD + "\"" + StateReportRequest.STATE_MESSAGE + "\"," + - JSONRPC_PARAMS_OPEN + - JSON_OBJECT_OPEN + - OBJECT + "\"" + OBJECT_VALUE.getValue() + "\"," + - OBSERVABLE + - JSON_ARRAY_OPEN + JSON_OBJECT_OPEN + managedObject + JSON_OBJECT_CLOSE + JSON_ARRAY_CLOSE + - JSON_OBJECT_CLOSE + - JSONRPC_PARAMS_CLOSE + - JSON_OBJECT_CLOSE; - - - - private static final String opflexStateResponse = - JSON_OBJECT_OPEN + - JSONRPC_ID + - JSONRPC_ERROR_OPEN + - JSONRPC_ERROR_CLOSE + "," + - JSONRPC_RESULT_OPEN + - JSONRPC_RESULT_CLOSE + - JSON_OBJECT_CLOSE; - - @Before - public void setUp() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - } - - - @Test - public void testIdentityRequest() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexIdentityRequest, IdentityRequest.class); - String foo = objectMapper.writeValueAsString(rpcMsg); - System.out.println(foo); - assertTrue(rpcMsg instanceof IdentityRequest); - IdentityRequest opflexRequest = (IdentityRequest)rpcMsg; - assertTrue(opflexRequest.getId().toString().contains(ID_UUID)); - assertTrue(opflexRequest.getMethod().equals(IdentityRequest.IDENTITY_MESSAGE)); - assertTrue(opflexRequest.getParams() - .get(0).getProto_version().equals(OPFLEX_PROTO_VERSION)); - assertTrue(opflexRequest.getParams() - .get(0).getDomain().equals(DOMAIN_UUID)); - assertTrue(opflexRequest.getParams() - .get(0).getName().equals(TEST_NAME)); - assertTrue(opflexRequest.getParams() - .get(0).getMy_role().get(0).equals(Role.POLICY_ELEMENT.toString())); - assertTrue(opflexRequest.getParams() - .get(0).getName().equals(TEST_NAME)); - } - - @Test - public void testIdentityResponse() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexIdentityResponse, IdentityResponse.class); - assertTrue(rpcMsg instanceof IdentityResponse); - IdentityResponse opflexResponse = (IdentityResponse)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - assertTrue(opflexResponse.getResult() - .getDomain().equals(DOMAIN_UUID)); - assertTrue(opflexResponse.getResult() - .getName().equals(TEST_NAME)); - assertTrue(opflexResponse.getResult() - .getMy_role().get(0).equals(Role.POLICY_REPOSITORY.toString())); - assertTrue(opflexResponse.getResult() - .getPeers().get(0).getRole().get(0).equals(Role.ENDPOINT_REGISTRY.toString())); - assertTrue(opflexResponse.getResult() - .getPeers().get(0).getRole().get(1).equals(Role.OBSERVER.toString())); - } - - /** - * Test a policy resolve message that uses the URI instead of the - * policy identity for passing the policy requested. - * - * @throws Exception - */ - @Test - public void testPolicyResolve1() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexPolicyResolve1, PolicyResolveRequest.class); - assertTrue(rpcMsg instanceof PolicyResolveRequest); - PolicyResolveRequest opflexRequest = (PolicyResolveRequest)rpcMsg; - assertTrue(opflexRequest.getId().toString().contains(ID_UUID)); - assertTrue(opflexRequest.getMethod().equals(PolicyResolveRequest.RESOLVE_MESSAGE)); - assertTrue(opflexRequest.getParams() - .get(0).getPolicy_uri().getValue().equals(POLICY_URI_VALUE.getValue())); - assertTrue(opflexRequest.getParams() - .get(0).getPolicy_ident().getContext().getValue() == ""); - assertTrue(opflexRequest.getParams() - .get(0).getPolicy_ident().getName() == ""); - assertTrue(opflexRequest.getParams() - .get(0).getPrr() == Integer.parseInt(PRR_VALUE)); - assertTrue(opflexRequest.getParams() - .get(0).getSubject().equals(SUBJECT_NAME)); - assertTrue(opflexRequest.getParams() - .get(0).getData().equals(DATA_NAME)); - - } - - /** - * Test a policy resolve message that uses he policy identity instead - * of the URI for passing the policy requested. - * - * @throws Exception - */ - @Test - public void testPolicyResolve2() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexPolicyResolve2, PolicyResolveRequest.class); - assertTrue(rpcMsg instanceof PolicyResolveRequest); - PolicyResolveRequest opflexRequest = (PolicyResolveRequest)rpcMsg; - assertTrue(opflexRequest.getId().toString().contains(ID_UUID)); - assertTrue(opflexRequest.getMethod().equals(PolicyResolveRequest.RESOLVE_MESSAGE)); - assertTrue(opflexRequest.getParams() - .get(0).getPolicy_uri().getValue() == ""); - assertTrue(opflexRequest.getParams() - .get(0).getPolicy_ident().getName().equals(POLICY_IDENT_URI)); - assertTrue(opflexRequest.getParams() - .get(0).getPolicy_ident().getContext().getValue() - .equals(POLICY_IDENT_CONTEXT_VALUE.getValue())); - assertTrue(opflexRequest.getParams() - .get(0).getPrr() == Integer.parseInt(PRR_VALUE)); - assertTrue(opflexRequest.getParams() - .get(0).getSubject().equals(SUBJECT_NAME)); - assertTrue(opflexRequest.getParams() - .get(0).getData().equals(DATA_NAME)); - - } - - /** - * Test the response to the policy resolve message - * - * @throws Exception - */ - @Test - public void testPolicyResolveResponse() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexPolicyResponse, PolicyResolveResponse.class); - assertTrue(rpcMsg instanceof PolicyResolveResponse); - PolicyResolveResponse opflexResponse = (PolicyResolveResponse)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - // TODO: add support for testing children? - assertTrue(opflexResponse.getResult() - .getPolicy().get(0).getChildren().size() == 0); - assertTrue(opflexResponse.getResult() - .getPolicy().get(0).getParent_relation().equals(PARENT_RELATION_NAME)); - assertTrue(opflexResponse.getResult() - .getPolicy().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME)); - assertTrue(opflexResponse.getResult() - .getPolicy().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue())); - assertTrue(opflexResponse.getResult() - .getPolicy().get(0).getUri().getValue().equals(URI_NAME.getValue())); - assertTrue(opflexResponse.getResult() - .getPolicy().get(0).getProperties().get(0).getName().equals(PROP_NAME)); - assertTrue(opflexResponse.getResult() - .getPolicy().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA)); - assertTrue(opflexResponse.getResult() - .getPolicy().get(0).getSubject().equals(SUBJECT_NAME)); - } - - /** - * Test a policy unresolve message that uses the URI instead of the - * policy identity for passing the policy requested. - * - * @throws Exception - */ - @Test - public void testPolicyUnresolveRequest() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - System.out.println(opflexPolicyUnresolveRequest); - RpcMessage rpcMsg = objectMapper. - readValue(opflexPolicyUnresolveRequest, PolicyResolveRequest.class); - assertTrue(rpcMsg instanceof PolicyResolveRequest); - PolicyResolveRequest opflexRequest = (PolicyResolveRequest)rpcMsg; - assertTrue(opflexRequest.getId().toString().contains(ID_UUID)); - assertTrue(opflexRequest.getMethod().equals(PolicyUnresolveRequest.UNRESOLVE_MESSAGE)); - System.out.println(POLICY_URI_VALUE.getValue()); - assertTrue(opflexRequest.getParams() - .get(0).getPolicy_ident().getContext().getValue().equals(POLICY_IDENT_CONTEXT_VALUE.getValue())); - assertTrue(opflexRequest.getParams() - .get(0).getPolicy_uri().getValue() == ""); - assertTrue(opflexRequest.getParams() - .get(0).getSubject().equals(SUBJECT_NAME)); - - } - - - @Test - public void testPolicyUnresolveResponse() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexPolicyUnresolveResponse, PolicyUnresolveResponse.class); - assertTrue(rpcMsg instanceof PolicyUnresolveResponse); - PolicyUnresolveResponse opflexResponse = (PolicyUnresolveResponse)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - } - - @Test - public void testPolicyUpdateRequest() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - System.out.println(opflexUpdateRequest); - RpcMessage rpcMsg = objectMapper. - readValue(opflexUpdateRequest, PolicyUpdateRequest.class); - assertTrue(rpcMsg instanceof PolicyUpdateRequest); - PolicyUpdateRequest opflexResponse = (PolicyUpdateRequest)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - assertTrue(opflexResponse.getParams().get(0) - .getDelete_uri().get(0).getValue().equals(POLICY_URI_VALUE.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getMerge_children().get(0).getParent_relation().equals(PARENT_RELATION_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getMerge_children().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getMerge_children().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getMerge_children().get(0).getUri().getValue().equals(URI_NAME.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getMerge_children().get(0).getProperties().get(0).getName().equals(PROP_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getMerge_children().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA)); - assertTrue(opflexResponse.getParams().get(0) - .getMerge_children().get(0).getSubject().equals(SUBJECT_NAME)); - // TODO: add support for testing children? - assertTrue(opflexResponse.getParams().get(0) - .getMerge_children().get(0).getChildren().size() == 0); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getParent_relation().equals(PARENT_RELATION_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getUri().getValue().equals(URI_NAME.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getProperties().get(0).getName().equals(PROP_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA)); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getSubject().equals(SUBJECT_NAME)); - // TODO: add support for testing children? - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getChildren().size() == 0); - } - - @Test - public void testUpdateResponse() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexUpdateResponse, PolicyUpdateResponse.class); - assertTrue(rpcMsg instanceof PolicyUpdateResponse); - PolicyUpdateResponse opflexResponse = (PolicyUpdateResponse)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - - } - - - @Test - public void testEpDeclareRequest() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpDeclareRequest, EndpointDeclareRequest.class); - assertTrue(rpcMsg instanceof EndpointDeclareRequest); - EndpointDeclareRequest opflexResponse = (EndpointDeclareRequest)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - assertTrue(opflexResponse.getParams().get(0) - .getEndpoint().get(0).getParent_relation().equals(PARENT_RELATION_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getEndpoint().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getEndpoint().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getEndpoint().get(0).getUri().getValue().equals(URI_NAME.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getEndpoint().get(0).getProperties().get(0).getName().equals(PROP_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getEndpoint().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA)); - assertTrue(opflexResponse.getParams().get(0) - .getEndpoint().get(0).getSubject().equals(SUBJECT_NAME)); - // TODO: add support for testing children? - assertTrue(opflexResponse.getParams().get(0) - .getEndpoint().get(0).getChildren().size() == 0); - assertTrue(opflexResponse.getParams().get(0) - .getPrr() == Integer.parseInt(PRR_VALUE)); - } - - @Test - public void testEpDeclareResponse() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpDeclareResponse, EndpointDeclareResponse.class); - assertTrue(rpcMsg instanceof EndpointDeclareResponse); - EndpointDeclareResponse opflexResponse = (EndpointDeclareResponse)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - } - - @Test - public void testEndpointUndeclareRequest() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpUndeclareRequest, EndpointUndeclareRequest.class); - assertTrue(rpcMsg instanceof EndpointUndeclareRequest); - EndpointUndeclareRequest opflexRequest = (EndpointUndeclareRequest)rpcMsg; - assertTrue(opflexRequest.getId().toString().contains(ID_UUID)); - assertTrue(opflexRequest.getMethod().equals(EndpointUndeclareRequest.UNDECLARE_MESSAGE)); - assertTrue(opflexRequest.getParams() - .get(0).getEndpoint_uri().getValue().equals(ENDPOINT_URI_VALUE.getValue())); - assertTrue(opflexRequest.getParams() - .get(0).getSubject().equals(SUBJECT_NAME)); - - } - - - @Test - public void testEpUndeclareResponse() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpUndeclareResponse, EndpointUndeclareResponse.class); - assertTrue(rpcMsg instanceof EndpointUndeclareResponse); - EndpointUndeclareResponse opflexResponse = (EndpointUndeclareResponse)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - } - - @Test - public void testEpResolveRequest1() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpResolveRequest1, EndpointResolveRequest.class); - assertTrue(rpcMsg instanceof EndpointResolveRequest); - EndpointResolveRequest opflexResponse = (EndpointResolveRequest)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - assertTrue(opflexResponse.getParams() - .get(0).getSubject().equals(SUBJECT_NAME)); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_uri().getValue().equals(ENDPOINT_URI_VALUE.getValue())); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_ident().getContext() == null); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_ident().getIdentifier() == null); - } - - - @Test - public void testEpResolveRequest2() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - System.out.println(opflexEpResolveRequest2); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpResolveRequest2, EndpointResolveRequest.class); - assertTrue(rpcMsg instanceof EndpointResolveRequest); - EndpointResolveRequest opflexResponse = (EndpointResolveRequest)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - assertTrue(opflexResponse.getParams() - .get(0).getSubject().equals(SUBJECT_NAME)); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_uri().getValue() == ""); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_ident().getIdentifier().equals(ENDPOINT_IDENT_URI)); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_ident().getContext() - .getValue().equals(ENDPOINT_IDENT_CONTEXT_VALUE.getValue())); - } - - @Test - public void testEpResolveResponse() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpResponse, EndpointResolveResponse.class); - assertTrue(rpcMsg instanceof EndpointResolveResponse); - EndpointResolveResponse opflexResponse = (EndpointResolveResponse)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - assertTrue(opflexResponse.getResult() - .getEndpoint().get(0).getParent_relation().equals(PARENT_RELATION_NAME)); - assertTrue(opflexResponse.getResult() - .getEndpoint().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME)); - assertTrue(opflexResponse.getResult() - .getEndpoint().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue())); - assertTrue(opflexResponse.getResult() - .getEndpoint().get(0).getUri().getValue().equals(URI_NAME.getValue())); - assertTrue(opflexResponse.getResult() - .getEndpoint().get(0).getProperties().get(0).getName().equals(PROP_NAME)); - assertTrue(opflexResponse.getResult() - .getEndpoint().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA)); - assertTrue(opflexResponse.getResult() - .getEndpoint().get(0).getSubject().equals(SUBJECT_NAME)); - // TODO: add support for testing children? - assertTrue(opflexResponse.getResult() - .getEndpoint().get(0).getChildren().size() == 0); - } - - @Test - public void testEpUnresolveRequest1() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpUnresolveRequest1, EndpointUnresolveRequest.class); - assertTrue(rpcMsg instanceof EndpointUnresolveRequest); - EndpointUnresolveRequest opflexResponse = (EndpointUnresolveRequest)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - assertTrue(opflexResponse.getParams() - .get(0).getSubject().equals(SUBJECT_NAME)); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_uri().getValue().equals(ENDPOINT_URI_VALUE.getValue())); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_ident().getContext() == null); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_ident().getIdentifier() == null); - } - - @Test - public void testEpUnresolveRequest2() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpUnresolveRequest2, EndpointUnresolveRequest.class); - assertTrue(rpcMsg instanceof EndpointUnresolveRequest); - EndpointUnresolveRequest opflexResponse = (EndpointUnresolveRequest)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - assertTrue(opflexResponse.getParams() - .get(0).getSubject().equals(SUBJECT_NAME)); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_uri().getValue() == ""); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_ident().getIdentifier().equals(ENDPOINT_IDENT_URI)); - assertTrue(opflexResponse.getParams() - .get(0).getEndpoint_ident().getContext() - .getValue().equals(ENDPOINT_IDENT_CONTEXT_VALUE.getValue())); - } - - @Test - public void testEpUnresolveResponse() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpUnresolveResponse, EndpointUnresolveResponse.class); - assertTrue(rpcMsg instanceof EndpointUnresolveResponse); - EndpointUnresolveResponse opflexResponse = (EndpointUnresolveResponse)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - } - - @Test - public void testEpUpdateRequest() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpUpdateRequest, EndpointUpdateRequest.class); - assertTrue(rpcMsg instanceof EndpointUpdateRequest); - EndpointUpdateRequest opflexResponse = (EndpointUpdateRequest)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getParent_relation().equals(PARENT_RELATION_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getParent_uri().getValue().equals(PARENT_URI_NAME.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getUri().getValue().equals(URI_NAME.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getProperties().get(0).getName().equals(PROP_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA)); - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getSubject().equals(SUBJECT_NAME)); - // TODO: add support for testing children? - assertTrue(opflexResponse.getParams().get(0) - .getReplace().get(0).getChildren().size() == 0); - assertTrue(opflexResponse.getParams().get(0) - .getDelete_uri().get(0).getValue().equals(POLICY_URI_VALUE.getValue())); - } - - - @Test - public void testEpUpdateResponse() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexEpUpdateResponse, EndpointUpdateResponse.class); - assertTrue(rpcMsg instanceof EndpointUpdateResponse); - EndpointUpdateResponse opflexResponse = (EndpointUpdateResponse)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - } - - - //@Test - public void testStateRequest() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexStateRequest, StateReportRequest.class); - assertTrue(rpcMsg instanceof StateReportRequest); - StateReportRequest opflexResponse = (StateReportRequest)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - assertTrue(opflexResponse.getParams().get(0) - .getObservable().get(0).getParent_relation().equals(PARENT_RELATION_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getObservable().get(0).getParent_subject().equals(PARENT_SUBJECT_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getObservable().get(0).getParent_uri().equals(PARENT_URI_NAME.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getObservable().get(0).getUri().equals(URI_NAME.getValue())); - assertTrue(opflexResponse.getParams().get(0) - .getObservable().get(0).getProperties().get(0).getName().equals(PROP_NAME)); - assertTrue(opflexResponse.getParams().get(0) - .getObservable().get(0).getProperties().get(0).getData().asText().equals(PROP_DATA)); - assertTrue(opflexResponse.getParams().get(0) - .getObservable().get(0).getSubject().equals(SUBJECT_NAME)); - // TODO: add support for testing children? - assertTrue(opflexResponse.getParams().get(0) - .getObservable().get(0).getChildren() == null); - assertTrue(opflexResponse.getParams().get(0) - .getObject().getValue().equals(OBJECT_VALUE.getValue())); - } - - //@Test - public void testStateResponse() throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - RpcMessage rpcMsg = objectMapper. - readValue(opflexStateResponse, StateReportResponse.class); - assertTrue(rpcMsg instanceof StateReportResponse); - StateReportResponse opflexResponse = (StateReportResponse)rpcMsg; - assertTrue(opflexResponse.getId().toString().contains(ID_UUID)); - } - - - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/EnumInfoTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/EnumInfoTest.java deleted file mode 100644 index 1d8841c42..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/EnumInfoTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : tbachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import static org.junit.Assert.assertTrue; - -import java.math.BigInteger; - -import org.junit.Test; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.EnumInfo.EnumInfoBuilder; - -public class EnumInfoTest { - - private static final String TEST_NAME_1 = "Foo"; - private static final String TEST_NAME_2 = "Boo"; - private static final String TEST_NAME_3 = "Zoo"; - private static final String TEST_VALUE_1_STRING = "100"; - private static final String TEST_VALUE_2_STRING = "101"; - private static final String TEST_VALUE_3_STRING = "102"; - - - - @Test - public void testBuilder() throws Exception { - EnumInfoBuilder eib = new EnumInfoBuilder(); - - BigInteger bi1 = new BigInteger(TEST_VALUE_1_STRING); - BigInteger bi2 = new BigInteger(TEST_VALUE_2_STRING); - BigInteger bi3 = new BigInteger(TEST_VALUE_3_STRING); - - eib.setEnumValue(TEST_NAME_1, bi1); - eib.setEnumValue(TEST_NAME_2, bi2); - eib.setEnumValue(TEST_NAME_3, bi3); - - EnumInfo ei = eib.build(); - assertTrue(ei.getEnumValue(TEST_NAME_1).equals(bi1)); - assertTrue(ei.getEnumValue(bi1).equals(TEST_NAME_1)); - assertTrue(ei.getEnumValue(TEST_NAME_2).equals(bi2)); - assertTrue(ei.getEnumValue(bi2).equals(TEST_NAME_2)); - assertTrue(ei.getEnumValue(TEST_NAME_3).equals(bi3)); - assertTrue(ei.getEnumValue(bi3).equals(TEST_NAME_3)); - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/MitLibTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/MitLibTest.java deleted file mode 100644 index 5444b17ed..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/MitLibTest.java +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : tbachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import static org.junit.Assert.assertTrue; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.ManagedObject; -import org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages.ManagedObject.Property; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.EnumInfo.EnumInfoBuilder; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyClassInfo.PolicyClassInfoBuilder; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyId; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyInfoBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class MitLibTest { - - private static final String TEST_CLASS_1_NAME = "ClassBar"; - private static final String TEST_CLASS_2_NAME = "ClassBee"; - private static final String TEST_CLASS_3_NAME = "ClassZoo"; - private static final String TEST_PROP_1_NAME = "PropBoo"; - private static final String TEST_PROP_2_NAME = "PropFoo"; - private static final String TEST_PROP_3_NAME = "PropGoo"; - private static final String TEST_PROP_4_NAME = "PropFew"; - private static final String TEST_PROP_5_NAME = "PropLou"; - private static final String TEST_PROP_6_NAME = "PropDue"; - private static final String TEST_PROP_7_NAME = "PropSue"; - private static final String TEST_ENUM_1_NAME = "EnumBlue"; - private static final String TEST_ENUM_VAL_1_NAME = "Hello"; - private static final String TEST_ENUM_VAL_2_NAME = "World"; - private static final String TEST_DATA_2_STRING = "FooToYou"; - private static final String TEST_DATA_4_STRING = "00:01:02:03:04:05"; - private static final String TEST_DATA_6_STRING = "2148040771"; - private static final String TEST_DATA_7_STRING = "200"; - - private static final int TEST_PROP_1_ID = 101; - private static final int TEST_PROP_2_ID = 102; - private static final int TEST_PROP_3_ID = 103; - private static final int TEST_PROP_4_ID = 104; - private static final int TEST_PROP_5_ID = 105; - private static final int TEST_PROP_6_ID = 106; - private static final int TEST_PROP_7_ID = 106; - private static final int TEST_CLASS_1_ID = 201; - private static final int TEST_CLASS_2_ID = 202; - private static final int TEST_CLASS_3_ID = 203; - private static final int TEST_ENUM_VAL_1_VAL = 3; - private static final int TEST_ENUM_VAL_2_VAL = 4; - - private ObjectMapper objectMapper; - private JsonNodeFactory jnf; - - public static class TestMit implements OpflexMit { - - private Map metaDataMap = null; - private Map classIdMap = null; - - public TestMit() { - EnumInfo ei; - PolicyPropertyInfo ppi; - PolicyClassInfo pci; - EnumInfoBuilder eib; - PolicyPropertyInfoBuilder ppib; - PolicyClassInfoBuilder pcib; - List ppil; - List classKeys; - - Map metaData = new HashMap(); - Map classIds = new HashMap(); - - /* - * Construct a test MIT tree - * - * TODO: test vectored values - */ - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(TEST_PROP_1_ID)). - setPropName(TEST_PROP_1_NAME). - setType(PolicyPropertyInfo.PropertyType.COMPOSITE). - setClassId(TEST_CLASS_2_ID). - setPropCardinality(PolicyPropertyInfo.PropertyCardinality.VECTOR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(TEST_PROP_2_ID)). - setPropName(TEST_PROP_2_NAME). - setType(PolicyPropertyInfo.PropertyType.STRING). - setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - classKeys.add(ppi.getPropId()); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(TEST_PROP_3_ID)). - setPropName(TEST_PROP_3_NAME). - setType(PolicyPropertyInfo.PropertyType.REFERENCE). - setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(TEST_CLASS_1_ID). - setClassName(TEST_CLASS_1_NAME). - setPolicyType(PolicyClassInfo.PolicyClassType.POLICY). - setProperty(ppil). - setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIds.put(new Long(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(TEST_PROP_4_ID)). - setPropName(TEST_PROP_4_NAME). - setType(PolicyPropertyInfo.PropertyType.MAC). - setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - eib = new EnumInfoBuilder(); - eib.setName(TEST_ENUM_1_NAME); - eib.setEnumValue(TEST_ENUM_VAL_1_NAME,new BigInteger(String.valueOf(TEST_ENUM_VAL_1_VAL))); - eib.setEnumValue(TEST_ENUM_VAL_2_NAME,new BigInteger(String.valueOf(TEST_ENUM_VAL_2_VAL))); - ei = eib.build(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(TEST_PROP_5_ID)). - setPropName(TEST_PROP_5_NAME). - setType(PolicyPropertyInfo.PropertyType.ENUM8). - setEnumInfo(ei). - setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(TEST_CLASS_2_ID). - setClassName(TEST_CLASS_2_NAME). - setPolicyType(PolicyClassInfo.PolicyClassType.POLICY). - setProperty(ppil). - setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIds.put(new Long(pci.getClassId()), pci.getClassName()); - - ppil = new ArrayList(); - classKeys = new ArrayList(); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(TEST_PROP_6_ID)). - setPropName(TEST_PROP_6_NAME). - setType(PolicyPropertyInfo.PropertyType.U64). - setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - ppib = new PolicyPropertyInfoBuilder(); - ppib.setPropId(new PolicyPropertyId(TEST_PROP_7_ID)). - setPropName(TEST_PROP_7_NAME). - setType(PolicyPropertyInfo.PropertyType.S64). - setPropCardinality(PolicyPropertyInfo.PropertyCardinality.SCALAR); - ppi = ppib.build(); - ppil.add(ppi); - pcib = new PolicyClassInfoBuilder(); - pcib.setClassId(TEST_CLASS_3_ID). - setClassName(TEST_CLASS_3_NAME). - setPolicyType(PolicyClassInfo.PolicyClassType.LOCAL_ONLY). - setProperty(ppil). - setKey(classKeys); - pci = pcib.build(); - metaData.put(pci.getClassName(), pci); - classIds.put(new Long(pci.getClassId()), pci.getClassName()); - - metaDataMap = Collections.unmodifiableMap(metaData); - classIdMap = Collections.unmodifiableMap(classIds); - - } - - @Override - public PolicyClassInfo getClass(String name) { - return metaDataMap.get(name); - - } - - @Override - public PolicyClassInfo getClass(Long classId) { - String className = classIdMap.get(classId); - if (className == null) return null; - return metaDataMap.get(className); - } - - } - - private TestMit testMit; - private ManagedObject testMo; - private MitLib lib; - - @Before - public void setUp() throws Exception { - lib = new MitLib(); - testMit = new TestMit(); - objectMapper = new ObjectMapper(); - objectMapper.configure( - DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - jnf = objectMapper.getNodeFactory(); - - } - - private ManagedObject constructClass1Mo() { - List propList = new ArrayList(); - Property prop = null; - ManagedObject mo = new ManagedObject(); - mo = new ManagedObject(); - mo.setSubject(TEST_CLASS_1_NAME); - - JsonNode jn = jnf.textNode(TEST_DATA_2_STRING); - prop = new Property(); - prop.setName(TEST_PROP_2_NAME); - prop.setData(jn); - propList.add(prop); - prop = new Property(); - prop.setName(TEST_PROP_3_NAME); - ObjectNode on = jnf.objectNode(); - on.put(MitLib.REFERENCE_SUBJECT, TEST_CLASS_3_NAME); - on.put(MitLib.REFERENCE_URI, "/" + TEST_CLASS_3_NAME); - prop.setData(on); - propList.add(prop); - mo.setProperties(propList); - return mo; - - } - - private ManagedObject constructClass2Mo() { - List propList = new ArrayList(); - Property prop = null; - ManagedObject mo = new ManagedObject(); - mo = new ManagedObject(); - mo.setSubject(TEST_CLASS_2_NAME); - - prop = new Property(); - prop.setName(TEST_PROP_4_NAME); - JsonNode jn = jnf.textNode(TEST_DATA_4_STRING); - prop.setData(jn); - propList.add(prop); - prop = new Property(); - prop.setName(TEST_PROP_5_NAME); - jn = jnf.textNode(TEST_ENUM_VAL_2_NAME); - prop.setData(jn); - propList.add(prop); - mo.setProperties(propList); - - return mo; - } - - private ManagedObject constructClass3Mo() { - List propList = new ArrayList(); - Property prop = null; - ManagedObject mo = new ManagedObject(); - mo = new ManagedObject(); - - mo.setSubject(TEST_CLASS_3_NAME); - - prop = new Property(); - prop.setName(TEST_PROP_6_NAME); - JsonNode jn = jnf.numberNode(new BigInteger(TEST_DATA_6_STRING)); - prop.setData(jn); - propList.add(prop); - prop = new Property(); - jn = jnf.numberNode(new BigInteger(TEST_DATA_7_STRING)); - prop.setName(TEST_PROP_7_NAME); - prop.setData(jn); - propList.add(prop); - mo.setProperties(propList); - - return mo; - } - - @Test - public void testDeserializeMoProperties() throws Exception { - PolicyObjectInstance poi = null; - - /* - * Each MO is a class, with the properties of the class - * matching the properties of the MO. Construct the MO, - * run through the deserializer, and verify that the - * resulting object instance is of the right class and - * has all the properties with correct values - */ - - // Test MO/Class 1 - testMo = constructClass1Mo(); - - poi = lib.deserializeMoProperties(testMo, testMit); - assertTrue(poi.getClassId() == TEST_CLASS_1_ID); - assertTrue(poi.isSet(new PolicyPropertyId(TEST_PROP_2_ID), - PolicyPropertyInfo.PropertyType.STRING, - PolicyPropertyInfo.PropertyCardinality.SCALAR)); - assertTrue(poi.getString(new PolicyPropertyId(TEST_PROP_2_ID)).equals(TEST_DATA_2_STRING)); - - assertTrue(poi.isSet(new PolicyPropertyId(TEST_PROP_3_ID), - PolicyPropertyInfo.PropertyType.REFERENCE, - PolicyPropertyInfo.PropertyCardinality.SCALAR)); - PolicyObjectInstance.PolicyReference ref = poi.getReference(new PolicyPropertyId(TEST_PROP_3_ID)); - assertTrue(ref.getClassId() == TEST_CLASS_3_ID); - assertTrue(ref.getUri().getValue().equals("/" + TEST_CLASS_3_NAME)); - - // Test MO/Class 2 - testMo = constructClass2Mo(); - poi = lib.deserializeMoProperties(testMo, testMit); - - assertTrue(poi.getClassId() == TEST_CLASS_2_ID); - assertTrue(poi.isSet(new PolicyPropertyId(TEST_PROP_4_ID), - PolicyPropertyInfo.PropertyType.MAC, - PolicyPropertyInfo.PropertyCardinality.SCALAR)); - MacAddress mac = poi.getMacAddress(new PolicyPropertyId(TEST_PROP_4_ID)); - assertTrue(mac.equals(new MacAddress(TEST_DATA_4_STRING))); - - assertTrue(poi.isSet(new PolicyPropertyId(TEST_PROP_5_ID), - PolicyPropertyInfo.PropertyType.ENUM8, - PolicyPropertyInfo.PropertyCardinality.SCALAR)); - assertTrue(poi.getUint64(new PolicyPropertyId(TEST_PROP_5_ID)).intValue() == TEST_ENUM_VAL_2_VAL); - - // Test MO/Class 3 - testMo = constructClass3Mo(); - poi = lib.deserializeMoProperties(testMo, testMit); - - assertTrue(poi.getClassId() == TEST_CLASS_3_ID); - assertTrue(poi.isSet(new PolicyPropertyId(TEST_PROP_6_ID), - PolicyPropertyInfo.PropertyType.U64, - PolicyPropertyInfo.PropertyCardinality.SCALAR)); - assertTrue(poi.getUint64(new PolicyPropertyId(TEST_PROP_6_ID)).equals(new BigInteger(TEST_DATA_6_STRING))); - assertTrue(mac.equals(new MacAddress(TEST_DATA_4_STRING))); - - assertTrue(poi.isSet(new PolicyPropertyId(TEST_PROP_7_ID), - PolicyPropertyInfo.PropertyType.S64, - PolicyPropertyInfo.PropertyCardinality.SCALAR)); - assertTrue(poi.getInt64(new PolicyPropertyId(TEST_PROP_7_ID)) == new Long(TEST_DATA_7_STRING)); - - - } - - @Test - public void testSerializeMoProperties() throws Exception { - PolicyClassInfo pci = null; - PolicyObjectInstance poi = null; - boolean prop2Found = false, prop3Found = false, - prop4Found = false, prop5Found = false, - prop6Found = false, prop7Found = false; - - /* - * Construct the PolicyObjectInfo object by - * running it through the deserializer - */ - - testMo = constructClass1Mo(); - poi = lib.deserializeMoProperties(testMo, testMit); - pci = testMit.getClass(TEST_CLASS_1_NAME); - lib.serializeMoProperties( pci, poi, testMo, testMit); - List props = testMo.getProperties(); - assertTrue(props.size() == 2); - for (Property prop: props) { - - if (prop.getName().equals(TEST_PROP_2_NAME)) { - assertTrue(prop.getData().asText().equals(TEST_DATA_2_STRING)); - prop2Found = true; - } - - if (prop.getName().equals(TEST_PROP_3_NAME)) { - assertTrue(prop.getName().equals(TEST_PROP_3_NAME)); - assertTrue(prop.getData().has(MitLib.REFERENCE_SUBJECT)); - JsonNode jn = prop.getData().findValue(MitLib.REFERENCE_SUBJECT); - assertTrue(jn.asText().equals(TEST_CLASS_3_NAME)); - assertTrue(prop.getData().has(MitLib.REFERENCE_URI)); - jn = prop.getData().findValue(MitLib.REFERENCE_URI); - assertTrue(jn.asText().equals("/" + TEST_CLASS_3_NAME)); - prop3Found = true; - } - } - assertTrue(prop2Found); - assertTrue(prop3Found); - - testMo = constructClass2Mo(); - poi = lib.deserializeMoProperties(testMo, testMit); - pci = testMit.getClass(TEST_CLASS_2_NAME); - lib.serializeMoProperties( pci, poi, testMo, testMit); - props = testMo.getProperties(); - assertTrue(props.size() == 2); - for (Property prop: props) { - - if (prop.getName().equals(TEST_PROP_4_NAME)) { - assertTrue(prop.getData().asText().equals(TEST_DATA_4_STRING)); - prop4Found = true; - } - if (prop.getName().equals(TEST_PROP_5_NAME)) { - assertTrue(prop.getData().asText().equals(TEST_ENUM_VAL_2_NAME)); - prop5Found = true; - } - } - assertTrue(prop4Found); - assertTrue(prop5Found); - - - testMo = constructClass3Mo(); - poi = lib.deserializeMoProperties(testMo, testMit); - pci = testMit.getClass(TEST_CLASS_3_NAME); - lib.serializeMoProperties( pci, poi, testMo, testMit); - props = testMo.getProperties(); - assertTrue(props.size() == 2); - for (Property prop: props) { - if (prop.getName().equals(TEST_PROP_6_NAME)) { - assertTrue(prop.getData().asText().equals(TEST_DATA_6_STRING)); - prop6Found = true; - } - if (prop.getName().equals(TEST_PROP_7_NAME)) { - assertTrue(prop.getData().asText().equals(TEST_DATA_7_STRING)); - prop7Found = true; - } - } - assertTrue(prop6Found); - assertTrue(prop7Found); - - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyClassInfoTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyClassInfoTest.java deleted file mode 100644 index 7af3e6bad..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyClassInfoTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : tbachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import static org.junit.Assert.assertTrue; - - - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyClassInfo.PolicyClassInfoBuilder; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyId; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyInfoBuilder; - -public class PolicyClassInfoTest { - - List testKeyList; - List testPropertyInfoList; - PolicyPropertyInfo testPpi; - - private static final int TEST_PROP_ID = 200; - private static final int TEST_CLASS_ID = 100; - private static final String TEST_CLASS_NAME = "foobar"; - private static final PolicyClassInfo.PolicyClassType TEST_CLASS_TYPE = - PolicyClassInfo.PolicyClassType.POLICY; - - @Before - public void setUp() throws Exception { - PolicyPropertyInfoBuilder ppib = new PolicyPropertyInfoBuilder(); - testPpi = ppib.build(); - testKeyList = new ArrayList(); - testKeyList.add(new PolicyPropertyId(TEST_PROP_ID)); - testPropertyInfoList = new ArrayList(); - testPropertyInfoList.add(testPpi); - } - - @Test - public void testBuilder() throws Exception { - PolicyClassInfoBuilder pcib = new PolicyClassInfoBuilder(); - PolicyClassInfo pci = null; - pcib.setClassId(TEST_CLASS_ID); - pcib.setClassName(TEST_CLASS_NAME); - pcib.setKey(testKeyList); - pcib.setPolicyType(TEST_CLASS_TYPE); - pcib.setProperty(testPropertyInfoList); - pci = pcib.build(); - - assertTrue(pci.getClassId() == TEST_CLASS_ID); - assertTrue(pci.getClassName().equals(TEST_CLASS_NAME)); - assertTrue(pci.getKeys().get(0) == testKeyList.get(0)); - assertTrue(pci.getPolicyType() == TEST_CLASS_TYPE); - assertTrue(pci.getProperties().get(0) == testPropertyInfoList.get(0)); - - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyPropertyInfoTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyPropertyInfoTest.java deleted file mode 100644 index 870879e6a..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyPropertyInfoTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : tbachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import static org.junit.Assert.assertTrue; - -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.groupbasedpolicy.renderer.opflex.mit.PolicyPropertyInfo.PolicyPropertyInfoBuilder; - -public class PolicyPropertyInfoTest { - - - private static int TEST_PROP_NUM = 200; - private static int TEST_CLASS_ID = 100; - private static String TEST_PROP_NAME = "foobar"; - private static PolicyPropertyInfo.PolicyPropertyId propId; - private static PolicyPropertyInfo.PropertyCardinality TEST_PROP_CARDINALITY = - PolicyPropertyInfo.PropertyCardinality.SCALAR; - private static PolicyPropertyInfo.PropertyType TEST_PROP_TYPE = - PolicyPropertyInfo.PropertyType.COMPOSITE; - @Mock - EnumInfo mockEnumInfo; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - propId = new PolicyPropertyInfo.PolicyPropertyId(TEST_PROP_NUM); - } - - @Test - public void builderTest() throws Exception { - PolicyPropertyInfoBuilder ppib = new PolicyPropertyInfoBuilder(); - PolicyPropertyInfo ppi; - ppib.setClassId(TEST_CLASS_ID); - ppib.setEnumInfo(mockEnumInfo); - ppib.setPropCardinality(TEST_PROP_CARDINALITY); - ppib.setPropId(propId); - ppib.setPropName(TEST_PROP_NAME); - ppib.setType(TEST_PROP_TYPE); - ppi = ppib.build(); - assertTrue(ppi.getClassId() == TEST_CLASS_ID); - assertTrue(ppi.getEnumInfo() == mockEnumInfo); - assertTrue(ppi.getPropCardinality() == TEST_PROP_CARDINALITY); - assertTrue(ppi.getPropId() == propId); - assertTrue(ppi.getPropName().equals(TEST_PROP_NAME)); - assertTrue(ppi.getType() == TEST_PROP_TYPE); - - } - -} diff --git a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyUriTest.java b/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyUriTest.java deleted file mode 100644 index 80adcb7fa..000000000 --- a/renderers/opflex/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/mit/PolicyUriTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2014 Cisco Systems, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Authors : tbachman - */ -package org.opendaylight.groupbasedpolicy.renderer.opflex.mit; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -public class PolicyUriTest { - - private static final String TEST_STRING_1 = "foo"; - private static final String TEST_STRING_2 = "bar"; - private static final String TEST_STRING_3 = "boo"; - private static final String TEST_TOKEN_1 = "PolicyUniverse"; - private static final String TEST_TOKEN_2 = "PolicySpace"; - private static final String TEST_TOKEN_3 = "7a44000e-056d-4566-bbb0-32b973f90369"; - private static final String FULL_URI = PolicyUri.POLICY_URI_SEP + TEST_TOKEN_1 + - PolicyUri.POLICY_URI_SEP + TEST_TOKEN_2 + - PolicyUri.POLICY_URI_SEP + TEST_TOKEN_3; - - - @Test - public void testConstructors() throws Exception { - PolicyUri uri1 = new PolicyUri(FULL_URI); - PolicyUri uri2 = new PolicyUri(uri1); - assertTrue(uri1.equals(uri2)); - List tokens = new ArrayList(); - tokens.add(TEST_TOKEN_1); - tokens.add(TEST_TOKEN_2); - tokens.add(TEST_TOKEN_3); - PolicyUri uri3 = new PolicyUri(tokens); - assertTrue(uri3.equals(uri1)); - PolicyUri uri4 = new PolicyUri(); - uri4.push(TEST_TOKEN_1); - uri4.push(TEST_TOKEN_2); - uri4.push(TEST_TOKEN_3); - assertTrue(uri4.equals(uri1)); - } - - @Test - public void testPushPop() throws Exception { - PolicyUri uri = new PolicyUri(); - - uri.push(TEST_STRING_1); - uri.push(TEST_STRING_2); - uri.push(TEST_STRING_3); - - assertTrue(uri.pop().equals(TEST_STRING_3)); - assertTrue(uri.pop().equals(TEST_STRING_2)); - - uri.push(TEST_STRING_3); - uri.push(TEST_STRING_1); - - assertTrue(uri.pop().equals(TEST_STRING_1)); - assertTrue(uri.pop().equals(TEST_STRING_3)); - assertTrue(uri.pop().equals(TEST_STRING_1)); - assertTrue(uri.pop() == null); - - } - - @Test - public void testFullUri1() throws Exception { - List TEST_TOKENS = - Arrays.asList(TEST_TOKEN_1, - TEST_TOKEN_2, - TEST_TOKEN_3); - PolicyUri uri = new PolicyUri(TEST_TOKENS); - assertTrue(uri.pop().equals(TEST_TOKEN_3)); - assertTrue(uri.pop().equals(TEST_TOKEN_2)); - assertTrue(uri.pop().equals(TEST_TOKEN_1)); - } - - @Test - public void testFullUri2() throws Exception { - PolicyUri uri = new PolicyUri(FULL_URI); - assertTrue(uri.pop().equals(TEST_TOKEN_3)); - assertTrue(uri.pop().equals(TEST_TOKEN_2)); - assertTrue(uri.pop().equals(TEST_TOKEN_1)); - - } - - @Test - public void testGetParent() throws Exception { - PolicyUri uri = new PolicyUri(FULL_URI); - String parent = uri.getParent(); - uri.pop(); - assertTrue(parent.equals(uri.originalPath())); - } - - @Test - public void testValid() throws Exception { - PolicyUri uri = new PolicyUri(); - - assertFalse(uri.valid()); - uri.push(TEST_TOKEN_1); - assertTrue(uri.valid()); - } - - @Test - public void testGetElement() throws Exception { - PolicyUri uri = new PolicyUri(FULL_URI); - - String element = uri.getElement(0); - assertTrue(element.equals(TEST_TOKEN_1)); - element = uri.getElement(1); - assertTrue(element.equals(TEST_TOKEN_2)); - element = uri.getElement(2); - assertTrue(element.equals(TEST_TOKEN_3)); - } - - @Test - public void testTotalElements() throws Exception { - PolicyUri uri = new PolicyUri(FULL_URI); - assertTrue(uri.totalElements() == 3); - } - - @Test - public void testContains() throws Exception { - PolicyUri uri = new PolicyUri(FULL_URI); - assertFalse(uri.contains(TEST_STRING_1)); - assertTrue(uri.contains(TEST_TOKEN_3)); - } - - @Test - public void testStrings() throws Exception { - PolicyUri uri = new PolicyUri(FULL_URI); - assertTrue(uri.toString().equals(FULL_URI)); - assertTrue(uri.originalPath().equals(FULL_URI)); - } - -} diff --git a/renderers/opflex/src/test/resources/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/pretty-test.json b/renderers/opflex/src/test/resources/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/pretty-test.json deleted file mode 100644 index abbe83a9f..000000000 --- a/renderers/opflex/src/test/resources/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/pretty-test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "Image": { - "Width": 800, - "Height": 600, - "Title": "View from 15th Floor", - "Thumbnail": { - "Url": "http://www.example.com/image/481989943", - "Height": 125, - "Width": "100" - }, - "IDs": [ - 116, - 943, - 234, - 38793 - ] - } -} diff --git a/renderers/opflex/src/test/resources/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/test.json b/renderers/opflex/src/test/resources/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/test.json deleted file mode 100644 index 0d4e4b662..000000000 --- a/renderers/opflex/src/test/resources/org/opendaylight/groupbasedpolicy/renderer/opflex/jsonrpc/test.json +++ /dev/null @@ -1 +0,0 @@ -{"Image":{"Width":800,"Height":600,"Title":"View from 15th Floor","Thumbnail":{"Url":"http://www.example.com/image/481989943","Height":125,"Width":"100"},"IDs":[116,943,234,38793]}} diff --git a/renderers/pom.xml b/renderers/pom.xml index ca2ffbccd..da9137a61 100644 --- a/renderers/pom.xml +++ b/renderers/pom.xml @@ -18,7 +18,6 @@ pom - opflex ofoverlay -- 2.36.6