diff options
48 files changed, 1120 insertions, 164 deletions
diff --git a/common/src/test/resources/examples/controlloop/PMSH/pmsh.postman2.0_collection.json b/common/src/test/resources/examples/controlloop/PMSH/pmsh.postman2.0_collection.json new file mode 100644 index 000000000..b31c8ca01 --- /dev/null +++ b/common/src/test/resources/examples/controlloop/PMSH/pmsh.postman2.0_collection.json @@ -0,0 +1,254 @@ +{ + "info": { + "name": "CL-PMSH usecase", + "_postman_id": "5fb85996-3b5b-40fb-9564-bd44eff287d4", + "description": "", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "id": "b436e642-10a0-40d7-a37f-9979693cdb02", + "name": "Get Instantiated Control loops", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "d9328b54-71fa-43aa-96cd-0d002e958da9" + } + ] + }, + { + "id": "021d7ff6-5cad-4967-afe2-f68317cba1f1", + "name": "Update a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"PASSIVE\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"PmshInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "15718e82-6647-4102-9c1e-7e5c0cc48261" + } + ] + }, + { + "id": "96d15818-1f95-41bd-ac18-37a96f99a0d8", + "name": "UnInitialise a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"UNINTIALISED\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"PmshInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "a02ccea0-d357-4ced-9f19-82bd5712d318" + } + ] + }, + { + "id": "43776ab0-4851-41bb-8c43-407d0b807696", + "name": "Instantiate a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"controlLoopList\": [\r\n {\r\n \"name\": \"PmshInstance0\",\r\n \"version\": \"1.0.1\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.sample.GenericK8s_ControlLoopDefinition\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s control loop instance 0\",\r\n \"elements\": {\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c21\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c21\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the PMSH instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c22\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c22\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the local instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c25\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c25\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"DCAE Control Loop Element for the PMSH instance 0 control loop\"\r\n }\r\n }\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "855ec245-13ef-48ab-a0e0-3de6e11090a4" + } + ] + }, + { + "id": "3f6d5d18-8a29-46c3-8fec-d6645e7f7c2b", + "name": "Commission a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "commission" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/yaml", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "tosca_definitions_version: tosca_simple_yaml_1_3\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\n \n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n restRequestId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a REST request to be sent to a REST endpoint\n httpMethod:\n type: string\n required: true\n constraints:\n - valid_values: [POST, PUT, GET, DELETE]\n description: The REST method to use\n path:\n type: string\n required: true\n description: The path of the REST request relative to the base URL\n body:\n type: string\n required: false\n description: The body of the REST request for PUT and POST requests\n expectedResponse:\n type: integer\n required: true\n constraints:\n - in_range: [100, 599]\n description: THe expected HTTP status code for the REST request\n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n configurationEntityId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a Configuration Entity to be handled by the HTTP Control Loop Element\n restSequence:\n type: list\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest\n typeVersion: 1.0.0\n description: A sequence of REST commands to send to the REST endpoint \nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n participant_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n chart:\n type: string\n required: true\n configs:\n type: list\n required: false\n requirements:\n type: string\n requred: false\n templates:\n type: list\n required: false\n entry_schema:\n values:\n type: string\n requred: true\n \n org.onap.policy.clamp.controlloop.HttpControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n baseUrl:\n type: string\n required: true\n description: The base URL to be prepended to each path, identifies the host for the REST endpoints.\n httpHeaders:\n type: map\n required: false\n entry_schema:\n type: string\n description: HTTP headers to send on REST requests\n configurationEntities:\n type: map\n required: true\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity\n typeVersion: 1.0.0\n description: The connfiguration entities the Control Loop Element is managing and their associated REST requests \n \n \ntopology_template:\n node_templates:\n org.onap.k8s.controlloop.K8SControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for K8S\n properties:\n provider: ONAP \n\n org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement: \n # Chart from new repository \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for PMSH\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart: \n chartId: \n name: dcae-pmsh \n version: 8.0.0\n namespace: onap \n releaseName: pmshms\n repository:\n repoName: chartmuseum\n protocol: http\n address: 10.152.183.120\n port: 80\n userName: onapinitializer\n password: demo123456!\n overrideParams:\n global.masterPassword: test\n \n \n\n org.onap.domain.database.Local_K8SMicroserviceControlLoopElement: \n # Chart installation without passing repository info \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for local chart\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart:\n chartId: \n name: nginx-ingress\n version: 0.9.1 \n releaseName: nginxms\n namespace: test \n \n org.onap.controlloop.HttpControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for Http requests\n properties:\n provider: ONAP\n\n org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement:\n # Consul http config for PMSH.\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.HttpControlLoopElement\n type_version: 1.0.1\n description: Control loop element for the http requests of PMSH microservice\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.controlloop.HttpControlLoopParticipant\n version: 2.3.4\n uninitializedToPassiveTimeout: 180\n baseUrl: http://10.152.183.51:8500\n httpHeaders:\n Content-Type: application/json\n configurationEntities:\n - configurationEntityId:\n name: entity1\n version: 1.0.1\n restSequence:\n - restRequestId:\n name: request1\n version: 1.0.1\n httpMethod: PUT\n path: v1/kv/dcae-pmsh2\n body: '{\n \"control_loop_name\":\"pmsh-control-loop\",\n \"operational_policy_name\":\"pmsh-operational-policy\",\n \"aaf_password\":\"demo123456!\",\n \"aaf_identity\":\"dcae@dcae.onap.org\",\n \"cert_path\":\"/opt/app/pmsh/etc/certs/cert.pem\",\n \"key_path\":\"/opt/app/pmsh/etc/certs/key.pem\",\n \"ca_cert_path\":\"/opt/app/pmsh/etc/certs/cacert.pem\",\n \"enable_tls\":\"true\",\n \"pmsh_policy\":{\n \"subscription\":{\n \"subscriptionName\":\"ExtraPM-All-gNB-R2B\",\n \"administrativeState\":\"UNLOCKED\",\n \"fileBasedGP\":15,\n \"fileLocation\":\"\\/pm\\/pm.xml\",\n \"nfFilter\":{\n \"nfNames\":[\n \"^pnf.*\",\n \"^vnf.*\"\n ],\n \"modelInvariantIDs\":[\n ],\n \"modelVersionIDs\":[\n ],\n \"modelNames\":[\n ]\n },\n \"measurementGroups\":[\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"countera\"\n },\n {\n \"measurementType\":\"counterb\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dna\"\n },\n {\n \"DN\":\"dnb\"\n }\n ]\n }\n },\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"counterc\"\n },\n {\n \"measurementType\":\"counterd\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dnc\"\n },\n {\n \"DN\":\"dnd\"\n }\n ]\n }\n }\n ]\n }\n },\n \"streams_subscribes\":{\n \"aai_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/AAI_EVENT\",\n \"client_role\":\"org.onap.dcae.aaiSub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575976809466\"\n }\n },\n \"policy_pm_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmSubscriber\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575876809456\"\n }\n }\n },\n \"streams_publishes\":{\n \"policy_pm_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmPublisher\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1475976809466\"\n }\n },\n \"other_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.SOME_OTHER_TOPIC\",\n \"client_role\":\"org.onap.dcae.pmControlPub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1875976809466\"\n }\n }\n }\n }'\n expectedResponse: 200\n \n\n org.onap.domain.sample.GenericK8s_ControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for Hello World\n properties:\n provider: ONAP\n elements: \n - name: org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\n version: 1.2.3\n ", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "d120b824-7fb5-478b-92a3-4d06b92bd00f" + } + ] + } + ], + "variable": [], + "auth": { + "type": "basic", + "basic": { + "username": "healthcheck", + "password": "zb!XztG34" + } + } +}
\ No newline at end of file diff --git a/common/src/test/resources/examples/controlloop/http-participant/http.postman2.0_collection.json b/common/src/test/resources/examples/controlloop/http-participant/http.postman2.0_collection.json new file mode 100644 index 000000000..38deb43ae --- /dev/null +++ b/common/src/test/resources/examples/controlloop/http-participant/http.postman2.0_collection.json @@ -0,0 +1,254 @@ +{ + "info": { + "name": "CL-http-participant", + "_postman_id": "cd83c1ac-bc96-41f2-a5a4-f021015461b7", + "description": "", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "id": "45fed070-6a8f-4e0a-a3cf-904db5596984", + "name": "Get Instantiated Control loops", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "5727aa3e-5f62-426b-9a37-ddae2d346165" + } + ] + }, + { + "id": "1bf1a143-38fd-49b8-afab-4c801546ba3b", + "name": "Update a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"PASSIVE\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "f619f68b-4dbe-4c3d-8236-e90ea85c4094" + } + ] + }, + { + "id": "e5b64f76-c4f5-4c23-b273-e2d6cfb48cd7", + "name": "UnInitialise a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"UNINTIALISED\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "bc8e0792-85df-4934-9f55-69eaf8535fe3" + } + ] + }, + { + "id": "4f359a02-cd9a-4ffd-b594-3478bf32cc2f", + "name": "Instantiate a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"controlLoopList\": [\r\n {\r\n \"name\": \"ConsulInstance0\",\r\n \"version\": \"1.0.1\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.sample.PMSH_Http_ControlLoopDefinition\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"PMSH control loop instance 0\",\r\n \"elements\": {\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c25\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c25\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.controlloop.HttpControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"DCAE Control Loop Element for the PMSH instance 0 control loop\"\r\n }\r\n }\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "dbdea1c3-05fe-4757-b9a2-74a16d065a12" + } + ] + }, + { + "id": "ad24b4ac-c6f2-4444-97a7-90b007814ba6", + "name": "Commission a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "commission" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/yaml", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "tosca_definitions_version: tosca_simple_yaml_1_3\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\n\n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n restRequestId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a REST request to be sent to a REST endpoint\n httpMethod:\n type: string\n required: true\n constraints:\n - valid_values: [POST, PUT, GET, DELETE]\n description: The REST method to use\n path:\n type: string\n required: true\n description: The path of the REST request relative to the base URL\n body:\n type: string\n required: false\n description: The body of the REST request for PUT and POST requests\n expectedResponse:\n type: integer\n required: true\n constraints:\n - in_range: [100, 599]\n description: THe expected HTTP status code for the REST request\n org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity:\n version: 1.0.0\n derived_from: tosca.datatypes.Root\n properties:\n configurationEntityId:\n type: onap.datatypes.ToscaConceptIdentifier\n typeVersion: 1.0.0\n required: true\n description: The name and version of a Configuration Entity to be handled by the HTTP Control Loop Element\n restSequence:\n type: list\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest\n typeVersion: 1.0.0\n description: A sequence of REST commands to send to the REST endpoint\n\n\nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n participant_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.HttpControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n baseUrl:\n type: string\n required: true\n description: The base URL to be prepended to each path, identifies the host for the REST endpoints.\n httpHeaders:\n type: map\n required: false\n entry_schema:\n type: string\n description: HTTP headers to send on REST requests\n configurationEntities:\n type: map\n required: true\n entry_schema:\n type: org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity\n typeVersion: 1.0.0\n description: The connfiguration entities the Control Loop Element is managing and their associated REST requests\ntopology_template:\n node_templates:\n org.onap.controlloop.HttpControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for Http requests\n properties:\n provider: ONAP\n\n org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement:\n # Http config for PMSH.\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.HttpControlLoopElement\n type_version: 1.0.1\n description: Control loop element for the http requests of PMSH microservice\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.controlloop.HttpControlLoopParticipant\n version: 2.3.4\n uninitializedToPassiveTimeout: 180\n baseUrl: http://10.152.183.51:8500\n httpHeaders:\n Content-Type: application/json\n configurationEntities:\n - configurationEntityId:\n name: entity1\n version: 1.0.1\n restSequence:\n - restRequestId:\n name: request1\n version: 1.0.1\n httpMethod: PUT\n path: v1/kv/dcae-pmsh\n body: '{\n \"control_loop_name\":\"pmsh-control-loop\",\n \"operational_policy_name\":\"pmsh-operational-policy\",\n \"aaf_password\":\"demo123456!\",\n \"aaf_identity\":\"dcae@dcae.onap.org\",\n \"cert_path\":\"/opt/app/pmsh/etc/certs/cert.pem\",\n \"key_path\":\"/opt/app/pmsh/etc/certs/key.pem\",\n \"ca_cert_path\":\"/opt/app/pmsh/etc/certs/cacert.pem\",\n \"enable_tls\":\"true\",\n \"pmsh_policy\":{\n \"subscription\":{\n \"subscriptionName\":\"ExtraPM-All-gNB-R2B\",\n \"administrativeState\":\"UNLOCKED\",\n \"fileBasedGP\":15,\n \"fileLocation\":\"\\/pm\\/pm.xml\",\n \"nfFilter\":{\n \"nfNames\":[\n \"^pnf.*\",\n \"^vnf.*\"\n ],\n \"modelInvariantIDs\":[\n ],\n \"modelVersionIDs\":[\n ],\n \"modelNames\":[\n ]\n },\n \"measurementGroups\":[\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"countera\"\n },\n {\n \"measurementType\":\"counterb\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dna\"\n },\n {\n \"DN\":\"dnb\"\n }\n ]\n }\n },\n {\n \"measurementGroup\":{\n \"measurementTypes\":[\n {\n \"measurementType\":\"counterc\"\n },\n {\n \"measurementType\":\"counterd\"\n }\n ],\n \"managedObjectDNsBasic\":[\n {\n \"DN\":\"dnc\"\n },\n {\n \"DN\":\"dnd\"\n }\n ]\n }\n }\n ]\n }\n },\n \"streams_subscribes\":{\n \"aai_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/AAI_EVENT\",\n \"client_role\":\"org.onap.dcae.aaiSub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575976809466\"\n }\n },\n \"policy_pm_subscriber\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmSubscriber\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1575876809456\"\n }\n }\n },\n \"streams_publishes\":{\n \"policy_pm_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\",\n \"client_role\":\"org.onap.dcae.pmPublisher\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1475976809466\"\n }\n },\n \"other_publisher\":{\n \"type\":\"message_router\",\n \"dmaap_info\":{\n \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.SOME_OTHER_TOPIC\",\n \"client_role\":\"org.onap.dcae.pmControlPub\",\n \"location\":\"san-francisco\",\n \"client_id\":\"1875976809466\"\n }\n }\n }\n }'\n expectedResponse: 200\n\n\n org.onap.domain.sample.PMSH_Http_ControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for HTTP request to Consul\n properties:\n provider: ONAP\n elements:\n - name: org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement\n version: 1.2.3", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "0e98286f-2143-4af9-a291-4f3719b2cedb" + } + ] + } + ], + "variable": [], + "auth": { + "type": "basic", + "basic": { + "username": "healthcheck", + "password": "zb!XztG34" + } + } +}
\ No newline at end of file diff --git a/common/src/test/resources/examples/controlloop/k8s-participant/k8s.postman2.0_collection.json b/common/src/test/resources/examples/controlloop/k8s-participant/k8s.postman2.0_collection.json new file mode 100644 index 000000000..923782128 --- /dev/null +++ b/common/src/test/resources/examples/controlloop/k8s-participant/k8s.postman2.0_collection.json @@ -0,0 +1,254 @@ +{ + "info": { + "name": "CL-K8s-participant", + "_postman_id": "90ac155d-08ff-4dce-a4f0-24e8d8aefa70", + "description": "", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" + }, + "item": [ + { + "id": "711b8171-7b0f-4461-b5ad-fb00bc03b1a3", + "name": "Get Instantiated Control loops", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "d10bdd1f-ff18-49ed-9798-1705bb579668" + } + ] + }, + { + "id": "3b0c5920-42b4-4647-8a15-bfcb02cfbd54", + "name": "Update a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"PASSIVE\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "9b6719f4-d325-45ee-9951-ac50bc8e4d38" + } + ] + }, + { + "id": "d9c9a188-3fe1-4950-b851-9f76b0c72f63", + "name": "UnInitialise a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation/command" + ], + "port": "6969" + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"orderedState\": \"UNINTIALISED\",\r\n \"controlLoopIdentifierList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\"\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "69ae3508-0fef-42c7-b96b-28f3b98f599e" + } + ] + }, + { + "id": "3626da99-5645-4386-85cf-0bbe296adf6d", + "name": "Instantiate a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "instantiation" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Content-Type", + "value": "application/json", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"controlLoopList\": [\r\n {\r\n \"name\": \"K8SInstance0\",\r\n \"version\": \"1.0.1\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.sample.GenericK8s_ControlLoopDefinition\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s control loop instance 0\",\r\n \"elements\": {\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c20\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c20\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the k8s instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c21\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c21\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the PMSH instance 0 control loop\"\r\n },\r\n \"709c62b3-8918-41b9-a747-d21eb79c6c22\": {\r\n \"id\": \"709c62b3-8918-41b9-a747-d21eb79c6c22\",\r\n \"definition\": {\r\n \"name\": \"org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\",\r\n \"version\": \"1.2.3\"\r\n },\r\n \"participantId\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"participantType\": {\r\n \"name\": \"org.onap.k8s.controlloop.K8SControlLoopParticipant\",\r\n \"version\": \"2.3.4\"\r\n },\r\n \"state\": \"UNINITIALISED\",\r\n \"orderedState\": \"UNINITIALISED\",\r\n \"description\": \"K8s Control Loop Element for the local instance 0 control loop\"\r\n }\r\n }\r\n }\r\n ]\r\n}", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "76e0d5e8-f5c9-456e-b908-c9f24ebc5613" + } + ] + }, + { + "id": "9e88fc2f-6a65-4693-ab78-d69139d06d02", + "name": "Commission a Control loop", + "request": { + "url": { + "protocol": "https", + "host": "localhost", + "path": [ + "onap", + "controlloop", + "v2", + "commission" + ], + "port": "6969" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/yaml", + "description": "", + "disabled": false + }, + { + "key": "X-ONAP-RequestID", + "value": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "description": "", + "disabled": false + }, + { + "key": "Accept", + "value": "*/*", + "disabled": false + } + ], + "body": { + "mode": "raw", + "raw": "tosca_definitions_version: tosca_simple_yaml_1_3\ndata_types:\n onap.datatypes.ToscaConceptIdentifier:\n derived_from: tosca.datatypes.Root\n properties:\n name:\n type: string\n required: true\n version:\n type: string\n required: true\nnode_types:\n org.onap.policy.clamp.controlloop.Participant:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n org.onap.policy.clamp.controlloop.ControlLoopElement:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n participant_id:\n type: onap.datatypes.ToscaConceptIdentifier\n requred: true\n org.onap.policy.clamp.controlloop.ControlLoop:\n version: 1.0.1\n derived_from: tosca.nodetypes.Root\n properties:\n provider:\n type: string\n requred: false\n elements:\n type: list\n required: true\n entry_schema:\n type: onap.datatypes.ToscaConceptIdentifier\n org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement:\n version: 1.0.1\n derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement\n properties:\n chart:\n type: string\n required: true\n configs:\n type: list\n required: false\n requirements:\n type: string\n requred: false\n templates:\n type: list\n required: false\n entry_schema:\n values:\n type: string\n requred: true\ntopology_template:\n node_templates:\n org.onap.k8s.controlloop.K8SControlLoopParticipant:\n version: 2.3.4\n type: org.onap.policy.clamp.controlloop.Participant\n type_version: 1.0.1\n description: Participant for K8S\n properties:\n provider: ONAP\n \n org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement:\n # Chart from any chart repository configured on helm client.\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for Hello World\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart: \n chartId: \n name: dummy\n version: 0.1.0 \n releaseName: test \n namespace: test \n\n org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement: \n # Chart from local file system \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for PMSH\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart: \n chartId: \n name: dcae-pmsh \n version: 8.0.0\n namespace: onap \n releaseName: pmshms\n repository:\n repoName: chartmuseum\n protocol: http\n address: 10.152.183.120\n port: 80\n userName: onapinitializer\n password: demo123456!\n overrideParams:\n global.masterPassword: test\n \n \n\n org.onap.domain.database.Local_K8SMicroserviceControlLoopElement: \n # Chart installation without passing repository name \n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement\n type_version: 1.0.0\n description: Control loop element for the K8S microservice for local chart\n properties:\n provider: ONAP\n participant_id:\n name: org.onap.k8s.controlloop.K8SControlLoopParticipant\n version: 2.3.4\n chart:\n chartId: \n name: nginx-ingress\n version: 0.9.1 \n releaseName: nginxms\n namespace: test \n repository:\n repoName: nginx-stable \n\n org.onap.domain.sample.GenericK8s_ControlLoopDefinition:\n version: 1.2.3\n type: org.onap.policy.clamp.controlloop.ControlLoop\n type_version: 1.0.0\n description: Control loop for Hello World\n properties:\n provider: ONAP\n elements: \n - name: org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n - name: org.onap.domain.database.Local_K8SMicroserviceControlLoopElement\n version: 1.2.3 \n ", + "disabled": false + }, + "description": "" + }, + "response": [ + { + "header": [], + "code": 200, + "name": "Response_200", + "id": "ab57b923-a484-486c-a03a-b1ad6bf64d09" + } + ] + } + ], + "variable": [], + "auth": { + "type": "basic", + "basic": { + "username": "healthcheck", + "password": "zb!XztG34" + } + } +}
\ No newline at end of file diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java index 51cce5377..72db7d97e 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +28,6 @@ import lombok.Setter; import lombok.ToString; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; import org.onap.policy.models.base.PfUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** * Class to represent the PARTICIPANT_UPDATE message that the control loop runtime sends to a participant. diff --git a/packages/policy-clamp-docker/pom.xml b/packages/policy-clamp-docker/pom.xml index 16c416126..90e88c941 100644 --- a/packages/policy-clamp-docker/pom.xml +++ b/packages/policy-clamp-docker/pom.xml @@ -218,6 +218,38 @@ </assembly> </build> </image> + <image> + <name>onap/http-participant</name> + <alias>onap-http-participant</alias> + <build> + <cleanup>try</cleanup> + <dockerFile>HttpParticipantDockerfile</dockerFile> + <tags> + <tag>${project.version}</tag> + <tag>${project.version}-${maven.build.timestamp}</tag> + <tag>${project.docker.latest.minmax.tag.version}</tag> + </tags> + <assembly> + <inline> + <dependencySets> + <dependencySet> + <includes> + <include>org.onap.policy.clamp:policy-clamp-tarball</include> + </includes> + <outputDirectory>/lib</outputDirectory> + <outputFileNameMapping>http-participant.tar.gz</outputFileNameMapping> + </dependencySet> + <dependencySet> + <includes> + <include>org.onap.policy.clamp.participant:policy-clamp-participant-impl-http</include> + </includes> + <outputFileNameMapping>app.jar</outputFileNameMapping> + </dependencySet> + </dependencySets> + </inline> + </assembly> + </build> + </image> </images> </configuration> @@ -288,5 +320,10 @@ <artifactId>policy-clamp-participant-impl-kubernetes</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.onap.policy.clamp.participant</groupId> + <artifactId>policy-clamp-participant-impl-http</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> </project> diff --git a/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile b/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile index 3d57418e5..1b9cb251a 100644 --- a/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile +++ b/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile @@ -21,7 +21,7 @@ # # Docker file to build an image that runs CLAMP on Java 11 or better in alpine # -FROM onap/policy-jre-alpine:2.2.1 +FROM onap/policy-jre-alpine:2.3.0 LABEL maintainer="Policy Team" diff --git a/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile index ed09c50d3..876f94687 100644 --- a/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile +++ b/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile @@ -21,7 +21,7 @@ # # Docker file to build an image that runs CLAMP on Java 11 or better in alpine # -FROM onap/policy-jre-alpine:2.2.1 +FROM onap/policy-jre-alpine:2.3.0 LABEL maintainer="Policy Team" diff --git a/packages/policy-clamp-docker/src/main/docker/HttpParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/HttpParticipantDockerfile new file mode 100644 index 000000000..fe14f7d7c --- /dev/null +++ b/packages/policy-clamp-docker/src/main/docker/HttpParticipantDockerfile @@ -0,0 +1,52 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +#------------------------------------------------------------------------------- + +# +# Docker file to build an image that runs CLAMP on Java 11 or better in alpine +# + +FROM onap/policy-jre-alpine:2.3.0 + +LABEL maintainer="Policy Team" + +ARG POLICY_LOGS=/var/log/onap/policy/clamp + +ENV POLICY_LOGS=$POLICY_LOGS +ENV POLICY_HOME=$POLICY_HOME/clamp + +RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \ + chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \ + mkdir /packages +COPY /maven/lib/http-participant.tar.gz /packages + +RUN tar xvfz /packages/http-participant.tar.gz --directory $POLICY_HOME && \ + rm /packages/http-participant.tar.gz + +WORKDIR $POLICY_HOME +COPY http-participant.sh bin/. +COPY /maven/app.jar /app + +RUN chown -R policy:policy * && \ + chmod 755 bin/*.sh && \ + chown -R policy:policy /app + +USER policy +WORKDIR $POLICY_HOME/bin +ENTRYPOINT [ "./http-participant.sh" ] diff --git a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile index d08e14fff..26fb66f22 100644 --- a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile +++ b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile @@ -21,7 +21,7 @@ # # Docker file to build an image that runs CLAMP on Java 11 or better in alpine # -FROM onap/policy-jre-alpine:2.2.1 +FROM onap/policy-jre-alpine:2.3.0 LABEL maintainer="Policy Team" diff --git a/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile index 8eca34d42..916ec2328 100644 --- a/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile +++ b/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile @@ -21,7 +21,7 @@ # # Docker file to build an image that runs CLAMP on Java 11 or better in alpine # -FROM onap/policy-jre-alpine:2.2.1 +FROM onap/policy-jre-alpine:2.3.0 LABEL maintainer="Policy Team" diff --git a/packages/policy-clamp-docker/src/main/docker/http-participant.sh b/packages/policy-clamp-docker/src/main/docker/http-participant.sh new file mode 100644 index 000000000..d74b903e3 --- /dev/null +++ b/packages/policy-clamp-docker/src/main/docker/http-participant.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env sh +# +# ============LICENSE_START======================================================= +# Copyright (C) 2021 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +# + +JAVA_HOME=/usr/lib/jvm/java-11-openjdk/ +KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}" +TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}" +KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}" +TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}" + +if [ "$#" -eq 1 ]; then + CONFIG_FILE=$1 +else + CONFIG_FILE=${CONFIG_FILE} +fi + +if [ -z "$CONFIG_FILE" ]; then + CONFIG_FILE="${POLICY_HOME}/etc/HttpParticipantParameters.yaml" +fi + +echo "Policy clamp config file: $CONFIG_FILE" + +if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then + echo "overriding policy-truststore" + cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}" +fi + +if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then + echo "overriding policy-keystore" + cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}" +fi + +if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then + echo "overriding logback xml files" + cp -f "${POLICY_HOME}"/etc/mounted/logback*.xml "${POLICY_HOME}"/etc/ +fi + +mkdir -p "${POLICY_HOME}"/config/ +cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/HttpParticipantParameters.yaml + +$JAVA_HOME/bin/java -Dserver.ssl.keyStore="${KEYSTORE}" \ + -Dserver.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \ + -Dserver.ssl.trustStore="${TRUSTSTORE}" \ + -Dserver.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \ + -jar /app/app.jar \ + --spring.config.location="${POLICY_HOME}/config/HttpParticipantParameters.yaml" diff --git a/packages/policy-clamp-tarball/pom.xml b/packages/policy-clamp-tarball/pom.xml index 4689433a7..9be98dff2 100644 --- a/packages/policy-clamp-tarball/pom.xml +++ b/packages/policy-clamp-tarball/pom.xml @@ -52,6 +52,11 @@ <artifactId>policy-clamp-participant-impl-kubernetes</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.onap.policy.clamp.participant</groupId> + <artifactId>policy-clamp-participant-impl-http</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> <build> diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/HttpParticipantParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/HttpParticipantParameters.yaml new file mode 100644 index 000000000..76f48bbdd --- /dev/null +++ b/packages/policy-clamp-tarball/src/main/resources/etc/HttpParticipantParameters.yaml @@ -0,0 +1,23 @@ +participant: + intermediaryParameters: + reportingTimeIntervalMs: 120000 + description: Participant Description + participantId: + name: HttpParticipant0 + version: 1.0.0 + participantType: + name: org.onap.k8s.controlloop.HttpControlLoopParticipant + version: 2.3.4 + clampControlLoopTopics: + topicSources: + - topic: POLICY-CLRUNTIME-PARTICIPANT + servers: + - ${topicServer:message-router} + topicCommInfrastructure: dmaap + fetchTimeout: 15000 + topicSinks: + - topic: POLICY-CLRUNTIME-PARTICIPANT + servers: + - ${topicServer:message-router} + topicCommInfrastructure: dmaap + diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml index d91cc7394..ebd744f13 100644 --- a/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml +++ b/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml @@ -7,7 +7,7 @@ security: enable-csrf: false participant: - localChartDirectory: /var/helm-manager/local-charts + localChartDirectory: /home/policy/local-charts infoFileName: CHART_INFO.json intermediaryParameters: reportingTimeIntervalMs: 120000 @@ -51,4 +51,4 @@ logging: org.springframework.data: ERROR org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR file: - name: /var/log/helm-manager/application.log + name: /var/log/onap/policy/clamp/application.log diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java index 2d8e0acd8..0b8d1b30f 100644 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java @@ -1,8 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +23,6 @@ package org.onap.policy.clamp.controlloop.participant.dcae.main.handler; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/exception/HttpWebClientException.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/exception/HttpWebClientException.java index b10af884c..6b27700c4 100644 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/exception/HttpWebClientException.java +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/main/exception/HttpWebClientException.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +25,7 @@ package org.onap.policy.clamp.controlloop.participant.http.main.exception; import org.springframework.web.reactive.function.client.WebClientResponseException; public class HttpWebClientException extends WebClientResponseException { + private static final long serialVersionUID = 1L; public HttpWebClientException(int statusCode, String statusText) { super(statusCode, statusText, null, null, null); diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/parameters/ParticipantHttpParameters.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/parameters/ParticipantHttpParameters.java index 5f1630706..62bbd7593 100644 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/parameters/ParticipantHttpParameters.java +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/controlloop/participant/http/parameters/ParticipantHttpParameters.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +22,6 @@ package org.onap.policy.clamp.controlloop.participant.http.parameters; import javax.validation.Valid; -import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; diff --git a/participant/participant-impl/participant-impl-http/src/test/java/utils/CommonTestData.java b/participant/participant-impl/participant-impl-http/src/test/java/utils/CommonTestData.java index aa4f56225..0ebf9212a 100644 --- a/participant/participant-impl/participant-impl-http/src/test/java/utils/CommonTestData.java +++ b/participant/participant-impl/participant-impl-http/src/test/java/utils/CommonTestData.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,13 +28,10 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.participant.http.main.models.ConfigurationEntity; import org.onap.policy.clamp.controlloop.participant.http.main.models.RestParams; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; public class CommonTestData { - private static final Coder CODER = new StandardCoder(); private static final String TEST_KEY_NAME = "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement"; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java index d7991d172..a12fdcaac 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java @@ -147,6 +147,9 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { var config = CODER.convert(nodeTemplate.getProperties(), ThreadConfig.class); checkPodStatus(chartInfo, config.uninitializedToPassiveTimeout, config.podStatusCheckInterval); + intermediaryApi.updateControlLoopElementState(element.getId(), ControlLoopOrderedState.PASSIVE, + ControlLoopState.UNINITIALISED, ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); + } catch (ServiceException | CoderException | IOException e) { LOGGER.warn("Installation of Helm chart failed", e); } diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java index 7954dbbb9..1c405539b 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java @@ -183,12 +183,16 @@ public class HelmClient { } private ProcessBuilder prepareRepoAddCommand(HelmRepository repo) { + var url = repo.getProtocol() + "://" + repo.getAddress(); + if (repo.getPort() != null) { + url = url + ":" + repo.getPort(); + } // @formatter:off List<String> helmArguments = new ArrayList<>( List.of( "helm", "repo", - "add", repo.getRepoName(), repo.getProtocol() + "://" + repo.getAddress() + ":" + repo.getPort() + "add", repo.getRepoName(), url )); if (repo.getUserName() != null && repo.getPassword() != null) { helmArguments.addAll(List.of("--username", repo.getUserName(), "--password", repo.getPassword())); diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java index 770bbb291..a07fca596 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java @@ -112,7 +112,7 @@ public class ChartService { * @throws ServiceException incase of error */ public void configureRepository(HelmRepository repo) throws ServiceException { - if (repo.getAddress() != null && repo.getPort() != null) { + if (repo.getAddress() != null) { helmClient.addRepository(repo); } } diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml index 713b072a2..e1693318e 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml @@ -7,7 +7,7 @@ security: enable-csrf: false participant: - localChartDirectory: /var/helm-manager/local-charts + localChartDirectory: /home/policy/local-charts infoFileName: CHART_INFO.json intermediaryParameters: reportingTimeIntervalMs: 120000 @@ -53,4 +53,4 @@ logging: org.springframework.data: ERROR org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR file: - name: /var/log/helm-manager/application.log + name: /var/log/onap/policy/clamp/application.log diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java index 113f75dd5..95bbb2940 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -34,7 +35,7 @@ import org.onap.policy.common.utils.coder.StandardCoderObject; * Abstract Listener for Participant Ack messages sent by runtime. */ public abstract class ParticipantAckListener<T extends ParticipantAckMessage> extends ScoListener<T> - implements Listener { + implements Listener<T> { private final ParticipantHandler participantHandler; private final Consumer<T> consumer; diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java index 67af5c844..5326ccddc 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantListener.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +32,7 @@ import org.onap.policy.common.utils.coder.StandardCoderObject; /** * Abstract Listener for Participant messages sent by CLAMP. */ -public abstract class ParticipantListener<T extends ParticipantMessage> extends ScoListener<T> implements Listener { +public abstract class ParticipantListener<T extends ParticipantMessage> extends ScoListener<T> implements Listener<T> { private final ParticipantHandler participantHandler; private final Consumer<T> consumer; diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java index 754bf2887..5458f7c34 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,9 +59,9 @@ public class IntermediaryActivator extends ServiceManagerContainer implements Cl * @param publishers list of Publishers * @param listeners list of Listeners */ - public IntermediaryActivator(final ParticipantParameters parameters, + public <T> IntermediaryActivator(final ParticipantParameters parameters, ParticipantIntermediaryApi participantIntermediaryApi, List<Publisher> publishers, - List<Listener> listeners) { + List<Listener<T>> listeners) { this.participantIntermediaryApi = participantIntermediaryApi; topicSinks = TopicEndpointManager.getManager() @@ -73,8 +74,8 @@ public class IntermediaryActivator extends ServiceManagerContainer implements Cl // @formatter:off addAction("Topic endpoint management", - () -> TopicEndpointManager.getManager().start(), - () -> TopicEndpointManager.getManager().shutdown()); + () -> TopicEndpointManager.getManager().start(), + () -> TopicEndpointManager.getManager().shutdown()); publishers.forEach(publisher -> addAction("Publisher " + publisher.getClass().getSimpleName(), @@ -83,8 +84,8 @@ public class IntermediaryActivator extends ServiceManagerContainer implements Cl listeners.forEach(listener -> addAction("Listener " + listener.getClass().getSimpleName(), - () -> msgDispatcher.register(listener.getType(), listener.getScoListener()), - () -> msgDispatcher.unregister(listener.getType()))); + () -> msgDispatcher.register(listener.getType(), listener.getScoListener()), + () -> msgDispatcher.unregister(listener.getType()))); addAction("Topic Message Dispatcher", this::registerMsgDispatcher, this::unregisterMsgDispatcher); // @formatter:on diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java index bca71afda..19bad9a67 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/Listener.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ package org.onap.policy.clamp.controlloop.participant.intermediary.handler; import org.onap.policy.common.endpoints.listeners.ScoListener; -public interface Listener { +public interface Listener<T> { /** * Get the type of message of interest to the listener. @@ -36,5 +37,5 @@ public interface Listener { * * @return listener to register */ - <T> ScoListener<T> getScoListener(); + ScoListener<T> getScoListener(); } @@ -47,6 +47,7 @@ o policy-clamp-participant-impl-kubernetes: A standard participant for Kubernetes microservices o policy-clamp-participant-impl-policy: A standard participant for handling polcies for Policy Framework o policy-clamp-participant-impl-simulator: A participant simulator for integration testing + o policy-clamp-participant-impl-http: A standard participant for http configurations </description> <properties> diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java index b67ddf2a7..0afbf1c4c 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/Listener.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ package org.onap.policy.clamp.controlloop.runtime.config.messaging; import org.onap.policy.common.endpoints.listeners.ScoListener; -public interface Listener { +public interface Listener<T> { /** * Get the type of message of interest to the listener. @@ -36,5 +37,5 @@ public interface Listener { * * @return listener to register */ - <T> ScoListener<T> getScoListener(); + ScoListener<T> getScoListener(); } diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java index d196dd193..284094bc4 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivator.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,8 +57,8 @@ public class MessageDispatcherActivator extends ServiceManagerContainer implemen * @param listeners list of Listeners * @throws ControlLoopRuntimeException if the activator does not start */ - public MessageDispatcherActivator(final ClRuntimeParameterGroup clRuntimeParameterGroup, List<Publisher> publishers, - List<Listener> listeners) { + public <T> MessageDispatcherActivator(final ClRuntimeParameterGroup clRuntimeParameterGroup, + List<Publisher> publishers, List<Listener<T>> listeners) { topicSinks = TopicEndpointManager.getManager() .addTopicSinks(clRuntimeParameterGroup.getTopicParameterGroup().getTopicSinks()); @@ -68,8 +69,8 @@ public class MessageDispatcherActivator extends ServiceManagerContainer implemen // @formatter:off addAction("Topic endpoint management", - () -> TopicEndpointManager.getManager().start(), - () -> TopicEndpointManager.getManager().shutdown()); + () -> TopicEndpointManager.getManager().start(), + () -> TopicEndpointManager.getManager().shutdown()); publishers.forEach(publisher -> addAction("Publisher " + publisher.getClass().getSimpleName(), @@ -78,8 +79,8 @@ public class MessageDispatcherActivator extends ServiceManagerContainer implemen listeners.forEach(listener -> addAction("Listener " + listener.getClass().getSimpleName(), - () -> msgDispatcher.register(listener.getType(), listener.getScoListener()), - () -> msgDispatcher.unregister(listener.getType()))); + () -> msgDispatcher.register(listener.getType(), listener.getScoListener()), + () -> msgDispatcher.unregister(listener.getType()))); addAction("Topic Message Dispatcher", this::registerMsgDispatcher, this::unregisterMsgDispatcher); // @formatter:on diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java index dd08b7a0f..c40095bef 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,7 @@ import org.springframework.stereotype.Component; * Listener for ControlLoopStateChangeAck messages sent by participants. */ @Component -public class ControlLoopStateChangeAckListener extends ScoListener<ControlLoopAck> implements Listener { +public class ControlLoopStateChangeAckListener extends ScoListener<ControlLoopAck> implements Listener<ControlLoopAck> { private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopStateChangeAckListener.class); private final SupervisionHandler supervisionHandler; diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java index 2f14dc8f5..b8b5126ad 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,7 @@ import org.springframework.stereotype.Component; * Listener for ControlLoopUpdateAck messages sent by participants. */ @Component -public class ControlLoopUpdateAckListener extends ScoListener<ControlLoopAck> implements Listener { +public class ControlLoopUpdateAckListener extends ScoListener<ControlLoopAck> implements Listener<ControlLoopAck> { private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopUpdateAckListener.class); private final SupervisionHandler supervisionHandler; diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java index a03ff0a63..b8b209bac 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,8 @@ import org.springframework.stereotype.Component; * Listener for ParticipantDeregister messages sent by participants. */ @Component -public class ParticipantDeregisterListener extends ScoListener<ParticipantDeregister> implements Listener { +public class ParticipantDeregisterListener extends ScoListener<ParticipantDeregister> + implements Listener<ParticipantDeregister> { private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantDeregisterListener.class); private final SupervisionHandler supervisionHandler; diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java index a4d8c7697..fdf0bf3f7 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,8 @@ import org.springframework.stereotype.Component; * Listener for ParticipantRegister messages sent by participants. */ @Component -public class ParticipantRegisterListener extends ScoListener<ParticipantRegister> implements Listener { +public class ParticipantRegisterListener extends ScoListener<ParticipantRegister> + implements Listener<ParticipantRegister> { private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantRegisterListener.class); private final SupervisionHandler supervisionHandler; diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java index 9da886026..43a07e220 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,7 @@ import org.springframework.stereotype.Component; * Listener for ParticipantStatus messages sent by participants. */ @Component -public class ParticipantStatusListener extends ScoListener<ParticipantStatus> implements Listener { +public class ParticipantStatusListener extends ScoListener<ParticipantStatus> implements Listener<ParticipantStatus> { private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusListener.class); private final SupervisionHandler supervisionHandler; diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java index 4eeb0a8ce..fcfa80a9f 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,8 @@ import org.springframework.stereotype.Component; * Listener for ParticipantUpdateAck messages sent by participants. */ @Component -public class ParticipantUpdateAckListener extends ScoListener<ParticipantUpdateAck> implements Listener { +public class ParticipantUpdateAckListener extends ScoListener<ParticipantUpdateAck> + implements Listener<ParticipantUpdateAck> { private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdateAckListener.class); private final SupervisionHandler supervisionHandler; diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java index 936bb1444..8dbc710dd 100644 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java +++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +34,7 @@ import static org.mockito.Mockito.when; import java.util.List; import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup; import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusListener; import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData; @@ -67,7 +69,7 @@ class MessageDispatcherActivatorTest { when(listenerSecond.getType()).thenReturn(TOPIC_SECOND); when(listenerSecond.getScoListener()).thenReturn(listenerSecond); - List<Listener> listeners = List.of(listenerFirst, listenerSecond); + List<Listener<ParticipantStatus>> listeners = List.of(listenerFirst, listenerSecond); try (var activator = new MessageDispatcherActivator(parameterGroup, publishers, listeners)) { diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java index f136b9f10..7f04056cf 100644 --- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java +++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java @@ -246,8 +246,8 @@ class ControlLoopInstantiationProviderTest { new ControlLoopInstantiationProvider(clProvider, commissioningProvider, supervisionHandler); assertThatThrownBy( - () -> instantiationProvider.deleteControlLoop(controlLoop0.getName(), controlLoop0.getVersion())) - .hasMessageMatching(CONTROL_LOOP_NOT_FOUND); + () -> instantiationProvider.deleteControlLoop(controlLoop0.getName(), controlLoop0.getVersion())) + .hasMessageMatching(CONTROL_LOOP_NOT_FOUND); InstantiationUtils.assertInstantiationResponse(instantiationProvider.createControlLoops(controlLoops), controlLoops); @@ -282,8 +282,8 @@ class ControlLoopInstantiationProviderTest { instantiationProvider.updateControlLoops(controlLoops); assertThatThrownBy( - () -> instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion())) - .hasMessageMatching(String.format(DELETE_BAD_REQUEST, state)); + () -> instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion())) + .hasMessageMatching(String.format(DELETE_BAD_REQUEST, state)); } @Test diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java b/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java index 524733115..387ea8c1f 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.util.Date; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; -import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.ExchangeBuilder; import org.json.simple.JSONArray; import org.json.simple.JSONObject; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java index 0880e9b74..b1141ea49 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java @@ -91,10 +91,6 @@ public class CamelConfiguration extends RouteBuilder { @Value("${clamp.config.keyFile:#{null}}") private String keyFile; - - @Autowired - private ClampProperties clampProperties; - private void configureDefaultSslProperties() { if (trustStore != null) { System.setProperty("javax.net.ssl.trustStore", Thread.currentThread().getContextClassLoader() diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java index 71986f6fb..f871df70e 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java @@ -88,9 +88,9 @@ public class SdcControllersConfiguration { Map<String, SdcSingleControllerConfiguration> result = new HashMap<>(); if (jsonRootNode.get(CONTROLLER_SUBTREE_KEY) != null) { jsonRootNode.get(CONTROLLER_SUBTREE_KEY).getAsJsonObject().entrySet().forEach( - entry -> result.put(entry.getKey(), - new SdcSingleControllerConfiguration(entry.getValue().getAsJsonObject(), entry.getKey(), - keyFile))); + entry -> result.put(entry.getKey(), + new SdcSingleControllerConfiguration(entry.getValue().getAsJsonObject(), entry.getKey(), + keyFile))); } else { throw new SdcParametersException( CONTROLLER_SUBTREE_KEY + " key not found in the file: " + sdcControllerFile); diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java index 2d193355e..4a4155446 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java @@ -29,10 +29,8 @@ import java.util.Map; import javax.annotation.PostConstruct; import org.onap.policy.clamp.clds.tosca.update.execution.cds.ToscaMetadataCdsProcess; import org.onap.policy.clamp.loop.service.Service; -import org.onap.policy.clamp.tosca.DictionaryService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -44,9 +42,6 @@ public class ToscaMetadataExecutor { private static final Logger logger = LoggerFactory.getLogger(ToscaMetadataExecutor.class); - @Autowired - private DictionaryService dictionaryService; - private Map<String, ToscaMetadataProcess> mapOfProcesses = new HashMap<>(); /** diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java index 1d5ed26e0..9fe199af2 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java @@ -27,7 +27,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedHashMap; +import java.util.Map; import java.util.Map.Entry; import org.onap.policy.clamp.clds.tosca.update.elements.ToscaElement; import org.onap.policy.clamp.clds.tosca.update.elements.ToscaElementProperty; @@ -59,8 +59,8 @@ public class ToscaConverterToJsonSchema { private static final String TITLE = "title"; private static final String TYPE = "type"; - private LinkedHashMap<String, ToscaElement> components; - private LinkedHashMap<String, JsonTemplate> templates; + private Map<String, ToscaElement> components; + private Map<String, JsonTemplate> templates; private ToscaMetadataParser metadataParser; @@ -74,8 +74,8 @@ public class ToscaConverterToJsonSchema { * @param metadataParser The metadata parser to use for metadata section * @param serviceModel The service model for clamp enrichment */ - public ToscaConverterToJsonSchema(LinkedHashMap<String, ToscaElement> toscaElementsMap, - LinkedHashMap<String, JsonTemplate> jsonSchemaTemplates, ToscaMetadataParser metadataParser, + public ToscaConverterToJsonSchema(Map<String, ToscaElement> toscaElementsMap, + Map<String, JsonTemplate> jsonSchemaTemplates, ToscaMetadataParser metadataParser, Service serviceModel) { this.components = toscaElementsMap; this.templates = jsonSchemaTemplates; @@ -204,43 +204,7 @@ public class ToscaConverterToJsonSchema { for (String propertyField : toscaElementProperty.getItems().keySet()) { switch (propertyField) { case TYPE: - if (currentPropertyJsonTemplate.hasFields(propertyField)) { - String fieldtype = (String) toscaElementProperty.getItems().get(propertyField); - switch (fieldtype.toLowerCase()) { - case LIST: - propertiesInJson.addProperty(TYPE, ARRAY); - break; - case MAP: - propertiesInJson.addProperty(TYPE, OBJECT); - break; - case "scalar-unit.time": - case "scalar-unit.frequency": - case "scalar-unit.size": - propertiesInJson.addProperty(TYPE, "string"); - break; - case "timestamp": - propertiesInJson.addProperty(TYPE, "string"); - propertiesInJson.addProperty(FORMAT, "date-time"); - break; - case "float": - propertiesInJson.addProperty(TYPE, "number"); - break; - case "range": - propertiesInJson.addProperty(TYPE, "integer"); - if (!checkConstraintPresence(toscaElementProperty, "greater_than") - && currentPropertyJsonTemplate.hasFields("exclusiveMinimum")) { - propertiesInJson.addProperty("exclusiveMinimum", false); - } - if (!checkConstraintPresence(toscaElementProperty, "less_than") - && currentPropertyJsonTemplate.hasFields("exclusiveMaximum")) { - propertiesInJson.addProperty("exclusiveMaximum", false); - } - break; - default: - propertiesInJson.addProperty(TYPE, currentPropertyJsonTemplate.getName()); - break; - } - } + parseType(toscaElementProperty, propertyField, propertiesInJson, currentPropertyJsonTemplate); break; case METADATA: if (metadataParser != null) { @@ -254,37 +218,7 @@ public class ToscaConverterToJsonSchema { currentPropertyJsonTemplate); break; case ENTRY_SCHEMA: - // Here, a way to check if entry is a component (datatype) or a simple string - if (getToscaElement(this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA)) != null) { - String nameComponent = this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA); - var child = new ToscaConverterToJsonSchema(components, templates, metadataParser, serviceModel); - var propertiesContainer = new JsonObject(); - - if (((String) toscaElementProperty.getItems().get(TYPE)).equals(MAP)) { - JsonObject componentAsProperty = child.getJsonSchemaOfToscaElement(nameComponent); - propertiesContainer.add(nameComponent, componentAsProperty); - if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) { - propertiesInJson.add(PROPERTIES, propertiesContainer); - } - } else { - JsonObject componentAsItem = child.getJsonSchemaOfToscaElement(nameComponent); - if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) { - propertiesInJson.add("items", componentAsItem); - propertiesInJson.addProperty(FORMAT, "tabs-top"); - } - } - } else if (toscaElementProperty.getItems().get(TYPE).equals(LIST)) { - // Native cases - var itemContainer = new JsonObject(); - String valueInEntrySchema = - this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA); - itemContainer.addProperty(TYPE, valueInEntrySchema); - propertiesInJson.add("items", itemContainer); - propertiesInJson.addProperty(FORMAT, "tabs-top"); - } - - // MAP Case, for now nothing - + parseEntrySchema(toscaElementProperty, propertiesInJson, currentPropertyJsonTemplate); break; default: // Each classical field : type, description, default.. @@ -298,6 +232,81 @@ public class ToscaConverterToJsonSchema { return propertiesInJson; } + private void parseType(ToscaElementProperty toscaElementProperty, String propertyField, JsonObject propertiesInJson, + JsonTemplate currentPropertyJsonTemplate) { + if (currentPropertyJsonTemplate.hasFields(propertyField)) { + String fieldtype = (String) toscaElementProperty.getItems().get(propertyField); + switch (fieldtype.toLowerCase()) { + case LIST: + propertiesInJson.addProperty(TYPE, ARRAY); + break; + case MAP: + propertiesInJson.addProperty(TYPE, OBJECT); + break; + case "scalar-unit.time": + case "scalar-unit.frequency": + case "scalar-unit.size": + propertiesInJson.addProperty(TYPE, "string"); + break; + case "timestamp": + propertiesInJson.addProperty(TYPE, "string"); + propertiesInJson.addProperty(FORMAT, "date-time"); + break; + case "float": + propertiesInJson.addProperty(TYPE, "number"); + break; + case "range": + propertiesInJson.addProperty(TYPE, "integer"); + if (!checkConstraintPresence(toscaElementProperty, "greater_than") + && currentPropertyJsonTemplate.hasFields("exclusiveMinimum")) { + propertiesInJson.addProperty("exclusiveMinimum", false); + } + if (!checkConstraintPresence(toscaElementProperty, "less_than") + && currentPropertyJsonTemplate.hasFields("exclusiveMaximum")) { + propertiesInJson.addProperty("exclusiveMaximum", false); + } + break; + default: + propertiesInJson.addProperty(TYPE, currentPropertyJsonTemplate.getName()); + break; + } + } + } + + private void parseEntrySchema(ToscaElementProperty toscaElementProperty, JsonObject propertiesInJson, + JsonTemplate currentPropertyJsonTemplate) { + // Here, a way to check if entry is a component (datatype) or a simple string + if (getToscaElement(this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA)) != null) { + String nameComponent = this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA); + var child = new ToscaConverterToJsonSchema(components, templates, metadataParser, serviceModel); + var propertiesContainer = new JsonObject(); + + if (((String) toscaElementProperty.getItems().get(TYPE)).equals(MAP)) { + JsonObject componentAsProperty = child.getJsonSchemaOfToscaElement(nameComponent); + propertiesContainer.add(nameComponent, componentAsProperty); + if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) { + propertiesInJson.add(PROPERTIES, propertiesContainer); + } + } else { + JsonObject componentAsItem = child.getJsonSchemaOfToscaElement(nameComponent); + if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) { + propertiesInJson.add("items", componentAsItem); + propertiesInJson.addProperty(FORMAT, "tabs-top"); + } + } + } else if (toscaElementProperty.getItems().get(TYPE).equals(LIST)) { + // Native cases + var itemContainer = new JsonObject(); + String valueInEntrySchema = + this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA); + itemContainer.addProperty(TYPE, valueInEntrySchema); + propertiesInJson.add("items", itemContainer); + propertiesInJson.addProperty(FORMAT, "tabs-top"); + } + + // MAP Case, for now nothing + } + /** * Look for a matching Component for the name parameter, in the components list. * @@ -326,8 +335,8 @@ public class ToscaConverterToJsonSchema { */ @SuppressWarnings("unchecked") public String extractSpecificFieldFromMap(ToscaElementProperty toscaElementProperty, String fieldName) { - LinkedHashMap<String, String> entrySchemaFields = - (LinkedHashMap<String, String>) toscaElementProperty.getItems().get(fieldName); + Map<String, String> entrySchemaFields = + (Map<String, String>) toscaElementProperty.getItems().get(fieldName); return entrySchemaFields.get(TYPE); } @@ -344,8 +353,8 @@ public class ToscaConverterToJsonSchema { @SuppressWarnings("unchecked") ArrayList<Object> constraints = (ArrayList<Object>) toscaElementProperty.getItems().get(CONSTRAINTS); for (Object constraint : constraints) { - if (constraint instanceof LinkedHashMap - && ((LinkedHashMap<?, ?>) constraint).containsKey(nameConstraint)) { + if (constraint instanceof Map + && ((Map<?, ?>) constraint).containsKey(nameConstraint)) { presentConstraint = true; } } diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java index af7f8cc54..f9b274e26 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -38,8 +38,8 @@ import org.onap.policy.clamp.clds.util.JsonUtils; import org.onap.policy.clamp.loop.service.Service; public class JsonTemplateManager { - private LinkedHashMap<String, JsonTemplate> jsonSchemaTemplates; - private LinkedHashMap<String, ToscaElement> toscaElements; + private Map<String, JsonTemplate> jsonSchemaTemplates; + private Map<String, ToscaElement> toscaElements; /** * Constructor. @@ -58,19 +58,19 @@ public class JsonTemplateManager { } // GETTERS & SETTERS - public LinkedHashMap<String, ToscaElement> getToscaElements() { + public Map<String, ToscaElement> getToscaElements() { return toscaElements; } - public void setToscaElements(LinkedHashMap<String, ToscaElement> toscaElements) { + public void setToscaElements(Map<String, ToscaElement> toscaElements) { this.toscaElements = toscaElements; } - public LinkedHashMap<String, JsonTemplate> getJsonSchemaTemplates() { + public Map<String, JsonTemplate> getJsonSchemaTemplates() { return jsonSchemaTemplates; } - public void setJsonSchemaTemplates(LinkedHashMap<String, JsonTemplate> jsonSchemaTemplates) { + public void setJsonSchemaTemplates(Map<String, JsonTemplate> jsonSchemaTemplates) { this.jsonSchemaTemplates = jsonSchemaTemplates; } @@ -157,10 +157,9 @@ public class JsonTemplateManager { * @param jsonTemplates The template properties as String * @return a map */ - @SuppressWarnings("unused") - private LinkedHashMap<String, JsonTemplate> initializeTemplates(String jsonTemplates) { + private Map<String, JsonTemplate> initializeTemplates(String jsonTemplates) { - LinkedHashMap<String, JsonTemplate> generatedTemplates = new LinkedHashMap<>(); + Map<String, JsonTemplate> generatedTemplates = new LinkedHashMap<>(); JsonObject templates = JsonUtils.GSON.fromJson(jsonTemplates, JsonObject.class); for (Map.Entry<String, JsonElement> templateAsJson : templates.entrySet()) { diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java b/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java index aefe4556d..1542d9736 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java @@ -43,7 +43,6 @@ import org.onap.policy.clamp.loop.service.Service; import org.onap.policy.clamp.loop.template.LoopElementModel; import org.onap.policy.clamp.loop.template.LoopTemplate; import org.onap.policy.clamp.loop.template.LoopTemplatesRepository; -import org.onap.policy.clamp.loop.template.PolicyModelsRepository; import org.onap.policy.clamp.policy.PolicyEngineServices; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,9 +62,6 @@ public class CsarInstaller { private static final Logger logger = LoggerFactory.getLogger(CsarInstaller.class); @Autowired - private PolicyModelsRepository policyModelsRepository; - - @Autowired private LoopTemplatesRepository loopTemplatesRepository; @Autowired diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java index bbf33d54c..a161860ad 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java +++ b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java @@ -119,12 +119,12 @@ public class PdpGroupPayload { this.deploymentGroups.getGroups().stream().filter(group -> group.getName().equals(pdpGroup)).findFirst() .ifPresentOrElse(group -> group.getDeploymentSubgroups().add(newSubGroup), - () -> { - var newGroup = new DeploymentGroup(); - newGroup.setName(pdpGroup); - newGroup.setDeploymentSubgroups(new ArrayList<>(Arrays.asList(newSubGroup))); - this.deploymentGroups.getGroups().add(newGroup); - }); + () -> { + var newGroup = new DeploymentGroup(); + newGroup.setName(pdpGroup); + newGroup.setDeploymentSubgroups(new ArrayList<>(Arrays.asList(newSubGroup))); + this.deploymentGroups.getGroups().add(newGroup); + }); } /** diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItTestCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItTestCase.java index 1d78d6ce1..165fd3fd6 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItTestCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItTestCase.java @@ -29,7 +29,6 @@ import javax.transaction.Transactional; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.policy.clamp.clds.Application; -import org.onap.policy.clamp.clds.tosca.update.execution.ToscaMetadataExecutor; import org.onap.policy.clamp.clds.tosca.update.parser.metadata.ToscaMetadataParserWithDictionarySupport; import org.onap.policy.clamp.clds.tosca.update.templates.JsonTemplateManager; import org.onap.policy.clamp.clds.util.JsonUtils; @@ -55,9 +54,6 @@ public class ToscaConverterWithDictionarySupportItTestCase { @Autowired private ToscaMetadataParserWithDictionarySupport toscaMetadataParserWithDictionarySupport; - @Autowired - private ToscaMetadataExecutor toscaMetadataExecutor; - /** * This Test validates Tosca yaml with metadata tag that contains policy_model_type and acronym * parameters which defines the Tosca Policy name and its short name. diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java index f3ca978e7..57837eff4 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * Copyright (C) 2019 Samsung. All rights reserved. +* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,6 @@ package org.onap.policy.clamp.clds.util; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -38,7 +38,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/ExternalComponentStateTest.java b/runtime/src/test/java/org/onap/policy/clamp/loop/ExternalComponentStateTest.java index 567cad69d..de8ec4a48 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/ExternalComponentStateTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/ExternalComponentStateTest.java @@ -40,6 +40,7 @@ public class ExternalComponentStateTest { } @Test + @SuppressWarnings("unlikely-arg-type") public void equalsTest() { assertThat(state.equals(null)).isFalse(); @@ -68,7 +69,7 @@ public class ExternalComponentStateTest { public void compareToTest() { ExternalComponentState state2 = new ExternalComponentState("NOT_SENT", "The policies defined have NOT yet been created on the policy engine", 90); - assertThat(state.compareTo(state2)).isEqualTo(0); + assertThat(state).isEqualByComparingTo(state2); ExternalComponentState state3 = new ExternalComponentState("SENT", "The policies defined have NOT yet been created on the policy engine", 50); |