diff options
author | Lee, Tian (tl5884) <TianL@amdocs.com> | 2018-06-28 17:35:04 +0100 |
---|---|---|
committer | Lee, Tian (tl5884) <TianL@amdocs.com> | 2018-06-28 17:35:04 +0100 |
commit | 80a8e4b685a16ef58603fc487d7c0c2adf427b02 (patch) | |
tree | 3cc1789f15a1908b858876c440c19ea1ef02856e | |
parent | 4036c9aae1965d3fa53956085e9d6f90feb217a8 (diff) |
Support Port Mirroring Configuration model
Add support for Port Mirroring Configuration XML model generation from SDC TOSCA
Change-Id: I44718d20a53e343ee34ae47ef2bc35d49c862ddf
Issue-ID: AAI-1345
Signed-off-by: Lee, Tian (tl5884) <TianL@amdocs.com>
9 files changed, 168 insertions, 1 deletions
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Configuration.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Configuration.java new file mode 100644 index 0000000..20dbea9 --- /dev/null +++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Configuration.java @@ -0,0 +1,28 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 European Software Marketing 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.aai.babel.xml.generator.model; + +import org.onap.aai.babel.xml.generator.types.Cardinality; +import org.onap.aai.babel.xml.generator.types.Model; + +@Model(widget = Widget.Type.CONFIGURATION, cardinality = Cardinality.UNBOUNDED, dataDeleteFlag = true) +public class Configuration extends Resource { +} diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/ConfigurationWidget.java b/src/main/java/org/onap/aai/babel/xml/generator/model/ConfigurationWidget.java new file mode 100644 index 0000000..7822926 --- /dev/null +++ b/src/main/java/org/onap/aai/babel/xml/generator/model/ConfigurationWidget.java @@ -0,0 +1,31 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 European Software Marketing 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.aai.babel.xml.generator.model; + +import org.onap.aai.babel.xml.generator.types.Cardinality; +import org.onap.aai.babel.xml.generator.types.ModelType; +import org.onap.aai.babel.xml.generator.types.ModelWidget; + +@org.onap.aai.babel.xml.generator.types.Model(widget = Widget.Type.CONFIGURATION, cardinality = Cardinality.UNBOUNDED, + dataDeleteFlag = true) +@ModelWidget(type = ModelType.WIDGET, name = "configuration") +public class ConfigurationWidget extends ResourceWidget { +} diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java index 0ee0838..dcd5d15 100644 --- a/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java +++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java @@ -76,6 +76,9 @@ public abstract class Model { case "org.openecomp.resource.vfc.nodes.heat.cinder": modelToBeReturned = new VolumeWidget(); break; + case "org.openecomp.nodes.PortMirroringConfiguration": + modelToBeReturned = new Configuration(); + break; default: modelToBeReturned = null; break; diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java index be58844..7f39438 100644 --- a/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java +++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java @@ -36,7 +36,7 @@ public abstract class Widget extends Model { public static final String GENERATOR_AAI_CONFIGLPROP_NOT_FOUND = "Cannot generate artifacts. Widget configuration not found for %s"; public enum Type { - SERVICE, VF, VFC, VSERVER, VOLUME, FLAVOR, TENANT, VOLUME_GROUP, LINT, L3_NET, VFMODULE, IMAGE, OAM_NETWORK, ALLOTTED_RESOURCE, TUNNEL_XCONNECT; + SERVICE, VF, VFC, VSERVER, VOLUME, FLAVOR, TENANT, VOLUME_GROUP, LINT, L3_NET, VFMODULE, IMAGE, OAM_NETWORK, ALLOTTED_RESOURCE, TUNNEL_XCONNECT, CONFIGURATION; } private Set<String> keys = new HashSet<>(); @@ -80,6 +80,8 @@ public abstract class Widget extends Model { return new AllotedResourceWidget(); case TUNNEL_XCONNECT: return new TunnelXconnectWidget(); + case CONFIGURATION: + return new ConfigurationWidget(); default: return null; } diff --git a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java index 3dd8382..62e9265 100644 --- a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java +++ b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java @@ -63,6 +63,9 @@ public class CsarToXmlConverterTest { ), NO_YAML_FILES( "noYmlFilesArchive.zip" + ), + PORT_MIRROR_CSAR( + "service_PortMirror.csar" ); private String filename; @@ -147,6 +150,18 @@ public class CsarToXmlConverterTest { ga.getPayload(), matches(expectedXmlFiles.get(ga.getName())))); } + @Test + public void generatePortMirrorConfigurationModel() + throws CsarConverterException, IOException, XmlArtifactGenerationException { + Map<String, String> expectedXmlFiles = createExpectedXmlFiles(); + List<BabelArtifact> generatedArtifacts = converter.generateXmlFromCsar(CsarTest.PORT_MIRROR_CSAR.getContent(), + CsarTest.PORT_MIRROR_CSAR.getName(), SERVICE_VERSION); + + generatedArtifacts + .forEach(ga -> assertThat("The content of " + ga.getName() + " must match the expected content", + ga.getPayload(), matches(expectedXmlFiles.get(ga.getName())))); + } + public Matcher<String> matches(final String expected) { return new BaseMatcher<String>() { protected String theExpected = expected; @@ -171,6 +186,8 @@ public class CsarToXmlConverterTest { filesToLoad.add("AAI-SdWanTestVsp..DUMMY..module-0-resource-2.xml"); filesToLoad.add("AAI-Tunnel_XConnTest-resource-2.0.xml"); filesToLoad.add("AAI-SD-WAN-Test-VSP-resource-1.0.xml"); + filesToLoad.add("AAI-Port Mirror_Test-service-1.0.xml"); + filesToLoad.add("AAI-Port Mirroring Configuration-resource-35.0.xml"); for (String filename : filesToLoad) { xmlMap.put(filename, new ArtifactTestUtils().loadResourceAsString("generatedXml/" + filename)); diff --git a/src/test/resources/artifact-generator.properties b/src/test/resources/artifact-generator.properties index 1d7e5fa..74897d6 100644 --- a/src/test/resources/artifact-generator.properties +++ b/src/test/resources/artifact-generator.properties @@ -22,6 +22,9 @@ AAI.model-invariant-id.cloud-region=425b2158-e51d-4509-9945-dad4556474a3 #complex widget details AAI.model-invariant-id.complex=af91c2f7-35fc-43cf-a13d-443f385b2353 AAI.model-version-id.complex=3a8ab1ee-9220-4fe8-b89c-9251d160ddc2 +#configuration widget details +AAI.model-invariant-id.configuration=166c050d-f69d-4305-943e-0bc58c3a26cf +AAI.model-version-id.configuration=5a175add-57e4-4a5d-8b02-c36f1d69c52b #connector widget details AAI.model-version-id.connector=22104c9f-29fd-462f-be07-96cd6b46dd33 AAI.model-invariant-id.connector=4c01c948-7607-4d66-8a6c-99c2c2717936 diff --git a/src/test/resources/compressedArtifacts/service_PortMirror.csar b/src/test/resources/compressedArtifacts/service_PortMirror.csar Binary files differnew file mode 100644 index 0000000..e04a3bc --- /dev/null +++ b/src/test/resources/compressedArtifacts/service_PortMirror.csar diff --git a/src/test/resources/generatedXml/AAI-Port Mirror_Test-service-1.0.xml b/src/test/resources/generatedXml/AAI-Port Mirror_Test-service-1.0.xml new file mode 100644 index 0000000..5653c8a --- /dev/null +++ b/src/test/resources/generatedXml/AAI-Port Mirror_Test-service-1.0.xml @@ -0,0 +1,51 @@ +<model xmlns="http://org.onap.aai.inventory/v13"> + <model-invariant-id>cd674566-ce17-4262-ae99-d526e7b8d47a</model-invariant-id> + <model-type>service</model-type> + <model-vers> + <model-ver> + <model-version-id>e033128a-ab5d-4b69-bfe6-c94f93a34f7c</model-version-id> + <model-name>Port Mirror_Test</model-name> + <model-version>1.0</model-version> + <model-description>Port Mirror_Test</model-description> + <model-elements> + <model-element> + <new-data-del-flag>T</new-data-del-flag> + <cardinality>unbounded</cardinality> + <model-elements> + <model-element> + <new-data-del-flag>T</new-data-del-flag> + <cardinality>unbounded</cardinality> + <model-elements/> + <relationship-list> + <relationship> + <related-to>model-ver</related-to> + <relationship-data> + <relationship-key>model-ver.model-version-id</relationship-key> + <relationship-value>ea4e93c3-1a6d-4314-8165-c284a91422dc</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>model.model-invariant-id</relationship-key> + <relationship-value>cf53c1d6-8708-4b4e-a056-ead7daa57cd5</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </model-element> + </model-elements> + <relationship-list> + <relationship> + <related-to>model-ver</related-to> + <relationship-data> + <relationship-key>model-ver.model-version-id</relationship-key> + <relationship-value>46b92144-923a-4d20-b85a-3cbd847668a9</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>model.model-invariant-id</relationship-key> + <relationship-value>82194af1-3c2c-485a-8f44-420e22a9eaa4</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </model-element> + </model-elements> + </model-ver> + </model-vers> +</model>
\ No newline at end of file diff --git a/src/test/resources/generatedXml/AAI-Port Mirroring Configuration-resource-35.0.xml b/src/test/resources/generatedXml/AAI-Port Mirroring Configuration-resource-35.0.xml new file mode 100644 index 0000000..9418205 --- /dev/null +++ b/src/test/resources/generatedXml/AAI-Port Mirroring Configuration-resource-35.0.xml @@ -0,0 +1,32 @@ +<model xmlns="http://org.onap.aai.inventory/v13"> + <model-invariant-id>cf53c1d6-8708-4b4e-a056-ead7daa57cd5</model-invariant-id> + <model-type>resource</model-type> + <model-vers> + <model-ver> + <model-version-id>ea4e93c3-1a6d-4314-8165-c284a91422dc</model-version-id> + <model-name>Port Mirroring Configuration</model-name> + <model-version>35.0</model-version> + <model-description>A port mirroring configuration object</model-description> + <model-elements> + <model-element> + <new-data-del-flag>T</new-data-del-flag> + <cardinality>unbounded</cardinality> + <model-elements/> + <relationship-list> + <relationship> + <related-to>model-ver</related-to> + <relationship-data> + <relationship-key>model-ver.model-version-id</relationship-key> + <relationship-value>5a175add-57e4-4a5d-8b02-c36f1d69c52b</relationship-value> + </relationship-data> + <relationship-data> + <relationship-key>model.model-invariant-id</relationship-key> + <relationship-value>166c050d-f69d-4305-943e-0bc58c3a26cf</relationship-value> + </relationship-data> + </relationship> + </relationship-list> + </model-element> + </model-elements> + </model-ver> + </model-vers> +</model>
\ No newline at end of file |