X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=rapp-manager-sme%2Fsrc%2Fmain%2Fjava%2Fcom%2Foransc%2Frappmanager%2Fsme%2Fservice%2FSmeDeployer.java;h=cab3ef8a5741026e53d581e60b5d2212536e68b7;hb=65e1da472f81364372b6c5eccb60b1bcf2ef3976;hp=e1d994369a98305472fe45b80b51e774ce99d225;hpb=a58b2c0d0cfaff779ece990a4bd33d7d10ad576c;p=nonrtric%2Fplt%2Frappmanager.git diff --git a/rapp-manager-sme/src/main/java/com/oransc/rappmanager/sme/service/SmeDeployer.java b/rapp-manager-sme/src/main/java/com/oransc/rappmanager/sme/service/SmeDeployer.java index e1d9943..cab3ef8 100755 --- a/rapp-manager-sme/src/main/java/com/oransc/rappmanager/sme/service/SmeDeployer.java +++ b/rapp-manager-sme/src/main/java/com/oransc/rappmanager/sme/service/SmeDeployer.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START====================================================================== * Copyright (C) 2023 Nordix Foundation. All rights reserved. + * Copyright (C) 2024 OpenInfra Foundation Europe. 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. @@ -88,32 +89,42 @@ public class SmeDeployer implements RappDeployer { @Override public boolean deployRappInstance(Rapp rapp, RappInstance rappInstance) { logger.debug("Deploying SME functions for RappInstance {}", rappInstance.getRappInstanceId()); - if (createProviderDomain(rapp, rappInstance) && createPublishApi(rapp, rappInstance) && createInvoker(rapp, - rappInstance)) { - rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEDEPLOYED); - return true; + if (rappInstance.isSMEEnabled()) { + if ((rappInstance.getSme().getProviderFunction() == null || createProviderDomain(rapp, rappInstance)) && ( + rappInstance.getSme().getServiceApis() == null || createPublishApi(rapp, rappInstance)) && ( + rappInstance.getSme().getInvokers() == null || createInvoker(rapp, rappInstance))) { + rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEDEPLOYED); + return true; + } + rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEDEPLOYFAILED); + rappInstance.setReason("Unable to deploy SME"); + return false; } - rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEDEPLOYFAILED); - rappInstance.setReason("Unable to deploy SME"); - return false; + return true; } @Override public boolean undeployRappInstance(Rapp rapp, RappInstance rappInstance) { logger.debug("Undeploying SME functions for Rapp {}", rapp.getName()); - try { - rappInstance.getSme().getInvokerIds().forEach(this::deleteInvoker); - rappInstance.getSme().getServiceApiIds() - .forEach(s -> deletePublishApi(s, rappInstance.getSme().getApfId())); - rappInstance.getSme().getProviderFunctionIds().forEach(this::deleteProviderFunc); - rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEUNDEPLOYED); - return true; - } catch (Exception e) { - logger.warn("Failed to Undeploy SME functions for Rapp {}", rapp.getName(), e); + if (rappInstance.isSMEEnabled()) { + try { + Optional.ofNullable(rappInstance.getSme().getInvokerIds()) + .ifPresent(invokerList -> invokerList.forEach(this::deleteInvoker)); + Optional.ofNullable(rappInstance.getSme().getServiceApiIds()).ifPresent( + serviceApiList -> serviceApiList.forEach( + s -> deletePublishApi(s, rappInstance.getSme().getApfId()))); + Optional.ofNullable(rappInstance.getSme().getProviderFunctionIds()) + .ifPresent(providerList -> providerList.forEach(this::deleteProviderFunc)); + rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEUNDEPLOYED); + return true; + } catch (Exception e) { + logger.warn("Failed to Undeploy SME functions for Rapp {}", rapp.getName(), e); + } + rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEUNDEPLOYFAILED); + rappInstance.setReason("Unable to undeploy SME"); + return false; } - rappInstanceStateMachine.sendRappInstanceEvent(rappInstance, RappEvent.SMEUNDEPLOYFAILED); - rappInstance.setReason("Unable to undeploy SME"); - return false; + return true; } @Override