From 109ccd46e27c1a5a244ab15c75e324e7d1a98291 Mon Sep 17 00:00:00 2001 From: sebdet Date: Thu, 2 May 2019 18:18:58 +0200 Subject: Rework the Model Json Rework the model Json returned by the backend to the UI Issue-ID: CLAMP-365 Change-Id: I8b4e24292d62140b4b2e105d8b18042f84e1fd38 Signed-off-by: sebdet --- src/test/resources/tosca/model-properties.json | 123 +++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/test/resources/tosca/model-properties.json (limited to 'src/test/resources/tosca/model-properties.json') diff --git a/src/test/resources/tosca/model-properties.json b/src/test/resources/tosca/model-properties.json new file mode 100644 index 000000000..9e7db8ebc --- /dev/null +++ b/src/test/resources/tosca/model-properties.json @@ -0,0 +1,123 @@ +{ + "serviceDetails": { + "serviceType": "", + "namingPolicy": "", + "environmentContext": "General_Revenue-Bearing", + "serviceEcompNaming": "true", + "serviceRole": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f", + "ecompGeneratedNaming": "true", + "category": "Network L4+", + "type": "Service", + "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0", + "instantiationType": "A-la-carte" + }, + "resourceDetails": { + "CP": { + + }, + "VL": { + + }, + "VF": { + "vLoadBalancerMS 0": { + "resourceVendor": "Test", + "resourceVendorModelNumber": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", + "subcategory": "Load Balancer", + "category": "Application L4+", + "type": "VF", + "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", + "version": "1.0", + "resourceVendorRelease": "1.0", + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" + } + }, + "CR": { + + }, + "VFC": { + + }, + "PNF": { + + }, + "Service": { + + }, + "CVFC": { + + }, + "Service Proxy": { + + }, + "Configuration": { + + }, + "AllottedResource": { + + }, + "VFModule": { + "Vloadbalancerms..vpkg..module-1": { + "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", + "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "min_vf_module_instances": 0, + "vf_module_label": "vpkg", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..vdns..module-3": { + "vfModuleModelInvariantUUID": "4c10ba9b-f88f-415e-9de3-5d33336047fa", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vdns..module-3", + "vfModuleModelUUID": "4fa73b49-8a6c-493e-816b-eb401567b720", + "vfModuleModelCustomizationUUID": "bafcdab0-801d-4d81-9ead-f464640a38b1", + "min_vf_module_instances": 0, + "vf_module_label": "vdns", + "max_vf_module_instances": 50, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..base_template..module-0": { + "vfModuleModelInvariantUUID": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..base_template..module-0", + "vfModuleModelUUID": "63734409-f745-4e4d-a38b-131638a0edce", + "vfModuleModelCustomizationUUID": "86baddea-c730-4fb8-9410-cd2e17fd7f27", + "min_vf_module_instances": 1, + "vf_module_label": "base_template", + "max_vf_module_instances": 1, + "vf_module_type": "Base", + "isBase": true, + "initial_count": 1, + "volume_group": false + }, + "Vloadbalancerms..vlb..module-2": { + "vfModuleModelInvariantUUID": "a772a1f4-0064-412c-833d-4749b15828dd", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vlb..module-2", + "vfModuleModelUUID": "0f5c3f6a-650a-4303-abb6-fff3e573a07a", + "vfModuleModelCustomizationUUID": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806", + "min_vf_module_instances": 0, + "vf_module_label": "vlb", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + } + } + } +} \ No newline at end of file -- cgit 1.2.3-korg From 289e8e1f1858e970f92b50a1e601521edeefd44f Mon Sep 17 00:00:00 2001 From: xuegao Date: Fri, 8 Nov 2019 13:10:36 +0100 Subject: Create Service object User Service object to store loop service and resource realted info. Issue-ID: CLAMP-545 Change-Id: I0df6f5d43d7e0575346e02a27bca5c0b5ecdb0a0 Signed-off-by: xuegao --- extra/sql/bulkload/create-tables.sql | 15 +- src/main/java/org/onap/clamp/loop/Loop.java | 18 +- .../org/onap/clamp/loop/LoopCsarInstaller.java | 18 +- .../java/org/onap/clamp/loop/service/Service.java | 137 ++++ .../OperationalPolicyRepresentationBuilder.java | 14 +- .../org/onap/clamp/clds/it/CldsServiceItCase.java | 2 +- .../org/onap/clamp/loop/CsarInstallerItCase.java | 9 +- .../org/onap/clamp/loop/LoopServiceTestItCase.java | 4 +- .../java/org/onap/clamp/loop/LoopToJsonTest.java | 28 +- src/test/java/org/onap/clamp/loop/ServiceTest.java | 55 ++ ...OperationalPolicyRepresentationBuilderTest.java | 5 +- src/test/resources/tosca/loop.json | 704 +++++++++++++++++++++ src/test/resources/tosca/model-properties.json | 10 - src/test/resources/tosca/resource-details.json | 96 +++ src/test/resources/tosca/service-details.json | 15 + ui-react/src/api/LoopCache.js | 4 +- ui-react/src/api/LoopCache_mokeLoopJsonCache.json | 2 +- ui-react/src/api/example.json | 2 +- 18 files changed, 1092 insertions(+), 46 deletions(-) create mode 100644 src/main/java/org/onap/clamp/loop/service/Service.java create mode 100644 src/test/java/org/onap/clamp/loop/ServiceTest.java create mode 100644 src/test/resources/tosca/loop.json create mode 100644 src/test/resources/tosca/resource-details.json create mode 100644 src/test/resources/tosca/service-details.json (limited to 'src/test/resources/tosca/model-properties.json') diff --git a/extra/sql/bulkload/create-tables.sql b/extra/sql/bulkload/create-tables.sql index 0e15d4d3a..dafd80034 100644 --- a/extra/sql/bulkload/create-tables.sql +++ b/extra/sql/bulkload/create-tables.sql @@ -23,9 +23,9 @@ dcae_deployment_status_url varchar(255), global_properties_json json, last_computed_state varchar(255) not null, - model_properties_json json, operational_policy_schema json, svg_representation MEDIUMTEXT, + service_uuid varchar(255), primary key (name) ) engine=InnoDB; @@ -52,11 +52,24 @@ primary key (name) ) engine=InnoDB; + create table services ( + service_uuid varchar(255) not null, + name varchar(255) not null, + resource_details json, + service_details json, + primary key (service_uuid) + ) engine=InnoDB; + alter table loop_logs add constraint FK1j0cda46aickcaoxqoo34khg2 foreign key (loop_id) references loops (name); + alter table loops + add constraint FK4b9wnqopxogwek014i1shqw7w + foreign key (service_uuid) + references services (service_uuid); + alter table loops_microservicepolicies add constraint FKem7tp1cdlpwe28av7ef91j1yl foreign key (microservicepolicy_id) diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index 37d597eeb..ef70ba80e 100644 --- a/src/main/java/org/onap/clamp/loop/Loop.java +++ b/src/main/java/org/onap/clamp/loop/Loop.java @@ -48,6 +48,7 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Transient; @@ -61,6 +62,7 @@ import org.onap.clamp.loop.components.external.DcaeComponent; import org.onap.clamp.loop.components.external.ExternalComponent; import org.onap.clamp.loop.components.external.PolicyComponent; import org.onap.clamp.loop.log.LoopLog; +import org.onap.clamp.loop.service.Service; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.operational.OperationalPolicy; import org.onap.clamp.policy.operational.OperationalPolicyRepresentationBuilder; @@ -109,9 +111,9 @@ public class Loop implements Serializable { private JsonObject globalPropertiesJson; @Expose - @Type(type = "json") - @Column(columnDefinition = "json", name = "model_properties_json") - private JsonObject modelPropertiesJson; + @ManyToOne(fetch = FetchType.EAGER,cascade = CascadeType.ALL) + @JoinColumn(name = "service_uuid") + private Service modelService; @Column(columnDefinition = "MEDIUMTEXT", nullable = false, name = "blueprint_yaml") private String blueprint; @@ -266,15 +268,15 @@ public class Loop implements Serializable { this.dcaeBlueprintId = dcaeBlueprintId; } - public JsonObject getModelPropertiesJson() { - return modelPropertiesJson; + public Service getModelService() { + return modelService; } - void setModelPropertiesJson(JsonObject modelPropertiesJson) { - this.modelPropertiesJson = modelPropertiesJson; + void setModelService(Service modelService) { + this.modelService = modelService; try { this.operationalPolicySchema = OperationalPolicyRepresentationBuilder - .generateOperationalPolicySchema(this.getModelPropertiesJson()); + .generateOperationalPolicySchema(this.getModelService()); } catch (JsonSyntaxException | IOException | NullPointerException e) { logger.error("Unable to generate the operational policy Schema ... ", e); this.operationalPolicySchema = new JsonObject(); diff --git a/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java b/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java index b8bc1f524..55009bc22 100644 --- a/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java +++ b/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java @@ -46,6 +46,7 @@ import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller; import org.onap.clamp.clds.sdc.controller.installer.MicroService; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.drawing.SvgFacade; +import org.onap.clamp.loop.service.Service; import org.onap.clamp.policy.Policy; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.operational.OperationalPolicy; @@ -138,7 +139,7 @@ public class LoopCsarInstaller implements CsarInstaller { if (microServicesChain.isEmpty()) { microServicesChain = blueprintParser.fallbackToOneMicroService(blueprintArtifact.getDcaeBlueprint()); } - newLoop.setModelPropertiesJson(createModelPropertiesJson(csar)); + newLoop.setModelService(createServiceModel(csar)); newLoop.setMicroServicePolicies( createMicroServicePolicies(microServicesChain, csar, blueprintArtifact, newLoop)); newLoop.setOperationalPolicies(createOperationalPolicies(csar, blueprintArtifact, newLoop)); @@ -219,16 +220,17 @@ public class LoopCsarInstaller implements CsarInstaller { return resourcesProp; } - private static JsonObject createModelPropertiesJson(CsarHandler csar) { - JsonObject modelProperties = new JsonObject(); - // Add service details - modelProperties.add("serviceDetails", JsonUtils.GSON.fromJson( - JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class)); + private Service createServiceModel(CsarHandler csar) { + JsonObject serviceDetails = JsonUtils.GSON.fromJson( + JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class); + // Add properties details for each type, VfModule, VF, VFC, .... JsonObject resourcesProp = createServicePropertiesByType(csar); resourcesProp.add("VFModule", createVfModuleProperties(csar)); - modelProperties.add("resourceDetails", resourcesProp); - return modelProperties; + + Service modelService = new Service(serviceDetails, resourcesProp); + + return modelService; } private JsonObject getAllBlueprintParametersInJson(BlueprintArtifact blueprintArtifact, Loop newLoop) { diff --git a/src/main/java/org/onap/clamp/loop/service/Service.java b/src/main/java/org/onap/clamp/loop/service/Service.java new file mode 100644 index 000000000..ac1216b9d --- /dev/null +++ b/src/main/java/org/onap/clamp/loop/service/Service.java @@ -0,0 +1,137 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 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. + * 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. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.loop.service; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.gson.JsonObject; +import com.google.gson.annotations.Expose; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; + +import org.hibernate.annotations.Type; +import org.hibernate.annotations.TypeDef; +import org.hibernate.annotations.TypeDefs; +import org.onap.clamp.dao.model.jsontype.StringJsonUserType; + + +@Entity +@Table(name = "services") +@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) }) +public class Service implements Serializable { + + /** + * The serial version id. + */ + private static final long serialVersionUID = 1331119060272760758L; + + @Transient + private static final EELFLogger logger = EELFManager.getInstance().getLogger(Service.class); + + @Id + @Column(name = "service_uuid", unique = true) + private String serviceUuid; + + @Column(nullable = false, name = "name") + private String name; + + @Expose + @Type(type = "json") + @Column(columnDefinition = "json", name = "service_details") + private JsonObject serviceDetails; + + @Expose + @Type(type = "json") + @Column(columnDefinition = "json", name = "resource_details") + private JsonObject resourceDetails; + + /** + * Public constructor. + */ + public Service() { + } + + /** + * Constructor. + */ + public Service(JsonObject serviceDetails, JsonObject resourceDetails) { + this.name = serviceDetails.get("name").getAsString(); + this.serviceUuid = serviceDetails.get("UUID").getAsString(); + this.serviceDetails = serviceDetails; + this.resourceDetails = resourceDetails; + } + + public String getServiceUuid() { + return serviceUuid; + } + + public JsonObject getServiceDetails() { + return serviceDetails; + } + + public JsonObject getResourceDetails() { + return resourceDetails; + } + + public JsonObject getResourceByType(String type) { + return (JsonObject) resourceDetails.get(type); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((serviceUuid == null) ? 0 : serviceUuid.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Service other = (Service) obj; + if (serviceUuid == null) { + if (other.serviceUuid != null) { + return false; + } + } else if (!serviceUuid.equals(other.serviceUuid)) { + return false; + } + return true; + } + +} diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java index f6f3f498d..1d0d99080 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java @@ -33,6 +33,7 @@ import java.util.Map.Entry; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.loop.service.Service; public class OperationalPolicyRepresentationBuilder { @@ -47,7 +48,7 @@ public class OperationalPolicyRepresentationBuilder { * @throws JsonSyntaxException If the schema template cannot be parsed * @throws IOException In case of issue when opening the schema template */ - public static JsonObject generateOperationalPolicySchema(JsonObject modelJson) + public static JsonObject generateOperationalPolicySchema(Service modelJson) throws JsonSyntaxException, IOException { JsonObject jsonSchema = JsonUtils.GSON.fromJson( ResourceFileUtil.getResourceAsString("clds/json-schema/operational_policies/operational_policy.json"), @@ -78,9 +79,9 @@ public class OperationalPolicyRepresentationBuilder { return property; } - private static JsonArray createVnfSchema(JsonObject modelJson) { + private static JsonArray createVnfSchema(Service modelService) { JsonArray vnfSchemaArray = new JsonArray(); - JsonObject modelVnfs = modelJson.get("resourceDetails").getAsJsonObject().get("VF").getAsJsonObject(); + JsonObject modelVnfs = modelService.getResourceByType("VF"); for (Entry entry : modelVnfs.entrySet()) { JsonObject vnfOneOfSchema = new JsonObject(); @@ -96,10 +97,9 @@ public class OperationalPolicyRepresentationBuilder { return vnfSchemaArray; } - private static JsonArray createVfModuleSchema(JsonObject modelJson) { + private static JsonArray createVfModuleSchema(Service modelService) { JsonArray vfModuleOneOfSchemaArray = new JsonArray(); - JsonObject modelVfModules = modelJson.get("resourceDetails").getAsJsonObject().get("VFModule") - .getAsJsonObject(); + JsonObject modelVfModules = modelService.getResourceByType("VFModule"); for (Entry entry : modelVfModules.entrySet()) { JsonObject vfModuleOneOfSchema = new JsonObject(); @@ -137,7 +137,7 @@ public class OperationalPolicyRepresentationBuilder { return vfModuleOneOfSchemaArray; } - private static JsonArray createAnyOfArray(JsonObject modelJson) { + private static JsonArray createAnyOfArray(Service modelJson) { JsonArray targetOneOfStructure = new JsonArray(); targetOneOfStructure.addAll(createVnfSchema(modelJson)); targetOneOfStructure.addAll(createVfModuleSchema(modelJson)); diff --git a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java index 072d57712..40cc0650e 100644 --- a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java @@ -104,7 +104,6 @@ public class CldsServiceItCase { @Test public void testCldsInfoAuthorized() throws Exception { - Authentication authentication; List authList = new LinkedList(); authList.add(new SimpleGrantedAuthority("permission-type-cl-manage|dev|*")); authList.add(new SimpleGrantedAuthority("permission-type-cl|dev|read")); @@ -113,6 +112,7 @@ public class CldsServiceItCase { authList.add(new SimpleGrantedAuthority("permission-type-template|dev|update")); authList.add(new SimpleGrantedAuthority("permission-type-filter-vf|dev|*")); authList.add(new SimpleGrantedAuthority("permission-type-cl-event|dev|*")); + Authentication authentication; authentication = new UsernamePasswordAuthenticationToken(new User("admin", "", authList), "", authList); Mockito.when(securityContext.getAuthentication()).thenReturn(authentication); diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index fbf1f2079..e3271c7a6 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -202,10 +202,13 @@ public class CsarInstallerItCase { assertThat(loop.getGlobalPropertiesJson().get("dcaeDeployParameters")).isNotNull(); assertThat(loop.getMicroServicePolicies()).hasSize(1); assertThat(loop.getOperationalPolicies()).hasSize(1); - assertThat(loop.getModelPropertiesJson().get("serviceDetails")).isNotNull(); - assertThat(loop.getModelPropertiesJson().get("resourceDetails")).isNotNull(); + assertThat(loop.getModelService().getServiceUuid()).isEqualTo("63cac700-ab9a-4115-a74f-7eac85e3fce0"); JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"), - JsonUtils.GSON.toJson(loop.getModelPropertiesJson()), true); + JsonUtils.GSON_JPA_MODEL.toJson(loop.getModelService()), true); + JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/service-details.json"), + JsonUtils.GSON_JPA_MODEL.toJson(loop.getModelService().getServiceDetails()), true); + JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/resource-details.json"), + JsonUtils.GSON_JPA_MODEL.toJson(loop.getModelService().getResourceDetails()), true); assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty(); loop = loopsRepo diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java index 1fedc9abe..28a92e371 100644 --- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java +++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java @@ -347,8 +347,8 @@ public class LoopServiceTestItCase { saveTestLoopToDb(); assertThat(microServicePolicyService.isExisting("policyName")).isFalse(); MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", "", - "tosca_definitions_version: tosca_simple_yaml_1_0_0", false, - JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); + "tosca_definitions_version: tosca_simple_yaml_1_0_0", false, + JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); loopService.updateMicroservicePolicy(EXAMPLE_LOOP_NAME, microServicePolicy); assertThat(microServicePolicyService.isExisting("policyName")).isTrue(); } diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java index 3010fe50b..b68bf48a0 100644 --- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java +++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java @@ -29,7 +29,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertNotNull; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; +import com.google.gson.JsonSyntaxException; import java.io.IOException; import java.util.HashSet; @@ -41,6 +43,7 @@ import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.clamp.loop.components.external.PolicyComponent; import org.onap.clamp.loop.log.LogType; import org.onap.clamp.loop.log.LoopLog; +import org.onap.clamp.loop.service.Service; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.operational.OperationalPolicy; import org.skyscreamer.jsonassert.JSONAssert; @@ -54,7 +57,7 @@ public class LoopToJsonTest { } private Loop getLoop(String name, String svgRepresentation, String blueprint, String globalPropertiesJson, - String dcaeId, String dcaeUrl, String dcaeBlueprintId) { + String dcaeId, String dcaeUrl, String dcaeBlueprintId) throws JsonSyntaxException, IOException { Loop loop = new Loop(name, blueprint, svgRepresentation); loop.setGlobalPropertiesJson(new Gson().fromJson(globalPropertiesJson, JsonObject.class)); loop.setLastComputedState(LoopState.DESIGN); @@ -115,6 +118,29 @@ public class LoopToJsonTest { "loop"); } + @Test + public void loopServiceTest() throws IOException { + Loop loopTest2 = getLoop("ControlLoopTest", "", "yamlcontent", "{\"testname\":\"testvalue\"}", + "123456789", "https://dcaetest.org", "UUID-blueprint"); + + JsonObject jsonModel = new GsonBuilder().create() + .fromJson(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"), JsonObject.class); + Service service = new Service(jsonModel.get("serviceDetails").getAsJsonObject(), + jsonModel.get("resourceDetails").getAsJsonObject()); + loopTest2.setModelService(service); + + String jsonSerialized = JsonUtils.GSON_JPA_MODEL.toJson(loopTest2); + assertThat(jsonSerialized).isNotNull().isNotEmpty(); + System.out.println(jsonSerialized); + JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/loop.json"), + jsonSerialized, true); + + Loop loopTestDeserialized = JsonUtils.GSON_JPA_MODEL.fromJson(jsonSerialized, Loop.class); + assertNotNull(loopTestDeserialized); + assertThat(loopTestDeserialized).isEqualToIgnoringGivenFields(loopTest2, "modelService", + "svgRepresentation", "blueprint", "components"); + } + @Test public void createPoliciesPayloadPdpGroupTest() throws IOException { Loop loopTest = getLoop("ControlLoopTest", "", "yamlcontent", "{\"testname\":\"testvalue\"}", diff --git a/src/test/java/org/onap/clamp/loop/ServiceTest.java b/src/test/java/org/onap/clamp/loop/ServiceTest.java new file mode 100644 index 000000000..45de5385e --- /dev/null +++ b/src/test/java/org/onap/clamp/loop/ServiceTest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 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. + * 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. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.loop; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.gson.JsonObject; + +import org.junit.Test; +import org.onap.clamp.clds.util.JsonUtils; +import org.onap.clamp.loop.service.Service; + +public class ServiceTest { + + @Test + public void equalMethodTest() { + String serviceStr1 = "{\"name\": \"vLoadBalancerMS\", \"UUID\": \"63cac700-ab9a-4115-a74f-7eac85e3fce0\"}"; + String serviceStr2 = "{\"name\": \"vLoadBalancerMS2\", \"UUID\": \"63cac700-ab9a-4115-a74f-7eac85e3fce0\"}"; + String serviceStr3 = "{\"name\": \"vLoadBalancerMS\",\"UUID\": \"63cac700-ab9a-4115-a74f-7eac85e3fc11\"}"; + String resourceStr = "{\"CP\": {}}"; + + Service service1 = new Service(JsonUtils.GSON.fromJson(serviceStr1, JsonObject.class), + JsonUtils.GSON.fromJson(resourceStr, JsonObject.class)); + + Service service2 = new Service(JsonUtils.GSON.fromJson(serviceStr2, JsonObject.class), null); + + Service service3 = new Service(JsonUtils.GSON.fromJson(serviceStr3, JsonObject.class), + JsonUtils.GSON.fromJson(resourceStr, JsonObject.class)); + + assertThat(service1.equals(service2)).isEqualTo(true); + assertThat(service1.equals(service3)).isEqualTo(false); + } + +} diff --git a/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java index 904525bea..673ac323d 100644 --- a/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java +++ b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java @@ -32,6 +32,7 @@ import java.io.IOException; import org.junit.Test; import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.loop.service.Service; import org.skyscreamer.jsonassert.JSONAssert; public class OperationalPolicyRepresentationBuilderTest { @@ -40,8 +41,10 @@ public class OperationalPolicyRepresentationBuilderTest { public void testOperationalPolicyPayloadConstruction() throws IOException { JsonObject jsonModel = new GsonBuilder().create() .fromJson(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"), JsonObject.class); + Service service = new Service(jsonModel.get("serviceDetails").getAsJsonObject(), + jsonModel.get("resourceDetails").getAsJsonObject()); - JsonObject jsonSchema = OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(jsonModel); + JsonObject jsonSchema = OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(service); assertThat(jsonSchema).isNotNull(); diff --git a/src/test/resources/tosca/loop.json b/src/test/resources/tosca/loop.json new file mode 100644 index 000000000..557fa6f69 --- /dev/null +++ b/src/test/resources/tosca/loop.json @@ -0,0 +1,704 @@ +{ + "name": "ControlLoopTest", + "dcaeDeploymentId": "123456789", + "dcaeDeploymentStatusUrl": "https://dcaetest.org", + "dcaeBlueprintId": "UUID-blueprint", + "operationalPolicySchema": { + "schema": { + "uniqueItems": "true", + "format": "tabs", + "type": "array", + "minItems": 1, + "maxItems": 1, + "title": "Operational policies", + "items": { + "type": "object", + "title": "Operational Policy Item", + "id": "operational_policy_item", + "headerTemplate": "{{self.name}}", + "required": [ + "name", + "configurationsJson" + ], + "properties": { + "name": { + "type": "string", + "title": "Operational policy name", + "readOnly": "True" + }, + "configurationsJson": { + "type": "object", + "title": "Configuration", + "required": [ + "operational_policy", + "guard_policies" + ], + "properties": { + "operational_policy": { + "type": "object", + "title": "Related Parameters", + "required": [ + "controlLoop", + "policies" + ], + "properties": { + "controlLoop": { + "type": "object", + "title": "Control Loop details", + "required": [ + "timeout", + "abatement", + "trigger_policy", + "controlLoopName" + ], + "properties": { + "timeout": { + "type": "string", + "title": "Overall Time Limit", + "default": "0", + "format": "number" + }, + "abatement": { + "type": "string", + "title": "Abatement", + "enum": [ + "True", + "False" + ] + }, + "trigger_policy": { + "type": "string", + "title": "Policy Decision Entry" + }, + "controlLoopName": { + "type": "string", + "title": "Control loop name", + "readOnly": "True" + } + } + }, + "policies": { + "uniqueItems": "true", + "id": "policies_array", + "type": "array", + "title": "Policy Decision Tree", + "format": "tabs-top", + "items": { + "title": "Policy Decision", + "type": "object", + "id": "policy_item", + "headerTemplate": "{{self.id}} - {{self.recipe}}", + "format": "categories", + "basicCategoryTitle": "recipe", + "required": [ + "id", + "recipe", + "retry", + "timeout", + "actor", + "success", + "failure", + "failure_timeout", + "failure_retries", + "failure_exception", + "failure_guard", + "target" + ], + "properties": { + "id": { + "default": "Policy 1", + "title": "Policy ID", + "type": "string" + }, + "recipe": { + "title": "Recipe", + "type": "string", + "enum": [ + "Restart", + "Rebuild", + "Migrate", + "Health-Check", + "ModifyConfig", + "VF Module Create", + "VF Module Delete", + "Reroute" + ] + }, + "retry": { + "default": "0", + "title": "Number of Retry", + "type": "string", + "format": "number" + }, + "timeout": { + "default": "0", + "title": "Timeout", + "type": "string", + "format": "number" + }, + "actor": { + "title": "Actor", + "type": "string", + "enum": [ + "APPC", + "SO", + "VFC", + "SDNC", + "SDNR" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + }, + "success": { + "default": "final_success", + "title": "When Success", + "type": "string" + }, + "failure": { + "default": "final_failure", + "title": "When Failure", + "type": "string" + }, + "failure_timeout": { + "default": "final_failure_timeout", + "title": "When Failure Timeout", + "type": "string" + }, + "failure_retries": { + "default": "final_failure_retries", + "title": "When Failure Retries", + "type": "string" + }, + "failure_exception": { + "default": "final_failure_exception", + "title": "When Failure Exception", + "type": "string" + }, + "failure_guard": { + "default": "final_failure_guard", + "title": "When Failure Guard", + "type": "string" + }, + "target": { + "type": "object", + "required": [ + "type", + "resourceID" + ], + "anyOf": [ + { + "title": "User Defined", + "additionalProperties": "True", + "properties": { + "type": { + "title": "Target type", + "type": "string", + "default": "", + "enum": [ + "VNF", + "VFMODULE", + "VM" + ] + }, + "resourceID": { + "title": "Target type", + "type": "string", + "default": "" + } + } + }, + { + "title": "VNF-vLoadBalancerMS 0", + "properties": { + "type": { + "title": "Type", + "type": "string", + "default": "VNF", + "readOnly": "True" + }, + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "vLoadBalancerMS", + "readOnly": "True" + } + } + }, + { + "title": "VFMODULE-Vloadbalancerms..vpkg..module-1", + "properties": { + "type": { + "title": "Type", + "type": "string", + "default": "VFMODULE", + "readOnly": "True" + }, + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "Vloadbalancerms..vpkg..module-1", + "readOnly": "True" + }, + "modelInvariantId": { + "title": "Model Invariant Id (ModelInvariantUUID)", + "type": "string", + "default": "ca052563-eb92-4b5b-ad41-9111768ce043", + "readOnly": "True" + }, + "modelVersionId": { + "title": "Model Version Id (ModelUUID)", + "type": "string", + "default": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "readOnly": "True" + }, + "modelName": { + "title": "Model Name", + "type": "string", + "default": "Vloadbalancerms..vpkg..module-1", + "readOnly": "True" + }, + "modelVersion": { + "title": "Model Version", + "type": "string", + "default": "1", + "readOnly": "True" + }, + "modelCustomizationId": { + "title": "Customization ID", + "type": "string", + "default": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "readOnly": "True" + } + } + }, + { + "title": "VFMODULE-Vloadbalancerms..vdns..module-3", + "properties": { + "type": { + "title": "Type", + "type": "string", + "default": "VFMODULE", + "readOnly": "True" + }, + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "Vloadbalancerms..vdns..module-3", + "readOnly": "True" + }, + "modelInvariantId": { + "title": "Model Invariant Id (ModelInvariantUUID)", + "type": "string", + "default": "4c10ba9b-f88f-415e-9de3-5d33336047fa", + "readOnly": "True" + }, + "modelVersionId": { + "title": "Model Version Id (ModelUUID)", + "type": "string", + "default": "4fa73b49-8a6c-493e-816b-eb401567b720", + "readOnly": "True" + }, + "modelName": { + "title": "Model Name", + "type": "string", + "default": "Vloadbalancerms..vdns..module-3", + "readOnly": "True" + }, + "modelVersion": { + "title": "Model Version", + "type": "string", + "default": "1", + "readOnly": "True" + }, + "modelCustomizationId": { + "title": "Customization ID", + "type": "string", + "default": "bafcdab0-801d-4d81-9ead-f464640a38b1", + "readOnly": "True" + } + } + }, + { + "title": "VFMODULE-Vloadbalancerms..base_template..module-0", + "properties": { + "type": { + "title": "Type", + "type": "string", + "default": "VFMODULE", + "readOnly": "True" + }, + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "Vloadbalancerms..base_template..module-0", + "readOnly": "True" + }, + "modelInvariantId": { + "title": "Model Invariant Id (ModelInvariantUUID)", + "type": "string", + "default": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3", + "readOnly": "True" + }, + "modelVersionId": { + "title": "Model Version Id (ModelUUID)", + "type": "string", + "default": "63734409-f745-4e4d-a38b-131638a0edce", + "readOnly": "True" + }, + "modelName": { + "title": "Model Name", + "type": "string", + "default": "Vloadbalancerms..base_template..module-0", + "readOnly": "True" + }, + "modelVersion": { + "title": "Model Version", + "type": "string", + "default": "1", + "readOnly": "True" + }, + "modelCustomizationId": { + "title": "Customization ID", + "type": "string", + "default": "86baddea-c730-4fb8-9410-cd2e17fd7f27", + "readOnly": "True" + } + } + }, + { + "title": "VFMODULE-Vloadbalancerms..vlb..module-2", + "properties": { + "type": { + "title": "Type", + "type": "string", + "default": "VFMODULE", + "readOnly": "True" + }, + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "Vloadbalancerms..vlb..module-2", + "readOnly": "True" + }, + "modelInvariantId": { + "title": "Model Invariant Id (ModelInvariantUUID)", + "type": "string", + "default": "a772a1f4-0064-412c-833d-4749b15828dd", + "readOnly": "True" + }, + "modelVersionId": { + "title": "Model Version Id (ModelUUID)", + "type": "string", + "default": "0f5c3f6a-650a-4303-abb6-fff3e573a07a", + "readOnly": "True" + }, + "modelName": { + "title": "Model Name", + "type": "string", + "default": "Vloadbalancerms..vlb..module-2", + "readOnly": "True" + }, + "modelVersion": { + "title": "Model Version", + "type": "string", + "default": "1", + "readOnly": "True" + }, + "modelCustomizationId": { + "title": "Customization ID", + "type": "string", + "default": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806", + "readOnly": "True" + } + } + } + ] + } + } + } + } + } + }, + "guard_policies": { + "type": "array", + "format": "tabs-top", + "title": "Associated Guard policies", + "items": { + "headerTemplate": "{{self.policy-id}} - {{self.content.recipe}}", + "anyOf": [ + { + "title": "Guard MinMax", + "type": "object", + "properties": { + "policy-id": { + "type": "string", + "default": "guard.minmax.new", + "pattern": "^(guard.minmax\\..*)$" + }, + "content": { + "properties": { + "actor": { + "type": "string", + "enum": [ + "APPC", + "SO", + "VFC", + "SDNC", + "SDNR" + ] + }, + "recipe": { + "type": "string", + "enum": [ + "Restart", + "Rebuild", + "Migrate", + "Health-Check", + "ModifyConfig", + "VF Module Create", + "VF Module Delete", + "Reroute" + ] + }, + "targets": { + "type": "string", + "default": ".*" + }, + "clname": { + "type": "string", + "template": "{{loopName}}", + "watch": { + "loopName": "operational_policy_item.configurationsJson.operational_policy.controlLoop.controlLoopName" + } + }, + "guardActiveStart": { + "type": "string", + "default": "00:00:00Z" + }, + "guardActiveEnd": { + "type": "string", + "default": "10:00:00Z" + }, + "min": { + "type": "string", + "default": "0" + }, + "max": { + "type": "string", + "default": "1" + } + } + } + } + }, + { + "title": "Guard Frequency", + "type": "object", + "properties": { + "policy-id": { + "type": "string", + "default": "guard.frequency.new", + "pattern": "^(guard.frequency\\..*)$" + }, + "content": { + "properties": { + "actor": { + "type": "string", + "enum": [ + "APPC", + "SO", + "VFC", + "SDNC", + "SDNR" + ] + }, + "recipe": { + "type": "string", + "enum": [ + "Restart", + "Rebuild", + "Migrate", + "Health-Check", + "ModifyConfig", + "VF Module Create", + "VF Module Delete", + "Reroute" + ] + }, + "targets": { + "type": "string", + "default": ".*" + }, + "clname": { + "type": "string", + "template": "{{loopName}}", + "watch": { + "loopName": "operational_policy_item.configurationsJson.operational_policy.controlLoop.controlLoopName" + } + }, + "guardActiveStart": { + "type": "string", + "default": "00:00:00Z" + }, + "guardActiveEnd": { + "type": "string", + "default": "10:00:00Z" + }, + "limit": { + "type": "string" + }, + "timeWindow": { + "type": "string" + }, + "timeUnits": { + "type": "string", + "enum": [ + "minute", + "hour", + "day", + "week", + "month", + "year" + ] + } + } + } + } + } + ] + } + } + } + } + } + } + } + }, + "globalPropertiesJson": { + "testname": "testvalue" + }, + "modelService": { + "serviceDetails": { + "serviceType": "", + "namingPolicy": "", + "environmentContext": "General_Revenue-Bearing", + "serviceEcompNaming": "true", + "serviceRole": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f", + "ecompGeneratedNaming": "true", + "category": "Network L4+", + "type": "Service", + "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0", + "instantiationType": "A-la-carte" + }, + "resourceDetails": { + "CP": {}, + "VL": {}, + "VF": { + "vLoadBalancerMS 0": { + "resourceVendor": "Test", + "resourceVendorModelNumber": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", + "subcategory": "Load Balancer", + "category": "Application L4+", + "type": "VF", + "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", + "version": "1.0", + "resourceVendorRelease": "1.0", + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" + } + }, + "CR": {}, + "VFC": {}, + "PNF": {}, + "Service": {}, + "CVFC": {}, + "Service Proxy": {}, + "Configuration": {}, + "AllottedResource": {}, + "VFModule": { + "Vloadbalancerms..vpkg..module-1": { + "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", + "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "min_vf_module_instances": 0, + "vf_module_label": "vpkg", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..vdns..module-3": { + "vfModuleModelInvariantUUID": "4c10ba9b-f88f-415e-9de3-5d33336047fa", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vdns..module-3", + "vfModuleModelUUID": "4fa73b49-8a6c-493e-816b-eb401567b720", + "vfModuleModelCustomizationUUID": "bafcdab0-801d-4d81-9ead-f464640a38b1", + "min_vf_module_instances": 0, + "vf_module_label": "vdns", + "max_vf_module_instances": 50, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..base_template..module-0": { + "vfModuleModelInvariantUUID": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..base_template..module-0", + "vfModuleModelUUID": "63734409-f745-4e4d-a38b-131638a0edce", + "vfModuleModelCustomizationUUID": "86baddea-c730-4fb8-9410-cd2e17fd7f27", + "min_vf_module_instances": 1, + "vf_module_label": "base_template", + "max_vf_module_instances": 1, + "vf_module_type": "Base", + "isBase": true, + "initial_count": 1, + "volume_group": false + }, + "Vloadbalancerms..vlb..module-2": { + "vfModuleModelInvariantUUID": "a772a1f4-0064-412c-833d-4749b15828dd", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vlb..module-2", + "vfModuleModelUUID": "0f5c3f6a-650a-4303-abb6-fff3e573a07a", + "vfModuleModelCustomizationUUID": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806", + "min_vf_module_instances": 0, + "vf_module_label": "vlb", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + } + } + } + }, + "lastComputedState": "DESIGN", + "components": { + "POLICY": { + "componentState": { + "stateName": "UNKNOWN", + "description": "The current status is not clear. Need to regresh the status to get the current status." + } + }, + "DCAE": { + "componentState": { + "stateName": "BLUEPRINT_DEPLOYED", + "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop" + } + } + }, + "operationalPolicies": [], + "microServicePolicies": [], + "loopLogs": [] +} diff --git a/src/test/resources/tosca/model-properties.json b/src/test/resources/tosca/model-properties.json index 9e7db8ebc..e41471b16 100644 --- a/src/test/resources/tosca/model-properties.json +++ b/src/test/resources/tosca/model-properties.json @@ -16,10 +16,8 @@ }, "resourceDetails": { "CP": { - }, "VL": { - }, "VF": { "vLoadBalancerMS 0": { @@ -38,28 +36,20 @@ } }, "CR": { - }, "VFC": { - }, "PNF": { - }, "Service": { - }, "CVFC": { - }, "Service Proxy": { - }, "Configuration": { - }, "AllottedResource": { - }, "VFModule": { "Vloadbalancerms..vpkg..module-1": { diff --git a/src/test/resources/tosca/resource-details.json b/src/test/resources/tosca/resource-details.json new file mode 100644 index 000000000..7b53f3972 --- /dev/null +++ b/src/test/resources/tosca/resource-details.json @@ -0,0 +1,96 @@ +{ + "CP": { + }, + "VL": { + }, + "VF": { + "vLoadBalancerMS 0": { + "resourceVendor": "Test", + "resourceVendorModelNumber": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", + "subcategory": "Load Balancer", + "category": "Application L4+", + "type": "VF", + "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", + "version": "1.0", + "resourceVendorRelease": "1.0", + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" + } + }, + "CR": { + }, + "VFC": { + }, + "PNF": { + }, + "Service": { + }, + "CVFC": { + }, + "Service Proxy": { + }, + "Configuration": { + }, + "AllottedResource": { + }, + "VFModule": { + "Vloadbalancerms..vpkg..module-1": { + "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", + "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "min_vf_module_instances": 0, + "vf_module_label": "vpkg", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..vdns..module-3": { + "vfModuleModelInvariantUUID": "4c10ba9b-f88f-415e-9de3-5d33336047fa", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vdns..module-3", + "vfModuleModelUUID": "4fa73b49-8a6c-493e-816b-eb401567b720", + "vfModuleModelCustomizationUUID": "bafcdab0-801d-4d81-9ead-f464640a38b1", + "min_vf_module_instances": 0, + "vf_module_label": "vdns", + "max_vf_module_instances": 50, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..base_template..module-0": { + "vfModuleModelInvariantUUID": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..base_template..module-0", + "vfModuleModelUUID": "63734409-f745-4e4d-a38b-131638a0edce", + "vfModuleModelCustomizationUUID": "86baddea-c730-4fb8-9410-cd2e17fd7f27", + "min_vf_module_instances": 1, + "vf_module_label": "base_template", + "max_vf_module_instances": 1, + "vf_module_type": "Base", + "isBase": true, + "initial_count": 1, + "volume_group": false + }, + "Vloadbalancerms..vlb..module-2": { + "vfModuleModelInvariantUUID": "a772a1f4-0064-412c-833d-4749b15828dd", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vlb..module-2", + "vfModuleModelUUID": "0f5c3f6a-650a-4303-abb6-fff3e573a07a", + "vfModuleModelCustomizationUUID": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806", + "min_vf_module_instances": 0, + "vf_module_label": "vlb", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + } + } +} \ No newline at end of file diff --git a/src/test/resources/tosca/service-details.json b/src/test/resources/tosca/service-details.json new file mode 100644 index 000000000..f41eec107 --- /dev/null +++ b/src/test/resources/tosca/service-details.json @@ -0,0 +1,15 @@ +{ + "serviceType": "", + "namingPolicy": "", + "environmentContext": "General_Revenue-Bearing", + "serviceEcompNaming": "true", + "serviceRole": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f", + "ecompGeneratedNaming": "true", + "category": "Network L4+", + "type": "Service", + "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0", + "instantiationType": "A-la-carte" +} \ No newline at end of file diff --git a/ui-react/src/api/LoopCache.js b/ui-react/src/api/LoopCache.js index dd8c5b520..95eb9310e 100644 --- a/ui-react/src/api/LoopCache.js +++ b/ui-react/src/api/LoopCache.js @@ -99,11 +99,11 @@ export default class LoopCache { } getResourceDetailsVfProperty() { - return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VF"]; + return this.loopJsonCache["modelService"]["resourceDetails"]["VF"]; } getResourceDetailsVfModuleProperty() { - return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VFModule"]; + return this.loopJsonCache["modelService"]["resourceDetails"]["VFModule"]; } getLoopLogsArray() { diff --git a/ui-react/src/api/LoopCache_mokeLoopJsonCache.json b/ui-react/src/api/LoopCache_mokeLoopJsonCache.json index 184eaf7cd..c84b5b691 100644 --- a/ui-react/src/api/LoopCache_mokeLoopJsonCache.json +++ b/ui-react/src/api/LoopCache_mokeLoopJsonCache.json @@ -8,7 +8,7 @@ "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" } }, - "modelPropertiesJson": { + "modelService": { "serviceDetails": { "serviceType": "", "namingPolicy": "", diff --git a/ui-react/src/api/example.json b/ui-react/src/api/example.json index 108cf78e2..7b9a95a23 100644 --- a/ui-react/src/api/example.json +++ b/ui-react/src/api/example.json @@ -8,7 +8,7 @@ "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" } }, - "modelPropertiesJson": { + "modelService": { "serviceDetails": { "serviceType": "", "namingPolicy": "", -- cgit 1.2.3-korg From 3121b5bee2e70b1f753f9988344d41f3132edf69 Mon Sep 17 00:00:00 2001 From: Vidyashree-Huawei Date: Wed, 4 Mar 2020 19:22:08 +0530 Subject: CLAMP-CDS integration to display all CDS actions for blueprint in CL CLAMP-CDS integration to display all CDS actions for blueprint in CL Change-Id: I18b972b8952e5de9ac8e39d6c9cc4ecba0ec9b02 Issue-ID: CLAMP-491 Signed-off-by: Vidyashree-Huawei --- .../org/onap/clamp/clds/client/CdsServices.java | 171 +++++++++++++++ .../clds/model/cds/CdsBpWorkFlowListResponse.java | 67 ++++++ .../clamp/loop/service/CsarServiceInstaller.java | 58 ++++- .../operational/LegacyOperationalPolicy.java | 55 ++++- .../policy/operational/OperationalPolicy.java | 3 +- .../OperationalPolicyRepresentationBuilder.java | 69 +++++- src/main/resources/application.properties | 5 + src/main/resources/clds/camel/routes/cds-flows.xml | 46 ++++ .../operational_policies/operational_policy.json | 177 ++++++++++++--- src/test/resources/application.properties | 7 +- .../example/sdc/service_Vloadbalancerms_csar.csar | Bin 115690 -> 115771 bytes .../.file | 68 ++++++ .../.header | 1 + .../1.0.0?connectionTimeToLive=5000/.file | 12 ++ .../1.0.0?connectionTimeToLive=5000/.header | 1 + src/test/resources/tosca/model-properties.json | 86 +++++++- .../tosca/operational-policy-json-schema.json | 240 ++++++++++++++++++--- .../tosca/operational-policy-payload.yaml | 16 +- .../tosca/operational-policy-properties.json | 16 +- src/test/resources/tosca/resource-details.json | 86 +++++++- 20 files changed, 1103 insertions(+), 81 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/client/CdsServices.java create mode 100644 src/main/java/org/onap/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java create mode 100644 src/main/resources/clds/camel/routes/cds-flows.xml create mode 100644 src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.file create mode 100644 src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.header create mode 100644 src/test/resources/http-cache/example/api/v1/blueprint-model/workflows/blueprint-name/baseconfiguration/version/1.0.0?connectionTimeToLive=5000/.file create mode 100644 src/test/resources/http-cache/example/api/v1/blueprint-model/workflows/blueprint-name/baseconfiguration/version/1.0.0?connectionTimeToLive=5000/.header (limited to 'src/test/resources/tosca/model-properties.json') diff --git a/src/main/java/org/onap/clamp/clds/client/CdsServices.java b/src/main/java/org/onap/clamp/clds/client/CdsServices.java new file mode 100644 index 000000000..fe1937ab1 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/CdsServices.java @@ -0,0 +1,171 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * ================================================================================ + * + */ + +package org.onap.clamp.clds.client; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.util.Date; +import java.util.Map; + +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.builder.ExchangeBuilder; +import org.onap.clamp.clds.model.cds.CdsBpWorkFlowListResponse; +import org.onap.clamp.clds.util.JsonUtils; +import org.onap.clamp.clds.util.LoggingUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This class implements the communication with CDS for the service inventory. + */ +@Component +public class CdsServices { + + @Autowired + CamelContext camelContext; + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CdsServices.class); + + /** + * Constructor. + */ + @Autowired + public CdsServices() { + } + + + /** + * Query CDS to get blueprint's workflow list. + * + * @param blueprintName CDS blueprint name + * @param blueprintVersion CDS blueprint version + * @return CdsBpWorkFlowListResponse CDS blueprint's workflow list + */ + public CdsBpWorkFlowListResponse getBlueprintWorkflowList(String blueprintName, String blueprintVersion) { + LoggingUtils.setTargetContext("CDS", "getBlueprintWorkflowList"); + + Exchange myCamelExchange = ExchangeBuilder.anExchange(camelContext) + .withProperty("blueprintName", blueprintName).withProperty("blueprintVersion", blueprintVersion) + .build(); + + Exchange exchangeResponse = camelContext.createProducerTemplate() + .send("direct:get-blueprint-workflow-list", myCamelExchange); + + if (Integer.valueOf(200).equals(exchangeResponse.getIn().getHeader("CamelHttpResponseCode"))) { + String cdsResponse = (String) exchangeResponse.getIn().getBody(); + logger.info("getBlueprintWorkflowList, response from CDS:" + cdsResponse); + LoggingUtils.setResponseContext("0", "Get Blueprint workflow list", this.getClass().getName()); + Date startTime = new Date(); + LoggingUtils.setTimeContext(startTime, new Date()); + return JsonUtils.GSON_JPA_MODEL.fromJson(cdsResponse, CdsBpWorkFlowListResponse.class); + } + return null; + } + + /** + * Query CDS to get input properties of workflow. + * + * @param blueprintName CDS blueprint name + * @param blueprintVersion CDS blueprint name + * @param workflow CDS blueprint's workflow + * @return input properties in json format + */ + public JsonObject getWorkflowInputProperties(String blueprintName, String blueprintVersion, + String workflow) { + LoggingUtils.setTargetContext("CDS", "getWorkflowInputProperties"); + + Exchange myCamelExchange = ExchangeBuilder.anExchange(camelContext) + .withBody(getCdsPayloadForWorkFlow(blueprintName, blueprintVersion, workflow)) + .build(); + + Exchange exchangeResponse = camelContext.createProducerTemplate() + .send("direct:get-blueprint-workflow-input-properties", myCamelExchange); + + if (Integer.valueOf(200).equals(exchangeResponse.getIn().getHeader("CamelHttpResponseCode"))) { + String cdsResponse = (String) exchangeResponse.getIn().getBody(); + logger.info("getWorkflowInputProperties, response from CDS:" + cdsResponse); + LoggingUtils.setResponseContext("0", "Get Blueprint workflow input properties", this.getClass().getName()); + Date startTime = new Date(); + LoggingUtils.setTimeContext(startTime, new Date()); + return parseCdsResponse(cdsResponse); + } + return null; + } + + private JsonObject parseCdsResponse(String response) { + JsonObject root = JsonParser.parseString(response).getAsJsonObject(); + JsonObject inputs = root.getAsJsonObject("workFlowData").getAsJsonObject("inputs"); + JsonObject dataTypes = root.getAsJsonObject("dataTypes"); + + JsonObject workFlowProperties = new JsonObject(); + workFlowProperties.add("inputs", getInputProperties(inputs, dataTypes)); + return workFlowProperties; + } + + private JsonObject getInputProperties(JsonObject inputs, JsonObject dataTypes) { + JsonObject inputObject = new JsonObject(); + for (Map.Entry entry : inputs.entrySet()) { + String key = entry.getKey(); + JsonObject inputProperty = inputs.getAsJsonObject(key); + String type = inputProperty.get("type").getAsString(); + if (isComplexType(type, dataTypes)) { + inputObject.add(key, handleComplexType(type, dataTypes)); + } else { + inputObject.addProperty(key, ""); + } + } + return inputObject; + } + + private JsonObject handleComplexType(String key, JsonObject dataTypes) { + JsonObject properties = dataTypes.get(key).getAsJsonObject().get("properties").getAsJsonObject(); + return getInputProperties(properties, dataTypes); + } + + private boolean isComplexType(String type, JsonObject dataTypes) { + return dataTypes.get(type) != null; + } + + /** + * Creates payload to query CDS to get workflow input properties. + * + * @param blueprintName CDS blueprint name + * @param version CDS blueprint version + * @param workflow CDS blueprint workflow + * @return returns payload in json format + */ + public String getCdsPayloadForWorkFlow(String blueprintName, String version, String workflow) { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("blueprintName", blueprintName); + jsonObject.addProperty("version", version); + jsonObject.addProperty("returnContent", "json"); + jsonObject.addProperty("workflowName", workflow); + jsonObject.addProperty("specType", "TOSCA"); + return jsonObject.toString(); + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java b/src/main/java/org/onap/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java new file mode 100644 index 000000000..66025c479 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * ================================================================================ + * + */ + +package org.onap.clamp.clds.model.cds; + +import com.google.gson.annotations.Expose; + +import java.util.LinkedList; +import java.util.List; + +/** + * This class maps the CDS response to a pojo. + */ +public class CdsBpWorkFlowListResponse { + + @Expose + private String blueprintName; + + @Expose + private String version; + + @Expose + private List workflows = new LinkedList(); + + public String getBlueprintName() { + return blueprintName; + } + + public void setBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public List getWorkflows() { + return workflows; + } + + public void setWorkflows(List workflows) { + this.workflows = workflows; + } +} diff --git a/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java b/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java index 277fe004a..889125fee 100644 --- a/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java +++ b/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +30,9 @@ import com.google.gson.JsonObject; import java.util.Map.Entry; +import org.onap.clamp.clds.client.CdsServices; import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException; +import org.onap.clamp.clds.model.cds.CdsBpWorkFlowListResponse; import org.onap.clamp.clds.sdc.controller.installer.CsarHandler; import org.onap.clamp.clds.util.JsonUtils; import org.onap.sdc.tosca.parser.api.IEntityDetails; @@ -53,9 +56,12 @@ public class CsarServiceInstaller { @Autowired ServiceRepository serviceRepository; + @Autowired + CdsServices cdsServices; + /** * Install the Service from the csar. - * + * * @param csar The Csar Handler * @return The service object */ @@ -77,7 +83,7 @@ public class CsarServiceInstaller { return modelService; } - private static JsonObject createServicePropertiesByType(CsarHandler csar) { + private JsonObject createServicePropertiesByType(CsarHandler csar) { JsonObject resourcesProp = new JsonObject(); // Iterate on all types defined in the tosca lib for (SdcTypes type : SdcTypes.values()) { @@ -86,6 +92,13 @@ public class CsarServiceInstaller { for (NodeTemplate nodeTemplate : csar.getSdcCsarHelper().getServiceNodeTemplateBySdcType(type)) { resourcesPropByType.add(nodeTemplate.getName(), JsonUtils.GSON.toJsonTree(nodeTemplate.getMetaData().getAllProperties())); + // get cds artifact information and save in resources Prop + if (SdcTypes.PNF == type || SdcTypes.VF == type) { + JsonObject controllerProperties = createCdsArtifactProperties(nodeTemplate); + if (controllerProperties != null) { + resourcesPropByType.getAsJsonObject(nodeTemplate.getName()).add("controllerProperties", controllerProperties); + } + } } resourcesProp.add(type.getValue(), resourcesPropByType); } @@ -114,7 +127,7 @@ public class CsarServiceInstaller { /** * Verify whether Service in Csar is deployed. - * + * * @param csar The Csar Handler * @return The flag indicating whether Service is deployed * @throws SdcArtifactInstallerException The SdcArtifactInstallerException @@ -127,4 +140,43 @@ public class CsarServiceInstaller { return alreadyInstalled; } + + /** + * Retrive CDS artifacts information from node template and save in resource object. + * + * @param nodeTemplate node template + * @return Returns CDS artifacts information + */ + private JsonObject createCdsArtifactProperties(NodeTemplate nodeTemplate) { + Object artifactName = nodeTemplate.getPropertyValue("sdnc_model_name"); + Object artifactVersion = nodeTemplate.getPropertyValue("sdnc_model_version"); + if (artifactName != null && artifactVersion != null) { + CdsBpWorkFlowListResponse response = queryCdsToGetWorkFlowList(artifactName.toString(), artifactVersion.toString()); + if (response == null) { + return null; + } + + JsonObject workFlowProps = new JsonObject(); + for (String workFlow : response.getWorkflows()) { + JsonObject inputs = queryCdsToGetWorkFlowInputProperties(response.getBlueprintName(), + response.getVersion(), workFlow); + workFlowProps.add(workFlow, inputs); + } + + JsonObject controllerProperties = new JsonObject(); + controllerProperties.addProperty("sdnc_model_name", artifactName.toString()); + controllerProperties.addProperty("sdnc_model_version", artifactVersion.toString()); + controllerProperties.add("workflows", workFlowProps); + return controllerProperties; + } + return null; + } + + private CdsBpWorkFlowListResponse queryCdsToGetWorkFlowList(String artifactName, String artifactVersion) { + return cdsServices.getBlueprintWorkflowList(artifactName, artifactVersion); + } + + private JsonObject queryCdsToGetWorkFlowInputProperties(String artifactName, String artifactVersion, String workFlow) { + return cdsServices.getWorkflowInputProperties(artifactName, artifactVersion, workFlow); + } } diff --git a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java index ff7777f7f..033f2cebb 100644 --- a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,6 +47,11 @@ import org.yaml.snakeyaml.Yaml; */ public class LegacyOperationalPolicy { + private static final String ACTOR = "actor"; + private static final String RECIPE = "recipe"; + private static final String POLICIES = "policies"; + private static final String PAYLOAD = "payload"; + private LegacyOperationalPolicy() { } @@ -79,7 +85,7 @@ public class LegacyOperationalPolicy { /** * This method rework the payload attribute (yaml) that is normally wrapped in a * string when coming from the UI. - * + * * @param policyJson The operational policy json config * @return The same object reference but modified */ @@ -150,7 +156,7 @@ public class LegacyOperationalPolicy { /** * This method transforms the configuration json to a Yaml format. - * + * * @param operationalPolicyJsonElement The operational policy json config * @return The Yaml as string */ @@ -162,13 +168,13 @@ public class LegacyOperationalPolicy { // Policy can't support { } in the yaml options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); return (new Yaml(options)).dump(createMap(fulfillPoliciesTreeField( - removeAllQuotes(reworkPayloadAttributes(operationalPolicyJsonElement.getAsJsonObject().deepCopy()))))); + removeAllQuotes(reworkActorAttributes(operationalPolicyJsonElement.getAsJsonObject().deepCopy()))))); } /** * This method load mandatory field in the operational policy configuration * JSON. - * + * * @param configurationsJson The operational policy JSON * @param loop The parent loop object */ @@ -182,4 +188,45 @@ public class LegacyOperationalPolicy { configurationsJson.add("operational_policy", controlLoop); } } + + /** + * This method rework on the actor/recipe and payload attribute. + * + * @param policyJson The operational policy json config + * @return The same object reference but modified + */ + public static JsonElement reworkActorAttributes(JsonElement policyJson) { + for (JsonElement policy : policyJson.getAsJsonObject().get(POLICIES).getAsJsonArray()) { + JsonObject actor = policy.getAsJsonObject().get(ACTOR).getAsJsonObject(); + policy.getAsJsonObject().remove(ACTOR); + String actorStr = actor.getAsJsonObject().get(ACTOR).getAsString(); + policy.getAsJsonObject().addProperty(ACTOR, actorStr); + policy.getAsJsonObject().addProperty(RECIPE, getRecipe(actor)); + + if ("CDS".equalsIgnoreCase(actorStr)) { + addPayloadAttributes(actor.getAsJsonObject(ACTOR).getAsJsonObject(RECIPE), policy); + } else { + addPayloadAttributes(actor, policy); + } + } + return policyJson; + } + + private static void addPayloadAttributes(JsonObject jsonObject, + JsonElement policy) { + JsonElement payloadElem = jsonObject.getAsJsonObject().get(PAYLOAD); + String payloadString = payloadElem != null ? payloadElem.getAsString() : ""; + if (!payloadString.isEmpty()) { + Map testMap = new Yaml().load(payloadString); + String json = new GsonBuilder().create().toJson(testMap); + policy.getAsJsonObject().add(PAYLOAD, + new GsonBuilder().create().fromJson(json, JsonElement.class)); + } else { + policy.getAsJsonObject().addProperty(PAYLOAD, ""); + } + } + + private static String getRecipe(JsonObject actor) { + return actor.getAsJsonObject().get("type").getAsString(); + } } diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java index aab30bfb6..7cf06dcfc 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -222,7 +223,7 @@ public class OperationalPolicy extends Policy implements Serializable { metadata.addProperty("policy-id", this.name); operationalPolicyDetails.add("properties", LegacyOperationalPolicy - .reworkPayloadAttributes(this.getConfigurationsJson().get("operational_policy").deepCopy())); + .reworkActorAttributes(this.getConfigurationsJson().get("operational_policy").deepCopy())); DumperOptions options = new DumperOptions(); options.setIndent(2); diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java index 1d0d99080..244f4c27a 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights * reserved. + * Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +43,7 @@ public class OperationalPolicyRepresentationBuilder { * used by ui for rendering. It uses the model (VF and VFModule) defined in the * loop object to do so, so it's dynamic. It also uses the operational policy * schema template defined in the resource folder. - * + * * @param modelJson The loop model json * @return The json representation * @throws JsonSyntaxException If the schema template cannot be parsed @@ -58,6 +59,22 @@ public class OperationalPolicyRepresentationBuilder { .get("operational_policy").getAsJsonObject().get("properties").getAsJsonObject().get("policies") .getAsJsonObject().get("items").getAsJsonObject().get("properties").getAsJsonObject().get("target") .getAsJsonObject().get("anyOf").getAsJsonArray().addAll(createAnyOfArray(modelJson)); + + // update CDS recipe and payload information to schema + JsonArray actors = jsonSchema.get("schema").getAsJsonObject().get("items").getAsJsonObject().get("properties") + .getAsJsonObject().get("configurationsJson").getAsJsonObject().get("properties").getAsJsonObject() + .get("operational_policy").getAsJsonObject().get("properties").getAsJsonObject().get("policies") + .getAsJsonObject().get("items").getAsJsonObject().get("properties").getAsJsonObject().get("actor") + .getAsJsonObject().get("anyOf").getAsJsonArray(); + + for (JsonElement actor : actors) { + if ("CDS".equalsIgnoreCase(actor.getAsJsonObject().get("title").getAsString())) { + actor.getAsJsonObject().get("properties").getAsJsonObject().get("type").getAsJsonObject() + .get("anyOf").getAsJsonArray() + .addAll(createAnyOfArrayForCdsRecipe(modelJson.getResourceDetails())); + } + } + return jsonSchema; } @@ -143,4 +160,54 @@ public class OperationalPolicyRepresentationBuilder { targetOneOfStructure.addAll(createVfModuleSchema(modelJson)); return targetOneOfStructure; } + + private static JsonArray createAnyOfArrayForCdsRecipe(JsonObject resourceDetails) { + JsonArray anyOfStructure = new JsonArray(); + anyOfStructure.addAll(createAnyOfCdsRecipe(resourceDetails.getAsJsonObject("VF"))); + anyOfStructure.addAll(createAnyOfCdsRecipe(resourceDetails.getAsJsonObject("PNF"))); + return anyOfStructure; + } + + private static JsonArray createAnyOfCdsRecipe(JsonObject jsonObject) { + JsonArray schemaArray = new JsonArray(); + for (Entry entry : jsonObject.entrySet()) { + JsonObject controllerProperties = entry.getValue().getAsJsonObject() + .getAsJsonObject("controllerProperties"); + + if (controllerProperties != null) { + JsonObject workflows = controllerProperties.getAsJsonObject("workflows"); + for (Entry workflowsEntry : workflows.entrySet()) { + JsonObject obj = new JsonObject(); + obj.addProperty("title", workflowsEntry.getKey()); + obj.add("properties", createPayloadProperty(workflowsEntry.getValue().getAsJsonObject(), + controllerProperties)); + schemaArray.add(obj); + } + + } + } + return schemaArray; + } + + private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties) { + JsonObject type = new JsonObject(); + type.addProperty("title", "Payload (YAML)"); + type.addProperty("type", "string"); + type.addProperty("default", createDefaultStringForPayload(workFlow, controllerProperties)); + type.addProperty("format", "textarea"); + JsonObject properties = new JsonObject(); + properties.add("type", type); + return properties; + } + + private static String createDefaultStringForPayload(JsonObject workFlow, JsonObject controllerProperties) { + String artifactName = controllerProperties.get("sdnc_model_name").toString(); + String artifactVersion = controllerProperties.get("sdnc_model_version").toString(); + String data = workFlow.getAsJsonObject("inputs").toString(); + StringBuilder builder = new StringBuilder("'").append("artifact_name : ").append(artifactName).append("\n") + .append("artifact_version : ").append(artifactVersion).append("\n") + .append("mode : async").append("\n") + .append("data : ").append("'").append("\\").append("'").append(data).append("\\").append("'").append("'"); + return builder.toString(); + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 695319d5b..3abbcd57a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -223,3 +223,8 @@ clamp.config.cadi.cadiX509Issuers=CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US:CN ## Tosca converter clamp.config.tosca.converter.templates=classpath:/clds/tosca_updates/templates.properties + +# Configuration settings for CDS +clamp.config.cds.url=http4://blueprints-processor-http:8080 +clamp.config.cds.userName=ccsdkapps +clamp.config.cds.password=ccsdkapps \ No newline at end of file diff --git a/src/main/resources/clds/camel/routes/cds-flows.xml b/src/main/resources/clds/camel/routes/cds-flows.xml new file mode 100644 index 000000000..5c10a0cd2 --- /dev/null +++ b/src/main/resources/clds/camel/routes/cds-flows.xml @@ -0,0 +1,46 @@ + + + + + + + + GET + + + application/json + + + + + + + + + + + + + + + + + POST + + + application/json + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/clds/json-schema/operational_policies/operational_policy.json b/src/main/resources/clds/json-schema/operational_policies/operational_policy.json index 93738c809..ef22e815d 100644 --- a/src/main/resources/clds/json-schema/operational_policies/operational_policy.json +++ b/src/main/resources/clds/json-schema/operational_policies/operational_policy.json @@ -87,7 +87,6 @@ "basicCategoryTitle": "recipe", "required": [ "id", - "recipe", "retry", "timeout", "actor", @@ -105,20 +104,6 @@ "title": "Policy ID", "type": "string" }, - "recipe": { - "title": "Recipe", - "type": "string", - "enum": [ - "Restart", - "Rebuild", - "Migrate", - "Health-Check", - "ModifyConfig", - "VF Module Create", - "VF Module Delete", - "Reroute" - ] - }, "retry": { "default": "0", "title": "Number of Retry", @@ -132,21 +117,157 @@ "format": "number" }, "actor": { + "type": "object", "title": "Actor", - "type": "string", - "enum": [ - "APPC", - "SO", - "VFC", - "SDNC", - "SDNR" + "anyOf": [ + { + "title": "APPC", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "APPC", + "options": { + "hidden": true + } + }, + "type": { + "title": "recipe", + "type": "string", + "default": "", + "enum": [ + "Restart", + "Rebuild", + "Migrate", + "Health-Check", + "ModifyConfig" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "SO", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "SO", + "options": { + "hidden": true + } + }, + "type": { + "title": "recipe", + "type": "string", + "default": "", + "enum": [ + "VF Module Create", + "VF Module Delete" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "SDNC", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "SDNC", + "options": { + "hidden": true + } + }, + "type": { + "title": "recipe", + "type": "string", + "default": "", + "enum": [ + "Reroute", + "BandwidthOnDemand" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "VFC", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "VFC", + "options": { + "hidden": true + } + }, + "type": { + "title": "recipe", + "type": "string", + "required": [ + "payload" + ], + "default": "", + "enum": [ + "ModifyConfig" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "CDS", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "CDS", + "options": { + "hidden": true + } + }, + "type": { + "title": "recipe", + "type": "object", + "required": [ + "payload" + ], + "anyOf": [ + { + "title": "user-defined", + "properties": { + "type": { + "title": "Payload (YAML)", + "type": "string", + "default" : "", + "format" : "textarea" + } + } + } + ] + } + } + } ] }, - "payload": { - "title": "Payload (YAML)", - "type": "string", - "format": "textarea" - }, "success": { "default": "final_success", "title": "When Success", @@ -186,7 +307,7 @@ "anyOf": [ { "title": "User Defined", - "additionalProperties":"True", + "additionalProperties": "True", "properties": { "type": { "title": "Target type", diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 5b921e9e3..4f1a845c3 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -194,4 +194,9 @@ clamp.config.security.permission.type.template=permission-type-template clamp.config.security.permission.type.tosca=permission-type-tosca #This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties clamp.config.security.permission.instance=dev -clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal \ No newline at end of file +clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal + +# Configuration settings for CDS +clamp.config.cds.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.cds.userName=ccsdkapps +clamp.config.cds.password=ccsdkapps \ No newline at end of file diff --git a/src/test/resources/example/sdc/service_Vloadbalancerms_csar.csar b/src/test/resources/example/sdc/service_Vloadbalancerms_csar.csar index 3330dd1e8..ff337993a 100644 Binary files a/src/test/resources/example/sdc/service_Vloadbalancerms_csar.csar and b/src/test/resources/example/sdc/service_Vloadbalancerms_csar.csar differ diff --git a/src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.file new file mode 100644 index 000000000..13d3feaaf --- /dev/null +++ b/src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.file @@ -0,0 +1,68 @@ +{ + "blueprintName": "baseconfiguration", + "version": "1.0.0", + "workFlowData": { + "workFlowName": "resource-assignment", + "inputs": { + "resource-assignment-properties": { + "required": true, + "type": "dt-resource-assignment-properties" + } + }, + "outputs": { + "response-property": { + "type": "string", + "value": "executed" + }, + "template-properties": { + "type": "json", + "value": { + "get_attribute": [ + "resource-assignment", + "assignment-params" + ] + } + } + } + }, + "dataTypes": { + "dt-resource-assignment-properties": { + "description": "This is Dynamically generated data type for workflow activate", + "version": "1.0.0", + "metadata": null, + "attributes": null, + "properties": { + "request-id": { + "required": true, + "type": "string" + }, + "service-instance-id": { + "required": true, + "type": "string" + }, + "vnf-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + }, + "vnf_name": { + "required": true, + "type": "string" + } + }, + "constraints": null, + "derived_from": "tosca.datatypes.Dynamic" + } + } +} \ No newline at end of file diff --git a/src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.header b/src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.header new file mode 100644 index 000000000..6a280d972 --- /dev/null +++ b/src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.header @@ -0,0 +1 @@ +{"Transfer-Encoding": "chunked", "Set-Cookie": "JSESSIONID=158qxkdtdobkd1umr3ikkgrmlx;Path=/", "Expires": "Thu, 01 Jan 1970 00:00:00 GMT", "Server": "Jetty(9.3.21.v20170918)", "Content-Type": "application/json", "X-ECOMP-RequestID": "e2ddb3c8-994f-47df-b4dc-097d4fb55c08"} \ No newline at end of file diff --git a/src/test/resources/http-cache/example/api/v1/blueprint-model/workflows/blueprint-name/baseconfiguration/version/1.0.0?connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/api/v1/blueprint-model/workflows/blueprint-name/baseconfiguration/version/1.0.0?connectionTimeToLive=5000/.file new file mode 100644 index 000000000..58975d86a --- /dev/null +++ b/src/test/resources/http-cache/example/api/v1/blueprint-model/workflows/blueprint-name/baseconfiguration/version/1.0.0?connectionTimeToLive=5000/.file @@ -0,0 +1,12 @@ +{ + "blueprintName": "baseconfiguration", + "version": "1.0.0", + "workflows": [ + "resource-assignment", + "activate", + "activate-restconf", + "activate-cli", + "assign-activate", + "imperative-test-wf" + ] +} \ No newline at end of file diff --git a/src/test/resources/http-cache/example/api/v1/blueprint-model/workflows/blueprint-name/baseconfiguration/version/1.0.0?connectionTimeToLive=5000/.header b/src/test/resources/http-cache/example/api/v1/blueprint-model/workflows/blueprint-name/baseconfiguration/version/1.0.0?connectionTimeToLive=5000/.header new file mode 100644 index 000000000..6a280d972 --- /dev/null +++ b/src/test/resources/http-cache/example/api/v1/blueprint-model/workflows/blueprint-name/baseconfiguration/version/1.0.0?connectionTimeToLive=5000/.header @@ -0,0 +1 @@ +{"Transfer-Encoding": "chunked", "Set-Cookie": "JSESSIONID=158qxkdtdobkd1umr3ikkgrmlx;Path=/", "Expires": "Thu, 01 Jan 1970 00:00:00 GMT", "Server": "Jetty(9.3.21.v20170918)", "Content-Type": "application/json", "X-ECOMP-RequestID": "e2ddb3c8-994f-47df-b4dc-097d4fb55c08"} \ No newline at end of file diff --git a/src/test/resources/tosca/model-properties.json b/src/test/resources/tosca/model-properties.json index e41471b16..c405964ee 100644 --- a/src/test/resources/tosca/model-properties.json +++ b/src/test/resources/tosca/model-properties.json @@ -32,7 +32,91 @@ "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", "version": "1.0", "resourceVendorRelease": "1.0", - "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552", + "controllerProperties": { + "sdnc_model_name": "baseconfiguration", + "sdnc_model_version": "1.0.0", + "workflows": { + "resource-assignment": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + }, + "activate": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + }, + "activate-restconf": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + }, + "activate-cli": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + }, + "assign-activate": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + }, + "imperative-test-wf": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + } + } + } } }, "CR": { diff --git a/src/test/resources/tosca/operational-policy-json-schema.json b/src/test/resources/tosca/operational-policy-json-schema.json index d6870dc9d..b43f6f9d4 100644 --- a/src/test/resources/tosca/operational-policy-json-schema.json +++ b/src/test/resources/tosca/operational-policy-json-schema.json @@ -87,7 +87,6 @@ "basicCategoryTitle": "recipe", "required": [ "id", - "recipe", "retry", "timeout", "actor", @@ -105,20 +104,6 @@ "title": "Policy ID", "type": "string" }, - "recipe": { - "title": "Recipe", - "type": "string", - "enum": [ - "Restart", - "Rebuild", - "Migrate", - "Health-Check", - "ModifyConfig", - "VF Module Create", - "VF Module Delete", - "Reroute" - ] - }, "retry": { "default": "0", "title": "Number of Retry", @@ -132,21 +117,222 @@ "format": "number" }, "actor": { + "type": "object", "title": "Actor", - "type": "string", - "enum": [ - "APPC", - "SO", - "VFC", - "SDNC", - "SDNR" + "anyOf": [ + { + "title": "APPC", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "APPC", + "options": { + "hidden": true + } + }, + "type": { + "title": "recipe", + "type": "string", + "default": "", + "enum": [ + "Restart", + "Rebuild", + "Migrate", + "Health-Check", + "ModifyConfig" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "SO", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "SO", + "options": { + "hidden": true + } + }, + "type": { + "title": "recipe", + "type": "string", + "default": "", + "enum": [ + "VF Module Create", + "VF Module Delete" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "SDNC", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "SDNC", + "options": { + "hidden": true + } + }, + "type": { + "title": "recipe", + "type": "string", + "default": "", + "enum": [ + "Reroute", + "BandwidthOnDemand" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "VFC", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "VFC", + "options": { + "hidden": true + } + }, + "type": { + "title": "recipe", + "type": "string", + "required": [ + "payload" + ], + "default": "", + "enum": [ + "ModifyConfig" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "CDS", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "CDS", + "options": { + "hidden": true + } + }, + "type": { + "title": "recipe", + "type": "object", + "required": [ + "payload" + ], + "anyOf": [ + { + "title": "user-defined", + "properties": { + "type": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "resource-assignment", + "properties": { + "type": { + "title": "Payload (YAML)", + "type": "string", + "default": "'artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : '\\'{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\''", + "format": "textarea" + } + } + }, + { + "title": "activate", + "properties": { + "type": { + "title": "Payload (YAML)", + "type": "string", + "default": "'artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : '\\'{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\''", + "format": "textarea" + } + } + }, + { + "title": "activate-restconf", + "properties": { + "type": { + "title": "Payload (YAML)", + "type": "string", + "default": "'artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : '\\'{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\''", + "format": "textarea" + } + } + }, + { + "title": "activate-cli", + "properties": { + "type": { + "title": "Payload (YAML)", + "type": "string", + "default": "'artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : '\\'{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\''", + "format": "textarea" + } + } + }, + { + "title": "assign-activate", + "properties": { + "type": { + "title": "Payload (YAML)", + "type": "string", + "default": "'artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : '\\'{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\''", + "format": "textarea" + } + } + }, + { + "title": "imperative-test-wf", + "properties": { + "type": { + "title": "Payload (YAML)", + "type": "string", + "default": "'artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : '\\'{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\''", + "format": "textarea" + } + } + } + ] + } + } + } ] }, - "payload": { - "title": "Payload (YAML)", - "type": "string", - "format": "textarea" - }, "success": { "default": "final_success", "title": "When Success", diff --git a/src/test/resources/tosca/operational-policy-payload.yaml b/src/test/resources/tosca/operational-policy-payload.yaml index ed03842f5..553a8afd4 100644 --- a/src/test/resources/tosca/operational-policy-payload.yaml +++ b/src/test/resources/tosca/operational-policy-payload.yaml @@ -14,13 +14,8 @@ topology_template: controlLoopName: LOOP_ASJOy_v1_0_ResourceInstanceName1_tca policies: - id: policy1 - recipe: Restart retry: '0' timeout: '0' - actor: APPC - payload: - requestParameters: '{"usePreload":true,"userParams":[]}' - configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[10].value","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[15].value","enabled":"$.vf-module-topology.vf-module-parameters.param[22].value"}]' success: final_success failure: policy2 failure_timeout: final_failure_timeout @@ -30,12 +25,14 @@ topology_template: target: type: VNF resourceID: vLoadBalancerMS + actor: APPC + recipe: Restart + payload: + requestParameters: '{"usePreload":true,"userParams":[]}' + configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[10].value","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[15].value","enabled":"$.vf-module-topology.vf-module-parameters.param[22].value"}]' - id: policy2 - recipe: VF Module Create retry: '0' timeout: '0' - actor: SO - payload: '' success: final_success failure: final_failure failure_timeout: final_failure_timeout @@ -50,3 +47,6 @@ topology_template: modelName: Vloadbalancerms..vpkg..module-1 modelVersion: '1' modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52 + actor: SO + recipe: VF Module Create + payload: '' diff --git a/src/test/resources/tosca/operational-policy-properties.json b/src/test/resources/tosca/operational-policy-properties.json index ac1314ecb..a2de76a98 100644 --- a/src/test/resources/tosca/operational-policy-properties.json +++ b/src/test/resources/tosca/operational-policy-properties.json @@ -8,12 +8,14 @@ }, "policies": [ { + "actor": { + "actor": "APPC", + "type": "Restart", + "payload": "requestParameters: '{\"usePreload\":true,\"userParams\":[]}'\r\nconfigurationParameters: '[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[10].value\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[15].value\",\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[22].value\"}]'" + }, "id": "policy1", - "recipe": "Restart", "retry": "0", "timeout": "0", - "actor": "APPC", - "payload": "requestParameters: '{\"usePreload\":true,\"userParams\":[]}'\r\nconfigurationParameters: '[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[10].value\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[15].value\",\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[22].value\"}]'", "success": "final_success", "failure": "policy2", "failure_timeout": "final_failure_timeout", @@ -26,12 +28,14 @@ } }, { + "actor": { + "actor": "SO", + "type": "VF Module Create", + "payload": "" + }, "id": "policy2", - "recipe": "VF Module Create", "retry": "0", "timeout": "0", - "actor": "SO", - "payload": "", "success": "final_success", "failure": "final_failure", "failure_timeout": "final_failure_timeout", diff --git a/src/test/resources/tosca/resource-details.json b/src/test/resources/tosca/resource-details.json index 7b53f3972..a638c350d 100644 --- a/src/test/resources/tosca/resource-details.json +++ b/src/test/resources/tosca/resource-details.json @@ -16,7 +16,91 @@ "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", "version": "1.0", "resourceVendorRelease": "1.0", - "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552", + "controllerProperties": { + "sdnc_model_name": "baseconfiguration", + "sdnc_model_version": "1.0.0", + "workflows": { + "resource-assignment": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + }, + "activate": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + }, + "activate-restconf": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + }, + "activate-cli": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + }, + "assign-activate": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + }, + "imperative-test-wf": { + "inputs": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + } + } + } } }, "CR": { -- cgit 1.2.3-korg From 3ec03cca444a2810005053a308ed0f3ecb00b063 Mon Sep 17 00:00:00 2001 From: Vidyashree-Huawei Date: Fri, 10 Apr 2020 17:36:09 +0530 Subject: CDS attributes are not shown properly in UI Handled for legacy and operational policy Change-Id: I504c4aa2531b19b09965ad1dbc03c9944931f77b Issue-ID: CLAMP-809 Signed-off-by: Vidyashree-Huawei --- .../org/onap/clamp/clds/client/CdsServices.java | 2 +- .../execution/cds/ToscaMetadataCdsProcess.java | 104 ++++- .../operational/LegacyOperationalPolicy.java | 21 +- .../OperationalPolicyRepresentationBuilder.java | 44 +- .../operational_policies/operational_policy.json | 30 +- src/test/resources/tosca/model-properties.json | 210 +++++++-- .../new-converter/tosca_apex_with_metadata.json | 326 ++++++++++--- .../tosca/operational-policy-json-schema.json | 518 +++++++++++++++++++-- .../tosca/operational-policy-payload-legacy.yaml | 32 ++ .../tosca/operational-policy-payload.json | 2 +- .../tosca/operational-policy-payload.yaml | 32 ++ .../tosca/operational-policy-properties.json | 52 ++- src/test/resources/tosca/resource-details.json | 210 +++++++-- 13 files changed, 1327 insertions(+), 256 deletions(-) (limited to 'src/test/resources/tosca/model-properties.json') diff --git a/src/main/java/org/onap/clamp/clds/client/CdsServices.java b/src/main/java/org/onap/clamp/clds/client/CdsServices.java index fe1937ab1..f25e8b80f 100644 --- a/src/main/java/org/onap/clamp/clds/client/CdsServices.java +++ b/src/main/java/org/onap/clamp/clds/client/CdsServices.java @@ -136,7 +136,7 @@ public class CdsServices { if (isComplexType(type, dataTypes)) { inputObject.add(key, handleComplexType(type, dataTypes)); } else { - inputObject.addProperty(key, ""); + inputObject.add(key, entry.getValue()); } } return inputObject; diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java index 81e30cf43..ce1f94699 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java +++ b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java @@ -26,7 +26,10 @@ package org.onap.clamp.clds.tosca.update.execution.cds; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; + import java.util.Map; +import java.util.Set; + import org.onap.clamp.clds.tosca.update.execution.ToscaMetadataProcess; import org.onap.clamp.loop.service.Service; import org.onap.clamp.tosca.DictionaryService; @@ -58,9 +61,11 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { } private static void generatePayload(JsonObject childObject, Service serviceModel) { - generatePayloadPerResource(childObject, "VF", serviceModel); - generatePayloadPerResource(childObject, "PNF", serviceModel); - addToJsonArray(childObject, "anyOf", createBlankEntry()); + JsonArray schemaAnyOf = new JsonArray(); + schemaAnyOf.addAll(createBlankEntry()); + schemaAnyOf.addAll(generatePayloadPerResource("VF", serviceModel)); + schemaAnyOf.addAll(generatePayloadPerResource("PNF", serviceModel)); + addToJsonArray(childObject, "anyOf", schemaAnyOf); } private static void generateOperation(JsonObject childObject, Service serviceModel) { @@ -92,8 +97,8 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { } - private static void generatePayloadPerResource(JsonObject childObject, String resourceName, - Service serviceModel) { + private static JsonArray generatePayloadPerResource(String resourceName, + Service serviceModel) { JsonArray schemaAnyOf = new JsonArray(); for (Map.Entry entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName) @@ -105,13 +110,14 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { .entrySet()) { JsonObject obj = new JsonObject(); obj.addProperty("title", workflowsEntry.getKey()); - obj.add("properties", createPayloadProperty(workflowsEntry.getValue().getAsJsonObject(), - controllerProperties)); + obj.add("properties", + createInputPropertiesForPayload(workflowsEntry.getValue().getAsJsonObject(), + controllerProperties)); schemaAnyOf.add(obj); } } } - addToJsonArray(childObject, "anyOf", schemaAnyOf); + return schemaAnyOf; } private static JsonArray createBlankEntry() { @@ -123,20 +129,6 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { return result; } - private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties) { - JsonObject payloadResult = new JsonObject(); - - payloadResult.add("artifact_name", - createAnyOfJsonProperty("artifact_name", controllerProperties.get("sdnc_model_name").getAsString())); - payloadResult.add("artifact_version", - createAnyOfJsonProperty("artifact_version", - controllerProperties.get("sdnc_model_version").getAsString())); - payloadResult.add("mode", createAnyOfJsonProperty("mode", "async")); - - payloadResult.add("data", createAnyOfJsonObject("data", workFlow.getAsJsonObject("inputs"))); - return payloadResult; - } - private static JsonObject createAnyOfJsonProperty(String name, String defaultValue) { JsonObject result = new JsonObject(); result.addProperty("title", name); @@ -157,9 +149,73 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { private static void addToJsonArray(JsonObject childObject, String section, JsonArray value) { if (childObject.getAsJsonArray(section) != null) { childObject.getAsJsonArray(section).addAll(value); - } - else { + } else { childObject.add(section, value); } } + + /** + * Returns the properties of payload based on the cds work flows. + * + * @param workFlow cds work flows to update payload + * @param controllerProperties cds properties to get blueprint name and + * version + * @return returns the properties of payload + */ + public static JsonObject createInputPropertiesForPayload(JsonObject workFlow, + JsonObject controllerProperties) { + String artifactName = controllerProperties.get("sdnc_model_name").getAsString(); + String artifactVersion = controllerProperties.get("sdnc_model_version").getAsString(); + JsonObject inputs = workFlow.getAsJsonObject("inputs"); + JsonObject jsonObject = new JsonObject(); + jsonObject.add("artifact_name", createAnyOfJsonProperty( + "artifact name", artifactName)); + jsonObject.add("artifact_version", createAnyOfJsonProperty( + "artifact version", artifactVersion)); + jsonObject.add("mode", createCdsInputProperty( + "mode", "string", "async")); + jsonObject.add("data", createDataProperty(inputs)); + + return jsonObject; + } + + private static JsonObject createDataProperty(JsonObject inputs) { + JsonObject data = new JsonObject(); + data.addProperty("title", "data"); + data.add("properties", addDataFields(inputs)); + return data; + } + + private static JsonObject addDataFields(JsonObject inputs) { + JsonObject jsonObject = new JsonObject(); + Set> entrySet = inputs.entrySet(); + for (Map.Entry entry : entrySet) { + String key = entry.getKey(); + JsonObject inputProperty = inputs.getAsJsonObject(key); + if (inputProperty.get("type") == null) { + jsonObject.add(entry.getKey(), + createAnyOfJsonObject(key, + addDataFields(entry.getValue().getAsJsonObject()))); + } else { + jsonObject.add(entry.getKey(), + createCdsInputProperty(key, + inputProperty.get("type").getAsString(), + null)); + } + } + return jsonObject; + } + + private static JsonObject createCdsInputProperty(String title, + String type, + String defaultValue) { + JsonObject property = new JsonObject(); + property.addProperty("title", title); + property.addProperty("type", type); + if (defaultValue != null) { + property.addProperty("default", defaultValue); + } + property.addProperty("format", "textarea"); + return property; + } } diff --git a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java index 033f2cebb..3765277d8 100644 --- a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java @@ -201,11 +201,13 @@ public class LegacyOperationalPolicy { policy.getAsJsonObject().remove(ACTOR); String actorStr = actor.getAsJsonObject().get(ACTOR).getAsString(); policy.getAsJsonObject().addProperty(ACTOR, actorStr); - policy.getAsJsonObject().addProperty(RECIPE, getRecipe(actor)); if ("CDS".equalsIgnoreCase(actorStr)) { - addPayloadAttributes(actor.getAsJsonObject(ACTOR).getAsJsonObject(RECIPE), policy); + policy.getAsJsonObject().addProperty(RECIPE, getRecipe(actor)); + addCdsPayloadAttributes(actor.getAsJsonObject(RECIPE), policy); } else { + policy.getAsJsonObject().addProperty(RECIPE, + actor.getAsJsonObject().get(RECIPE).getAsString()); addPayloadAttributes(actor, policy); } } @@ -226,7 +228,20 @@ public class LegacyOperationalPolicy { } } + private static void addCdsPayloadAttributes(JsonObject jsonObject, + JsonElement policy) { + JsonElement payloadElem = jsonObject.getAsJsonObject().get(PAYLOAD); + JsonObject payloadObject = payloadElem != null ? + payloadElem.getAsJsonObject() : null; + if (payloadObject != null) { + policy.getAsJsonObject().add(PAYLOAD, + payloadObject); + } else { + policy.getAsJsonObject().addProperty(PAYLOAD, ""); + } + } + private static String getRecipe(JsonObject actor) { - return actor.getAsJsonObject().get("type").getAsString(); + return actor.getAsJsonObject().get("recipe").getAsJsonObject().get("recipe").getAsString(); } } diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java index 44ee11970..4e362d841 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java @@ -24,13 +24,17 @@ package org.onap.clamp.policy.operational; +import static org.onap.clamp.clds.tosca.update.execution.cds.ToscaMetadataCdsProcess.createInputPropertiesForPayload; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; + import java.io.IOException; import java.util.Map.Entry; + import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.clamp.loop.service.Service; @@ -70,7 +74,7 @@ public class OperationalPolicyRepresentationBuilder { for (JsonElement actor : actors) { if ("CDS".equalsIgnoreCase(actor.getAsJsonObject().get("title").getAsString())) { - actor.getAsJsonObject().get("properties").getAsJsonObject().get("type").getAsJsonObject() + actor.getAsJsonObject().get("properties").getAsJsonObject().get("recipe").getAsJsonObject() .get("anyOf").getAsJsonArray() .addAll(createAnyOfArrayForCdsRecipe(modelJson)); } @@ -195,8 +199,9 @@ public class OperationalPolicyRepresentationBuilder { for (Entry workflowsEntry : workflows.entrySet()) { JsonObject obj = new JsonObject(); obj.addProperty("title", workflowsEntry.getKey()); + obj.addProperty("type", "object"); obj.add("properties", createPayloadProperty(workflowsEntry.getValue().getAsJsonObject(), - controllerProperties)); + controllerProperties, workflowsEntry.getKey())); schemaArray.add(obj); } @@ -205,26 +210,27 @@ public class OperationalPolicyRepresentationBuilder { return schemaArray; } - private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties) { - JsonObject type = new JsonObject(); - type.addProperty("title", "Payload (YAML)"); - type.addProperty("type", "string"); - type.addProperty("default", createDefaultStringForPayload(workFlow, controllerProperties)); - type.addProperty("format", "textarea"); + private static JsonObject createPayloadProperty(JsonObject workFlow, + JsonObject controllerProperties, String workFlowName) { + JsonObject payload = new JsonObject(); + payload.addProperty("title", "Payload (YAML)"); + payload.addProperty("type", "object"); + payload.add("properties", createInputPropertiesForPayload(workFlow, + controllerProperties)); JsonObject properties = new JsonObject(); - properties.add("type", type); + properties.add("recipe", createRecipeForCdsWorkflow(workFlowName)); + properties.add("payload", payload); return properties; } - private static String createDefaultStringForPayload(JsonObject workFlow, JsonObject controllerProperties) { - String artifactName = controllerProperties.get("sdnc_model_name").toString(); - String artifactVersion = controllerProperties.get("sdnc_model_version").toString(); - String data = workFlow.getAsJsonObject("inputs").toString(); - StringBuilder builder = new StringBuilder("'").append("artifact_name : ").append(artifactName).append("\n") - .append("artifact_version : ").append(artifactVersion).append("\n") - .append("mode : async").append("\n") - .append("data : ").append("'").append("\\").append("'").append(data).append("\\").append("'") - .append("'"); - return builder.toString(); + private static JsonObject createRecipeForCdsWorkflow(String workflow) { + JsonObject recipe = new JsonObject(); + recipe.addProperty("title", "recipe"); + recipe.addProperty("type", "string"); + recipe.addProperty("default", workflow); + JsonObject options = new JsonObject(); + options.addProperty("hidden", true); + recipe.add("options", options); + return recipe; } } diff --git a/src/main/resources/clds/json-schema/operational_policies/operational_policy.json b/src/main/resources/clds/json-schema/operational_policies/operational_policy.json index 49d7878a8..7214b022c 100644 --- a/src/main/resources/clds/json-schema/operational_policies/operational_policy.json +++ b/src/main/resources/clds/json-schema/operational_policies/operational_policy.json @@ -99,6 +99,7 @@ "anyOf": [ { "title": "APPC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -108,7 +109,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -129,6 +130,7 @@ }, { "title": "SO", + "type": "object", "properties": { "actor": { "title": "actor", @@ -138,7 +140,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -156,6 +158,7 @@ }, { "title": "SDNC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -165,7 +168,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -183,6 +186,7 @@ }, { "title": "VFC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -192,12 +196,9 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", - "required": [ - "payload" - ], "default": "", "enum": [ "ModifyConfig" @@ -212,6 +213,7 @@ }, { "title": "CDS", + "type": "object", "properties": { "actor": { "title": "actor", @@ -221,17 +223,21 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "object", - "required": [ - "payload" - ], "anyOf": [ { "title": "user-defined", + "type": "object", "properties": { - "type": { + "recipe": { + "title": "recipe", + "type": "string", + "default": "user-defined", + "format": "textarea" + }, + "payload": { "title": "Payload (YAML)", "type": "string", "default": "", diff --git a/src/test/resources/tosca/model-properties.json b/src/test/resources/tosca/model-properties.json index c405964ee..688a09ab4 100644 --- a/src/test/resources/tosca/model-properties.json +++ b/src/test/resources/tosca/model-properties.json @@ -40,78 +40,204 @@ "resource-assignment": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate-restconf": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate-cli": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "assign-activate": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "imperative-test-wf": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } } diff --git a/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json b/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json index 58dff236e..12edd7738 100644 --- a/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json +++ b/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json @@ -65,17 +65,21 @@ "type": "object", "description": "Name/value pairs of payload information passed by Policy to the actor", "anyOf": [ + { + "title": "User defined", + "properties": {} + }, { "title": "resource-assignment", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -84,20 +88,51 @@ "title": "mode", "type": "string", "default": "async", - "readOnly": "True" + "format": "textarea" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } } } } @@ -107,13 +142,13 @@ "title": "activate", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -122,20 +157,51 @@ "title": "mode", "type": "string", "default": "async", - "readOnly": "True" + "format": "textarea" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } } } } @@ -145,13 +211,13 @@ "title": "activate-restconf", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -160,20 +226,51 @@ "title": "mode", "type": "string", "default": "async", - "readOnly": "True" + "format": "textarea" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } } } } @@ -183,13 +280,13 @@ "title": "activate-cli", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -198,20 +295,51 @@ "title": "mode", "type": "string", "default": "async", - "readOnly": "True" + "format": "textarea" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } } } } @@ -221,13 +349,13 @@ "title": "assign-activate", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -236,20 +364,51 @@ "title": "mode", "type": "string", "default": "async", - "readOnly": "True" + "format": "textarea" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } } } } @@ -259,13 +418,13 @@ "title": "imperative-test-wf", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -274,28 +433,55 @@ "title": "mode", "type": "string", "default": "async", - "readOnly": "True" + "format": "textarea" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } } } } } - }, - { - "title": "User defined", - "properties": {} } ] }, diff --git a/src/test/resources/tosca/operational-policy-json-schema.json b/src/test/resources/tosca/operational-policy-json-schema.json index 6ab84a8cf..ffa88ecaf 100644 --- a/src/test/resources/tosca/operational-policy-json-schema.json +++ b/src/test/resources/tosca/operational-policy-json-schema.json @@ -99,6 +99,7 @@ "anyOf": [ { "title": "APPC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -108,7 +109,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -129,6 +130,7 @@ }, { "title": "SO", + "type": "object", "properties": { "actor": { "title": "actor", @@ -138,7 +140,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -156,6 +158,7 @@ }, { "title": "SDNC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -165,7 +168,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -183,6 +186,7 @@ }, { "title": "VFC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -192,12 +196,9 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", - "required": [ - "payload" - ], "default": "", "enum": [ "ModifyConfig" @@ -212,6 +213,7 @@ }, { "title": "CDS", + "type": "object", "properties": { "actor": { "title": "actor", @@ -221,17 +223,21 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "object", - "required": [ - "payload" - ], "anyOf": [ { "title": "user-defined", + "type": "object", "properties": { - "type": { + "recipe": { + "title": "recipe", + "type": "string", + "default": "user-defined", + "format": "textarea" + }, + "payload": { "title": "Payload (YAML)", "type": "string", "default": "", @@ -241,67 +247,505 @@ }, { "title": "resource-assignment", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "resource-assignment", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async", + "format": "textarea" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } + } + } + } + } } } }, { "title": "activate", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "activate", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async", + "format": "textarea" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } + } + } + } + } } } }, { "title": "activate-restconf", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "activate-restconf", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async", + "format": "textarea" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } + } + } + } + } } } }, { "title": "activate-cli", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "activate-cli", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async", + "format": "textarea" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } + } + } + } + } } } }, { "title": "assign-activate", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "assign-activate", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async", + "format": "textarea" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } + } + } + } + } } } }, { "title": "imperative-test-wf", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "imperative-test-wf", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async", + "format": "textarea" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string", + "format": "textarea" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string", + "format": "textarea" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string", + "format": "textarea" + }, + "action-name": { + "title": "action-name", + "type": "string", + "format": "textarea" + }, + "scope-type": { + "title": "scope-type", + "type": "string", + "format": "textarea" + }, + "hostname": { + "title": "hostname", + "type": "string", + "format": "textarea" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string", + "format": "textarea" + } + } + } + } + } + } } } } @@ -731,4 +1175,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/test/resources/tosca/operational-policy-payload-legacy.yaml b/src/test/resources/tosca/operational-policy-payload-legacy.yaml index f4708ebc3..72bbf9bad 100644 --- a/src/test/resources/tosca/operational-policy-payload-legacy.yaml +++ b/src/test/resources/tosca/operational-policy-payload-legacy.yaml @@ -40,3 +40,35 @@ policies: resourceID: Vloadbalancerms..vpkg..module-1 type: VFMODULE timeout: 0 +- actor: CDS + failure: final_failure + failure_exception: final_failure_exception + failure_guard: final_failure_guard + failure_retries: final_failure_retries + failure_timeout: final_failure_timeout + id: policy3 + payload: + artifact_name: baseconfiguration + artifact_version: 1.0.0 + data: + resource-assignment-properties: + action-name: action-name + hostname: hostname + request-id: request-id + scope-type: scope-type + service-instance-id: service-instance-id + vnf-id: vnf-id + vnf_name: vnf_name + mode: async + recipe: resource-assignment + retry: 0 + success: final_success + target: + modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52 + modelInvariantId: ca052563-eb92-4b5b-ad41-9111768ce043 + modelName: Vloadbalancerms..vpkg..module-1 + modelVersion: 1 + modelVersionId: 1e725ccc-b823-4f67-82b9-4f4367070dbc + resourceID: Vloadbalancerms..vpkg..module-1 + type: VFMODULE + timeout: 0 diff --git a/src/test/resources/tosca/operational-policy-payload.json b/src/test/resources/tosca/operational-policy-payload.json index 033eecd17..e53950af3 100644 --- a/src/test/resources/tosca/operational-policy-payload.json +++ b/src/test/resources/tosca/operational-policy-payload.json @@ -1,4 +1,4 @@ { "policy-id": "testPolicy.legacy", - "content": "controlLoop%3A%0A++abatement%3A+true%0A++controlLoopName%3A+LOOP_ASJOy_v1_0_ResourceInstanceName1_tca%0A++timeout%3A+0%0A++trigger_policy%3A+policy1%0Apolicies%3A%0A-+actor%3A+APPC%0A++failure%3A+policy2%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy1%0A++payload%3A%0A++++configurationParameters%3A+%27%5B%7B%22ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B10%5D.value%22%2C%22oam-ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B15%5D.value%22%2C%22enabled%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B22%5D.value%22%7D%5D%27%0A++++requestParameters%3A+%27%7B%22usePreload%22%3Atrue%2C%22userParams%22%3A%5B%5D%7D%27%0A++recipe%3A+Restart%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++resourceID%3A+vLoadBalancerMS%0A++++type%3A+VNF%0A++timeout%3A+0%0A-+actor%3A+SO%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy2%0A++recipe%3A+VF+Module+Create%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++modelCustomizationId%3A+1bffdc31-a37d-4dee-b65c-dde623a76e52%0A++++modelInvariantId%3A+ca052563-eb92-4b5b-ad41-9111768ce043%0A++++modelName%3A+Vloadbalancerms..vpkg..module-1%0A++++modelVersion%3A+1%0A++++modelVersionId%3A+1e725ccc-b823-4f67-82b9-4f4367070dbc%0A++++resourceID%3A+Vloadbalancerms..vpkg..module-1%0A++++type%3A+VFMODULE%0A++timeout%3A+0%0A" + "content": "controlLoop%3A%0A++abatement%3A+true%0A++controlLoopName%3A+LOOP_ASJOy_v1_0_ResourceInstanceName1_tca%0A++timeout%3A+0%0A++trigger_policy%3A+policy1%0Apolicies%3A%0A-+actor%3A+APPC%0A++failure%3A+policy2%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy1%0A++payload%3A%0A++++configurationParameters%3A+%27%5B%7B%22ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B10%5D.value%22%2C%22oam-ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B15%5D.value%22%2C%22enabled%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B22%5D.value%22%7D%5D%27%0A++++requestParameters%3A+%27%7B%22usePreload%22%3Atrue%2C%22userParams%22%3A%5B%5D%7D%27%0A++recipe%3A+Restart%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++resourceID%3A+vLoadBalancerMS%0A++++type%3A+VNF%0A++timeout%3A+0%0A-+actor%3A+SO%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy2%0A++recipe%3A+VF+Module+Create%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++modelCustomizationId%3A+1bffdc31-a37d-4dee-b65c-dde623a76e52%0A++++modelInvariantId%3A+ca052563-eb92-4b5b-ad41-9111768ce043%0A++++modelName%3A+Vloadbalancerms..vpkg..module-1%0A++++modelVersion%3A+1%0A++++modelVersionId%3A+1e725ccc-b823-4f67-82b9-4f4367070dbc%0A++++resourceID%3A+Vloadbalancerms..vpkg..module-1%0A++++type%3A+VFMODULE%0A++timeout%3A+0%0A-+actor%3A+CDS%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy3%0A++payload%3A%0A++++artifact_name%3A+baseconfiguration%0A++++artifact_version%3A+1.0.0%0A++++data%3A%0A++++++resource-assignment-properties%3A%0A++++++++action-name%3A+action-name%0A++++++++hostname%3A+hostname%0A++++++++request-id%3A+request-id%0A++++++++scope-type%3A+scope-type%0A++++++++service-instance-id%3A+service-instance-id%0A++++++++vnf-id%3A+vnf-id%0A++++++++vnf_name%3A+vnf_name%0A++++mode%3A+async%0A++recipe%3A+resource-assignment%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++modelCustomizationId%3A+1bffdc31-a37d-4dee-b65c-dde623a76e52%0A++++modelInvariantId%3A+ca052563-eb92-4b5b-ad41-9111768ce043%0A++++modelName%3A+Vloadbalancerms..vpkg..module-1%0A++++modelVersion%3A+1%0A++++modelVersionId%3A+1e725ccc-b823-4f67-82b9-4f4367070dbc%0A++++resourceID%3A+Vloadbalancerms..vpkg..module-1%0A++++type%3A+VFMODULE%0A++timeout%3A+0%0A" } \ No newline at end of file diff --git a/src/test/resources/tosca/operational-policy-payload.yaml b/src/test/resources/tosca/operational-policy-payload.yaml index 69c86cc84..aaa962769 100644 --- a/src/test/resources/tosca/operational-policy-payload.yaml +++ b/src/test/resources/tosca/operational-policy-payload.yaml @@ -50,3 +50,35 @@ topology_template: actor: SO recipe: VF Module Create payload: '' + - id: policy3 + retry: '0' + timeout: '0' + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard + target: + type: VFMODULE + resourceID: Vloadbalancerms..vpkg..module-1 + modelInvariantId: ca052563-eb92-4b5b-ad41-9111768ce043 + modelVersionId: 1e725ccc-b823-4f67-82b9-4f4367070dbc + modelName: Vloadbalancerms..vpkg..module-1 + modelVersion: '1' + modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52 + actor: CDS + recipe: resource-assignment + payload: + artifact_name: baseconfiguration + artifact_version: 1.0.0 + mode: async + data: + resource-assignment-properties: + request-id: request-id + service-instance-id: service-instance-id + vnf-id: vnf-id + action-name: action-name + scope-type: scope-type + hostname: hostname + vnf_name: vnf_name diff --git a/src/test/resources/tosca/operational-policy-properties.json b/src/test/resources/tosca/operational-policy-properties.json index a2de76a98..2777a158c 100644 --- a/src/test/resources/tosca/operational-policy-properties.json +++ b/src/test/resources/tosca/operational-policy-properties.json @@ -10,7 +10,7 @@ { "actor": { "actor": "APPC", - "type": "Restart", + "recipe": "Restart", "payload": "requestParameters: '{\"usePreload\":true,\"userParams\":[]}'\r\nconfigurationParameters: '[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[10].value\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[15].value\",\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[22].value\"}]'" }, "id": "policy1", @@ -27,11 +27,11 @@ "resourceID": "vLoadBalancerMS" } }, - { + { "actor": { - "actor": "SO", - "type": "VF Module Create", - "payload": "" + "actor": "SO", + "recipe": "VF Module Create", + "payload": "" }, "id": "policy2", "retry": "0", @@ -51,6 +51,48 @@ "modelVersion": "1", "modelCustomizationId": "1bffdc31-a37d-4dee-b65c-dde623a76e52" } + }, + { + "actor": { + "actor": "CDS", + "recipe": { + "recipe": "resource-assignment", + "payload": { + "artifact_name": "baseconfiguration", + "artifact_version": "1.0.0", + "mode": "async", + "data": { + "resource-assignment-properties": { + "request-id": "request-id", + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id", + "action-name": "action-name", + "scope-type": "scope-type", + "hostname": "hostname", + "vnf_name": "vnf_name" + } + } + } + } + }, + "id": "policy3", + "retry": "0", + "timeout": "0", + "success": "final_success", + "failure": "final_failure", + "failure_timeout": "final_failure_timeout", + "failure_retries": "final_failure_retries", + "failure_exception": "final_failure_exception", + "failure_guard": "final_failure_guard", + "target": { + "type": "VFMODULE", + "resourceID": "Vloadbalancerms..vpkg..module-1", + "modelInvariantId": "ca052563-eb92-4b5b-ad41-9111768ce043", + "modelVersionId": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "modelName": "Vloadbalancerms..vpkg..module-1", + "modelVersion": "1", + "modelCustomizationId": "1bffdc31-a37d-4dee-b65c-dde623a76e52" + } } ] }, diff --git a/src/test/resources/tosca/resource-details.json b/src/test/resources/tosca/resource-details.json index a638c350d..dc47b44db 100644 --- a/src/test/resources/tosca/resource-details.json +++ b/src/test/resources/tosca/resource-details.json @@ -24,78 +24,204 @@ "resource-assignment": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate-restconf": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate-cli": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "assign-activate": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "imperative-test-wf": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } } -- cgit 1.2.3-korg From 2d9f989e0d37002c758bdf66a3f25fcfdac35b62 Mon Sep 17 00:00:00 2001 From: root1 Date: Tue, 11 Aug 2020 18:44:29 +0530 Subject: CLAMP should not display all CDS workflow properties CLAMP should not display all CDS workflow properties Issue-ID: CLAMP-856 Signed-off-by: root1 Change-Id: I98fc46c9c9ba574a3606740921d74743cb6f38ea --- .../org/onap/clamp/clds/client/CdsServices.java | 79 +++-- .../execution/cds/ToscaMetadataCdsProcess.java | 41 ++- .../OperationalPolicyRepresentationBuilder.java | 49 +-- .../ToscaConverterWithDictionarySupportItCase.java | 2 +- ...OperationalPolicyRepresentationBuilderTest.java | 4 +- .../vFW-CDS-modify-config-wf-expected-result.json | 72 ++--- .../vFW-CDS-modify-config-workflow.json | 7 +- ...CDS-resource-assignment-wf-expected-result.json | 32 +- .../vFW-CDS-resource-assignment-workflow.json | 2 + .../.file | 34 +- src/test/resources/tosca/model-properties-cds.json | 23 +- .../tosca/model-properties-operational-policy.json | 353 ++++++++++++++++++++ src/test/resources/tosca/model-properties.json | 358 +++++++++++---------- .../new-converter/tosca_apex_with_metadata.json | 12 +- .../tosca/operational-policy-json-schema.json | 168 +++++----- src/test/resources/tosca/resource-details-cds.json | 336 +++++++++++++++++++ src/test/resources/tosca/resource-details.json | 354 ++++++++++---------- 17 files changed, 1369 insertions(+), 557 deletions(-) create mode 100644 src/test/resources/tosca/model-properties-operational-policy.json create mode 100644 src/test/resources/tosca/resource-details-cds.json (limited to 'src/test/resources/tosca/model-properties.json') diff --git a/src/main/java/org/onap/clamp/clds/client/CdsServices.java b/src/main/java/org/onap/clamp/clds/client/CdsServices.java index fa15e2778..fd3b3539a 100644 --- a/src/main/java/org/onap/clamp/clds/client/CdsServices.java +++ b/src/main/java/org/onap/clamp/clds/client/CdsServices.java @@ -22,6 +22,8 @@ package org.onap.clamp.clds.client; +import static java.lang.Boolean.parseBoolean; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.gson.JsonElement; @@ -52,6 +54,10 @@ public class CdsServices { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CdsServices.class); + private static final String TYPE = "type"; + private static final String PROPERTIES = "properties"; + private static final String LIST = "list"; + /** * Constructor. */ @@ -129,55 +135,80 @@ public class CdsServices { JsonObject dataTypes = root.getAsJsonObject("dataTypes"); JsonObject workFlowProperties = new JsonObject(); - workFlowProperties.add("inputs", getInputProperties(inputs, dataTypes)); + workFlowProperties.add("inputs", getInputProperties(inputs, dataTypes, new JsonObject())); return workFlowProperties; } - private JsonObject getInputProperties(JsonObject inputs, JsonObject dataTypes) { - JsonObject inputObject = new JsonObject(); + private JsonObject getInputProperties(JsonObject inputs, JsonObject dataTypes, + JsonObject inputObject) { + if (inputs == null) { + return inputObject; + } + for (Map.Entry entry : inputs.entrySet()) { String key = entry.getKey(); JsonObject inputProperty = inputs.getAsJsonObject(key); - String type = inputProperty.get("type").getAsString(); + String type = inputProperty.get(TYPE).getAsString(); if (isComplexType(type, dataTypes)) { inputObject.add(key, handleComplexType(type, dataTypes)); - } else if (type.equalsIgnoreCase("list")) { - inputObject.add(key, handleListType(key, inputProperty, - dataTypes)); - } else { + } else if (LIST.equalsIgnoreCase(type)) { + handleListType(key, inputProperty, dataTypes, inputObject); + } else if (isInputParam(inputProperty)) { inputObject.add(key, entry.getValue()); } } return inputObject; } - private JsonObject handleListType(String propertyName, + private void handleListType(String propertyName, JsonObject inputProperty, - JsonObject dataTypes) { - if (inputProperty.get("entry_schema") != null) { - String type = inputProperty.get("entry_schema").getAsJsonObject().get( - "type").getAsString(); - if (dataTypes.get(type) != null) { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("type", "list"); - jsonObject.add("properties", handleComplexType(type, dataTypes)); - return jsonObject; - } else { - return inputProperty; - } + JsonObject dataTypes, + JsonObject inputObject) { + if (inputProperty.get("entry_schema") == null) { + throw new CdsParametersException("Entry schema is null for " + propertyName); + } + + String type = inputProperty.get("entry_schema").getAsJsonObject().get( + TYPE).getAsString(); + if (dataTypes.get(type) != null) { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty(TYPE, LIST); + jsonObject.add(PROPERTIES, getPropertiesObject(type, dataTypes)); + inputObject.add(propertyName, jsonObject); + } else if (isInputParam(inputProperty)) { + inputObject.add(propertyName, inputProperty); } - throw new CdsParametersException("Entry schema is null for " + propertyName); } private JsonObject handleComplexType(String key, JsonObject dataTypes) { - JsonObject properties = dataTypes.get(key).getAsJsonObject().get("properties").getAsJsonObject(); - return getInputProperties(properties, dataTypes); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty(TYPE, "object"); + jsonObject.add(PROPERTIES, getPropertiesObject(key, dataTypes)); + return jsonObject; + } + + private JsonObject getPropertiesObject(String key, JsonObject dataTypes) { + JsonObject properties = dataTypes.get(key).getAsJsonObject().get(PROPERTIES).getAsJsonObject(); + JsonObject object = new JsonObject(); + getInputProperties(properties, dataTypes, object); + return object; } private boolean isComplexType(String type, JsonObject dataTypes) { + if (dataTypes == null) { + return false; + } return dataTypes.get(type) != null; } + private boolean isInputParam(JsonObject inputProperty) { + JsonElement inputParam = inputProperty.get("input-param"); + if (inputParam == null) { + return false; + } + return parseBoolean(inputParam.getAsString()); + } + /** * Creates payload to query CDS to get workflow input properties. * diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java index 94a477fe5..39fa25a2b 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java +++ b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java @@ -24,6 +24,7 @@ package org.onap.clamp.clds.tosca.update.execution.cds; import static org.onap.clamp.clds.tosca.ToscaSchemaConstants.TYPE; +import static org.onap.clamp.clds.tosca.ToscaSchemaConstants.TYPE_LIST; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -108,7 +109,8 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { obj.addProperty("title", workflowsEntry.getKey()); obj.add("properties", createInputPropertiesForPayload(workflowsEntry.getValue().getAsJsonObject(), - controllerProperties)); + controllerProperties, + workflowsEntry.getKey())); schemaAnyOf.add(obj); } } @@ -150,10 +152,12 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { * @param workFlow cds work flows to update payload * @param controllerProperties cds properties to get blueprint name and * version + * @param workFlowName work flow name * @return returns the properties of payload */ public static JsonObject createInputPropertiesForPayload(JsonObject workFlow, - JsonObject controllerProperties) { + JsonObject controllerProperties, + String workFlowName) { String artifactName = controllerProperties.get("sdnc_model_name").getAsString(); String artifactVersion = controllerProperties.get("sdnc_model_version").getAsString(); JsonObject inputs = workFlow.getAsJsonObject("inputs"); @@ -164,32 +168,53 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { "artifact version", artifactVersion, true)); jsonObject.add("mode", createAnyOfJsonProperty( "mode", "async", false)); - jsonObject.add("data", createDataProperty(inputs)); + jsonObject.add("data", createDataProperty(inputs, workFlowName)); return jsonObject; } - private static JsonObject createDataProperty(JsonObject inputs) { + private static JsonObject createDataProperty(JsonObject inputs, String workFlowName) { JsonObject data = new JsonObject(); data.addProperty("title", "data"); data.addProperty("type", "string"); data.addProperty("format", "textarea"); JsonObject defaultValue = new JsonObject(); - addDefaultValueForData(inputs, defaultValue); + addDefaultValueForData(inputs, defaultValue, workFlowName); data.addProperty("default", defaultValue.toString()); return data; } private static void addDefaultValueForData(JsonObject inputs, - JsonObject defaultValue) { + JsonObject defaultValue, + String workFlowName) { Set> entrySet = inputs.entrySet(); for (Map.Entry entry : entrySet) { String key = entry.getKey(); JsonObject inputProperty = inputs.getAsJsonObject(key); - if (inputProperty.get(TYPE) == null) { - addDefaultValueForData(entry.getValue().getAsJsonObject(), defaultValue); + if (key.equalsIgnoreCase(workFlowName + "-properties")) { + addDefaultValueForData(entry.getValue().getAsJsonObject().get("properties") + .getAsJsonObject(), defaultValue, workFlowName); + } else if ("object".equalsIgnoreCase(inputProperty.get(TYPE).getAsString())) { + JsonObject object = new JsonObject(); + addDefaultValueForData(entry.getValue().getAsJsonObject().get("properties") + .getAsJsonObject(), object, workFlowName); + defaultValue.add(entry.getKey(), object); + } else if (TYPE_LIST.equalsIgnoreCase(inputProperty.get(TYPE).getAsString())) { + defaultValue.add(entry.getKey(), handleListType(entry.getValue().getAsJsonObject(), workFlowName)); } else { defaultValue.addProperty(entry.getKey(), ""); } } } + + private static JsonArray handleListType(JsonObject inputs, + String workFlowName) { + + JsonObject object = new JsonObject(); + if (inputs.get("properties") != null) { + addDefaultValueForData(inputs.get("properties").getAsJsonObject(), object, workFlowName); + } + JsonArray arr = new JsonArray(); + arr.add(object); + return arr; + } } diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java index ee4030656..c0e1c019e 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java @@ -53,6 +53,8 @@ public class OperationalPolicyRepresentationBuilder { public static final String STRING = "string"; public static final String TYPE = "type"; public static final String TYPE_LIST = "list"; + public static final String TYPE_OBJECT = "object"; + public static final String TYPE_ARRAY = "array"; private OperationalPolicyRepresentationBuilder() { throw new IllegalStateException("This is Utility class, not supposed to be initiated."); @@ -240,8 +242,8 @@ public class OperationalPolicyRepresentationBuilder { JsonObject payload = new JsonObject(); payload.addProperty(TITLE, "Payload"); payload.addProperty(TYPE, "object"); - payload.add(PROPERTIES, createInputPropertiesForPayload(workFlow, - controllerProperties)); + payload.add(PROPERTIES, createInputPropertiesForPayload(workFlow, controllerProperties, + workFlowName)); JsonObject properties = new JsonObject(); properties.add(RECIPE, createRecipeForCdsWorkflow(workFlowName)); properties.add("payload", payload); @@ -265,10 +267,12 @@ public class OperationalPolicyRepresentationBuilder { * @param workFlow cds work flows to update payload * @param controllerProperties cds properties to get blueprint name and * version + * @param workFlowName work flow name * @return returns the properties of payload */ public static JsonObject createInputPropertiesForPayload(JsonObject workFlow, - JsonObject controllerProperties) { + JsonObject controllerProperties, + String workFlowName) { String artifactName = controllerProperties.get("sdnc_model_name").getAsString(); String artifactVersion = controllerProperties.get("sdnc_model_version").getAsString(); JsonObject inputs = workFlow.getAsJsonObject("inputs"); @@ -279,33 +283,33 @@ public class OperationalPolicyRepresentationBuilder { "artifact version", STRING, artifactVersion, "True", null)); jsonObject.add("mode", createCdsInputProperty( "mode", STRING, "async" ,null)); - jsonObject.add("data", createDataProperty(inputs)); + jsonObject.add("data", createDataProperty(inputs, workFlowName)); return jsonObject; } - private static JsonObject createDataProperty(JsonObject inputs) { + private static JsonObject createDataProperty(JsonObject inputs, String workflowName) { JsonObject data = new JsonObject(); data.addProperty(TITLE, "data"); JsonObject dataObj = new JsonObject(); - addDataFields(inputs, dataObj); + addDataFields(inputs, dataObj, workflowName); data.add(PROPERTIES, dataObj); return data; } private static void addDataFields(JsonObject inputs, - JsonObject dataObj) { + JsonObject dataObj, + String workFlowName) { Set> entrySet = inputs.entrySet(); for (Map.Entry entry : entrySet) { String key = entry.getKey(); JsonObject inputProperty = inputs.getAsJsonObject(key); - if (inputProperty.get(TYPE) == null) { - addDataFields(entry.getValue().getAsJsonObject(), dataObj); + if (key.equalsIgnoreCase(workFlowName + "-properties")) { + addDataFields(entry.getValue().getAsJsonObject().get("properties").getAsJsonObject(), + dataObj, workFlowName); } else { dataObj.add(entry.getKey(), - createCdsInputProperty(key, - inputProperty.get(TYPE).getAsString(), - null, - entry.getValue().getAsJsonObject())); + createCdsInputProperty(key, inputProperty.get(TYPE).getAsString(),null, + entry.getValue().getAsJsonObject())); } } } @@ -318,15 +322,15 @@ public class OperationalPolicyRepresentationBuilder { property.addProperty(TITLE, title); if (TYPE_LIST.equalsIgnoreCase(type)) { - property.addProperty(TYPE, "array"); + property.addProperty(TYPE, TYPE_ARRAY); if (cdsProperty != null && cdsProperty.get(PROPERTIES) != null) { - JsonObject dataObject = new JsonObject(); - addDataFields(cdsProperty.get(PROPERTIES).getAsJsonObject(), - dataObject); JsonObject listProperties = new JsonObject(); - listProperties.add(PROPERTIES, dataObject); + listProperties.add(PROPERTIES, getProperties(cdsProperty.get(PROPERTIES).getAsJsonObject())); property.add(ITEMS, listProperties); } + } else if (TYPE_OBJECT.equalsIgnoreCase(type)) { + property.addProperty(TYPE, TYPE_OBJECT); + property.add(PROPERTIES, getProperties(cdsProperty.get(PROPERTIES).getAsJsonObject())); } else { property.addProperty(TYPE, type); } @@ -336,4 +340,13 @@ public class OperationalPolicyRepresentationBuilder { } return property; } + + private static JsonObject getProperties(JsonObject inputProperties) { + if (inputProperties == null) { + return null; + } + JsonObject dataObject = new JsonObject(); + addDataFields(inputProperties, dataObject, null); + return dataObject; + } } diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java index 7f0e57602..f7774214c 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java @@ -128,7 +128,7 @@ public class ToscaConverterWithDictionarySupportItCase { @Transactional public final void testMetadataClampPossibleValueWithExecutor() throws IOException, UnknownComponentException { Service service = new Service(ResourceFileUtil.getResourceAsString("tosca/service-details.json"), - ResourceFileUtil.getResourceAsString("tosca/resource-details.json")); + ResourceFileUtil.getResourceAsString("tosca/resource-details-cds.json")); JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" diff --git a/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java index b90a28616..4f728b44a 100644 --- a/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java +++ b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java @@ -37,8 +37,8 @@ public class OperationalPolicyRepresentationBuilderTest { @Test public void testOperationalPolicyPayloadConstruction() throws IOException { - JsonObject jsonModel = new GsonBuilder().create() - .fromJson(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"), JsonObject.class); + JsonObject jsonModel = new GsonBuilder().create().fromJson(ResourceFileUtil + .getResourceAsString("tosca/model-properties-operational-policy.json"), JsonObject.class); Service service = new Service(jsonModel.get("serviceDetails").getAsJsonObject(), jsonModel.get("resourceDetails").getAsJsonObject(), "1.0"); diff --git a/src/test/resources/example/cds-response/vFW-CDS-modify-config-wf-expected-result.json b/src/test/resources/example/cds-response/vFW-CDS-modify-config-wf-expected-result.json index 7e78bb062..2b6493176 100644 --- a/src/test/resources/example/cds-response/vFW-CDS-modify-config-wf-expected-result.json +++ b/src/test/resources/example/cds-response/vFW-CDS-modify-config-wf-expected-result.json @@ -1,57 +1,29 @@ { "inputs": { - "resolution-key": { - "required": true, - "type": "string" - }, "modify-config-properties": { - "vpg_onap_private_ip_0": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "" + "type": "object", + "properties": { + "service-instance-id": { + "type": "string", + "input-param": true + }, + "update-active-streams": { + "description": "", + "required": false, + "type": "string", + "input-param": true, + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "dt-data" + } + }, + "generic-vnf.vnf-id": { + "type": "string", + "input-param": true } - }, - "service-instance.service-instance-id": { - "type": "string" - }, - "vnf-id": { - "type": "string" - }, - "data": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "dt-data" - } - }, - "service-instance-id": { - "type": "string" - }, - "update-active-streams": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "dt-data" - } - }, - "generic-vnf.vnf-id": { - "type": "string" } } } diff --git a/src/test/resources/example/cds-response/vFW-CDS-modify-config-workflow.json b/src/test/resources/example/cds-response/vFW-CDS-modify-config-workflow.json index e46da6760..115d79b1f 100644 --- a/src/test/resources/example/cds-response/vFW-CDS-modify-config-workflow.json +++ b/src/test/resources/example/cds-response/vFW-CDS-modify-config-workflow.json @@ -51,12 +51,14 @@ } }, "service-instance-id": { - "type": "string" + "type": "string", + "input-param": true }, "update-active-streams": { "description": "", "required": false, "type": "string", + "input-param": true, "status": "", "constraints": [ {} @@ -66,7 +68,8 @@ } }, "generic-vnf.vnf-id": { - "type": "string" + "type": "string", + "input-param": true } }, "derived_from": "tosca.datatypes.Dynamic" diff --git a/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json b/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json index 5b373a45e..07d851f38 100644 --- a/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json +++ b/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json @@ -1,12 +1,5 @@ { "inputs": { - "template-prefix": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, "template-prefix-with-complex-type": { "type": "list", "properties": { @@ -14,6 +7,7 @@ "description": "", "required": false, "type": "string", + "input-param": true, "status": "", "constraints": [ {} @@ -25,16 +19,20 @@ } }, "resource-assignment-properties": { - "private1-prefix-id": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "" + "type": "object", + "properties": { + "private1-prefix-id": { + "description": "", + "required": false, + "type": "string", + "input-param": true, + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } } } } diff --git a/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-workflow.json b/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-workflow.json index d0f78cf1d..7f76c6cae 100644 --- a/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-workflow.json +++ b/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-workflow.json @@ -45,6 +45,7 @@ "description": "", "required": false, "type": "string", + "input-param": true, "status": "", "constraints": [ {} @@ -64,6 +65,7 @@ "description": "", "required": false, "type": "string", + "input-param": true, "status": "", "constraints": [ {} diff --git a/src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.file index 13d3feaaf..9e616dfea 100644 --- a/src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.file +++ b/src/test/resources/http-cache/example/api/v1/blueprint-model/workflow-spec?connectionTimeToLive=5000/.file @@ -34,11 +34,13 @@ "properties": { "request-id": { "required": true, - "type": "string" + "type": "string", + "input-param": true }, "service-instance-id": { "required": true, - "type": "string" + "type": "string", + "input-param": true }, "vnf-id": { "required": true, @@ -54,7 +56,13 @@ }, "hostname": { "required": true, - "type": "string" + "type": "string", + "input-param": true + }, + "request-info": { + "required": true, + "type": "dt-request-info-properties", + "input-param": true }, "vnf_name": { "required": true, @@ -63,6 +71,26 @@ }, "constraints": null, "derived_from": "tosca.datatypes.Dynamic" + }, + "dt-request-info-properties": { + "description": "This is Dynamically generated data type for workflow activate", + "version": "1.0.0", + "metadata": null, + "attributes": null, + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + }, + "constraints": null, + "derived_from": "tosca.datatypes.Dynamic" } } } \ No newline at end of file diff --git a/src/test/resources/tosca/model-properties-cds.json b/src/test/resources/tosca/model-properties-cds.json index 591840b49..fea658431 100644 --- a/src/test/resources/tosca/model-properties-cds.json +++ b/src/test/resources/tosca/model-properties-cds.json @@ -62,16 +62,19 @@ } }, "resource-assignment-properties": { - "private1-prefix-id": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "" + "type": "object", + "properties": { + "private1-prefix-id": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } } } } diff --git a/src/test/resources/tosca/model-properties-operational-policy.json b/src/test/resources/tosca/model-properties-operational-policy.json new file mode 100644 index 000000000..2a6568528 --- /dev/null +++ b/src/test/resources/tosca/model-properties-operational-policy.json @@ -0,0 +1,353 @@ +{ + "serviceDetails": { + "serviceType": "", + "namingPolicy": "", + "environmentContext": "General_Revenue-Bearing", + "serviceEcompNaming": "true", + "serviceRole": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f", + "ecompGeneratedNaming": "true", + "category": "Network L4+", + "type": "Service", + "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0", + "instantiationType": "A-la-carte" + }, + "resourceDetails": { + "CP": { + }, + "VL": { + }, + "VF": { + "vLoadBalancerMS 0": { + "resourceVendor": "Test", + "resourceVendorModelNumber": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", + "subcategory": "Load Balancer", + "category": "Application L4+", + "type": "VF", + "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", + "version": "1.0", + "resourceVendorRelease": "1.0", + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552", + "controllerProperties": { + "sdnc_model_name": "baseconfiguration", + "sdnc_model_version": "1.0.0", + "workflows": { + "resource-assignment": { + "inputs": { + "resource-assignment-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + }, + "activate": { + "inputs": { + "activate-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + }, + "activate-restconf": { + "inputs": { + "activate-restconf-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + }, + "activate-cli": { + "inputs": { + "activate-cli-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + }, + "assign-activate": { + "inputs": { + "assign-activate-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + }, + "imperative-test-wf": { + "inputs": { + "imperative-test-wf-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + } + } + } + } + }, + "CR": { + }, + "VFC": { + }, + "PNF": { + }, + "Service": { + }, + "CVFC": { + }, + "Service Proxy": { + }, + "Configuration": { + }, + "AllottedResource": { + }, + "VFModule": { + "Vloadbalancerms..vpkg..module-1": { + "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", + "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "min_vf_module_instances": 0, + "vf_module_label": "vpkg", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..vdns..module-3": { + "vfModuleModelInvariantUUID": "4c10ba9b-f88f-415e-9de3-5d33336047fa", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vdns..module-3", + "vfModuleModelUUID": "4fa73b49-8a6c-493e-816b-eb401567b720", + "vfModuleModelCustomizationUUID": "bafcdab0-801d-4d81-9ead-f464640a38b1", + "min_vf_module_instances": 0, + "vf_module_label": "vdns", + "max_vf_module_instances": 50, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..base_template..module-0": { + "vfModuleModelInvariantUUID": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..base_template..module-0", + "vfModuleModelUUID": "63734409-f745-4e4d-a38b-131638a0edce", + "vfModuleModelCustomizationUUID": "86baddea-c730-4fb8-9410-cd2e17fd7f27", + "min_vf_module_instances": 1, + "vf_module_label": "base_template", + "max_vf_module_instances": 1, + "vf_module_type": "Base", + "isBase": true, + "initial_count": 1, + "volume_group": false + }, + "Vloadbalancerms..vlb..module-2": { + "vfModuleModelInvariantUUID": "a772a1f4-0064-412c-833d-4749b15828dd", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vlb..module-2", + "vfModuleModelUUID": "0f5c3f6a-650a-4303-abb6-fff3e573a07a", + "vfModuleModelCustomizationUUID": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806", + "min_vf_module_instances": 0, + "vf_module_label": "vlb", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/tosca/model-properties.json b/src/test/resources/tosca/model-properties.json index 688a09ab4..1c0fe24b4 100644 --- a/src/test/resources/tosca/model-properties.json +++ b/src/test/resources/tosca/model-properties.json @@ -40,33 +40,38 @@ "resource-assignment": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } @@ -74,33 +79,38 @@ "activate": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } @@ -108,33 +118,38 @@ "activate-restconf": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } @@ -142,33 +157,38 @@ "activate-cli": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } @@ -176,33 +196,38 @@ "assign-activate": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } @@ -210,38 +235,43 @@ "imperative-test-wf": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } - } - } + } + } } } }, diff --git a/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json b/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json index f6713aff3..4519d5c9f 100644 --- a/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json +++ b/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json @@ -94,7 +94,7 @@ "title": "data", "type": "string", "format": "textarea", - "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"hostname\":\"\",\"request-info\":{\"prop1\":\"\",\"prop2\":\"\"}}" } } }, @@ -123,7 +123,7 @@ "title": "data", "type": "string", "format": "textarea", - "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"hostname\":\"\",\"request-info\":{\"prop1\":\"\",\"prop2\":\"\"}}" } } }, @@ -152,7 +152,7 @@ "title": "data", "type": "string", "format": "textarea", - "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"hostname\":\"\",\"request-info\":{\"prop1\":\"\",\"prop2\":\"\"}}" } } }, @@ -181,7 +181,7 @@ "title": "data", "type": "string", "format": "textarea", - "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"hostname\":\"\",\"request-info\":{\"prop1\":\"\",\"prop2\":\"\"}}" } } }, @@ -210,7 +210,7 @@ "title": "data", "type": "string", "format": "textarea", - "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"hostname\":\"\",\"request-info\":{\"prop1\":\"\",\"prop2\":\"\"}}" } } }, @@ -239,7 +239,7 @@ "title": "data", "type": "string", "format": "textarea", - "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"hostname\":\"\",\"request-info\":{\"prop1\":\"\",\"prop2\":\"\"}}" } } } diff --git a/src/test/resources/tosca/operational-policy-json-schema.json b/src/test/resources/tosca/operational-policy-json-schema.json index e8363b468..dc6c32fa7 100644 --- a/src/test/resources/tosca/operational-policy-json-schema.json +++ b/src/test/resources/tosca/operational-policy-json-schema.json @@ -288,25 +288,23 @@ "title": "service-instance-id", "type": "string" }, - "vnf-id": { - "title": "vnf-id", - "type": "string" - }, - "action-name": { - "title": "action-name", - "type": "string" - }, - "scope-type": { - "title": "scope-type", - "type": "string" - }, "hostname": { "title": "hostname", "type": "string" }, - "vnf_name": { - "title": "vnf_name", - "type": "string" + "request-info": { + "title": "request-info", + "type": "object", + "properties": { + "prop1": { + "title": "prop1", + "type": "string" + }, + "prop2": { + "title": "prop2", + "type": "string" + } + } } } } @@ -358,25 +356,23 @@ "title": "service-instance-id", "type": "string" }, - "vnf-id": { - "title": "vnf-id", - "type": "string" - }, - "action-name": { - "title": "action-name", - "type": "string" - }, - "scope-type": { - "title": "scope-type", - "type": "string" - }, "hostname": { "title": "hostname", "type": "string" }, - "vnf_name": { - "title": "vnf_name", - "type": "string" + "request-info": { + "title": "request-info", + "type": "object", + "properties": { + "prop1": { + "title": "prop1", + "type": "string" + }, + "prop2": { + "title": "prop2", + "type": "string" + } + } } } } @@ -428,25 +424,23 @@ "title": "service-instance-id", "type": "string" }, - "vnf-id": { - "title": "vnf-id", - "type": "string" - }, - "action-name": { - "title": "action-name", - "type": "string" - }, - "scope-type": { - "title": "scope-type", - "type": "string" - }, "hostname": { "title": "hostname", "type": "string" }, - "vnf_name": { - "title": "vnf_name", - "type": "string" + "request-info": { + "title": "request-info", + "type": "object", + "properties": { + "prop1": { + "title": "prop1", + "type": "string" + }, + "prop2": { + "title": "prop2", + "type": "string" + } + } } } } @@ -498,25 +492,23 @@ "title": "service-instance-id", "type": "string" }, - "vnf-id": { - "title": "vnf-id", - "type": "string" - }, - "action-name": { - "title": "action-name", - "type": "string" - }, - "scope-type": { - "title": "scope-type", - "type": "string" - }, "hostname": { "title": "hostname", "type": "string" }, - "vnf_name": { - "title": "vnf_name", - "type": "string" + "request-info": { + "title": "request-info", + "type": "object", + "properties": { + "prop1": { + "title": "prop1", + "type": "string" + }, + "prop2": { + "title": "prop2", + "type": "string" + } + } } } } @@ -568,25 +560,23 @@ "title": "service-instance-id", "type": "string" }, - "vnf-id": { - "title": "vnf-id", - "type": "string" - }, - "action-name": { - "title": "action-name", - "type": "string" - }, - "scope-type": { - "title": "scope-type", - "type": "string" - }, "hostname": { "title": "hostname", "type": "string" }, - "vnf_name": { - "title": "vnf_name", - "type": "string" + "request-info": { + "title": "request-info", + "type": "object", + "properties": { + "prop1": { + "title": "prop1", + "type": "string" + }, + "prop2": { + "title": "prop2", + "type": "string" + } + } } } } @@ -638,25 +628,23 @@ "title": "service-instance-id", "type": "string" }, - "vnf-id": { - "title": "vnf-id", - "type": "string" - }, - "action-name": { - "title": "action-name", - "type": "string" - }, - "scope-type": { - "title": "scope-type", - "type": "string" - }, "hostname": { "title": "hostname", "type": "string" }, - "vnf_name": { - "title": "vnf_name", - "type": "string" + "request-info": { + "title": "request-info", + "type": "object", + "properties": { + "prop1": { + "title": "prop1", + "type": "string" + }, + "prop2": { + "title": "prop2", + "type": "string" + } + } } } } diff --git a/src/test/resources/tosca/resource-details-cds.json b/src/test/resources/tosca/resource-details-cds.json new file mode 100644 index 000000000..d972d0cb9 --- /dev/null +++ b/src/test/resources/tosca/resource-details-cds.json @@ -0,0 +1,336 @@ +{ + "CP": { + }, + "VL": { + }, + "VF": { + "vLoadBalancerMS 0": { + "resourceVendor": "Test", + "resourceVendorModelNumber": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", + "subcategory": "Load Balancer", + "category": "Application L4+", + "type": "VF", + "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", + "version": "1.0", + "resourceVendorRelease": "1.0", + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552", + "controllerProperties": { + "sdnc_model_name": "baseconfiguration", + "sdnc_model_version": "1.0.0", + "workflows": { + "resource-assignment": { + "inputs": { + "resource-assignment-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + }, + "activate": { + "inputs": { + "activate-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + }, + "activate-restconf": { + "inputs": { + "activate-restconf-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + }, + "activate-cli": { + "inputs": { + "activate-cli-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + }, + "assign-activate": { + "inputs": { + "assign-activate-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + }, + "imperative-test-wf": { + "inputs": { + "imperative-test-wf-properties": { + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } + } + } + } + } + } + } + } + }, + "CR": { + }, + "VFC": { + }, + "PNF": { + }, + "Service": { + }, + "CVFC": { + }, + "Service Proxy": { + }, + "Configuration": { + }, + "AllottedResource": { + }, + "VFModule": { + "Vloadbalancerms..vpkg..module-1": { + "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", + "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "min_vf_module_instances": 0, + "vf_module_label": "vpkg", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..vdns..module-3": { + "vfModuleModelInvariantUUID": "4c10ba9b-f88f-415e-9de3-5d33336047fa", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vdns..module-3", + "vfModuleModelUUID": "4fa73b49-8a6c-493e-816b-eb401567b720", + "vfModuleModelCustomizationUUID": "bafcdab0-801d-4d81-9ead-f464640a38b1", + "min_vf_module_instances": 0, + "vf_module_label": "vdns", + "max_vf_module_instances": 50, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..base_template..module-0": { + "vfModuleModelInvariantUUID": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..base_template..module-0", + "vfModuleModelUUID": "63734409-f745-4e4d-a38b-131638a0edce", + "vfModuleModelCustomizationUUID": "86baddea-c730-4fb8-9410-cd2e17fd7f27", + "min_vf_module_instances": 1, + "vf_module_label": "base_template", + "max_vf_module_instances": 1, + "vf_module_type": "Base", + "isBase": true, + "initial_count": 1, + "volume_group": false + }, + "Vloadbalancerms..vlb..module-2": { + "vfModuleModelInvariantUUID": "a772a1f4-0064-412c-833d-4749b15828dd", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vlb..module-2", + "vfModuleModelUUID": "0f5c3f6a-650a-4303-abb6-fff3e573a07a", + "vfModuleModelCustomizationUUID": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806", + "min_vf_module_instances": 0, + "vf_module_label": "vlb", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + } + } +} \ No newline at end of file diff --git a/src/test/resources/tosca/resource-details.json b/src/test/resources/tosca/resource-details.json index dc47b44db..b55adbf52 100644 --- a/src/test/resources/tosca/resource-details.json +++ b/src/test/resources/tosca/resource-details.json @@ -24,33 +24,38 @@ "resource-assignment": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } @@ -58,33 +63,38 @@ "activate": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } @@ -92,33 +102,38 @@ "activate-restconf": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } @@ -126,33 +141,38 @@ "activate-cli": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } @@ -160,33 +180,38 @@ "assign-activate": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } @@ -194,33 +219,38 @@ "imperative-test-wf": { "inputs": { "resource-assignment-properties": { - "request-id": { - "type": "string", - "required": true - }, - "service-instance-id": { - "type": "string", - "required": true - }, - "vnf-id": { - "type": "string", - "required": true - }, - "action-name": { - "type": "string", - "required": true - }, - "scope-type": { - "type": "string", - "required": true - }, - "hostname": { - "type": "string", - "required": true - }, - "vnf_name": { - "type": "string", - "required": true + "type": "object", + "properties": { + "request-id": { + "type": "string", + "required": true, + "input-param": true + }, + "service-instance-id": { + "type": "string", + "required": true, + "input-param": true + }, + "hostname": { + "type": "string", + "required": true, + "input-param": true + }, + "request-info": { + "type": "object", + "properties": { + "prop1": { + "required": true, + "type": "string", + "input-param": true + }, + "prop2": { + "required": true, + "type": "string", + "input-param": true + } + } + } } } } -- cgit 1.2.3-korg