Search in sources :

Example 1 with ConfigDeployPropertiesForPnf

use of org.onap.so.client.cds.beans.ConfigDeployPropertiesForPnf in project so by onap.

the class PrepareConfigDeployDelegate method getRequestObject.

@Override
protected String getRequestObject(DelegateExecution delegateExecution) {
    ConfigDeployPropertiesForPnf configDeployProperties = new ConfigDeployPropertiesForPnf();
    configDeployProperties.setServiceInstanceId((String) delegateExecution.getVariable(SERVICE_INSTANCE_ID));
    /**
     * PNF Name matches the name in AAI, i.e., correlationID as in customized workflow.
     */
    configDeployProperties.setPnfName((String) delegateExecution.getVariable(PNF_CORRELATION_ID));
    /**
     * PNF id match AAI entry, i.e, PNF UUID.
     */
    configDeployProperties.setPnfId((String) delegateExecution.getVariable(PNF_UUID));
    configDeployProperties.setPnfCustomizationUuid((String) delegateExecution.getVariable(PRC_CUSTOMIZATION_UUID));
    configDeployProperties.setServiceModelUuid((String) delegateExecution.getVariable(MODEL_UUID));
    setIpAddress(configDeployProperties, delegateExecution);
    ConfigDeployRequestPnf configDeployRequest = new ConfigDeployRequestPnf();
    configDeployRequest.setConfigDeployPropertiesForPnf(configDeployProperties);
    /**
     * Resolution key is the same as PNF name.
     */
    configDeployRequest.setResolutionKey((String) delegateExecution.getVariable(PNF_CORRELATION_ID));
    return configDeployRequest.toString();
}
Also used : ConfigDeployRequestPnf(org.onap.so.client.cds.beans.ConfigDeployRequestPnf) ConfigDeployPropertiesForPnf(org.onap.so.client.cds.beans.ConfigDeployPropertiesForPnf)

Example 2 with ConfigDeployPropertiesForPnf

use of org.onap.so.client.cds.beans.ConfigDeployPropertiesForPnf in project so by onap.

the class PrepareConfigDeployDelegateTest method checkRequestJson.

private void checkRequestJson(String requestObject) {
    try {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode tree = mapper.readTree(requestObject);
        ConfigDeployRequestPnf configDeployRequestPnf = mapper.treeToValue(tree.at("/config-deploy-request"), ConfigDeployRequestPnf.class);
        assertThat(configDeployRequestPnf.getResolutionKey()).matches(TEST_PNF_CORRELATION_ID);
        ConfigDeployPropertiesForPnf properties = configDeployRequestPnf.getConfigDeployPropertiesForPnf();
        assertThat(properties.getServiceInstanceId()).matches(TEST_SERVICE_INSTANCE_ID);
        assertThat(properties.getPnfName()).matches(TEST_PNF_CORRELATION_ID);
        assertThat(properties.getPnfId()).matches(TEST_PNF_UUID);
        assertThat(properties.getPnfCustomizationUuid()).matches(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
        assertThat(properties.getServiceModelUuid()).matches(TEST_MODEL_UUID);
        assertThat(properties.getPnfIpV4Address()).matches(TEST_IPV4_ADDRESS);
        assertThat(properties.getPnfIpV6Address()).matches(TEST_IPV6_ADDRESS);
    } catch (IOException e) {
        e.printStackTrace();
        fail("Check request body is json message" + e.getMessage());
    }
}
Also used : ConfigDeployRequestPnf(org.onap.so.client.cds.beans.ConfigDeployRequestPnf) ConfigDeployPropertiesForPnf(org.onap.so.client.cds.beans.ConfigDeployPropertiesForPnf) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with ConfigDeployPropertiesForPnf

use of org.onap.so.client.cds.beans.ConfigDeployPropertiesForPnf in project so by onap.

the class PrepareConfigDeployDelegate method setIpAddress.

private void setIpAddress(ConfigDeployPropertiesForPnf configDeployProperties, DelegateExecution delegateExecution) {
    /**
     * Retrieve PNF entry from AAI.
     */
    try {
        String pnfName = (String) delegateExecution.getVariable(PNF_CORRELATION_ID);
        Optional<Pnf> pnfOptional = pnfManagement.getEntryFor(pnfName);
        if (pnfOptional.isPresent()) {
            Pnf pnf = pnfOptional.get();
            /**
             * PRH patches the AAI with oam address. Use ipaddress-v4-oam and ipaddress-v6-oam for the config deploy
             * request.
             */
            configDeployProperties.setPnfIpV4Address(pnf.getIpaddressV4Oam());
            configDeployProperties.setPnfIpV6Address(pnf.getIpaddressV6Oam());
        } else {
            exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, "AAI entry for PNF: " + pnfName + " does not exist");
        }
    } catch (IOException e) {
        logger.warn(e.getMessage(), e);
        exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, "Unable to fetch from AAI" + e.getMessage());
    }
}
Also used : ConfigDeployRequestPnf(org.onap.so.client.cds.beans.ConfigDeployRequestPnf) Pnf(org.onap.aai.domain.yang.Pnf) ConfigDeployPropertiesForPnf(org.onap.so.client.cds.beans.ConfigDeployPropertiesForPnf) IOException(java.io.IOException)

Aggregations

ConfigDeployPropertiesForPnf (org.onap.so.client.cds.beans.ConfigDeployPropertiesForPnf)3 ConfigDeployRequestPnf (org.onap.so.client.cds.beans.ConfigDeployRequestPnf)3 IOException (java.io.IOException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Pnf (org.onap.aai.domain.yang.Pnf)1