diff options
author | waqas.ikram <waqas.ikram@est.tech> | 2019-03-25 19:41:23 +0000 |
---|---|---|
committer | waqas.ikram <waqas.ikram@est.tech> | 2019-03-25 19:41:23 +0000 |
commit | 448899ee55a6cf1c55b5510adceba8b3bab98297 (patch) | |
tree | 33247077dcf4d56e37ed1d5a28081f0c70f9de18 /bpmn/so-bpmn-tasks/src/main/java | |
parent | e2a3995dd8dba9b9a18635ce37e4805dadcdb0fd (diff) |
Added input parameter loading handling from SDNC
Change-Id: I9076d793468db659358c7ef0e7cc859886d7fe17
Issue-ID: SO-1624
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
8 files changed, 492 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java index d03173d0ac..667ac133af 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java @@ -27,6 +27,8 @@ public class Constants { public static final String CREATE_VNF_REQUEST_PARAM_NAME = "createVnfRequest"; public static final String CREATE_VNF_RESPONSE_PARAM_NAME = "createVnfResponse"; + + public static final String INPUT_PARAMETER = "inputParameter"; public static final String DOT = "."; public static final String UNDERSCORE = "_"; @@ -34,6 +36,9 @@ public class Constants { public static final String VNFM_ADAPTER_DEFAULT_URL = "http://so-vnfm-adapter.onap:9092/so/vnfm-adapter/v1/"; public static final String VNFM_ADAPTER_DEFAULT_AUTH = "Basic dm5mbTpwYXNzd29yZDEk"; + + public static final String FORWARD_SLASH = "/"; + public static final String PRELOAD_VNFS_URL = "/restconf/config/VNF-API:preload-vnfs/vnf-preload-list/"; private Constants() {} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java new file mode 100644 index 0000000000..ebb9d521c3 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTask.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; + +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.INPUT_PARAMETER; +import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter; +import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParametersProvider; +import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.NullInputParameter; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This class retrieve input parameters + * + * @author waqas.ikram@est.tech + */ +@Component +public class InputParameterRetrieverTask { + + private static final Logger LOGGER = LoggerFactory.getLogger(InputParameterRetrieverTask.class); + + private final InputParametersProvider inputParametersProvider; + + private final ExtractPojosForBB extractPojosForBB; + + @Autowired + public InputParameterRetrieverTask(final InputParametersProvider inputParametersProvider, + final ExtractPojosForBB extractPojosForBB) { + this.inputParametersProvider = inputParametersProvider; + this.extractPojosForBB = extractPojosForBB; + } + + public void getInputParameters(final BuildingBlockExecution execution) { + try { + LOGGER.debug("Executing getInputParameters ..."); + + final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID); + final InputParameter inputParameter = inputParametersProvider.getInputParameter(vnf); + + LOGGER.debug("inputParameter: {}", inputParameter); + execution.setVariable(INPUT_PARAMETER, inputParameter); + + LOGGER.debug("Finished executing getInputParameters ..."); + } catch (final Exception exception) { + LOGGER.error("Unable to invoke create and instantiation request", exception); + execution.setVariable(INPUT_PARAMETER, NullInputParameter.NULL_INSTANCE); + } + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java index 23ddb6f3f7..4e15474e46 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterCreateVnfTask.java @@ -23,11 +23,14 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_REQUEST_PARAM_NAME; import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREATE_VNF_RESPONSE_PARAM_NAME; import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DOT; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.INPUT_PARAMETER; import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.SPACE; import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.UNDERSCORE; import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter; +import org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.NullInputParameter; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -83,10 +86,14 @@ public class VnfmAdapterCreateVnfTask { final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID); final ModelInfoGenericVnf modelInfoGenericVnf = vnf.getModelInfoGenericVnf(); + final InputParameter inputParameter = getInputParameter(execution); + final CreateVnfRequest createVnfRequest = new CreateVnfRequest(); createVnfRequest.setName(getName(vnf.getVnfName(), modelInfoGenericVnf.getModelInstanceName())); createVnfRequest.setTenant(getTenant(cloudRegion)); + createVnfRequest.setAdditionalParams(inputParameter.getAdditionalParams()); + createVnfRequest.setExternalVirtualLinks(inputParameter.getExtVirtualLinks()); LOGGER.info("CreateVnfRequest : {}", createVnfRequest); @@ -99,6 +106,11 @@ public class VnfmAdapterCreateVnfTask { } } + private InputParameter getInputParameter(final BuildingBlockExecution execution) { + final InputParameter inputParameter = execution.getVariable(INPUT_PARAMETER); + return inputParameter != null ? inputParameter : NullInputParameter.NULL_INSTANCE; + } + /** * Invoke VNFM adapter to create and instantiate VNF * diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java new file mode 100644 index 0000000000..5ade3240a0 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParameter.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.onap.vnfmadapter.v1.model.ExternalVirtualLink; + +/** + * Wrapper class for instance parameters which are based on SOL003 + * + * @author waqas.ikram@est.tech + */ +public class InputParameter implements Serializable { + + private static final long serialVersionUID = 42034634585595304L; + + private Map<String, String> additionalParams = new HashMap<>(); + + private List<ExternalVirtualLink> extVirtualLinks = new ArrayList<>(); + + public InputParameter(final Map<String, String> additionalParams, final List<ExternalVirtualLink> extVirtualLinks) { + this.additionalParams = additionalParams; + this.extVirtualLinks = extVirtualLinks; + } + + /** + * @return the additionalParams + */ + public Map<String, String> getAdditionalParams() { + return additionalParams; + } + + /** + * @return the extVirtualLinks + */ + public List<ExternalVirtualLink> getExtVirtualLinks() { + return extVirtualLinks; + } + + /** + * @param additionalParams the additionalParams to set + */ + public void setAdditionalParams(final Map<String, String> additionalParams) { + this.additionalParams = additionalParams; + } + + /** + * @param extVirtualLinks the extVirtualLinks to set + */ + public void setExtVirtualLinks(final List<ExternalVirtualLink> extVirtualLinks) { + this.extVirtualLinks = extVirtualLinks; + } + + @Override + public String toString() { + return "InputParameter [additionalParams=" + additionalParams + ", extVirtualLinks=" + extVirtualLinks + "]"; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProvider.java new file mode 100644 index 0000000000..55203fb7cc --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProvider.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils; + +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; + +/** + * @author waqas.ikram@est.tech + */ +public interface InputParametersProvider { + + InputParameter getInputParameter(final GenericVnf genericVnf); + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java new file mode 100644 index 0000000000..6027e78d8b --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/InputParametersProviderImpl.java @@ -0,0 +1,161 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils; + +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.FORWARD_SLASH; +import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.PRELOAD_VNFS_URL; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; +import org.onap.so.client.sdnc.SDNCClient; +import org.onap.vnfmadapter.v1.model.ExternalVirtualLink; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.jayway.jsonpath.JsonPath; + +import net.minidev.json.JSONArray; + +/** + * This class retrieve pre-load data from SDNC using <br/> + * <b>GET</b> /config/VNF-API:preload-vnfs/vnf-preload-list/{vnf-name}/{vnf-type} + * + * @author waqas.ikram@est.tech + */ +@Service +public class InputParametersProviderImpl implements InputParametersProvider { + + private static final Logger LOGGER = LoggerFactory.getLogger(InputParametersProviderImpl.class); + + private static final String EXT_VIRTUAL_LINKS = "extVirtualLinks"; + private static final String ADDITIONAL_PARAMS = "additionalParams"; + private static final String VNF_PARAMETERS_PATH = "$..vnf-parameters"; + + private final SDNCClient sdncClient; + + @Autowired + public InputParametersProviderImpl(final SDNCClient sdncClient) { + this.sdncClient = sdncClient; + } + + @Override + public InputParameter getInputParameter(final GenericVnf genericVnf) { + final String vnfName = genericVnf.getVnfName(); + final String vnfType = getVnfType(genericVnf); + final String url = getPreloadVnfsUrl(vnfName, vnfType); + + try { + LOGGER.debug("Will query sdnc for input parameters using url: {}", url); + final String jsonResponse = sdncClient.get(url); + + final JSONArray vnfParametersArray = JsonPath.read(jsonResponse, VNF_PARAMETERS_PATH); + if (vnfParametersArray != null) { + for (int index = 0; index < vnfParametersArray.size(); index++) { + final Object vnfParametersObject = vnfParametersArray.get(index); + if (vnfParametersObject instanceof JSONArray) { + final JSONArray vnfParameters = (JSONArray) vnfParametersObject; + final Map<String, String> vnfParametersMap = getVnfParameterMap(vnfParameters); + return new InputParameter(getAdditionalParameters(vnfParametersMap), + getExtVirtualLinks(vnfParametersMap)); + } + } + } + } catch (final Exception exception) { + LOGGER.error("Unable to retrieve/parse input parameters using URL: {} ", url, exception); + } + LOGGER.warn("No input parameters found ..."); + return NullInputParameter.NULL_INSTANCE; + + } + + private List<ExternalVirtualLink> getExtVirtualLinks(final Map<String, String> vnfParametersMap) + throws JsonParseException, IOException { + try { + final String extVirtualLinksString = vnfParametersMap.get(EXT_VIRTUAL_LINKS); + + if (extVirtualLinksString != null && !extVirtualLinksString.isEmpty()) { + final ObjectMapper mapper = new ObjectMapper(); + final TypeReference<List<ExternalVirtualLink>> extVirtualLinksStringTypeRef = + new TypeReference<List<ExternalVirtualLink>>() {}; + + return mapper.readValue(extVirtualLinksString, extVirtualLinksStringTypeRef); + } + } catch (final Exception exception) { + LOGGER.error("Unable to parse {} ", EXT_VIRTUAL_LINKS, exception); + } + return Collections.emptyList(); + } + + private Map<String, String> getAdditionalParameters(final Map<String, String> vnfParametersMap) + throws JsonParseException, IOException { + try { + final String additionalParamsString = vnfParametersMap.get(ADDITIONAL_PARAMS); + if (additionalParamsString != null && !additionalParamsString.isEmpty()) { + final ObjectMapper mapper = new ObjectMapper(); + final TypeReference<Map<String, String>> typeRef = new TypeReference<Map<String, String>>() {}; + return mapper.readValue(additionalParamsString, typeRef); + } + } catch (final Exception exception) { + LOGGER.error("Unable to parse {} ", ADDITIONAL_PARAMS, exception); + } + return Collections.emptyMap(); + } + + private Map<String, String> getVnfParameterMap(final JSONArray array) { + try { + if (array != null) { + final ObjectMapper mapper = new ObjectMapper(); + final VnfParameter[] readValue = mapper.readValue(array.toJSONString(), VnfParameter[].class); + LOGGER.debug("Vnf parameters: {}", Arrays.asList(readValue)); + return Arrays.asList(readValue).stream() + .filter(vnfParam -> vnfParam.getName() != null && vnfParam.getValue() != null) + .collect(Collectors.toMap(VnfParameter::getName, VnfParameter::getValue)); + } + } catch (final IOException exception) { + LOGGER.error("Unable to parse vnf parameters : {}", array, exception); + } + return Collections.emptyMap(); + } + + private String getPreloadVnfsUrl(final String vnfName, final String vnfType) { + return PRELOAD_VNFS_URL + vnfName + FORWARD_SLASH + vnfType; + } + + private String getVnfType(final GenericVnf genericVnf) { + final ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf(); + if (modelInfoGenericVnf != null && modelInfoGenericVnf.getModelName() != null) { + return modelInfoGenericVnf.getModelName(); + } + return genericVnf.getVnfType(); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameter.java new file mode 100644 index 0000000000..fb877ac55d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/NullInputParameter.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils; + +import java.util.Collections; + +/** + * @author waqas.ikram@est.tech + */ +public class NullInputParameter extends InputParameter { + + private static final long serialVersionUID = -7261286746726871696L; + + public static final NullInputParameter NULL_INSTANCE = new NullInputParameter(); + + private NullInputParameter() { + super(Collections.emptyMap(), Collections.emptyList()); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java new file mode 100644 index 0000000000..11e93e733d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Ericsson. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * This is used to deserialize vnf-parameters from vnf-preload-list/{vnf-name}/{vnf-type} response + * + * @author waqas.ikram@est.tech + */ +public class VnfParameter { + + @JsonProperty("vnf-parameter-name") + private String name; + + @JsonProperty("vnf-parameter-value") + private String value; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(final String name) { + this.name = name; + } + + /** + * @return the value + */ + public String getValue() { + return value; + } + + /** + * @param value the value to set + */ + public void setValue(final String value) { + this.value = value; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return Objects.hash(name, value); + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof VnfParameter) { + VnfParameter other = (VnfParameter) obj; + return Objects.equals(name, other.name) && Objects.equals(value, other.value); + } + + return false; + } + + @Override + public String toString() { + return "VnfParameter [name=" + name + ", value=" + value + "]"; + } + +} |