diff options
37 files changed, 1526 insertions, 2633 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java index 23230071c7..0af0e9422b 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java @@ -26,13 +26,10 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.annotate.JsonRootName; -import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; @@ -165,25 +162,23 @@ public class CloudConfig { return null; } - protected synchronized void reloadPropertiesFile() throws JsonParseException, JsonMappingException, IOException, MsoCloudIdentityNotFound { + protected synchronized void reloadPropertiesFile() throws IOException, MsoCloudIdentityNotFound { this.loadCloudConfig(this.configFilePath, this.refreshTimerInMinutes); } protected synchronized void loadCloudConfig(String configFile, int refreshTimer) - throws JsonParseException, JsonMappingException, IOException, MsoCloudIdentityNotFound { + throws IOException, MsoCloudIdentityNotFound { FileReader reader = null; configFilePath = configFile; this.refreshTimerInMinutes = refreshTimer; - - CloudConfig cloudConfig = null; this.validCloudConfig=false; try { reader = new FileReader(configFile); // Parse the JSON input into a CloudConfig - cloudConfig = mapper.readValue(reader, CloudConfig.class); + CloudConfig cloudConfig = mapper.readValue(reader, CloudConfig.class); this.cloudSites = cloudConfig.cloudSites; this.identityServices = cloudConfig.identityServices; diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java index 0f15dea577..d0ba7e09fc 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudIdentity.java @@ -26,26 +26,17 @@ package org.openecomp.mso.cloud; import java.io.IOException; import java.net.URISyntaxException; import java.security.GeneralSecurityException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.JsonSerializer; -import org.codehaus.jackson.JsonGenerator; -import org.codehaus.jackson.map.SerializerProvider; import org.codehaus.jackson.map.annotate.JsonDeserialize; import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.JsonProcessingException; - import org.openecomp.mso.openstack.exceptions.MsoAdapterException; import org.openecomp.mso.openstack.exceptions.MsoException; -import org.openecomp.mso.openstack.utils.MsoCommonUtils; import org.openecomp.mso.openstack.utils.MsoKeystoneUtils; import org.openecomp.mso.openstack.utils.MsoTenantUtils; import org.openecomp.mso.openstack.utils.MsoTenantUtilsFactory; import org.openecomp.mso.cloud.authentication.AuthenticationMethodFactory; import org.openecomp.mso.cloud.authentication.AuthenticationWrapper; -import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication; import org.openecomp.mso.cloud.authentication.wrappers.RackspaceAPIKeyWrapper; import org.openecomp.mso.cloud.authentication.wrappers.UsernamePasswordWrapper; import org.openecomp.mso.logger.MessageEnum; @@ -137,14 +128,6 @@ public class CloudIdentity { this.id = id; } - //DEPRECATED - public String getKeystoneUrl () throws MsoException { - if (this.identityServerType.equals(IdentityServerType.KEYSTONE)) - return this.identityUrl; - else - return null; - } - public String getKeystoneUrl (String regionId, String msoPropID) throws MsoException { if (IdentityServerType.KEYSTONE.equals(this.identityServerType)) { return this.identityUrl; diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java index 7e4eced884..dcd8de79aa 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java @@ -22,17 +22,15 @@ package org.openecomp.mso.cloud; import java.io.IOException;
import org.codehaus.jackson.JsonParser;
-import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.JsonToken;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;
-import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
public class IdentityAuthenticationTypeJsonDeserializer extends JsonDeserializer<IdentityAuthenticationTypeAbstract> {
@Override
public IdentityAuthenticationTypeAbstract deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
- throws IOException, JsonProcessingException {
+ throws IOException {
JsonToken token = jsonParser.getCurrentToken();
if (JsonToken.VALUE_STRING.equals(token)) {
return IdentityAuthenticationTypeAbstract.valueOf(jsonParser.getText());
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java index 6e030a9262..bb8a3f1fd9 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java @@ -24,18 +24,15 @@ package org.openecomp.mso.cloud; import java.io.IOException;
import org.codehaus.jackson.JsonParser;
-import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.JsonToken;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;
-import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
-
public class IdentityServerTypeJsonDeserializer extends JsonDeserializer<IdentityServerTypeAbstract> {
@Override
public IdentityServerTypeAbstract deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
- throws IOException, JsonProcessingException {
+ throws IOException {
JsonToken token = jsonParser.getCurrentToken();
if (JsonToken.VALUE_STRING.equals(token)) {
return IdentityServerTypeAbstract.valueOf(jsonParser.getText());
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java index 600f88b7bd..a05d0b8872 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java @@ -22,17 +22,14 @@ package org.openecomp.mso.cloud; import java.io.IOException;
import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
-import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
-
public class IdentityServerTypeJsonSerializer extends JsonSerializer<IdentityServerTypeAbstract> {
@Override
public void serialize(IdentityServerTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
- throws IOException, JsonProcessingException {
+ throws IOException {
jsonGenerator.writeObject(tmpObj.toString());
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java index 8236307f45..85cb2967d6 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java @@ -39,10 +39,7 @@ import com.woorea.openstack.keystone.model.Authentication; public final class AuthenticationMethodFactory {
private static Map<String, AuthenticationWrapper> authWrappers = new ConcurrentHashMap<>();
-
- /**
- *
- */
+
private AuthenticationMethodFactory() {}
/**
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/models/RackspaceAuthentication.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/models/RackspaceAuthentication.java index 2b8da9f641..c96b809ff9 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/models/RackspaceAuthentication.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/models/RackspaceAuthentication.java @@ -23,7 +23,6 @@ package org.openecomp.mso.cloud.authentication.models; -import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.annotate.JsonRootName; import com.woorea.openstack.keystone.model.Authentication; @@ -31,17 +30,8 @@ import com.woorea.openstack.keystone.model.Authentication; @JsonRootName("auth") public class RackspaceAuthentication extends Authentication { - /** - * - */ private static final long serialVersionUID = 5451283386875662918L; - @JsonIgnore - private String tenantId; - - @JsonIgnore - private String tenantName; - public static final class Token { private String username; diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java index fe380b27b9..7e21d9d15a 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java @@ -20,29 +20,22 @@ package org.openecomp.mso.openstack.exceptions; - /** - * Cloud site not found exception. + * Signals that an attempt to find a specific mso cloud identity has failed. */ public class MsoCloudIdentityNotFound extends MsoException { - /** - * Serialization id. - */ private static final long serialVersionUID = 2583769056266415665L; + /** * Default constructor (needed for BPEL/JAXB) */ public MsoCloudIdentityNotFound () { super("Cloud Identity not found"); super.category=MsoExceptionCategory.USERDATA; - } - - /** - * Constructor to create a new MsoOpenstackException instance - * @param cloudSite the cloud site - */ + } + public MsoCloudIdentityNotFound (String cloudIdentity) { // Set the detailed error as the Exception 'message' super("Cloud Identity [" + cloudIdentity + "] not found"); diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java index 17a5d55698..7c6e98d55f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java @@ -20,15 +20,11 @@ package org.openecomp.mso.openstack.exceptions; - /** - * Cloud site not found exception. + * Signals that an attempt to find a specific mso cloud site has failed. */ public class MsoCloudSiteNotFound extends MsoException { - /** - * Serialization id. - */ private static final long serialVersionUID = 2583769056266415664L; /** @@ -38,11 +34,7 @@ public class MsoCloudSiteNotFound extends MsoException { super("Cloud site not found"); super.category=MsoExceptionCategory.USERDATA; } - - /** - * Constructor to create a new MsoOpenstackException instance - * @param cloudSite the cloud site - */ + public MsoCloudSiteNotFound (String cloudSite) { // Set the detailed error as the Exception 'message' super("Cloud Site [" + cloudSite + "] not found"); diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java index 49d3a267a0..7a597d6f4d 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java @@ -7,9 +7,9 @@ * 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. @@ -20,16 +20,13 @@ package org.openecomp.mso.openstack.exceptions; - - public class MsoTenantAlreadyExists extends MsoOpenstackException { private static final long serialVersionUID = 1L; - // Constructor to create a new MsoOpenstackException instance public MsoTenantAlreadyExists (String tenant, String cloud) { // Set the detailed error as the Exception 'message' super(409, "Conflict", "Tenant " + tenant + " already exists in Cloud " + cloud); } - + } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/CloudConfigInitializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/CloudConfigInitializer.java deleted file mode 100644 index 43a6171699..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/CloudConfigInitializer.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.openstack.utils; - - -import javax.ejb.EJB; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import javax.servlet.annotation.WebListener; - -import org.openecomp.mso.cloud.CloudConfigFactory; -import org.openecomp.mso.cloud.CloudConfigIdentityMapper; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -/** - * This class will attempt to initialize Cloud Config when part of a web application. - * - * - * - */ -@WebListener -public class CloudConfigInitializer implements ServletContextListener -{ - - private CloudConfigFactory cloudConfigFactory=new CloudConfigFactory(); - - public CloudConfigInitializer () { - } - - @Override - public void contextDestroyed(ServletContextEvent event) { - // Nothing to do... - } - - - @Override - public void contextInitialized(ServletContextEvent event) - { - - // Note - this logger may be before or after MSO Logging configuration applied - MsoLogger initLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - try { - // Look first in the init-parameters - String msoPropConfigParam = event.getServletContext().getInitParameter("mso.cloud_config.configuration"); - - String[] configFileSplit = msoPropConfigParam.split(","); - for (String msoPropConfig:configFileSplit) { - String[] msoPropDecoded = msoPropConfig.split("="); - - try { - cloudConfigFactory.initializeCloudConfig(msoPropDecoded[0], Integer.valueOf(msoPropDecoded[1])); - initLogger.info(MessageEnum.RA_CONFIG_LOAD, msoPropDecoded[0], "", ""); - initLogger.debug("Mso properties successfully loaded:"+msoPropDecoded[0]+"(Timer(mins):"+Integer.valueOf(msoPropDecoded[1])); - } catch (NumberFormatException ne) { - initLogger.error(MessageEnum.RA_CONFIG_EXC, msoPropDecoded[0] + ". MSO Properties failed due to conversion error (in web.xml file)", "", "", MsoLogger.ErrorCode.DataError, "MSO Properties failed due to conversion error (in web.xml file)", ne); - } - } - - // Second, obtain class name that will register all mappings - String msoMapperClassParam = event.getServletContext().getInitParameter("mso.cloud_config.mapper.class"); - if (msoMapperClassParam != null) { - Class<?> mapperClass = Class.forName(msoMapperClassParam); - if (CloudConfigIdentityMapper.class.isAssignableFrom(mapperClass)) { - ((CloudConfigIdentityMapper)mapperClass.newInstance()).registerAllMappings(); - initLogger.info(MessageEnum.RA_CONFIG_LOAD,msoMapperClassParam+"(Openstack authentication mapper class)","",""); - } else { - initLogger.info(MessageEnum.RA_CONFIG_LOAD,msoMapperClassParam+"(Openstack authentication mapper class not an implementation of CloudConfigIdentityMapper)","",""); - } - } else { - initLogger.info(MessageEnum.RA_CONFIG_LOAD,"Openstack authentication mapper class not specified in web.xml (ONLY core authentication mechanisms will be loaded)","",""); - } - - } - catch (Exception e) { - initLogger.error(MessageEnum.RA_CONFIG_EXC, "Unknown. MSO Properties failed to initialize completely", "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception - MSO Properties failed to initialize completely", e); - } - } -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java index e47dea6350..269f6b0cdf 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java @@ -40,14 +40,12 @@ import com.woorea.openstack.quantum.model.NeutronError; public class MsoCommonUtils { - private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); - protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); - - protected static String retryDelayProp = "ecomp.mso.adapters.po.retryDelay"; + private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + protected static String retryDelayProp = "ecomp.mso.adapters.po.retryDelay"; protected static String retryCountProp = "ecomp.mso.adapters.po.retryCount"; protected static String retryCodesProp = "ecomp.mso.adapters.po.retryCodes"; - - protected static int retryDelayDefault = 5; + protected static int retryDelayDefault = 5; protected static int retryCountDefault = 3; protected static String retryCodesDefault = "504"; @@ -81,7 +79,6 @@ public class MsoCommonUtils { } } - long start = System.currentTimeMillis (); String requestType; if (request.getClass ().getEnclosingClass () != null) { requestType = request.getClass ().getEnclosingClass ().getSimpleName () + "." @@ -308,7 +305,7 @@ public class MsoCommonUtils { public static boolean isNullOrEmpty (String s) { return s == null || s.isEmpty(); } - - + + } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java index 8e35e39b22..ee89840c50 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java @@ -26,8 +26,6 @@ import java.util.Calendar; import java.util.HashMap; import java.util.Map; -import org.openecomp.mso.cloud.CloudConfig; -import org.openecomp.mso.cloud.CloudConfigFactory; import org.openecomp.mso.cloud.CloudIdentity; import org.openecomp.mso.cloud.CloudSite; import org.openecomp.mso.logger.MsoAlarmLogger; @@ -39,9 +37,6 @@ import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; import org.openecomp.mso.openstack.exceptions.MsoException; import org.openecomp.mso.openstack.exceptions.MsoOpenstackException; import org.openecomp.mso.openstack.exceptions.MsoTenantAlreadyExists; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesException; -import org.openecomp.mso.properties.MsoPropertiesFactory; import com.woorea.openstack.base.client.OpenStackBaseException; import com.woorea.openstack.base.client.OpenStackConnectException; import com.woorea.openstack.base.client.OpenStackRequest; @@ -87,7 +82,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { * <p> * * @param tenantName The tenant name to create - * @param cloudId The cloud identifier (may be a region) in which to create the tenant. + * @param cloudSiteId The cloud identifier (may be a region) in which to create the tenant. * @return the tenant ID of the newly created tenant * @throws MsoTenantAlreadyExists Thrown if the requested tenant already exists * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception @@ -200,7 +195,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { * @return the tenant properties of the queried tenant, or null if not found * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception */ - public MsoTenant queryTenant (String tenantId, String cloudSiteId) throws MsoException, MsoCloudSiteNotFound { + public MsoTenant queryTenant (String tenantId, String cloudSiteId) throws MsoException { // Obtain the cloud site information where we will query the tenant CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); if (cloudSite == null) { @@ -679,11 +674,11 @@ public class MsoKeystoneUtils extends MsoTenantUtils { * This may be useful if cached credentials get out of sync. */ public static void adminCacheReset () { - adminClientCache = new HashMap <String, KeystoneCacheEntry> (); + adminClientCache = new HashMap<>(); } @Override - public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity) throws MsoException { + public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity) { return cloudIdentity.getIdentityUrl(); } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java index be49cd947f..a659fb629e 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java @@ -24,19 +24,14 @@ import org.openecomp.mso.cloud.CloudConfig; import org.openecomp.mso.cloud.CloudConfigFactory; import org.openecomp.mso.cloud.CloudIdentity; import org.openecomp.mso.cloud.CloudSite; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJavaProperties; import java.lang.reflect.InvocationTargetException; public class MsoTenantUtilsFactory { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); - private CloudConfigFactory cloudConfigFactory= new CloudConfigFactory(); - protected CloudConfig cloudConfig; - protected MsoJavaProperties msoProps = null; + private CloudConfig cloudConfig; private String msoPropID; public MsoTenantUtilsFactory (String msoPropID) { diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java index 4d9b64e920..dd1b396fae 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java @@ -35,12 +35,8 @@ import org.openecomp.mso.cloud.CloudIdentity; import org.openecomp.mso.cloud.CloudSite; import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; - - /** * This class implements test methods of the CloudConfig features. - * - * */ public class CloudConfigTest { @@ -110,37 +106,29 @@ public class CloudConfigTest { CloudIdentity identity3 = identityMap.get("MTINJVCC101_DCP"); CloudIdentity identity4 = identityMap.get("MTSNJA3DCP1"); -// assertEquals (identity1.getKeystoneUrl(), "http://localhost:5000/v2.0"); -// assertEquals (identity1.getIdentityUrl(), "http://localhost:5000/v2.0"); - assertEquals (identity1.getMsoId(), "john"); - assertEquals (identity1.getMsoPass(), "changeme"); - assertEquals (identity1.getAdminTenant(), "admin"); - assertEquals (identity1.getMemberRole(), "_member_"); - assertEquals (identity1.hasTenantMetadata(), false); - -// assertEquals (identity2.getKeystoneUrl(), "http://localhost:5000/v2.0"); -// assertEquals (identity2.getIdentityUrl(), "http://localhost:5000/v2.0"); - assertEquals (identity2.getMsoId(), "mockId"); - assertEquals (identity2.getMsoPass(), "stack123"); - assertEquals (identity2.getAdminTenant(), "service"); - assertEquals (identity2.getMemberRole(), "_member_"); - assertEquals (identity2.hasTenantMetadata(), false); - -// assertEquals (identity3.getKeystoneUrl(), "http://localhost:5000/v2.0"); -// assertEquals (identity3.getIdentityUrl(), "http://localhost:5000/v2.0"); - assertEquals (identity3.getMsoId(), "mockIdToo"); - assertEquals (identity3.getMsoPass(), "AICG@mm@@2015"); - assertEquals (identity3.getAdminTenant(), "service"); - assertEquals (identity3.getMemberRole(), "admin"); - assertEquals (identity3.hasTenantMetadata(), true); - -// assertEquals (identity4.getKeystoneUrl(), "https://localhost:5000/v2.0"); -// assertEquals (identity4.getIdentityUrl(), "https://localhost:5000/v2.0"); - assertEquals (identity4.getMsoId(), "mockIdToo"); - assertEquals (identity4.getMsoPass(), "2315QRS2015srq"); - assertEquals (identity4.getAdminTenant(), "service"); - assertEquals (identity4.getMemberRole(), "admin"); - assertEquals (identity4.hasTenantMetadata(), true); + assertEquals("john", identity1.getMsoId()); + assertEquals("changeme", identity1.getMsoPass()); + assertEquals("admin", identity1.getAdminTenant()); + assertEquals("_member_", identity1.getMemberRole()); + assertEquals(false, identity1.hasTenantMetadata()); + + assertEquals("mockId", identity2.getMsoId()); + assertEquals("stack123", identity2.getMsoPass()); + assertEquals("service", identity2.getAdminTenant()); + assertEquals("_member_", identity2.getMemberRole()); + assertEquals(false, identity2.hasTenantMetadata()); + + assertEquals("mockIdToo", identity3.getMsoId()); + assertEquals("AICG@mm@@2015", identity3.getMsoPass()); + assertEquals("service", identity3.getAdminTenant()); + assertEquals("admin", identity3.getMemberRole()); + assertEquals(true, identity3.hasTenantMetadata()); + + assertEquals("mockIdToo", identity4.getMsoId()); + assertEquals("2315QRS2015srq", identity4.getMsoPass()); + assertEquals("service", identity4.getAdminTenant()); + assertEquals("admin", identity4.getMemberRole()); + assertEquals(true, identity4.hasTenantMetadata()); } @@ -162,8 +150,6 @@ public class CloudConfigTest { public final void testGetIdentityService () { CloudIdentity identity1 = con.getIdentityService("MT_KEYSTONE"); assertNotNull(identity1); -// assertEquals (identity1.getKeystoneUrl(), "http://localhost:5000/v2.0"); -// assertEquals (identity1.getIdentityUrl(), "http://localhost:5000/v2.0"); assertEquals (identity1.getMsoId(), "john"); assertEquals (identity1.getMsoPass(), "changeme"); assertEquals (identity1.getAdminTenant(), "admin"); diff --git a/adapters/mso-adapters-rest-interface/pom.xml b/adapters/mso-adapters-rest-interface/pom.xml index f10500d2ca..bbf614a644 100644 --- a/adapters/mso-adapters-rest-interface/pom.xml +++ b/adapters/mso-adapters-rest-interface/pom.xml @@ -54,5 +54,11 @@ <version>1.10.19</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <version>3.8.0</version> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java index f51cb0dd64..2a3a64ce1b 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/json/MapDeserializer.java @@ -21,7 +21,6 @@ package org.openecomp.mso.adapters.json; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonProcessingException; import org.codehaus.jackson.map.DeserializationContext; import org.codehaus.jackson.map.JsonDeserializer; import org.codehaus.jackson.map.ObjectMapper; @@ -48,27 +47,22 @@ import java.util.Map; * </pre> */ public class MapDeserializer extends JsonDeserializer<Map<String, String>> { + @Override public Map<String, String> deserialize(JsonParser parser, - DeserializationContext context) throws IOException, - JsonProcessingException { + DeserializationContext context) throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode tree = mapper.readTree(parser); - Map<String, String> map = new LinkedHashMap<>(); - Iterator<JsonNode> iterator = tree.iterator(); - - while (iterator.hasNext()) { - JsonNode element = iterator.next(); - Iterator<JsonNode> arrayIterator = element.iterator(); - while (arrayIterator.hasNext()) { - JsonNode arrayElement = arrayIterator.next(); + if (tree == null) + return map; + for (JsonNode element : tree) { + for (JsonNode arrayElement : element) { String key = arrayElement.get("key").getTextValue(); String value = arrayElement.get("value").getTextValue(); map.put(key, value); } } - return map; } } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java index 83c31336bb..2d359e059f 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/RollbackTenantError.java @@ -37,10 +37,6 @@ public class RollbackTenantError implements Serializable { public RollbackTenantError () {} - public RollbackTenantError (String message) { - this.message = message; - } - public RollbackTenantError (String message, MsoExceptionCategory category, boolean rolledBack) { this.message = message; this.category = category; diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java index d7b02e028a..c5105aa683 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/tenantrest/TenantExceptionResponse.java @@ -20,8 +20,6 @@ package org.openecomp.mso.adapters.tenantrest; - - import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; import java.io.Serializable; import javax.xml.bind.annotation.XmlRootElement; @@ -39,10 +37,6 @@ public class TenantExceptionResponse implements Serializable { public TenantExceptionResponse () {} - public TenantExceptionResponse (String message) { - this.message = message; - } - public TenantExceptionResponse (String message, MsoExceptionCategory category, boolean rolledBack) { this.message = message; this.category = category; diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java index 1a8dfc77ba..00c853ba0d 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java @@ -7,9 +7,9 @@ * 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.
@@ -21,102 +21,14 @@ package org.openecomp.mso.adapters;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashMap;
-
import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.JsonParser;
-import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.SerializerProvider;
import org.junit.Test;
import org.mockito.Mockito;
-import org.openecomp.mso.adapters.json.MapDeserializer;
import org.openecomp.mso.adapters.json.MapSerializer;
-import org.openecomp.mso.adapters.nwrest.ContrailNetwork;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkError;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.DeleteNetworkError;
-import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.NetworkExceptionResponse;
-import org.openecomp.mso.adapters.nwrest.NetworkRequestCommon;
-import org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork;
-import org.openecomp.mso.adapters.nwrest.QueryNetworkError;
-import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.RollbackNetworkError;
-import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkError;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse;
-import org.openecomp.mso.adapters.sdncrest.RequestInformation;
-import org.openecomp.mso.adapters.sdncrest.SDNCErrorCommon;
-import org.openecomp.mso.adapters.sdncrest.SDNCEvent;
-import org.openecomp.mso.adapters.sdncrest.SDNCRequestCommon;
-import org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon;
-import org.openecomp.mso.adapters.sdncrest.SDNCServiceError;
-import org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest;
-import org.openecomp.mso.adapters.sdncrest.SDNCServiceResponse;
-import org.openecomp.mso.adapters.sdncrest.ServiceInformation;
-import org.openecomp.mso.adapters.tenantrest.CreateTenantError;
-import org.openecomp.mso.adapters.tenantrest.CreateTenantRequest;
-import org.openecomp.mso.adapters.tenantrest.CreateTenantResponse;
-import org.openecomp.mso.adapters.tenantrest.DeleteTenantError;
-import org.openecomp.mso.adapters.tenantrest.DeleteTenantRequest;
-import org.openecomp.mso.adapters.tenantrest.DeleteTenantResponse;
-import org.openecomp.mso.adapters.tenantrest.HealthCheckHandler;
-import org.openecomp.mso.adapters.tenantrest.QueryTenantError;
-import org.openecomp.mso.adapters.tenantrest.QueryTenantResponse;
-import org.openecomp.mso.adapters.tenantrest.RollbackTenantError;
-import org.openecomp.mso.adapters.tenantrest.RollbackTenantRequest;
-import org.openecomp.mso.adapters.tenantrest.RollbackTenantResponse;
-import org.openecomp.mso.adapters.tenantrest.TenantExceptionResponse;
-import org.openecomp.mso.adapters.tenantrest.TenantRequestCommon;
-import org.openecomp.mso.adapters.tenantrest.TenantRollback;
-import org.openecomp.mso.adapters.vnfrest.CreateVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.CreateVfModuleResponse;
-import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleResponse;
-import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.QueryVfModuleResponse;
-import org.openecomp.mso.adapters.vnfrest.QueryVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleResponse;
-import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleResponse;
-import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupRequest;
-import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupResponse;
-import org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse;
-import org.openecomp.mso.adapters.vnfrest.VfModuleRollback;
-import org.openecomp.mso.adapters.vnfrest.VfRequestCommon;
-import org.openecomp.mso.adapters.vnfrest.VfResponseCommon;
-import org.openecomp.mso.adapters.vnfrest.VolumeGroupExceptionResponse;
-import org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
-import org.openecomp.mso.openstack.beans.Subnet;
-import org.openecomp.mso.openstack.beans.VnfRollback;
-import org.openecomp.mso.openstack.beans.VnfStatus;
public class AdapterRestInterfaceTest {
- @Test(expected = Exception.class)
- public final void mapDeserializerTest() {
- MapDeserializer mapDeserializer = new MapDeserializer();
- JsonParser jsonParser = Mockito.mock(JsonParser.class);
- DeserializationContext deserializationContext = Mockito
- .mock(DeserializationContext.class);
- try {
- mapDeserializer.deserialize(jsonParser, deserializationContext);
- } catch (IOException e) {
- }
- }
@Test
public final void mapSerializerTest() {
@@ -128,960 +40,9 @@ public class AdapterRestInterfaceTest { SerializerProvider serializerProvider = Mockito
.mock(SerializerProvider.class);
try {
- mapSerializer.serialize(new HashMap<String, String>(),
- jsonGenerator, serializerProvider);
+ mapSerializer.serialize(new HashMap(), jsonGenerator, serializerProvider);
} catch (IOException e) {
}
}
- /**
- * Test case for coverage
- */
- @Test
- public final void contrailNetworkPOJOTest() {
- try {
- ContrailNetwork contrailNetwork = new ContrailNetwork();
- ContrailNetwork contrailNetwork2 = new ContrailNetwork("", "",
- new ArrayList<String>(), new ArrayList<String>(),
- new ArrayList<String>());
- contrailNetwork.getExternal();
- contrailNetwork.setExternal("external");
- contrailNetwork.setPolicyFqdns(new ArrayList<String>());
- contrailNetwork.setRouteTableFqdns(new ArrayList<String>());
- contrailNetwork.setRouteTargets(new ArrayList<String>());
- contrailNetwork.setShared("shared");
- contrailNetwork.getShared();
- contrailNetwork.getPolicyFqdns();
- contrailNetwork.getRouteTableFqdns();
- contrailNetwork.getRouteTargets();
-
- UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
- updateNetworkRequest.setBackout(false);
- updateNetworkRequest.setCloudSiteId("cloudSiteId");
- updateNetworkRequest.setContrailNetwork(new ContrailNetwork());
- updateNetworkRequest.setMessageId("messageId");
- updateNetworkRequest
- .setModelCustomizationUuid("modelCustomizationUuid");
- updateNetworkRequest.setMsoRequest(new MsoRequest());
- updateNetworkRequest.setNetworkId("networkId");
- updateNetworkRequest.setNetworkName("networkName");
- updateNetworkRequest
- .setNetworkParams(new HashMap<String, String>());
- updateNetworkRequest.setNetworkStackId("networkStackId");
- updateNetworkRequest.setNetworkTechnology("networkTechnology");
- updateNetworkRequest.setNetworkType("networkType");
- updateNetworkRequest.setNetworkTypeVersion("networkTypeVersion");
- updateNetworkRequest.setNotificationUrl("notificationUrl");
- updateNetworkRequest
- .setProviderVlanNetwork(new ProviderVlanNetwork());
- updateNetworkRequest.setSkipAAI(true);
- updateNetworkRequest.setSubnets(new ArrayList<Subnet>());
- updateNetworkRequest.setTenantId("tenantId");
- updateNetworkRequest.isContrailRequest();
- updateNetworkRequest.getCloudSiteId();
- updateNetworkRequest.getContrailNetwork();
- updateNetworkRequest.getMessageId();
- updateNetworkRequest.getNetworkId();
- updateNetworkRequest.getModelCustomizationUuid();
- updateNetworkRequest.getMsoRequest();
- updateNetworkRequest.getNetworkName();
- updateNetworkRequest.getNetworkParams();
- updateNetworkRequest.getNetworkStackId();
- updateNetworkRequest.getNetworkTechnology();
- updateNetworkRequest.getNetworkType();
- updateNetworkRequest.getNetworkTypeVersion();
- updateNetworkRequest.getNotificationUrl();
- updateNetworkRequest.getProviderVlanNetwork();
- updateNetworkRequest.getSkipAAI();
- updateNetworkRequest.getSubnets();
- updateNetworkRequest.getTenantId();
- updateNetworkRequest.getBackout();
-
- CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
- createNetworkRequest.setBackout(false);
- createNetworkRequest.setCloudSiteId("cloudSiteId");
- createNetworkRequest.setContrailNetwork(new ContrailNetwork());
- createNetworkRequest.setFailIfExists(false);
- createNetworkRequest.setMessageId("messageId");
- createNetworkRequest
- .setModelCustomizationUuid("modelCustomizationUuid");
- createNetworkRequest.setMsoRequest(new MsoRequest());
- createNetworkRequest.setNetworkId("networkId");
- createNetworkRequest.setNetworkName("networkName");
- createNetworkRequest.setNetworkType("networkType");
- createNetworkRequest.setNetworkTypeVersion("networkTypeVersion");
- createNetworkRequest.setNotificationUrl("notificationUrl");
- createNetworkRequest
- .setProviderVlanNetwork(new ProviderVlanNetwork());
- createNetworkRequest.setSkipAAI(true);
- createNetworkRequest.setSubnets(new ArrayList<Subnet>());
- createNetworkRequest.setTenantId("tenantId");
- createNetworkRequest
- .setNetworkParams(new HashMap<String, String>());
- createNetworkRequest.setNetworkTechnology("VMWARE");
- createNetworkRequest.getBackout();
- createNetworkRequest.getCloudSiteId();
- createNetworkRequest.getContrailNetwork();
- createNetworkRequest.getFailIfExists();
- createNetworkRequest.getMessageId();
- createNetworkRequest.getModelCustomizationUuid();
- createNetworkRequest.getMsoRequest();
- createNetworkRequest.getNetworkId();
- createNetworkRequest.getNetworkName();
- createNetworkRequest.getNetworkParams();
- createNetworkRequest.getNetworkTechnology();
- createNetworkRequest.getNetworkType();
- createNetworkRequest.getNetworkTypeVersion();
- createNetworkRequest.getNotificationUrl();
- createNetworkRequest.getProviderVlanNetwork();
- createNetworkRequest.getSkipAAI();
- createNetworkRequest.getSubnets();
- createNetworkRequest.getTenantId();
- createNetworkRequest.isContrailRequest();
-
- QueryNetworkResponse queryNetworkResponse = new QueryNetworkResponse();
- QueryNetworkResponse queryNetworkResponse2 = new QueryNetworkResponse(
- "", "", "", NetworkStatus.ACTIVE,
- new HashMap<String, String>());
- queryNetworkResponse.setNetworkExists(true);
- queryNetworkResponse.setNetworkId("networkId");
- queryNetworkResponse
- .setNetworkOutputs(new HashMap<String, String>());
- queryNetworkResponse.setNetworkStackId("networkStackId");
- queryNetworkResponse.setNetworkStatus(NetworkStatus.ACTIVE);
- queryNetworkResponse.setNeutronNetworkId("neutronNetworkId");
- queryNetworkResponse.setRouteTargets(new ArrayList<String>());
- queryNetworkResponse.setSubnetIdMap(new HashMap<String, String>());
- queryNetworkResponse.setVlans(new ArrayList<Integer>());
- queryNetworkResponse.getNetworkExists();
- queryNetworkResponse.getNetworkId();
- queryNetworkResponse.getNetworkOutputs();
- queryNetworkResponse.getNetworkStackId();
- queryNetworkResponse.getNetworkStatus();
- queryNetworkResponse.getNeutronNetworkId();
- queryNetworkResponse.getRouteTargets();
- queryNetworkResponse.getSubnetIdMap();
- queryNetworkResponse.getVlans();
- queryNetworkResponse.toJsonString();
-
- CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
- CreateNetworkResponse createNetworkResponse2 = new CreateNetworkResponse(
- "", "", "", "", true, new HashMap<String, String>(),
- new NetworkRollback(), "");
- createNetworkResponse.setMessageId("messageId");
- createNetworkResponse.setNetworkCreated(true);
- createNetworkResponse.setNetworkFqdn("networkFqdn");
- createNetworkResponse.setNetworkId("networkId");
- createNetworkResponse.setNetworkStackId("networkStackId");
- createNetworkResponse.setNeutronNetworkId("neutronNetworkId");
- createNetworkResponse.setRollback(new NetworkRollback());
- createNetworkResponse.setSubnetMap(new HashMap<String, String>());
- createNetworkResponse.toJsonString();
- createNetworkResponse.toXmlString();
- createNetworkResponse.getMessageId();
- createNetworkResponse.getNetworkCreated();
- createNetworkResponse.getNetworkFqdn();
- createNetworkResponse.getNetworkId();
- createNetworkResponse.getNetworkStackId();
- createNetworkResponse.getNeutronNetworkId();
- createNetworkResponse.getRollback();
- createNetworkResponse.getSubnetMap();
-
- NetworkRequestCommon networkRequestCommon = new CreateNetworkRequest();
- networkRequestCommon.getMessageId();
- networkRequestCommon.getNotificationUrl();
- networkRequestCommon.getSkipAAI();
- networkRequestCommon.setMessageId("messageId");
- networkRequestCommon.setNotificationUrl("notificationUrl");
- networkRequestCommon.setSkipAAI(false);
- networkRequestCommon.isSynchronous();
- networkRequestCommon.toXmlString();
- networkRequestCommon.toJsonString();
-
- DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
- deleteNetworkRequest.setCloudSiteId("cloudSiteId");
- deleteNetworkRequest.setMessageId("messageId");
- deleteNetworkRequest
- .setModelCustomizationUuid("modelCustomizationUuid");
- deleteNetworkRequest.setMsoRequest(new MsoRequest());
- deleteNetworkRequest.setNetworkId("networkId");
- deleteNetworkRequest.setNetworkStackId("networkStackId");
- deleteNetworkRequest.setNetworkType("networkType");
- deleteNetworkRequest.setNotificationUrl("notificationUrl");
- deleteNetworkRequest.setSkipAAI(true);
- deleteNetworkRequest.setTenantId("tenantId");
- deleteNetworkRequest.getCloudSiteId();
- deleteNetworkRequest.getMessageId();
- deleteNetworkRequest.getModelCustomizationUuid();
- deleteNetworkRequest.getMsoRequest();
- deleteNetworkRequest.getNetworkId();
- deleteNetworkRequest.getNetworkStackId();
- deleteNetworkRequest.getNetworkType();
- deleteNetworkRequest.getNotificationUrl();
- deleteNetworkRequest.getSkipAAI();
- deleteNetworkRequest.getTenantId();
-
- NetworkExceptionResponse networkExceptionResponse = new NetworkExceptionResponse();
- NetworkExceptionResponse networkExceptionResponse2 = new NetworkExceptionResponse(
- "", null, false, "");
- NetworkExceptionResponse networkExceptionResponse3 = new NetworkExceptionResponse(
- "");
- networkExceptionResponse.setCategory(null);
- networkExceptionResponse.setMessage("message");
- networkExceptionResponse.setMessageId("messageId");
- networkExceptionResponse.setRolledBack(true);
- networkExceptionResponse.getCategory();
- networkExceptionResponse.getMessage();
- networkExceptionResponse.getMessageId();
- networkExceptionResponse.getRolledBack();
-
- UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse();
- UpdateNetworkResponse updateNetworkResponse2 = new UpdateNetworkResponse(
- "", "", null, "");
- updateNetworkResponse.setMessageId("messageId");
- updateNetworkResponse.setNetworkId("networkId");
- updateNetworkResponse.setNeutronNetworkId("");
- updateNetworkResponse.setSubnetMap(null);
- updateNetworkResponse.getNetworkId();
- updateNetworkResponse.getMessageId();
- updateNetworkResponse.getNeutronNetworkId();
- updateNetworkResponse.getSubnetMap();
-
- DeleteNetworkResponse deleteNetworkResponse = new DeleteNetworkResponse();
- DeleteNetworkResponse deleteNetworkResponse2 = new DeleteNetworkResponse(
- "", false, "");
- deleteNetworkResponse.setNetworkDeleted(false);
- deleteNetworkResponse.setNetworkId("networkId");
- deleteNetworkResponse.getNetworkDeleted();
- deleteNetworkResponse.getNetworkId();
-
- ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork();
- ProviderVlanNetwork providerVlanNetwork2 = new ProviderVlanNetwork(
- "", null);
- providerVlanNetwork.setPhysicalNetworkName("");
- providerVlanNetwork.setVlans(null);
- providerVlanNetwork.getPhysicalNetworkName();
- providerVlanNetwork.getVlans();
-
- RollbackNetworkResponse rollbackNetworkResponse = new RollbackNetworkResponse();
- RollbackNetworkResponse rollbackNetworkResponse2 = new RollbackNetworkResponse(
- false, "");
- rollbackNetworkResponse.setNetworkRolledBack(false);
- rollbackNetworkResponse.getNetworkRolledBack();
-
- CreateNetworkError createNetworkError = new CreateNetworkError();
- CreateNetworkError createNetworkError2 = new CreateNetworkError("");
- CreateNetworkError createNetworkError3 = new CreateNetworkError("",
- null, false, "");
-
- DeleteNetworkError deleteNetworkError = new DeleteNetworkError();
- DeleteNetworkError deleteNetworkError2 = new DeleteNetworkError("");
- DeleteNetworkError deleteNetworkError3 = new DeleteNetworkError("",
- null, false, "");
-
- RollbackNetworkError rollbackNetworkError = new RollbackNetworkError();
- RollbackNetworkError rollbackNetworkError2 = new RollbackNetworkError(
- "");
- RollbackNetworkError rollbackNetworkError3 = new RollbackNetworkError(
- "", null, false, "");
-
- UpdateNetworkError updateNetworkError = new UpdateNetworkError();
- UpdateNetworkError updateNetworkError2 = new UpdateNetworkError("");
- UpdateNetworkError updateNetworkError3 = new UpdateNetworkError("",
- null, false, "");
-
- RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
- rollbackNetworkRequest.setNetworkRollback(null);
- rollbackNetworkRequest.getNetworkRollback();
-
- QueryNetworkError queryNetworkError = new QueryNetworkError();
-
- UpdateVfModuleRequest updateVfModuleRequest = new UpdateVfModuleRequest();
- updateVfModuleRequest.setBackout(false);
- updateVfModuleRequest.setBaseVfModuleId("");
- updateVfModuleRequest.setBaseVfModuleStackId("");
- updateVfModuleRequest.setCloudSiteId("");
- updateVfModuleRequest.setFailIfExists(false);
- updateVfModuleRequest.setMessageId("");
- updateVfModuleRequest.setModelCustomizationUuid("");
- updateVfModuleRequest.setMsoRequest(null);
- updateVfModuleRequest.setNotificationUrl("");
- updateVfModuleRequest.setRequestType("");
- updateVfModuleRequest.setSkipAAI(false);
- updateVfModuleRequest.setTenantId("");
- updateVfModuleRequest.setVfModuleId("");
- updateVfModuleRequest.setVfModuleName("");
- updateVfModuleRequest.setVfModuleParams(null);
- updateVfModuleRequest.setVfModuleStackId("");
- updateVfModuleRequest.setVfModuleType("");
- updateVfModuleRequest.setVnfId("");
- updateVfModuleRequest.setVnfType("");
- updateVfModuleRequest.setVnfVersion("");
- updateVfModuleRequest.setVolumeGroupId("");
- updateVfModuleRequest.setVolumeGroupStackId("");
- updateVfModuleRequest.getBackout();
- updateVfModuleRequest.getBaseVfModuleId();
- updateVfModuleRequest.getBaseVfModuleStackId();
- updateVfModuleRequest.getCloudSiteId();
- updateVfModuleRequest.getFailIfExists();
- updateVfModuleRequest.getMessageId();
- updateVfModuleRequest.getModelCustomizationUuid();
- updateVfModuleRequest.getMsoRequest();
- updateVfModuleRequest.getNotificationUrl();
- updateVfModuleRequest.getRequestType();
- updateVfModuleRequest.getSkipAAI();
- updateVfModuleRequest.getTenantId();
- updateVfModuleRequest.getVfModuleId();
- updateVfModuleRequest.getVfModuleName();
- updateVfModuleRequest.getVfModuleParams();
- updateVfModuleRequest.getVfModuleStackId();
- updateVfModuleRequest.getVfModuleType();
- updateVfModuleRequest.getVnfId();
- updateVfModuleRequest.getVnfType();
- updateVfModuleRequest.getVnfVersion();
- updateVfModuleRequest.getVolumeGroupId();
- updateVfModuleRequest.getVolumeGroupStackId();
-
- CreateVfModuleRequest createVfModuleRequest = new CreateVfModuleRequest();
- createVfModuleRequest.setBackout(false);
- createVfModuleRequest.setBaseVfModuleId("");
- createVfModuleRequest.setBaseVfModuleStackId("");
- createVfModuleRequest.setCloudSiteId("");
- createVfModuleRequest.setFailIfExists(false);
- createVfModuleRequest.setModelCustomizationUuid("");
- createVfModuleRequest.setMsoRequest(null);
- createVfModuleRequest.setNotificationUrl("");
- createVfModuleRequest.setRequestType("");
- createVfModuleRequest.setSkipAAI(false);
- createVfModuleRequest.setTenantId("");
- createVfModuleRequest.setVfModuleId("");
- createVfModuleRequest.setVfModuleName("");
- createVfModuleRequest.setVfModuleParams(null);
- createVfModuleRequest.setVfModuleType("");
- createVfModuleRequest.setVnfId("");
- createVfModuleRequest.setVnfType("");
- createVfModuleRequest.setVnfVersion("");
- createVfModuleRequest.setVolumeGroupId("volumeGroupId");
- createVfModuleRequest.setVolumeGroupStackId("volumeGroupStackId");
- createVfModuleRequest.getBackout();
- createVfModuleRequest.getBaseVfModuleId();
- createVfModuleRequest.getBaseVfModuleStackId();
- createVfModuleRequest.getCloudSiteId();
- createVfModuleRequest.getFailIfExists();
- createVfModuleRequest.getModelCustomizationUuid();
- createVfModuleRequest.getMsoRequest();
- createVfModuleRequest.getNotificationUrl();
- createVfModuleRequest.getRequestType();
- createVfModuleRequest.getSkipAAI();
- createVfModuleRequest.getTenantId();
- createVfModuleRequest.getVfModuleId();
- createVfModuleRequest.getVfModuleName();
- createVfModuleRequest.getVfModuleParams();
- createVfModuleRequest.getVfModuleType();
- createVfModuleRequest.getVnfId();
- createVfModuleRequest.getVnfType();
- createVfModuleRequest.getVnfVersion();
- createVfModuleRequest.getVolumeGroupId();
- createVfModuleRequest.getVolumeGroupStackId();
-
- VnfRollback vnfRollback = new VnfRollback();
- vnfRollback.setBaseGroupHeatStackId("");
- vnfRollback.setCloudSiteId("");
- vnfRollback.setIsBase(false);
- vnfRollback.setModelCustomizationUuid("");
- vnfRollback.setMsoRequest(null);
- vnfRollback.setRequestType("");
- vnfRollback.setTenantCreated(false);
- vnfRollback.setTenantId("");
- vnfRollback.setVfModuleStackId("");
- vnfRollback.setVnfCreated(false);
- vnfRollback.setVnfId("");
- vnfRollback.setVolumeGroupHeatStackId("");
- vnfRollback.setVolumeGroupId("");
- vnfRollback.setVolumeGroupName("");
-
- VfModuleRollback vfModuleRollback = new VfModuleRollback();
- VfModuleRollback vfModuleRollback2 = new VfModuleRollback(
- vnfRollback, "", "", "");
- VfModuleRollback vfModuleRollback3 = new VfModuleRollback("", "",
- "", false, "", "", null, "");
- vfModuleRollback.setCloudSiteId("");
- vfModuleRollback.setMsoRequest(null);
- vfModuleRollback.setTenantId("");
- vfModuleRollback.setVfModuleCreated(false);
- vfModuleRollback.setVfModuleId("");
- vfModuleRollback.setVfModuleStackId("");
- vfModuleRollback.setVnfId("");
- vfModuleRollback.getCloudSiteId();
- vfModuleRollback.getMsoRequest();
- vfModuleRollback.getTenantId();
- vfModuleRollback.getVfModuleId();
- vfModuleRollback.getVfModuleStackId();
- vfModuleRollback.getVnfId();
-
- VolumeGroupRollback volumeGroupRollback = new VolumeGroupRollback();
- volumeGroupRollback.setCloudSiteId("cloudSiteId");
- volumeGroupRollback.setMsoRequest(null);
- volumeGroupRollback.setTenantId("");
- volumeGroupRollback.setVolumeGroupCreated(false);
- volumeGroupRollback.setVolumeGroupId("");
- volumeGroupRollback.setVolumeGroupStackId("");
- volumeGroupRollback.setMessageId("messageId");
- volumeGroupRollback.getMessageId();
- volumeGroupRollback.getCloudSiteId();
- volumeGroupRollback.getMsoRequest();
- volumeGroupRollback.getTenantId();
- volumeGroupRollback.getVolumeGroupId();
- volumeGroupRollback.getVolumeGroupStackId();
- VolumeGroupRollback volumeGroupRollback2 = new VolumeGroupRollback(
- volumeGroupRollback, "", "");
- VolumeGroupRollback volumeGroupRollback3 = new VolumeGroupRollback(
- "", "", false, "", "", null, "");
-
- CreateVolumeGroupRequest createVolumeGroupRequest = new CreateVolumeGroupRequest();
- createVolumeGroupRequest.setCloudSiteId("");
- createVolumeGroupRequest.setFailIfExists(false);
- createVolumeGroupRequest.setMessageId("messageId");
- createVolumeGroupRequest
- .setModelCustomizationUuid("modelCustomizationUuid");
- createVolumeGroupRequest.setMsoRequest(null);
- createVolumeGroupRequest.setNotificationUrl("");
- createVolumeGroupRequest.setSkipAAI(false);
- createVolumeGroupRequest.setSuppressBackout(false);
- createVolumeGroupRequest.setTenantId("");
- createVolumeGroupRequest.setVfModuleType("");
- createVolumeGroupRequest.setVnfType("");
- createVolumeGroupRequest.setVnfVersion("");
- createVolumeGroupRequest.setVolumeGroupId("");
- createVolumeGroupRequest.setVolumeGroupName("");
- createVolumeGroupRequest.setVolumeGroupParams(null);
- createVolumeGroupRequest.getCloudSiteId();
- createVolumeGroupRequest.getFailIfExists();
- createVolumeGroupRequest.getMessageId();
- createVolumeGroupRequest.getModelCustomizationUuid();
- createVolumeGroupRequest.getMsoRequest();
- createVolumeGroupRequest.getNotificationUrl();
- createVolumeGroupRequest.getSkipAAI();
- createVolumeGroupRequest.getSuppressBackout();
- createVolumeGroupRequest.getTenantId();
- createVolumeGroupRequest.getVfModuleType();
- createVolumeGroupRequest.getVnfType();
- createVolumeGroupRequest.getVnfVersion();
- createVolumeGroupRequest.getVolumeGroupId();
- createVolumeGroupRequest.getVolumeGroupName();
- createVolumeGroupRequest.getVolumeGroupParams();
-
- CreateVfModuleResponse createVfModuleResponse = new CreateVfModuleResponse();
- createVfModuleResponse.setMessageId("");
- createVfModuleResponse.setRollback(null);
- createVfModuleResponse.setVfModuleCreated(false);
- createVfModuleResponse.setVfModuleId("");
- createVfModuleResponse.setVfModuleOutputs(null);
- createVfModuleResponse.setVfModuleStackId("");
- createVfModuleResponse.setVnfId("");
- createVfModuleResponse.getMessageId();
- createVfModuleResponse.getRollback();
- createVfModuleResponse.getVfModuleCreated();
- createVfModuleResponse.getVfModuleId();
- createVfModuleResponse.getVfModuleOutputs();
- createVfModuleResponse.getVfModuleStackId();
- createVfModuleResponse.getVnfId();
- CreateVfModuleResponse createVfModuleResponse2 = new CreateVfModuleResponse(
- "", "", "", false, null, vfModuleRollback, "");
-
- UpdateVolumeGroupRequest updateVolumeGroupRequest = new UpdateVolumeGroupRequest();
- updateVolumeGroupRequest.setCloudSiteId("");
- updateVolumeGroupRequest.setMessageId("");
- updateVolumeGroupRequest.setModelCustomizationUuid("");
- updateVolumeGroupRequest.setMsoRequest(null);
- updateVolumeGroupRequest.setNotificationUrl("");
- updateVolumeGroupRequest.setSkipAAI(false);
- updateVolumeGroupRequest.setTenantId("");
- updateVolumeGroupRequest.setVfModuleType("");
- updateVolumeGroupRequest.setVnfType("");
- updateVolumeGroupRequest.setVnfVersion("");
- updateVolumeGroupRequest.setVolumeGroupId("");
- updateVolumeGroupRequest.setVolumeGroupParams(null);
- updateVolumeGroupRequest.setVolumeGroupStackId("");
- updateVolumeGroupRequest.getCloudSiteId();
- updateVolumeGroupRequest.getMessageId();
- updateVolumeGroupRequest.getModelCustomizationUuid();
- updateVolumeGroupRequest.getMsoRequest();
- updateVolumeGroupRequest.getNotificationUrl();
- updateVolumeGroupRequest.getSkipAAI();
- updateVolumeGroupRequest.getTenantId();
- updateVolumeGroupRequest.getVfModuleType();
- updateVolumeGroupRequest.getVnfType();
- updateVolumeGroupRequest.getVnfVersion();
- updateVolumeGroupRequest.getVolumeGroupId();
- updateVolumeGroupRequest.getVolumeGroupParams();
- updateVolumeGroupRequest.getVolumeGroupStackId();
-
- QueryVfModuleResponse queryVfModuleResponse = new QueryVfModuleResponse();
- queryVfModuleResponse.setVfModuleId("");
- queryVfModuleResponse.setVfModuleOutputs(null);
- queryVfModuleResponse.setVfModuleStackId("");
- queryVfModuleResponse.setVnfId("");
- queryVfModuleResponse.setVnfStatus(null);
- queryVfModuleResponse.getVfModuleId();
- queryVfModuleResponse.getVfModuleOutputs();
- queryVfModuleResponse.getVfModuleStackId();
- queryVfModuleResponse.getVnfId();
- queryVfModuleResponse.getVnfStatus();
- QueryVfModuleResponse queryVfModuleResponse2 = new QueryVfModuleResponse(
- "", "", "", VnfStatus.ACTIVE, null);
-
- CreateVolumeGroupResponse createVolumeGroupResponse = new CreateVolumeGroupResponse();
- CreateVolumeGroupResponse createVolumeGroupResponse2 = new CreateVolumeGroupResponse(
- "", "volumeGroupStackId", true, null, null, "");
- createVolumeGroupResponse.setMessageId("");
- createVolumeGroupResponse.setVolumeGroupCreated(false);
- createVolumeGroupResponse.setVolumeGroupId("");
- createVolumeGroupResponse.setVolumeGroupOutputs(null);
- createVolumeGroupResponse.setVolumeGroupRollback(null);
- createVolumeGroupResponse.setVolumeGroupStackId("");
- createVolumeGroupResponse.getMessageId();
- createVolumeGroupResponse.getVolumeGroupCreated();
- createVolumeGroupResponse.getVolumeGroupId();
- createVolumeGroupResponse.getVolumeGroupOutputs();
-
- VfResponseCommon vfResponseCommon = new CreateVfModuleResponse();
- vfResponseCommon.setMessageId("");
- vfResponseCommon.toJsonString();
- vfResponseCommon.getMessageId();
- vfResponseCommon.toXmlString();
-
- QueryVolumeGroupResponse queryVolumeGroupResponse = new QueryVolumeGroupResponse();
- QueryVolumeGroupResponse queryVolumeGroupResponse2 = new QueryVolumeGroupResponse(
- "", "", null, null);
- queryVolumeGroupResponse.setVolumeGroupId("");
- queryVolumeGroupResponse.setVolumeGroupOutputs(null);
- queryVolumeGroupResponse.setVolumeGroupStackId("");
- queryVolumeGroupResponse.setVolumeGroupStatus(null);
- queryVolumeGroupResponse.getVolumeGroupId();
- queryVolumeGroupResponse.getVolumeGroupOutputs();
- queryVolumeGroupResponse.getVolumeGroupStackId();
- queryVolumeGroupResponse.getVolumeGroupStatus();
- queryVolumeGroupResponse.toString();
- queryVolumeGroupResponse.toJsonString();
-
- DeleteVfModuleResponse deleteVfModuleResponse = new DeleteVfModuleResponse();
- DeleteVfModuleResponse deleteVfModuleResponse2 = new DeleteVfModuleResponse(
- "", "", false, "", null);
- deleteVfModuleResponse.setMessageId("");
- deleteVfModuleResponse.setVfModuleDeleted(false);
- deleteVfModuleResponse.setVfModuleId("");
- deleteVfModuleResponse.setVfModuleOutputs(null);
- deleteVfModuleResponse.setVnfId("");
- deleteVfModuleResponse.getMessageId();
- deleteVfModuleResponse.getVfModuleDeleted();
- deleteVfModuleResponse.getVfModuleId();
- deleteVfModuleResponse.getVfModuleOutputs();
- deleteVfModuleResponse.getVnfId();
-
- UpdateVfModuleResponse updateVfModuleResponse = new UpdateVfModuleResponse();
- UpdateVfModuleResponse updateVfModuleResponse2 = new UpdateVfModuleResponse(
- "", "", "", null, "");
- updateVfModuleResponse.setMessageId("");
- updateVfModuleResponse.setVfModuleId("");
- updateVfModuleResponse.setVfModuleOutputs(null);
- updateVfModuleResponse.setVfModuleStackId("");
- updateVfModuleResponse.setVnfId("");
- updateVfModuleResponse.getMessageId();
- updateVfModuleResponse.getVfModuleId();
- updateVfModuleResponse.getVfModuleOutputs();
- updateVfModuleResponse.getVfModuleStackId();
- updateVfModuleResponse.getVnfId();
-
- DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
- deleteVfModuleRequest.setCloudSiteId("");
- deleteVfModuleRequest.setMessageId("");
- deleteVfModuleRequest.setMsoRequest(null);
- deleteVfModuleRequest.setNotificationUrl("");
- deleteVfModuleRequest.setSkipAAI(false);
- deleteVfModuleRequest.setTenantId("");
- deleteVfModuleRequest.setVfModuleId("");
- deleteVfModuleRequest.setVfModuleStackId("");
- deleteVfModuleRequest.setVnfId("");
- deleteVfModuleRequest.getCloudSiteId();
- deleteVfModuleRequest.getMessageId();
- deleteVfModuleRequest.getMsoRequest();
- deleteVfModuleRequest.getNotificationUrl();
- deleteVfModuleRequest.getSkipAAI();
- deleteVfModuleRequest.getTenantId();
- deleteVfModuleRequest.getVfModuleId();
- deleteVfModuleRequest.getVfModuleStackId();
- deleteVfModuleRequest.getVnfId();
-
- VfModuleExceptionResponse vfModuleExceptionResponse = new VfModuleExceptionResponse();
- VfModuleExceptionResponse vfModuleExceptionResponse2 = new VfModuleExceptionResponse(
- "", null, false, "");
- vfModuleExceptionResponse.setCategory(null);
- vfModuleExceptionResponse.setMessage("");
- vfModuleExceptionResponse.setMessageId("");
- vfModuleExceptionResponse.setRolledBack(false);
- vfModuleExceptionResponse.getCategory();
- vfModuleExceptionResponse.getMessage();
- vfModuleExceptionResponse.getMessageId();
- vfModuleExceptionResponse.getRolledBack();
-
- DeleteVolumeGroupRequest deleteVolumeGroupRequest = new DeleteVolumeGroupRequest();
- deleteVolumeGroupRequest.setCloudSiteId("");
- deleteVolumeGroupRequest.setMessageId("");
- deleteVolumeGroupRequest.setMsoRequest(null);
- deleteVolumeGroupRequest.setNotificationUrl("");
- deleteVolumeGroupRequest.setSkipAAI(false);
- deleteVolumeGroupRequest.setTenantId("");
- deleteVolumeGroupRequest.setVolumeGroupId("");
- deleteVolumeGroupRequest.setVolumeGroupStackId("");
- deleteVolumeGroupRequest.getCloudSiteId();
- deleteVolumeGroupRequest.getMessageId();
- deleteVolumeGroupRequest.getMsoRequest();
- deleteVolumeGroupRequest.getNotificationUrl();
- deleteVolumeGroupRequest.getSkipAAI();
- deleteVolumeGroupRequest.getTenantId();
- deleteVolumeGroupRequest.getVolumeGroupId();
- deleteVolumeGroupRequest.getVolumeGroupStackId();
-
- // 1
- UpdateVolumeGroupResponse updateVolumeGroupResponse = new UpdateVolumeGroupResponse();
- UpdateVolumeGroupResponse updateVolumeGroupResponse2 = new UpdateVolumeGroupResponse(
- "", "", null, "");
- updateVolumeGroupResponse.setMessageId("");
- updateVolumeGroupResponse.setVolumeGroupId("");
- updateVolumeGroupResponse.setVolumeGroupOutputs(null);
- updateVolumeGroupResponse.setVolumeGroupStackId("");
- updateVolumeGroupResponse.getMessageId();
- updateVolumeGroupResponse.getVolumeGroupId();
- updateVolumeGroupResponse.getVolumeGroupOutputs();
- updateVolumeGroupResponse.getVolumeGroupStackId();
-
- VfRequestCommon vfRequestCommon = new CreateVfModuleRequest();
- vfRequestCommon.setMessageId("");
- vfRequestCommon.setNotificationUrl("");
- vfRequestCommon.setSkipAAI(false);
- vfRequestCommon.getMessageId();
- vfRequestCommon.getNotificationUrl();
- vfRequestCommon.getSkipAAI();
-
- DeleteVolumeGroupResponse deleteVolumeGroupResponse = new DeleteVolumeGroupResponse();
- DeleteVolumeGroupResponse deleteVolumeGroupResponse2 = new DeleteVolumeGroupResponse(
- false, "");
- deleteVolumeGroupResponse.setMessageId("");
- deleteVolumeGroupResponse.setVolumeGroupDeleted(false);
- deleteVolumeGroupResponse.getMessageId();
- deleteVolumeGroupResponse.getVolumeGroupDeleted();
- deleteVolumeGroupResponse.toJsonString();
- deleteVolumeGroupResponse.toXmlString();
-
- RollbackVfModuleResponse rollbackVfModuleResponse = new RollbackVfModuleResponse();
- RollbackVfModuleResponse rollbackVfModuleResponse2 = new RollbackVfModuleResponse(
- false, "");
- rollbackVfModuleResponse.setMessageId("");
- rollbackVfModuleResponse.setVfModuleRolledback(false);
- rollbackVfModuleResponse.getMessageId();
- rollbackVfModuleResponse.getVfModuleRolledback();
-
- RollbackVolumeGroupResponse rollbackVolumeGroupResponse = new RollbackVolumeGroupResponse();
- RollbackVolumeGroupResponse rollbackVolumeGroupResponse2 = new RollbackVolumeGroupResponse(
- false, "");
- rollbackVolumeGroupResponse.setMessageId("");
- rollbackVolumeGroupResponse.setVolumeGroupRolledBack(false);
- rollbackVolumeGroupResponse.getMessageId();
- rollbackVolumeGroupResponse.getVolumeGroupRolledBack();
-
- VolumeGroupExceptionResponse volumeGroupExceptionResponse = new VolumeGroupExceptionResponse();
- VolumeGroupExceptionResponse volumeGroupExceptionResponse2 = new VolumeGroupExceptionResponse(
- "");
- VolumeGroupExceptionResponse volumeGroupExceptionResponse3 = new VolumeGroupExceptionResponse(
- "", null, false, "");
- volumeGroupExceptionResponse.setCategory(null);
- volumeGroupExceptionResponse.setMessage("");
- volumeGroupExceptionResponse.setMessageId("");
- volumeGroupExceptionResponse.setRolledBack(false);
- volumeGroupExceptionResponse.getCategory();
- volumeGroupExceptionResponse.getMessage();
- volumeGroupExceptionResponse.getMessageId();
- volumeGroupExceptionResponse.getRolledBack();
- volumeGroupExceptionResponse.toJsonString();
- volumeGroupExceptionResponse.toXmlString();
-
- RollbackVfModuleRequest rollbackVfModuleRequest = new RollbackVfModuleRequest();
- rollbackVfModuleRequest.setMessageId("");
- rollbackVfModuleRequest.setNotificationUrl("");
- rollbackVfModuleRequest.setSkipAAI(false);
- rollbackVfModuleRequest.setVfModuleRollback(null);
- rollbackVfModuleRequest.getMessageId();
- rollbackVfModuleRequest.getNotificationUrl();
- rollbackVfModuleRequest.getSkipAAI();
- rollbackVfModuleRequest.getVfModuleRollback();
- rollbackVfModuleRequest.toJsonString();
- rollbackVfModuleRequest.toXmlString();
-
- SDNCResponseCommon SDNCResponseCommon = new SDNCServiceResponse();
- SDNCResponseCommon.setAckFinalIndicator("");
- SDNCResponseCommon.setResponseCode("");
- SDNCResponseCommon.setResponseMessage("");
- SDNCResponseCommon.setSDNCRequestId("");
- SDNCResponseCommon.getAckFinalIndicator();
- SDNCResponseCommon.getResponseCode();
- SDNCResponseCommon.getResponseMessage();
- SDNCResponseCommon.getSDNCRequestId();
- SDNCResponseCommon.toJson();
- // 2
-
- SDNCServiceResponse sDNCServiceResponse = new SDNCServiceResponse();
- SDNCServiceResponse sDNCServiceResponse2 = new SDNCServiceResponse(
- "", "", "", "");
- sDNCServiceResponse.addParam("", "");
- sDNCServiceResponse.setAckFinalIndicator("");
- sDNCServiceResponse.setParams(null);
- sDNCServiceResponse.setResponseCode("");
- sDNCServiceResponse.setResponseMessage("");
- sDNCServiceResponse.setSDNCRequestId("");
- sDNCServiceResponse.getAckFinalIndicator();
- sDNCServiceResponse.getParams();
- sDNCServiceResponse.getResponseCode();
- sDNCServiceResponse.getSDNCRequestId();
- sDNCServiceResponse.getResponseMessage();
-
- RollbackVolumeGroupRequest rollbackVolumeGroupRequest = new RollbackVolumeGroupRequest();
- rollbackVolumeGroupRequest.setMessageId("");
- rollbackVolumeGroupRequest.setNotificationUrl("");
- rollbackVolumeGroupRequest.setSkipAAI(false);
- rollbackVolumeGroupRequest.setVolumeGroupRollback(null);
- rollbackVolumeGroupRequest.getMessageId();
- rollbackVolumeGroupRequest.getNotificationUrl();
- rollbackVolumeGroupRequest.getSkipAAI();
- rollbackVolumeGroupRequest.getVolumeGroupRollback();
- rollbackVolumeGroupRequest.toJsonString();
- rollbackVolumeGroupRequest.toXmlString();
-
- RequestInformation requestInformation = new RequestInformation();
- RequestInformation requestInformation2 = new RequestInformation("",
- "", "");
- requestInformation.setNotificationUrl("");
- requestInformation.setRequestId("");
- requestInformation.setSource("");
- requestInformation.getNotificationUrl();
- requestInformation.getRequestId();
- requestInformation.getSource();
-
- SDNCErrorCommon sDNCErrorCommon = new SDNCServiceError();
- sDNCErrorCommon.setAckFinalIndicator("");
- sDNCErrorCommon.setResponseCode("");
- sDNCErrorCommon.setResponseMessage("");
- sDNCErrorCommon.setSDNCRequestId("");
- sDNCErrorCommon.getAckFinalIndicator();
- sDNCErrorCommon.getResponseCode();
- sDNCErrorCommon.getResponseMessage();
- sDNCErrorCommon.getSDNCRequestId();
-
- SDNCEvent sDNCEvent = new SDNCEvent();
- SDNCEvent sDNCEvent2 = new SDNCEvent("", "", "");
- sDNCEvent.setEventCorrelator("");
- sDNCEvent.setEventCorrelatorType("");
- sDNCEvent.setEventType("");
- sDNCEvent.setParams(null);
- sDNCEvent.getEventCorrelator();
- sDNCEvent.getEventCorrelatorType();
- sDNCEvent.getEventType();
- sDNCEvent.getParams();
- sDNCEvent.addParam("", "");
- sDNCEvent.toJson();
-
- SDNCRequestCommon sDNCRequestCommon = new SDNCServiceRequest();
- SDNCRequestCommon sDNCRequestCommon2 = new SDNCServiceRequest("",
- "", "", "", "", null, null, "", "");
- sDNCRequestCommon.setBPNotificationUrl("");
- sDNCRequestCommon.setBPTimeout("");
- sDNCRequestCommon.setSDNCRequestId("");
- sDNCRequestCommon.getBPNotificationUrl();
- sDNCRequestCommon.getBPTimeout();
- sDNCRequestCommon.getSDNCRequestId();
- sDNCRequestCommon.toJson();
- sDNCRequestCommon.isSynchronous();
-
- SDNCServiceError sDNCServiceError = new SDNCServiceError();
- SDNCServiceError sDNCServiceError2 = new SDNCServiceError("", "",
- "", "");
- sDNCServiceError.setAckFinalIndicator("");
- sDNCServiceError.setResponseCode("");
- sDNCServiceError.setResponseMessage("");
- sDNCServiceError.setSDNCRequestId("");
- sDNCServiceError.getAckFinalIndicator();
- sDNCServiceError.getResponseCode();
- sDNCServiceError.getResponseMessage();
- sDNCServiceError.getSDNCRequestId();
-
- SDNCServiceRequest sDNCServiceRequest = new SDNCServiceRequest();
- SDNCServiceRequest sDNCServiceRequest2 = new SDNCServiceRequest("",
- "", "", "", "", requestInformation, null, "", "");
- sDNCServiceRequest.setBPNotificationUrl("");
- sDNCServiceRequest.setBPTimeout("");
- sDNCServiceRequest.setRequestInformation(null);
- sDNCServiceRequest.setSDNCOperation("");
- sDNCServiceRequest.setSDNCRequestId("");
- sDNCServiceRequest.setSDNCService("");
- sDNCServiceRequest.setSDNCServiceData("");
- sDNCServiceRequest.setSDNCServiceDataType("");
- sDNCServiceRequest.setServiceInformation(null);
- sDNCServiceRequest.getBPNotificationUrl();
- sDNCServiceRequest.getBPTimeout();
- sDNCServiceRequest.getRequestInformation();
- sDNCServiceRequest.getSDNCOperation();
- sDNCServiceRequest.getSDNCRequestId();
- sDNCServiceRequest.getSDNCService();
- sDNCServiceRequest.getSDNCServiceData();
- sDNCServiceRequest.getSDNCServiceDataType();
- sDNCServiceRequest.getServiceInformation();
-
- // 3
- ServiceInformation serviceInformation = new ServiceInformation();
- ServiceInformation serviceInformation2 = new ServiceInformation("",
- "", "", "");
- serviceInformation.setServiceInstanceId("");
- serviceInformation.setServiceType("");
- serviceInformation.setSubscriberGlobalId("");
- serviceInformation.setSubscriberName("");
- serviceInformation.getServiceInstanceId();
- serviceInformation.getServiceType();
- serviceInformation.getSubscriberGlobalId();
- serviceInformation.getSubscriberName();
-
- CreateTenantError createTenantError = new CreateTenantError();
- CreateTenantError createTenantError2 = new CreateTenantError("");
- CreateTenantError createTenantError3 = new CreateTenantError("",
- null, false);
- createTenantError.setCategory(null);
- createTenantError.setMessage("");
- createTenantError.setRolledBack(false);
- createTenantError.getCategory();
- createTenantError.getMessage();
- createTenantError.getRolledBack();
-
- CreateTenantRequest createTenantRequest = new CreateTenantRequest();
- createTenantRequest.setBackout(false);
- createTenantRequest.setCloudSiteId("");
- createTenantRequest.setFailIfExists(false);
- createTenantRequest.setMetadata(null);
- createTenantRequest.setMsoRequest(null);
- createTenantRequest.setTenantName("");
- createTenantRequest.getBackout();
- createTenantRequest.getCloudSiteId();
- createTenantRequest.getFailIfExists();
- createTenantRequest.getMetadata();
- createTenantRequest.getMsoRequest();
- createTenantRequest.getTenantName();
- createTenantRequest.toString();
-
- CreateTenantResponse createTenantResponse = new CreateTenantResponse();
- CreateTenantResponse createTenantResponse2 = new CreateTenantResponse(
- "", "", false, null);
- createTenantResponse.setCloudSiteId("");
- createTenantResponse.setTenantCreated(false);
- createTenantResponse.setTenantId("");
- createTenantResponse.setTenantRollback(new TenantRollback());
- createTenantResponse.getCloudSiteId();
- createTenantResponse.getTenantCreated();
- createTenantResponse.getTenantId();
- createTenantResponse.getTenantRollback();
- createTenantResponse.toString();
-
- DeleteTenantError deleteTenantError = new DeleteTenantError();
- DeleteTenantError deleteTenantError2 = new DeleteTenantError("");
- DeleteTenantError deleteTenantError3 = new DeleteTenantError("",
- null, false);
- deleteTenantError.setCategory(null);
- deleteTenantError.setMessage("");
- deleteTenantError.setRolledBack(false);
- deleteTenantError.getCategory();
- deleteTenantError.getMessage();
- deleteTenantError.getRolledBack();
-
- DeleteTenantRequest deleteTenantRequest = new DeleteTenantRequest();
- deleteTenantRequest.setCloudSiteId("");
- deleteTenantRequest.setMsoRequest(null);
- deleteTenantRequest.setTenantId("");
- deleteTenantRequest.getCloudSiteId();
- deleteTenantRequest.getMsoRequest();
- deleteTenantRequest.getTenantId();
-
- DeleteTenantResponse deleteTenantResponse = new DeleteTenantResponse();
- deleteTenantResponse.setTenantDeleted(false);
- deleteTenantResponse.getTenantDeleted();
-
- HealthCheckHandler healthCheckHandler = new HealthCheckHandler();
- healthCheckHandler.healthcheck();
-
- QueryTenantError queryTenantError = new QueryTenantError();
- QueryTenantError queryTenantError2 = new QueryTenantError("");
- QueryTenantError queryTenantError3 = new QueryTenantError("", null);
- queryTenantError.setCategory(null);
- queryTenantError.setMessage("");
- queryTenantError.getCategory();
- queryTenantError.getMessage();
-
- QueryTenantResponse queryTenantResponse = new QueryTenantResponse();
- QueryTenantResponse queryTenantResponse2 = new QueryTenantResponse(
- "", "", null);
- queryTenantResponse.setMetadata(null);
- queryTenantResponse.setTenantId("");
- queryTenantResponse.setTenantName("");
- queryTenantResponse.getMetadata();
- queryTenantResponse.getTenantId();
- queryTenantResponse.getTenantName();
-
- RollbackTenantError rollbackTenantError = new RollbackTenantError();
- RollbackTenantError rollbackTenantError2 = new RollbackTenantError(
- "");
- RollbackTenantError rollbackTenantError3 = new RollbackTenantError(
- "", null, false);
- rollbackTenantError.setCategory(null);
- rollbackTenantError.setMessage("");
- rollbackTenantError.setRolledBack(false);
- rollbackTenantError.getCategory();
- rollbackTenantError.getMessage();
- rollbackTenantError.getRolledBack();
-
- RollbackTenantRequest rollbackTenantRequest = new RollbackTenantRequest();
- rollbackTenantRequest.setTenantRollback(null);
- rollbackTenantRequest.getTenantRollback();
-
- RollbackTenantResponse rollbackTenantResponse = new RollbackTenantResponse();
- rollbackTenantResponse.setTenantRolledback(false);
- rollbackTenantResponse.getTenantRolledback();
-
- TenantExceptionResponse tenantExceptionResponse = new TenantExceptionResponse();
- TenantExceptionResponse tenantExceptionResponse2 = new TenantExceptionResponse(
- "");
- TenantExceptionResponse tenantExceptionResponse3 = new TenantExceptionResponse(
- "", null, false);
- tenantExceptionResponse.setCategory(null);
- tenantExceptionResponse.setMessage("");
- tenantExceptionResponse.setRolledBack(false);
- tenantExceptionResponse.getCategory();
- tenantExceptionResponse.getMessage();
- tenantExceptionResponse.getRolledBack();
-
- TenantRequestCommon tenantRequestCommon = new TenantRequestCommon();
- tenantRequestCommon.toJsonString();
- tenantRequestCommon.toXmlString();
-
- TenantRollback tenantRollback = new TenantRollback();
- tenantRollback.toString();
- tenantRollback.setCloudId("");
- tenantRollback.setMsoRequest(null);
- tenantRollback.setTenantCreated(false);
- tenantRollback.setTenantId("");
- tenantRollback.getCloudId();
- tenantRollback.getMsoRequest();
- tenantRollback.getTenantCreated();
- tenantRollback.getTenantId();
-
- } catch (Exception e) {
- assert (false);
-
- }
- }
}
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/json/MapDeserializerTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/json/MapDeserializerTest.java new file mode 100644 index 0000000000..897c69d144 --- /dev/null +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/json/MapDeserializerTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.adapters.json; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +import java.util.Map; +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jettison.json.JSONException; +import org.codehaus.jettison.json.JSONObject; +import org.junit.Test; + +public class MapDeserializerTest { + + private static final String MAP_KEY = "keyTest"; + private static final String MAP_VALUE = "valueTest"; + + @Test + public void mapWithProperValuesIsReturned() throws Exception { + JsonParser parser = new ObjectMapper().getJsonFactory().createJsonParser(getJsonAsString()); + MapDeserializer testedObject = new MapDeserializer(); + Map<String, String> params = testedObject.deserialize(parser, mock(DeserializationContext.class)); + assertThat(params).hasSize(1).containsEntry(MAP_KEY, MAP_VALUE); + } + + private String getJsonAsString() throws JSONException { + JSONObject child2 = new JSONObject(); + child2.put("key", MAP_KEY); + child2.put("value", MAP_VALUE); + JSONObject child1 = new JSONObject(); + child1.put("child2", child2); + JSONObject parent = new JSONObject(); + parent.put("child1", child1); + return parent.toString(); + } +} diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java index a8e03d98f3..fb86b8c520 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java @@ -22,68 +22,59 @@ package org.openecomp.mso.adapters.vnf; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; - -import java.util.Arrays; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.Scanner; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.jws.WebService; -import javax.xml.ws.Holder; - +import org.codehaus.jackson.JsonNode; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.ObjectMapper; import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists; import org.openecomp.mso.adapters.vnf.exceptions.VnfException; import org.openecomp.mso.adapters.vnf.exceptions.VnfNotFound; -import org.openecomp.mso.cloud.CloudConfigFactory; import org.openecomp.mso.cloud.CloudConfig; +import org.openecomp.mso.cloud.CloudConfigFactory; import org.openecomp.mso.cloud.CloudSite; -import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; import org.openecomp.mso.db.catalog.CatalogDatabase; import org.openecomp.mso.db.catalog.beans.HeatEnvironment; import org.openecomp.mso.db.catalog.beans.HeatFiles; import org.openecomp.mso.db.catalog.beans.HeatTemplate; import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; -import org.openecomp.mso.db.catalog.beans.VnfResource; import org.openecomp.mso.db.catalog.beans.VfModule; import org.openecomp.mso.db.catalog.beans.VfModuleCustomization; -import org.openecomp.mso.db.catalog.beans.VnfComponent; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning; import org.openecomp.mso.entity.MsoRequest; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoAlarmLogger; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.openstack.beans.HeatStatus; import org.openecomp.mso.openstack.beans.StackInfo; -import org.openecomp.mso.openstack.beans.VnfStatus; import org.openecomp.mso.openstack.beans.VnfRollback; +import org.openecomp.mso.openstack.beans.VnfStatus; import org.openecomp.mso.openstack.exceptions.MsoException; import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory; +import org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry; import org.openecomp.mso.openstack.utils.MsoHeatUtils; import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate; -import org.openecomp.mso.openstack.utils.MsoHeatEnvironmentEntry; import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.ObjectMapper; +import javax.jws.WebService; +import javax.xml.ws.Holder; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; @WebService(serviceName = "VnfAdapter", endpointInterface = "org.openecomp.mso.adapters.vnf.MsoVnfAdapter", targetNamespace = "http://org.openecomp.mso/vnf") public class MsoVnfAdapterImpl implements MsoVnfAdapter { - CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); - protected CloudConfig cloudConfig = null; + CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); + protected CloudConfig cloudConfig = null; - MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); + MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); - private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER"; + private static final String MSO_PROP_VNF_ADAPTER = "MSO_PROP_VNF_ADAPTER"; private static final String MSO_CONFIGURATION_ERROR = "MsoConfigurationError"; private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter."; private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); @@ -93,19 +84,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); /** - * Health Check web method. Does nothing but return to show the adapter is deployed. - */ - @Override - public void healthCheck () { - LOGGER.debug ("Health check call in VNF Adapter"); - } - - /** * DO NOT use that constructor to instantiate this class, the msoPropertiesfactory will be NULL. * @see MsoVnfAdapterImpl#MsoVnfAdapterImpl(MsoPropertiesFactory, CloudConfigFactory) */ public MsoVnfAdapterImpl() { - + // empty implementation } /** @@ -113,8 +96,16 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { * @param msoPropFactory */ public MsoVnfAdapterImpl(MsoPropertiesFactory msoPropFactory, CloudConfigFactory cloudConfigFact) { - this.msoPropertiesFactory = msoPropFactory; - this.cloudConfigFactory = cloudConfigFact; + this.msoPropertiesFactory = msoPropFactory; + this.cloudConfigFactory = cloudConfigFact; + } + + /** + * Health Check web method. Does nothing but return to show the adapter is deployed. + */ + @Override + public void healthCheck () { + LOGGER.debug ("Health check call in VNF Adapter"); } /** @@ -169,66 +160,65 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Holder <String> vnfId, Holder <Map <String, String>> outputs, Holder <VnfRollback> rollback) throws VnfException { - // Create a hook here to catch shortcut createVf requests: - if (requestType != null) { - if (requestType.startsWith("VFMOD")) { - LOGGER.debug("Calling createVfModule from createVnf -- requestType=" + requestType); - String newRequestType = requestType.substring(5); - String vfVolGroupHeatStackId = ""; - String vfBaseHeatStackId = ""; - try { - if (volumeGroupHeatStackId != null) { - vfVolGroupHeatStackId = volumeGroupHeatStackId.substring(0, volumeGroupHeatStackId.lastIndexOf("|")); - vfBaseHeatStackId = volumeGroupHeatStackId.substring(volumeGroupHeatStackId.lastIndexOf("|")+1); - } - } catch (Exception e) { - // might be ok - both are just blank - LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId,e); - } - this.createVfModule(cloudSiteId, - tenantId, - vnfType, - vnfVersion, - vnfName, - newRequestType, - vfVolGroupHeatStackId, - vfBaseHeatStackId, + // Create a hook here to catch shortcut createVf requests: + if (requestType != null) { + if (requestType.startsWith("VFMOD")) { + LOGGER.debug("Calling createVfModule from createVnf -- requestType=" + requestType); + String newRequestType = requestType.substring(5); + String vfVolGroupHeatStackId = ""; + String vfBaseHeatStackId = ""; + try { + if (volumeGroupHeatStackId != null) { + vfVolGroupHeatStackId = volumeGroupHeatStackId.substring(0, volumeGroupHeatStackId.lastIndexOf("|")); + vfBaseHeatStackId = volumeGroupHeatStackId.substring(volumeGroupHeatStackId.lastIndexOf("|")+1); + } + } catch (Exception e) { + // might be ok - both are just blank + LOGGER.debug("ERROR trying to parse the volumeGroupHeatStackId " + volumeGroupHeatStackId,e); + } + this.createVfModule(cloudSiteId, + tenantId, + vnfType, + vnfVersion, + vnfName, + newRequestType, + vfVolGroupHeatStackId, + vfBaseHeatStackId, null, - inputs, - failIfExists, - backout, - msoRequest, - vnfId, - outputs, - rollback); - return; - } - } - // createVf will know if the requestType starts with "X" that it's the "old" way - StringBuilder newRequestTypeSb = new StringBuilder("X"); - String vfVolGroupHeatStackId = ""; - String vfBaseHeatStackId = ""; - if (requestType != null) { - newRequestTypeSb.append(requestType); - } - this.createVfModule(cloudSiteId, + inputs, + failIfExists, + backout, + msoRequest, + vnfId, + outputs, + rollback); + return; + } + } + // createVf will know if the requestType starts with "X" that it's the "old" way + StringBuilder newRequestTypeSb = new StringBuilder("X"); + String vfVolGroupHeatStackId = ""; + String vfBaseHeatStackId = ""; + if (requestType != null) { + newRequestTypeSb.append(requestType); + } + this.createVfModule(cloudSiteId, tenantId, - vnfType, - vnfVersion, + vnfType, + vnfVersion, vnfName, - newRequestTypeSb.toString(), - vfVolGroupHeatStackId, - vfBaseHeatStackId, - null, - inputs, - failIfExists, - backout, - msoRequest, - vnfId, - outputs, - rollback); - return; - // End createVf shortcut + newRequestTypeSb.toString(), + vfVolGroupHeatStackId, + vfBaseHeatStackId, + null, + inputs, + failIfExists, + backout, + msoRequest, + vnfId, + outputs, + rollback); + // End createVf shortcut } @Override @@ -243,10 +233,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoRequest msoRequest, Holder <Map <String, String>> outputs, Holder <VnfRollback> rollback) throws VnfException { - // As of 1707 - this method should no longer be called - MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ()); - MsoLogger.setServiceName ("UpdateVnf"); - LOGGER.debug("UpdateVnf called?? This should not be called any longer - update vfModule"); + // As of 1707 - this method should no longer be called + MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ()); + MsoLogger.setServiceName ("UpdateVnf"); + LOGGER.debug("UpdateVnf called?? This should not be called any longer - update vfModule"); } /** @@ -274,7 +264,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Holder <VnfStatus> status, Holder <Map <String, String>> outputs) throws VnfException { MsoLogger.setLogContext (msoRequest); - MsoLogger.setServiceName ("QueryVnf"); + MsoLogger.setServiceName ("QueryVnf"); LOGGER.debug ("Querying VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId); // Will capture execution time for metrics @@ -317,7 +307,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug ("VNF " + vnfName + " found, ID = " + vnfId.value); } LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query VNF"); - return; } /** @@ -337,7 +326,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String vnfName, MsoRequest msoRequest) throws VnfException { MsoLogger.setLogContext (msoRequest); - MsoLogger.setServiceName ("DeleteVnf"); + MsoLogger.setServiceName ("DeleteVnf"); LOGGER.debug ("Deleting VNF " + vnfName + " in " + cloudSiteId + "/" + tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -365,7 +354,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // On success, nothing is returned. LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VNF"); - return; } /** @@ -378,7 +366,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { public void rollbackVnf (VnfRollback rollback) throws VnfException { long startTime = System.currentTimeMillis (); MsoLogger.setServiceName ("RollbackVnf"); - // rollback may be null (e.g. if stack already existed when Create was called) + // rollback may be null (e.g. if stack already existed when Create was called) if (rollback == null) { LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "OpenStack", "rollbackVnf"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "Rollback request content is null"); @@ -415,7 +403,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { throw new VnfException (me); } LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back VNF"); - return; } private VnfStatus stackStatusToVnfStatus (HeatStatus stackStatus) { @@ -439,33 +426,33 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (value instanceof String) { stringOutputs.put (key, (String) value); } else if (value instanceof Integer) { - try { - String str = "" + value; - stringOutputs.put(key, str); - } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs",e); - } + try { + String str = "" + value; + stringOutputs.put(key, str); + } catch (Exception e) { + LOGGER.debug("Unable to add " + key + " to outputs",e); + } } else if (value instanceof JsonNode) { - try { - String str = this.convertNode((JsonNode) value); - stringOutputs.put(key, str); - } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode",e); - } + try { + String str = this.convertNode((JsonNode) value); + stringOutputs.put(key, str); + } catch (Exception e) { + LOGGER.debug("Unable to add " + key + " to outputs - exception converting JsonNode",e); + } } else if (value instanceof java.util.LinkedHashMap) { - try { - String str = JSON_MAPPER.writeValueAsString(value); - stringOutputs.put(key, str); - } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap",e); - } + try { + String str = JSON_MAPPER.writeValueAsString(value); + stringOutputs.put(key, str); + } catch (Exception e) { + LOGGER.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap",e); + } } else { - try { - String str = value.toString(); - stringOutputs.put(key, str); - } catch (Exception e) { - LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(),e); - } + try { + String str = value.toString(); + stringOutputs.put(key, str); + } catch (Exception e) { + LOGGER.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(),e); + } } } return stringOutputs; @@ -475,155 +462,72 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { return new HashMap <> (stringInputs); } - /* - * a helper method to make sure that any resource_registry entry of the format - * "xx::xx" : yyy.yaml (or yyy.template) - * has the file name prepended with "file:///" - * Return a String of the environment body that's passed in. - * Have to be careful not to mess up the original formatting. - */ - private String parseEnvironment (String environment) { - StringBuilder sb = new StringBuilder (); - try (Scanner scanner = new Scanner (environment)) { - scanner.useDelimiter ("\n"); - String line; - Pattern resource = Pattern.compile ("\\s*\"\\w+::\\S+\"\\s*:"); - LOGGER.debug ("regex pattern for finding a resource_registry: \\s*\"\\w+::\\S+\"\\s*:"); - while (scanner.hasNextLine ()) { - line = scanner.nextLine (); - if (line.toLowerCase ().contains ("resource_registry")) { - sb.append (line + "\n"); - boolean done = false; - // basically keep scanning until EOF or parameters: section - while (scanner.hasNextLine () && !done) { - line = scanner.nextLine (); - if ("parameters:".equalsIgnoreCase (line.trim ())) { - sb.append (line + "\n"); - done = true; - break; - } - Matcher m = resource.matcher (line); - if (m.find ()) { - sb.append (m.group ()); - String secondPart = line.substring (m.end ()).trim (); - String output = secondPart; - if (secondPart.endsWith (".yaml") - || secondPart.endsWith (".template") && !secondPart.startsWith ("file:///")) { - output = "file:///" + secondPart; - LOGGER.debug ("changed " + secondPart + " to " + output); - } // don't do anything if it's not .yaml or .template - sb.append (" " + output + "\n"); - } else { - sb.append (line + "\n"); - } - } - } else { - sb.append (line + "\n"); - continue; - } - } - scanner.close (); - } catch (Exception e) { - LOGGER.debug ("Error trying to scan " + environment, e); - return environment; + private boolean callHeatbridge(String heatStackId) { + String executionDir = "/usr/local/lib/python2.7/dist-packages/heatbridge"; + String openstackIdentityUrl = "", username = "", password = "", tenant = "", region = "", owner = ""; + long waitTimeMs = 10000l; + try { + String[] cmdarray = {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, heatStackId}; + String[] envp = null; + File dir = new File(executionDir); + LOGGER.debug("Calling HeatBridgeMain.py in " + dir + " with arguments " + Arrays.toString(cmdarray)); + Runtime r = Runtime.getRuntime(); + Process p = r.exec(cmdarray, envp, dir); + boolean wait = p.waitFor(waitTimeMs, TimeUnit.MILLISECONDS); + + LOGGER.debug(" HeatBridgeMain.py returned " + wait + " with code " + p.exitValue()); + return wait && p.exitValue()==0; + } catch (IOException e) { + LOGGER.debug(" HeatBridgeMain.py failed with IO Exception! " + e); + return false; + } catch (InterruptedException e) { + LOGGER.debug(" HeatBridgeMain.py failed when interrupted! " + e); + return false; + } catch (RuntimeException e) { + LOGGER.debug(" HeatBridgeMain.py failed for unknown reasons!" + e); + return false; } - return sb.toString (); } - /* - * helper class to add file:/// to the Provider_Resource_File entry in HEAT_NESTED_TEMPLATE - * and the File_Name entry in HEAT_FILES if the file:/// part is missing. - */ - private String enforceFilePrefix (String string) { - if (string.trim ().startsWith ("file:///")) { - // just leave it - return string; + private void sendMapToDebug(Map<String, Object> inputs, String optionalName) { + int i = 0; + StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName); + if (inputs == null) { + sb.append("\tNULL"); } - if (string.trim ().endsWith (".yaml") || string.trim ().endsWith (".template")) { - // only .yaml or .template are valid anyway - otherwise don't bother - return "file:///" + string.trim (); + else if (inputs.size() < 1) { + sb.append("\tEMPTY"); } else { - LOGGER.debug (string + " is NOT a .yaml or .template file"); + for (Map.Entry<String,Object> entry : inputs.entrySet()) { + String outputString; + String str = entry.getKey(); + Object value = entry.getValue(); + try { + outputString = value.toString(); + } catch (Exception e) { + LOGGER.debug("Exception :",e); + outputString = "Unable to call toString() on the value for " + str; + } + sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'"); + } } - return string; + LOGGER.debug(sb.toString()); } - private boolean callHeatbridge(String heatStackId) { - String executionDir = "/usr/local/lib/python2.7/dist-packages/heatbridge"; - String openstackIdentityUrl = "", username = "", password = "", tenant = "", region = "", owner = ""; - long waitTimeMs = 10000l; - try { - String[] cmdarray = {"/usr/bin/python", "HeatBridgeMain.py", openstackIdentityUrl, username, password, tenant, region, owner, heatStackId}; - String[] envp = null; - File dir = new File(executionDir); - LOGGER.debug("Calling HeatBridgeMain.py in " + dir + " with arguments " + Arrays.toString(cmdarray)); - Runtime r = Runtime.getRuntime(); - Process p = r.exec(cmdarray, envp, dir); - /* - BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream())); - String linein = stdout.readLine(); - while (linein!=null) { - System.out.println(linein); - linein = stdout.readLine(); - } - */ - boolean wait = p.waitFor(waitTimeMs, TimeUnit.MILLISECONDS); - - LOGGER.debug(" HeatBridgeMain.py returned " + wait + " with code " + p.exitValue()); - return wait && p.exitValue()==0; - } catch (IOException e) { - LOGGER.debug(" HeatBridgeMain.py failed with IO Exception! " + e); - return false; - } catch (InterruptedException e) { - LOGGER.debug(" HeatBridgeMain.py failed when interrupted! " + e); - return false; - } catch (RuntimeException e) { - LOGGER.debug(" HeatBridgeMain.py failed for unknown reasons!" + e); - return false; - } - } - - private void sendMapToDebug(Map<String, Object> inputs, String optionalName) { - int i = 0; - StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName); - if (inputs == null) { - sb.append("\tNULL"); - } - else if (inputs.size() < 1) { - sb.append("\tEMPTY"); - } else { - for (Map.Entry<String,Object> entry : inputs.entrySet()) { - String outputString; - String str = entry.getKey(); - Object value = entry.getValue(); - try { - outputString = value.toString(); - } catch (Exception e) { - LOGGER.debug("Exception :",e); - outputString = "Unable to call toString() on the value for " + str; - } - sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'"); - } - } - LOGGER.debug(sb.toString()); - return; - } - private void sendMapToDebug(Map<String, String> inputs) { - int i = 0; - StringBuilder sb = new StringBuilder("inputs:"); - if (inputs == null) { - sb.append("\tNULL"); - } - else if (inputs.size() < 1) { - sb.append("\tEMPTY"); - } else { - for (String str : inputs.keySet()) { - sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str)); - } - } - LOGGER.debug(sb.toString()); - return; + int i = 0; + StringBuilder sb = new StringBuilder("inputs:"); + if (inputs == null) { + sb.append("\tNULL"); + } + else if (inputs.size() < 1) { + sb.append("\tEMPTY"); + } else { + for (String str : inputs.keySet()) { + sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str)); + } + } + LOGGER.debug(sb.toString()); } private String convertNode(final JsonNode node) { @@ -656,7 +560,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String str = this.convertNode((JsonNode) obj); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key,e); + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode "+ key,e); //okay in this instance - only string values (fqdn) are expected to be needed } } else if (obj instanceof java.util.LinkedHashMap) { @@ -665,21 +569,21 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String str = JSON_MAPPER.writeValueAsString(obj); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key,e); - } - } else if (obj instanceof Integer) { - try { - String str = "" + obj; - stringMap.put(key, str); - } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key,e); + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap "+ key,e); + } + } else if (obj instanceof Integer) { + try { + String str = "" + obj; + stringMap.put(key, str); + } catch (Exception e) { + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value for Integer "+ key,e); } } else { try { - String str = obj.toString(); + String str = obj.toString(); stringMap.put(key, str); } catch (Exception e) { - LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")",e); + LOGGER.debug("DANGER WILL ROBINSON: unable to convert value "+ key + " (" + e.getMessage() + ")",e); } } } @@ -705,9 +609,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Holder <String> vnfId, Holder <Map <String, String>> outputs, Holder <VnfRollback> rollback) throws VnfException { - String vfModuleName = vnfName; - String vfModuleType = vnfType; - String vfVersion = vnfVersion; + String vfModuleName = vnfName; + String vfModuleType = vnfType; + String vfVersion = vnfVersion; String mcu = modelCustomizationUuid; boolean useMCUuid = false; if (mcu != null && !mcu.isEmpty()) { @@ -720,45 +624,45 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { useMCUuid = true; } } - MsoLogger.setLogContext (msoRequest); - MsoLogger.setServiceName ("CreateVfModule"); - String requestTypeString = ""; + MsoLogger.setLogContext (msoRequest); + MsoLogger.setServiceName ("CreateVfModule"); + String requestTypeString = ""; if (requestType != null && !"".equals(requestType)) { - requestTypeString = requestType; + requestTypeString = requestType; } String nestedStackId = null; if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) { - if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) { - nestedStackId = volumeGroupHeatStackId; - } + if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) { + nestedStackId = volumeGroupHeatStackId; + } } String nestedBaseStackId = null; if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) { - if (!"null".equalsIgnoreCase(baseVfHeatStackId)) { - nestedBaseStackId = baseVfHeatStackId; - } + if (!"null".equalsIgnoreCase(baseVfHeatStackId)) { + nestedBaseStackId = baseVfHeatStackId; + } } if (inputs == null) { - // Create an empty set of inputs - inputs = new HashMap<>(); - LOGGER.debug("inputs == null - setting to empty"); + // Create an empty set of inputs + inputs = new HashMap<>(); + LOGGER.debug("inputs == null - setting to empty"); } else { - this.sendMapToDebug(inputs); + this.sendMapToDebug(inputs); } //This method will also handle doing things the "old" way - i.e., just orchestrate a VNF boolean oldWay = false; if (requestTypeString.startsWith("X")) { - oldWay = true; - LOGGER.debug("orchestrating a VNF - *NOT* a module!"); - requestTypeString = requestTypeString.substring(1); + oldWay = true; + LOGGER.debug("orchestrating a VNF - *NOT* a module!"); + requestTypeString = requestTypeString.substring(1); } // 1607 - let's parse out the request type we're being sent boolean isBaseRequest = false; boolean isVolumeRequest = false; if (requestTypeString.startsWith("VOLUME")) { - isVolumeRequest = true; + isVolumeRequest = true; } LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId); @@ -799,44 +703,44 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // New with 1607 - more precise handling/messaging if the stack already exists if (heatStack != null && !(heatStack.getStatus () == HeatStatus.NOTFOUND)) { - // INIT, CREATED, NOTFOUND, FAILED, BUILDING, DELETING, UNKNOWN, UPDATING, UPDATED - HeatStatus status = heatStack.getStatus(); - if (status == HeatStatus.INIT || status == HeatStatus.BUILDING || status == HeatStatus.DELETING || status == HeatStatus.UPDATING) { - // fail - it's in progress - return meaningful error + // INIT, CREATED, NOTFOUND, FAILED, BUILDING, DELETING, UNKNOWN, UPDATING, UPDATED + HeatStatus status = heatStack.getStatus(); + if (status == HeatStatus.INIT || status == HeatStatus.BUILDING || status == HeatStatus.DELETING || status == HeatStatus.UPDATING) { + // fail - it's in progress - return meaningful error String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually."; LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); - } - if (status == HeatStatus.FAILED) { - // fail - it exists and is in a FAILED state + } + if (status == HeatStatus.FAILED) { + // fail - it exists and is in a FAILED state String error = "Create VF: Stack " + vfModuleName + " already exists and is in FAILED state in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in FAILED state"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); - } - if (status == HeatStatus.UNKNOWN || status == HeatStatus.UPDATED) { - // fail - it exists and is in a FAILED state + } + if (status == HeatStatus.UNKNOWN || status == HeatStatus.UPDATED) { + // fail - it exists and is in a FAILED state String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudSiteId + "/" + tenantId + "; requires manual intervention."; LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists and is in UPDATED or UNKNOWN state"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); - } - if (status == HeatStatus.CREATED) { - // fail - it exists - if (failIfExists != null && failIfExists) { - String error = "Create VF: Stack " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId; - LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists"); + } + if (status == HeatStatus.CREATED) { + // fail - it exists + if (failIfExists != null && failIfExists) { + String error = "Create VF: Stack " + vfModuleName + " already exists in " + cloudSiteId + "/" + tenantId; + LOGGER.error (MessageEnum.RA_VNF_ALREADY_EXIST, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.DataError, "Stack " + vfModuleName + " already exists"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); - } else { - LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ()); - // Populate the outputs from the existing stack. - vnfId.value = heatStack.getCanonicalName (); - outputs.value = copyStringOutputs (heatStack.getOutputs ()); - rollback.value = vfRollback; // Default rollback - no updates performed - } - } + throw new VnfAlreadyExists (vfModuleName, cloudSiteId, tenantId, heatStack.getCanonicalName ()); + } else { + LOGGER.debug ("Found Existing stack, status=" + heatStack.getStatus ()); + // Populate the outputs from the existing stack. + vnfId.value = heatStack.getCanonicalName (); + outputs.value = copyStringOutputs (heatStack.getOutputs ()); + rollback.value = vfRollback; // Default rollback - no updates performed + } + } LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module"); return; @@ -847,36 +751,36 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { long subStartTime2 = System.currentTimeMillis (); Map<String, Object> nestedVolumeOutputs = null; if (nestedStackId != null) { - try { - LOGGER.debug("Querying for nestedStackId = " + nestedStackId); - nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId); + try { + LOGGER.debug("Querying for nestedStackId = " + nestedStackId); + nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId); LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName); - } catch (MsoException me) { - // Failed to query the Stack due to an openstack exception. - // Convert to a generic VnfException - me.addContext ("CreateVFModule"); - String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("CreateVFModule"); + String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; LOGGER.recordMetricEvent (subStartTime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested stack", me); - LOGGER.debug("ERROR trying to query nested stack= " + error); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested stack", me); + LOGGER.debug("ERROR trying to query nested stack= " + error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); - } - if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { - String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached heatStack ID DOES NOT EXIST"); + throw new VnfException (me); + } + if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { + String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "queryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached heatStack ID DOES NOT EXIST"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - LOGGER.debug(error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); - } else { - LOGGER.debug("Found nested volume heat stack - copying values to inputs *later*"); - //this.sendMapToDebug(inputs); - nestedVolumeOutputs = nestedHeatStack.getOutputs(); - this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs"); - //TODO - //heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); - //this.sendMapToDebug(inputs); - } + LOGGER.debug(error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found nested volume heat stack - copying values to inputs *later*"); + //this.sendMapToDebug(inputs); + nestedVolumeOutputs = nestedHeatStack.getOutputs(); + this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs"); + //TODO + //heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); + //this.sendMapToDebug(inputs); + } } // handle a nestedBaseStackId if sent- this is the stack ID of the base. Should be null for VNF requests @@ -884,36 +788,36 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { long subStartTime3 = System.currentTimeMillis (); Map<String, Object> baseStackOutputs = null; if (nestedBaseStackId != null) { - try { - LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId); - nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId); + try { + LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId); + nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId); LOGGER.recordMetricEvent (subStartTime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "QueryStack", vfModuleName); - } catch (MsoException me) { - // Failed to query the Stack due to an openstack exception. - // Convert to a generic VnfException - me.addContext ("CreateVFModule"); - String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("CreateVFModule"); + String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; LOGGER.recordMetricEvent (subStartTime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", vfModuleName); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested base stack", me); - LOGGER.debug("ERROR trying to query nested base stack= " + error); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "MsoException trying to query nested base stack", me); + LOGGER.debug("ERROR trying to query nested base stack= " + error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); - } - if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) { - String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached base heatStack ID DOES NOT EXIST"); + throw new VnfException (me); + } + if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) { + String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: Attached base heatStack ID DOES NOT EXIST"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, error); - LOGGER.debug(error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); - } else { - LOGGER.debug("Found nested base heat stack - these values will be copied to inputs *later*"); - //this.sendMapToDebug(inputs); - baseStackOutputs = nestedBaseHeatStack.getOutputs(); - this.sendMapToDebug(baseStackOutputs, "baseStackOutputs"); - //TODO - //heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); - //this.sendMapToDebug(inputs); - } + LOGGER.debug(error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found nested base heat stack - these values will be copied to inputs *later*"); + //this.sendMapToDebug(inputs); + baseStackOutputs = nestedBaseHeatStack.getOutputs(); + this.sendMapToDebug(baseStackOutputs, "baseStackOutputs"); + //TODO + //heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); + //this.sendMapToDebug(inputs); + } } // Ready to deploy the new VNF @@ -922,25 +826,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { try { // Retrieve the VF - VfModule vf = null; - VnfResource vnfResource = null; - VfModuleCustomization vfmc = null; - LOGGER.debug("version: " + vfVersion); + VfModule vf = null; + VnfResource vnfResource = null; + VfModuleCustomization vfmc = null; + LOGGER.debug("version: " + vfVersion); if (useMCUuid) { - // 1707 - db refactoring - vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu); - vf = vfmc != null ? vfmc.getVfModule() : null; + // 1707 - db refactoring + vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu); + vf = vfmc != null ? vfmc.getVfModule() : null; // 1702 - this will be the new way going forward. We find the vf by mcu - otherwise, code is the same. - //vf = db.getVfModuleByModelCustomizationUuid(mcu); + //vf = db.getVfModuleByModelCustomizationUuid(mcu); if (vf == null) { - LOGGER.debug("Unable to find vfModuleCust with modelCustomizationUuid=" + mcu); - String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu; + LOGGER.debug("Unable to find vfModuleCust with modelCustomizationUuid=" + mcu); + String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu; LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug("Found vfModuleCust entry " + vfmc.toString()); + LOGGER.debug("Found vfModuleCust entry " + vfmc.toString()); } if (vf.isBase()) { isBaseRequest = true; @@ -951,211 +855,211 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); } } - } - /* - else if (!oldWay) { - // Need to handle old and new schema methods - for a time. Try the new way first. - if (vfVersion != null && !vfVersion.isEmpty()) { - vf = db.getVfModuleType(vfModuleType, vfVersion); - if (vf == null) { - LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the TYPE column - will try in MODEL_NAME"); - vf = db.getVfModuleModelName(vfModuleType, vfVersion); - if (vf == null) { - LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the MODEL_NAME field either - ERROR"); - } - } - } else { - vf = db.getVfModuleType(vfModuleType); - if (vf == null) { - LOGGER.debug("Unable to find " + vfModuleType + " in the TYPE column - will try in MODEL_NAME"); - vf = db.getVfModuleModelName(vfModuleType); - if (vf == null) { - LOGGER.debug("Unable to find " + vfModuleType + " in the MODEL_NAME field either - ERROR"); - } - } - } - if (vf == null) { - String error = "Create VF Module: Unable to determine specific VF Module Type: " - + vfModuleType; - if (vfVersion != null && !vfVersion.isEmpty()) { - error += " with version = " + vfVersion; - } - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to determine specific VF Module Type"); + } + /* + else if (!oldWay) { + // Need to handle old and new schema methods - for a time. Try the new way first. + if (vfVersion != null && !vfVersion.isEmpty()) { + vf = db.getVfModuleType(vfModuleType, vfVersion); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the TYPE column - will try in MODEL_NAME"); + vf = db.getVfModuleModelName(vfModuleType, vfVersion); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " and version=" + vfVersion + " in the MODEL_NAME field either - ERROR"); + } + } + } else { + vf = db.getVfModuleType(vfModuleType); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " in the TYPE column - will try in MODEL_NAME"); + vf = db.getVfModuleModelName(vfModuleType); + if (vf == null) { + LOGGER.debug("Unable to find " + vfModuleType + " in the MODEL_NAME field either - ERROR"); + } + } + } + if (vf == null) { + String error = "Create VF Module: Unable to determine specific VF Module Type: " + + vfModuleType; + if (vfVersion != null && !vfVersion.isEmpty()) { + error += " with version = " + vfVersion; + } + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, + "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to determine specific VF Module Type"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } - LOGGER.debug("Got VF module definition from Catalog: " - + vf.toString()); - - if (vf.isBase()) { - isBaseRequest = true; - LOGGER.debug("This is a BASE VF request!"); - } else { - LOGGER.debug("This is *not* a BASE VF request!"); - if (!isVolumeRequest && nestedBaseStackId == null) { - LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); - } - } - } */ - else { // This is to support gamma only - get info from vnf_resource table - if (vfVersion != null && !vfVersion.isEmpty()) { - vnfResource = db.getVnfResource(vnfType, vnfVersion); - } else { - vnfResource = db.getVnfResource(vnfType); - } - if (vnfResource == null) { - String error = "Create VNF: Unknown VNF Type: " + vnfType; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", - vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type"); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } + LOGGER.debug("Got VF module definition from Catalog: " + + vf.toString()); + + if (vf.isBase()) { + isBaseRequest = true; + LOGGER.debug("This is a BASE VF request!"); + } else { + LOGGER.debug("This is *not* a BASE VF request!"); + if (!isVolumeRequest && nestedBaseStackId == null) { + LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); + } + } + } */ + else { // This is to support gamma only - get info from vnf_resource table + if (vfVersion != null && !vfVersion.isEmpty()) { + vnfResource = db.getVnfResource(vnfType, vnfVersion); + } else { + vnfResource = db.getVnfResource(vnfType); + } + if (vnfResource == null) { + String error = "Create VNF: Unknown VNF Type: " + vnfType; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", + vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } - LOGGER.debug("Got VNF module definition from Catalog: " - + vnfResource.toString()); - } - // By here - we have either a vf or vnfResource + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } + LOGGER.debug("Got VNF module definition from Catalog: " + + vnfResource.toString()); + } + // By here - we have either a vf or vnfResource //1607 - Add version check // First - see if it's in the VnfResource record // if we have a vf Module - then we have to query to get the VnfResource record. if (!oldWay) { - if (vf.getVnfResourceModelUUId() != null) { - String vnfResourceModelUuid = vf.getVnfResourceModelUUId(); - //vnfResource = db.getVnfResourceById(vnfResourceId); - vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid); - if (vnfResource == null) { - LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); - } - } + if (vf.getVnfResourceModelUUId() != null) { + String vnfResourceModelUuid = vf.getVnfResourceModelUUId(); + //vnfResource = db.getVnfResourceById(vnfResourceId); + vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid); + if (vnfResource == null) { + LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); + } + } } String minVersionVnf = null; String maxVersionVnf = null; if (vnfResource != null) { - try { - minVersionVnf = vnfResource.getAicVersionMin(); - maxVersionVnf = vnfResource.getAicVersionMax(); - } catch (Exception e) { - LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e); - minVersionVnf = null; - maxVersionVnf = null; - } - if (minVersionVnf != null && "".equals(minVersionVnf)) { - minVersionVnf = null; - } - if (maxVersionVnf != null && "".equals(maxVersionVnf)) { - maxVersionVnf = null; - } - } - if (minVersionVnf != null && maxVersionVnf != null) { - MavenLikeVersioning aicV = new MavenLikeVersioning(); - CloudSite cloudSite = null; - if (this.cloudConfig == null) { - this.cloudConfig = this.cloudConfigFactory.getCloudConfig(); - } - // double check - if (this.cloudConfig != null) { - cloudSite = this.cloudConfig.getCloudSite(cloudSiteId); - if (cloudSite != null) { - aicV.setVersion(cloudSite.getAic_version()); - // Add code to handle unexpected values in here - boolean moreThanMin = true; - boolean equalToMin = true; - boolean moreThanMax = true; - boolean equalToMax = true; - boolean doNotTest = false; - try { - moreThanMin = aicV.isMoreRecentThan(minVersionVnf); - equalToMin = aicV.isTheSameVersion(minVersionVnf); - moreThanMax = aicV.isMoreRecentThan(maxVersionVnf); - equalToMax = aicV.isTheSameVersion(maxVersionVnf); - } catch (Exception e) { - LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + " - will default to not check",e); - doNotTest = true; - } - if (!doNotTest) { - if ((moreThanMin || equalToMin) // aic >= min - && (equalToMax || !(moreThanMax))) { //aic <= max - LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version()); - } else { - // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version(); - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); - LOGGER.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } - } else { - LOGGER.debug("bypassing testing AIC version..."); - } - } // let this error out downstream to avoid introducing uncertainty at this stage - } else { - LOGGER.debug("cloudConfig is NULL - cannot check cloud site version"); - } - } else { - LOGGER.debug("AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked."); - } - // End Version check 1607 + try { + minVersionVnf = vnfResource.getAicVersionMin(); + maxVersionVnf = vnfResource.getAicVersionMax(); + } catch (Exception e) { + LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e); + minVersionVnf = null; + maxVersionVnf = null; + } + if (minVersionVnf != null && "".equals(minVersionVnf)) { + minVersionVnf = null; + } + if (maxVersionVnf != null && "".equals(maxVersionVnf)) { + maxVersionVnf = null; + } + } + if (minVersionVnf != null && maxVersionVnf != null) { + MavenLikeVersioning aicV = new MavenLikeVersioning(); + CloudSite cloudSite = null; + if (this.cloudConfig == null) { + this.cloudConfig = this.cloudConfigFactory.getCloudConfig(); + } + // double check + if (this.cloudConfig != null) { + cloudSite = this.cloudConfig.getCloudSite(cloudSiteId); + if (cloudSite != null) { + aicV.setVersion(cloudSite.getAic_version()); + // Add code to handle unexpected values in here + boolean moreThanMin = true; + boolean equalToMin = true; + boolean moreThanMax = true; + boolean equalToMax = true; + boolean doNotTest = false; + try { + moreThanMin = aicV.isMoreRecentThan(minVersionVnf); + equalToMin = aicV.isTheSameVersion(minVersionVnf); + moreThanMax = aicV.isMoreRecentThan(maxVersionVnf); + equalToMax = aicV.isTheSameVersion(maxVersionVnf); + } catch (Exception e) { + LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + " - will default to not check",e); + doNotTest = true; + } + if (!doNotTest) { + if ((moreThanMin || equalToMin) // aic >= min + && (equalToMax || !(moreThanMax))) { //aic <= max + LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version()); + } else { + // ERROR + String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version(); + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); + LOGGER.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); + } + } else { + LOGGER.debug("bypassing testing AIC version..."); + } + } // let this error out downstream to avoid introducing uncertainty at this stage + } else { + LOGGER.debug("cloudConfig is NULL - cannot check cloud site version"); + } + } else { + LOGGER.debug("AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked."); + } + // End Version check 1607 // with VF_MODULE - we have both the non-vol and vol template/envs in that object // with VNF_RESOURCE - we use the old methods. //Integer heatTemplateId = null; //Integer heatEnvtId = null; - + String heatTemplateArtifactUuid = null; String heatEnvironmentArtifactUuid = null; - if (!oldWay) { - if (isVolumeRequest) { - heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId(); - heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid(); - } else { - heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId(); - heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid(); - } - } else { - if (isVolumeRequest) { - LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?"); - /* - VnfComponent vnfComponent = null; - vnfComponent = db.getVnfComponent(vnfResource.getId(), "VOLUME"); - if (vnfComponent == null) { - String error = "Create VNF: Cannot find VNF Component entry for: " + vnfType + ", type = VOLUME"; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", vnfType, "OpenStack", "getVnfComponent", MsoLogger.ErrorCode.DataError, "Create VNF: Cannot find VNF Component entry"); + if (!oldWay) { + if (isVolumeRequest) { + heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId(); + heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid(); + } else { + heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId(); + heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid(); + } + } else { + if (isVolumeRequest) { + LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?"); + /* + VnfComponent vnfComponent = null; + vnfComponent = db.getVnfComponent(vnfResource.getId(), "VOLUME"); + if (vnfComponent == null) { + String error = "Create VNF: Cannot find VNF Component entry for: " + vnfType + ", type = VOLUME"; + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", vnfType, "OpenStack", "getVnfComponent", MsoLogger.ErrorCode.DataError, "Create VNF: Cannot find VNF Component entry"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); - } else { - heatTemplateId = vnfComponent.getHeatTemplateId(); - heatEnvtId = vnfComponent.getHeatEnvironmentId(); - } - */ - } else { - heatTemplateArtifactUuid = vnfResource.getTemplateId(); - heatEnvironmentArtifactUuid = null; - } - } - // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null) - HeatTemplate heatTemplate = null; - if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) { - String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database"); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + heatTemplateId = vnfComponent.getHeatTemplateId(); + heatEnvtId = vnfComponent.getHeatEnvironmentId(); + } + */ + } else { + heatTemplateArtifactUuid = vnfResource.getTemplateId(); + heatEnvironmentArtifactUuid = null; + } + } + // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null) + HeatTemplate heatTemplate = null; + if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) { + String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); - throw new VnfException(error, MsoExceptionCategory.INTERNAL); - } else { - heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid); - } - if (heatTemplate == null) { - String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "Heat Template ID", - String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, + MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } else { + heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid); + } + if (heatTemplate == null) { + String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, + "Heat Template ID", + String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); - throw new VnfException(error, MsoExceptionCategory.INTERNAL); - } - LOGGER.debug("Got HEAT Template from DB"); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, + MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } + LOGGER.debug("Got HEAT Template from DB"); HeatEnvironment heatEnvironment = null; String heatEnvironmentString = null; @@ -1206,65 +1110,65 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 1510 - Also add the files: for any get_files associated with this vnf_resource_id // *if* there are any Map<String, HeatFiles> heatFiles = null; - Map<String, Object> heatFilesObjects = new HashMap<>(); + Map<String, Object> heatFilesObjects = new HashMap<>(); // Add ability to turn on adding get_files with volume requests (by property). boolean addGetFilesOnVolumeReq = false; try { - String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); - if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { - addGetFilesOnVolumeReq = true; - LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); - } + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); + if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { + addGetFilesOnVolumeReq = true; + LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); + } } catch (Exception e) { - LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e); - } - - if (!isVolumeRequest || addGetFilesOnVolumeReq) { - if (oldWay) { - LOGGER.debug("In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!"); - //heatFiles = db.getHeatFiles(vnfResource.getId()); - } else { - // 1607 - now use VF_MODULE_TO_HEAT_FILES table - LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" - + vf.getModelUUID()); - heatFiles = db - .getHeatFilesForVfModule(vf.getModelUUID()); - } - if (heatFiles != null) { - // add these to stack - to be done in createStack - // here, we will map them to Map<String, Object> from - // Map<String, HeatFiles> - // this will match the nested templates format - LOGGER.debug("Contents of heatFiles - to be added to files: on stack:"); - - for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) { - String heatFileName = entry.getKey(); - HeatFiles value = entry.getValue(); - if (heatFileName.startsWith("_ERROR|")) { - // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. - String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); - String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId; - LOGGER.debug(error); - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "HEAT_FILES entry not found"); + LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e); + } + + if (!isVolumeRequest || addGetFilesOnVolumeReq) { + if (oldWay) { + LOGGER.debug("In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!"); + //heatFiles = db.getHeatFiles(vnfResource.getId()); + } else { + // 1607 - now use VF_MODULE_TO_HEAT_FILES table + LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + + vf.getModelUUID()); + heatFiles = db + .getHeatFilesForVfModule(vf.getModelUUID()); + } + if (heatFiles != null) { + // add these to stack - to be done in createStack + // here, we will map them to Map<String, Object> from + // Map<String, HeatFiles> + // this will match the nested templates format + LOGGER.debug("Contents of heatFiles - to be added to files: on stack:"); + + for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) { + String heatFileName = entry.getKey(); + HeatFiles value = entry.getValue(); + if (heatFileName.startsWith("_ERROR|")) { + // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. + String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); + String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId; + LOGGER.debug(error); + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "HEAT_FILES entry not found"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); - } - String heatFileBody = value.getFileBody(); - String heatFileNameChecked = heatFileName; - LOGGER.debug(heatFileNameChecked + " -> " - + heatFileBody); - heatFilesObjects.put(heatFileNameChecked, heatFileBody); - } - } else { - LOGGER.debug("No heat files found -nothing to do here"); - heatFilesObjects = null; - } - } else { - LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES"); - } + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + throw new VnfException (error, MsoExceptionCategory.INTERNAL); + } + String heatFileBody = value.getFileBody(); + String heatFileNameChecked = heatFileName; + LOGGER.debug(heatFileNameChecked + " -> " + + heatFileBody); + heatFilesObjects.put(heatFileNameChecked, heatFileBody); + } + } else { + LOGGER.debug("No heat files found -nothing to do here"); + heatFilesObjects = null; + } + } else { + LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES"); + } // Check that required parameters have been supplied String missingParams = null; @@ -1295,47 +1199,47 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoHeatEnvironmentEntry mhee = null; if (heatEnvironmentString != null && heatEnvironmentString.contains ("parameters:")) { //LOGGER.debug ("Have an Environment argument with a parameters: section - will bypass checking for valid params - but will still check for aliases"); - LOGGER.debug("Enhanced environment checking enabled - 1604"); + LOGGER.debug("Enhanced environment checking enabled - 1604"); StringBuilder sb = new StringBuilder(heatEnvironmentString); //LOGGER.debug("About to create MHEE with " + sb); mhee = new MsoHeatEnvironmentEntry(sb); StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n"); for (HeatTemplateParam parm : heatTemplate.getParameters()) { - sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired()); + sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired()); } if (!mhee.isValid()) { - sb2.append("Environment says it's not valid! " + mhee.getErrorString()); + sb2.append("Environment says it's not valid! " + mhee.getErrorString()); } else { - sb2.append("\nEnvironment:"); - sb2.append(mhee.toFullString()); + sb2.append("\nEnvironment:"); + sb2.append(mhee.toFullString()); } LOGGER.debug(sb2.toString()); } else { - LOGGER.debug("NO ENVIRONMENT for this entry"); + LOGGER.debug("NO ENVIRONMENT for this entry"); } // New with 1707 - all variables converted to their native object types HashMap<String, Object> goldenInputs = null; - + LOGGER.debug("Now handle the inputs....first convert"); ArrayList<String> parameterNames = new ArrayList<>(); HashMap<String, String> aliasToParam = new HashMap<>(); StringBuilder sb = new StringBuilder("\nTemplate Parameters:\n"); int cntr = 0; - try { - for (HeatTemplateParam htp : heatTemplate.getParameters()) { - sb.append("param[" + cntr++ + "]=" + htp.getParamName()); - parameterNames.add(htp.getParamName()); - if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) { - aliasToParam.put(htp.getParamAlias(), htp.getParamName()); - sb.append(" ** (alias=" + htp.getParamAlias() + ")"); - } - sb.append("\n"); - } - LOGGER.debug(sb.toString()); + try { + for (HeatTemplateParam htp : heatTemplate.getParameters()) { + sb.append("param[" + cntr++ + "]=" + htp.getParamName()); + parameterNames.add(htp.getParamName()); + if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) { + aliasToParam.put(htp.getParamAlias(), htp.getParamName()); + sb.append(" ** (alias=" + htp.getParamAlias() + ")"); + } + sb.append("\n"); + } + LOGGER.debug(sb.toString()); } catch (Exception e) { - LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(),e); + LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(),e); } - // Step 1 - convert what we got as inputs (Map<String, String>) to a + // Step 1 - convert what we got as inputs (Map<String, String>) to a // Map<String, Object> - where the object matches the param type identified in the template // This will also not copy over params that aren't identified in the template goldenInputs = heat.convertInputMap(inputs, heatTemplate); @@ -1346,7 +1250,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug("Now add in the volume stack outputs if applicable"); heat.copyBaseOutputsToInputs(goldenInputs, nestedVolumeOutputs, parameterNames, aliasToParam); this.sendMapToDebug(goldenInputs, "Final inputs sent to openstack"); - + for (HeatTemplateParam parm : heatTemplate.getParameters ()) { LOGGER.debug ("Parameter:'" + parm.getParamName () + "', isRequired=" @@ -1355,8 +1259,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { + parm.getParamAlias ()); if (parm.isRequired () && (goldenInputs == null || !goldenInputs.containsKey (parm.getParamName ()))) { - // The check for an alias was moved to the method in MsoHeatUtils - when we converted the Map<String, String> to Map<String, Object> - LOGGER.debug("**Parameter " + parm.getParamName() + " is required and not in the inputs...check environment"); + // The check for an alias was moved to the method in MsoHeatUtils - when we converted the Map<String, String> to Map<String, Object> + LOGGER.debug("**Parameter " + parm.getParamName() + " is required and not in the inputs...check environment"); if (mhee != null && mhee.containsParameter(parm.getParamName())) { LOGGER.debug ("Required parameter " + parm.getParamName () + " appears to be in environment - do not count as missing"); @@ -1372,25 +1276,25 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { paramList.add (parm.getParamName ()); } if (missingParams != null) { - if (checkRequiredParameters) { - // Problem - missing one or more required parameters - String error = "Create VFModule: Missing Required inputs: " + missingParams; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs"); + if (checkRequiredParameters) { + // Problem - missing one or more required parameters + String error = "Create VFModule: Missing Required inputs: " + missingParams; + LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); - } else { - LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); - } + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); + } } else { LOGGER.debug ("No missing parameters found - ok to proceed"); } - // We can now remove the recreating of the ENV with only legit params - that check is done for us, + // We can now remove the recreating of the ENV with only legit params - that check is done for us, // and it causes problems with json that has arrays String newEnvironmentString = null; if (mhee != null) { - newEnvironmentString = mhee.getRawEntry().toString(); + newEnvironmentString = mhee.getRawEntry().toString(); } - + // "Fix" the template if it has CR/LF (getting this from Oracle) String template = heatTemplate.getHeatTemplate (); template = template.replaceAll ("\r\n", "\n"); @@ -1402,13 +1306,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { try { // heatStack = heat.createStack(cloudSiteId, tenantId, vnfName, template, inputs, true, // heatTemplate.getTimeoutMinutes()); - if (backout == null) { - backout = true; - } - if (heat != null) { - LOGGER.debug("heat is not null!!"); - } - heatStack = heat.createStack (cloudSiteId, + if (backout == null) { + backout = true; + } + if (heat != null) { + LOGGER.debug("heat is not null!!"); + } + heatStack = heat.createStack (cloudSiteId, tenantId, vfModuleName, template, @@ -1439,11 +1343,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack", "OpenStack", "CreateStack", vfModuleName); LOGGER.debug("unhandled exception at heat.createStack",e); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack"); - throw new VnfException("Exception during heat.createStack! " + e.getMessage()); + throw new VnfException("Exception during heat.createStack! " + e.getMessage()); } } catch (Exception e) { - LOGGER.debug("unhandled exception in create VF",e); - throw new VnfException("Exception during create VF " + e.getMessage()); + LOGGER.debug("unhandled exception in create VF",e); + throw new VnfException("Exception during create VF " + e.getMessage()); } finally { // Make sure DB session is closed @@ -1461,7 +1365,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug ("VF Module " + vfModuleName + " successfully created"); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create VF Module"); - return; } @Override @@ -1471,7 +1374,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoRequest msoRequest, Holder <Map <String, String>> outputs) throws VnfException { MsoLogger.setLogContext (msoRequest); - MsoLogger.setServiceName ("DeleteVf"); + MsoLogger.setServiceName ("DeleteVf"); LOGGER.debug ("Deleting VF " + vnfName + " in " + cloudSiteId + "/" + tenantId); // Will capture execution time for metrics long startTime = System.currentTimeMillis (); @@ -1517,7 +1420,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // On success, nothing is returned. LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete VF"); - return; } @Override @@ -1535,26 +1437,26 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { MsoRequest msoRequest, Holder <Map <String, String>> outputs, Holder <VnfRollback> rollback) throws VnfException { - String vfModuleName = vnfName; - String vfModuleType = vnfType; - String methodName = "updateVfModule"; - MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ()); - String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName; - MsoLogger.setServiceName (serviceName); - - StringBuilder sbInit = new StringBuilder(); - sbInit.append("updateVfModule: \n"); - sbInit.append("cloudSiteId=" + cloudSiteId + "\n"); - sbInit.append("tenantId=" + tenantId + "\n"); - sbInit.append("vnfType=" + vnfType + "\n"); - sbInit.append("vnfVersion=" + vnfVersion + "\n"); - sbInit.append("vnfName=" + vnfName + "\n"); - sbInit.append("requestType=" + requestType + "\n"); - sbInit.append("volumeGroupHeatStackId=" + volumeGroupHeatStackId + "\n"); - sbInit.append("baseVfHeatStackId=" + baseVfHeatStackId + "\n"); - sbInit.append("vfModuleStackId=" + vfModuleStackId + "\n"); - sbInit.append("modelCustomizationUuid=" + modelCustomizationUuid + "\n"); - LOGGER.debug(sbInit.toString()); + String vfModuleName = vnfName; + String vfModuleType = vnfType; + String methodName = "updateVfModule"; + MsoLogger.setLogContext (msoRequest.getRequestId (), msoRequest.getServiceInstanceId ()); + String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName; + MsoLogger.setServiceName (serviceName); + + StringBuilder sbInit = new StringBuilder(); + sbInit.append("updateVfModule: \n"); + sbInit.append("cloudSiteId=" + cloudSiteId + "\n"); + sbInit.append("tenantId=" + tenantId + "\n"); + sbInit.append("vnfType=" + vnfType + "\n"); + sbInit.append("vnfVersion=" + vnfVersion + "\n"); + sbInit.append("vnfName=" + vnfName + "\n"); + sbInit.append("requestType=" + requestType + "\n"); + sbInit.append("volumeGroupHeatStackId=" + volumeGroupHeatStackId + "\n"); + sbInit.append("baseVfHeatStackId=" + baseVfHeatStackId + "\n"); + sbInit.append("vfModuleStackId=" + vfModuleStackId + "\n"); + sbInit.append("modelCustomizationUuid=" + modelCustomizationUuid + "\n"); + LOGGER.debug(sbInit.toString()); String mcu = modelCustomizationUuid; boolean useMCUuid = false; @@ -1569,39 +1471,39 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } - String requestTypeString = ""; + String requestTypeString = ""; if (requestType != null && !"".equals(requestType)) { - requestTypeString = requestType; + requestTypeString = requestType; } String nestedStackId = null; if (volumeGroupHeatStackId != null && !"".equals(volumeGroupHeatStackId)) { - if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) { - nestedStackId = volumeGroupHeatStackId; - } + if (!"null".equalsIgnoreCase(volumeGroupHeatStackId)) { + nestedStackId = volumeGroupHeatStackId; + } } String nestedBaseStackId = null; if (baseVfHeatStackId != null && !"".equals(baseVfHeatStackId)) { - if (!"null".equalsIgnoreCase(baseVfHeatStackId)) { - nestedBaseStackId = baseVfHeatStackId; - } + if (!"null".equalsIgnoreCase(baseVfHeatStackId)) { + nestedBaseStackId = baseVfHeatStackId; + } } if (inputs == null) { - // Create an empty set of inputs - inputs = new HashMap<>(); - LOGGER.debug("inputs == null - setting to empty"); + // Create an empty set of inputs + inputs = new HashMap<>(); + LOGGER.debug("inputs == null - setting to empty"); } else { - this.sendMapToDebug(inputs); + this.sendMapToDebug(inputs); } boolean isBaseRequest = false; boolean isVolumeRequest = false; if (requestTypeString.startsWith("VOLUME")) { - isVolumeRequest = true; + isVolumeRequest = true; } if (vfModuleName == null || "".equals(vfModuleName.trim())) { - if (vfModuleStackId != null) { - vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId); - } + if (vfModuleStackId != null) { + vfModuleName = this.getVfModuleNameFromModuleStackId(vfModuleStackId); + } } LOGGER.debug ("Updating VFModule: " + vfModuleName + " of type " + vfModuleType + "in " + cloudSiteId + "/" + tenantId); @@ -1662,74 +1564,74 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { long queryStackStarttime2 = System.currentTimeMillis (); Map<String, Object> nestedVolumeOutputs = null; if (nestedStackId != null) { - try { - LOGGER.debug("Querying for nestedStackId = " + nestedStackId); - nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId); + try { + LOGGER.debug("Querying for nestedStackId = " + nestedStackId); + nestedHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedStackId); LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null); - } catch (MsoException me) { - // Failed to query the Stack due to an openstack exception. - // Convert to a generic VnfException - me.addContext ("UpdateVFModule"); - String error = "Update VF: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("UpdateVFModule"); + String error = "Update VF: Attached heatStack ID Query " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; LOGGER.recordMetricEvent (queryStackStarttime2, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); - LOGGER.debug("ERROR trying to query nested stack= " + error); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); + LOGGER.debug("ERROR trying to query nested stack= " + error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); - } - if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { - MsoLogger.setServiceName (serviceName); - String error = "Update VFModule: Attached volume heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error); - LOGGER.debug(error); + throw new VnfException (me); + } + if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { + MsoLogger.setServiceName (serviceName); + String error = "Update VFModule: Attached volume heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error); + LOGGER.debug(error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); - } else { - LOGGER.debug("Found nested heat stack - copying values to inputs *later*"); - nestedVolumeOutputs = nestedHeatStack.getOutputs(); - //this.sendMapToDebug(inputs); - this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs"); - //TODO - heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); - //this.sendMapToDebug(inputs); - } + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found nested heat stack - copying values to inputs *later*"); + nestedVolumeOutputs = nestedHeatStack.getOutputs(); + //this.sendMapToDebug(inputs); + this.sendMapToDebug(nestedVolumeOutputs, "volumeStackOutputs"); + //TODO + heat.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); + //this.sendMapToDebug(inputs); + } } // handle a nestedBaseStackId if sent - this is the stack ID of the base. StackInfo nestedBaseHeatStack = null; Map<String, Object> baseStackOutputs = null; if (nestedBaseStackId != null) { long queryStackStarttime3 = System.currentTimeMillis (); - try { - LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId); - nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId); + try { + LOGGER.debug("Querying for nestedBaseStackId = " + nestedBaseStackId); + nestedBaseHeatStack = heat.queryStack(cloudSiteId, tenantId, nestedBaseStackId); LOGGER.recordMetricEvent (queryStackStarttime3, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "QueryStack", null); - } catch (MsoException me) { - // Failed to query the Stack due to an openstack exception. - // Convert to a generic VnfException - me.addContext ("UpdateVfModule"); - String error = "Update VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; + } catch (MsoException me) { + // Failed to query the Stack due to an openstack exception. + // Convert to a generic VnfException + me.addContext ("UpdateVfModule"); + String error = "Update VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + ": " + me ; LOGGER.recordMetricEvent (queryStackStarttime3, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "QueryStack", null); - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); - LOGGER.debug("ERROR trying to query nested base stack= " + error); + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); + LOGGER.debug("ERROR trying to query nested base stack= " + error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); - } - if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) { - MsoLogger.setServiceName (serviceName); - String error = "Update VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error); + throw new VnfException (me); + } + if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) { + MsoLogger.setServiceName (serviceName); + String error = "Update VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR" ; + LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, cloudSiteId, tenantId, error, "OpenStack", "QueryStack", MsoLogger.ErrorCode.DataError, error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - LOGGER.debug(error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); - } else { - LOGGER.debug("Found nested base heat stack - copying values to inputs *later*"); - baseStackOutputs = nestedBaseHeatStack.getOutputs(); - //this.sendMapToDebug(inputs); - this.sendMapToDebug(baseStackOutputs, "baseStackOutputs"); - //TODO - heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); - //this.sendMapToDebug(inputs); - } + LOGGER.debug(error); + throw new VnfException (error, MsoExceptionCategory.USERDATA); + } else { + LOGGER.debug("Found nested base heat stack - copying values to inputs *later*"); + baseStackOutputs = nestedBaseHeatStack.getOutputs(); + //this.sendMapToDebug(inputs); + this.sendMapToDebug(baseStackOutputs, "baseStackOutputs"); + //TODO + heat.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); + //this.sendMapToDebug(inputs); + } } // Ready to deploy the new VNF @@ -1741,131 +1643,131 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { try { // Retrieve the VF definition VnfResource vnfResource = null; - VfModule vf = null; - VfModuleCustomization vfmc = null; + VfModule vf = null; + VfModuleCustomization vfmc = null; if (useMCUuid) { - //vf = db.getVfModuleByModelCustomizationUuid(mcu); - vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu); - vf = vfmc != null ? vfmc.getVfModule() : null; + //vf = db.getVfModuleByModelCustomizationUuid(mcu); + vfmc = db.getVfModuleCustomizationByModelCustomizationId(mcu); + vf = vfmc != null ? vfmc.getVfModule() : null; if (vf == null) { LOGGER.debug("Unable to find a vfModule matching modelCustomizationUuid=" + mcu); } - } else { - LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!"); + } else { + LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!"); } - if (vf == null) { - String error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu; + if (vf == null) { + String error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu; LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); throw new VnfException (error, MsoExceptionCategory.USERDATA); } LOGGER.debug ("Got VF module definition from Catalog: " + vf.toString ()); if (vf.isBase()) { - isBaseRequest = true; - LOGGER.debug("This a BASE update request"); + isBaseRequest = true; + LOGGER.debug("This a BASE update request"); } else { - LOGGER.debug("This is *not* a BASE VF update request"); - if (!isVolumeRequest && nestedBaseStackId == null) { - LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); - } + LOGGER.debug("This is *not* a BASE VF update request"); + if (!isVolumeRequest && nestedBaseStackId == null) { + LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); + } } - + //1607 - Add version check // First - see if it's in the VnfResource record // if we have a vf Module - then we have to query to get the VnfResource record. - if (vf.getVnfResourceModelUUId() != null) { - String vnfResourceModelUuid = vf.getVnfResourceModelUUId(); - //vnfResource = db.getVnfResourceById(vnfResourceId); - vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid); - if (vnfResource == null) { - LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); - } + if (vf.getVnfResourceModelUUId() != null) { + String vnfResourceModelUuid = vf.getVnfResourceModelUUId(); + //vnfResource = db.getVnfResourceById(vnfResourceId); + vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid); + if (vnfResource == null) { + LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); + } } String minVersionVnf = null; String maxVersionVnf = null; if (vnfResource != null) { - try { - minVersionVnf = vnfResource.getAicVersionMin(); - maxVersionVnf = vnfResource.getAicVersionMax(); - } catch (Exception e) { - LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e); - minVersionVnf = null; - maxVersionVnf = null; - } - if (minVersionVnf != null && "".equals(minVersionVnf)) { - minVersionVnf = null; - } - if (maxVersionVnf != null && "".equals(maxVersionVnf)) { - maxVersionVnf = null; - } - } - if (minVersionVnf != null && maxVersionVnf != null) { - MavenLikeVersioning aicV = new MavenLikeVersioning(); - CloudSite cloudSite = null; - //String aicVersion = ""; - if (this.cloudConfig == null) { - this.cloudConfig = this.cloudConfigFactory.getCloudConfig(); - } - // double check - if (this.cloudConfig != null) { - cloudSite = this.cloudConfig.getCloudSite(cloudSiteId); - if (cloudSite != null) { - aicV.setVersion(cloudSite.getAic_version()); - if ((aicV.isMoreRecentThan(minVersionVnf) || aicV.isTheSameVersion(minVersionVnf)) // aic >= min - && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV.isMoreRecentThan(maxVersionVnf)))) { //aic <= max - LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version()); - } else { - // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version(); - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); - LOGGER.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); + try { + minVersionVnf = vnfResource.getAicVersionMin(); + maxVersionVnf = vnfResource.getAicVersionMax(); + } catch (Exception e) { + LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e); + minVersionVnf = null; + maxVersionVnf = null; + } + if (minVersionVnf != null && "".equals(minVersionVnf)) { + minVersionVnf = null; + } + if (maxVersionVnf != null && "".equals(maxVersionVnf)) { + maxVersionVnf = null; + } + } + if (minVersionVnf != null && maxVersionVnf != null) { + MavenLikeVersioning aicV = new MavenLikeVersioning(); + CloudSite cloudSite = null; + //String aicVersion = ""; + if (this.cloudConfig == null) { + this.cloudConfig = this.cloudConfigFactory.getCloudConfig(); + } + // double check + if (this.cloudConfig != null) { + cloudSite = this.cloudConfig.getCloudSite(cloudSiteId); + if (cloudSite != null) { + aicV.setVersion(cloudSite.getAic_version()); + if ((aicV.isMoreRecentThan(minVersionVnf) || aicV.isTheSameVersion(minVersionVnf)) // aic >= min + && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV.isMoreRecentThan(maxVersionVnf)))) { //aic <= max + LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version()); + } else { + // ERROR + String error = "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSite.getId() + " with AIC_Version:" + cloudSite.getAic_version(); + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); + LOGGER.debug(error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); } - } // let this error out downstream to avoid introducing uncertainty at this stage + } // let this error out downstream to avoid introducing uncertainty at this stage } else { - LOGGER.debug("cloudConfig is NULL - cannot check cloud site version"); + LOGGER.debug("cloudConfig is NULL - cannot check cloud site version"); } - } else { - LOGGER.debug("AIC Version not set in VNF_Resource - do not error for now - not checked."); + } else { + LOGGER.debug("AIC Version not set in VNF_Resource - do not error for now - not checked."); } - // End Version check 1607 - - String heatTemplateArtifactUuid = null; - String heatEnvironmentArtifactUuid = null; + // End Version check 1607 + + String heatTemplateArtifactUuid = null; + String heatEnvironmentArtifactUuid = null; HeatTemplate heatTemplate = null; - if (isVolumeRequest) { - heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId(); - heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid(); - } else { - heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId(); - heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid(); - } - if (heatTemplateArtifactUuid == null) { - String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestTypeString; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + if (isVolumeRequest) { + heatTemplateArtifactUuid = vf.getVolHeatTemplateArtifactUUId(); + heatEnvironmentArtifactUuid = vfmc.getVolEnvironmentArtifactUuid(); + } else { + heatTemplateArtifactUuid = vf.getHeatTemplateArtifactUUId(); + heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid(); + } + if (heatTemplateArtifactUuid == null) { + String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestTypeString; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); - throw new VnfException(error, MsoExceptionCategory.INTERNAL); - } else { - heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid); - } - - if (heatTemplate == null) { - String error = "Update VNF: undefined Heat Template. VF=" - + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "Heat Template ID", - String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, + MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } else { + heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid); + } + + if (heatTemplate == null) { + String error = "Update VNF: undefined Heat Template. VF=" + + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, + "Heat Template ID", + String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, + MsoAlarmLogger.CRITICAL, error); - throw new VnfException(error, MsoExceptionCategory.INTERNAL); - } + throw new VnfException(error, MsoExceptionCategory.INTERNAL); + } LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ()); @@ -1929,19 +1831,19 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Add ability to turn on adding get_files with volume requests (by property). boolean addGetFilesOnVolumeReq = false; try { - String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); - if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { - addGetFilesOnVolumeReq = true; - LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); - } + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); + if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { + addGetFilesOnVolumeReq = true; + LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); + } } catch (Exception e) { - LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e); + LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e); } if (!isVolumeRequest || addGetFilesOnVolumeReq) { - LOGGER.debug("In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" - + vf.getModelUUID()); + LOGGER.debug("In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + + vf.getModelUUID()); - heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID()); + heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID()); if (heatFiles != null) { // add these to stack - to be done in createStack // here, we will map them to Map<String, Object> from Map<String, HeatFiles> @@ -1949,19 +1851,19 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug ("Contents of heatFiles - to be added to files: on stack:"); for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet ()) { - String heatFileName = entry.getKey(); - HeatFiles value = entry.getValue(); - if (heatFileName.startsWith("_ERROR|")) { - // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. - String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); - String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId; - LOGGER.debug(error); - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + String heatFileName = entry.getKey(); + HeatFiles value = entry.getValue(); + if (heatFileName.startsWith("_ERROR|")) { + // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. + String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); + String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId; + LOGGER.debug(error); + LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); - // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); - } + // Alarm on this error, configuration must be fixed + alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + throw new VnfException (error, MsoExceptionCategory.INTERNAL); + } String heatFileBody = value.getFileBody (); LOGGER.debug (heatFileName + " -> " + heatFileBody); heatFilesObjects.put (heatFileName, heatFileBody); @@ -2001,24 +1903,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Note this also removes any comments MsoHeatEnvironmentEntry mhee = null; if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase ().contains ("parameters:")) { - LOGGER.debug("Enhanced environment checking enabled - 1604"); + LOGGER.debug("Enhanced environment checking enabled - 1604"); haveEnvironmentParameters = true; StringBuilder sb = new StringBuilder(heatEnvironmentString); //LOGGER.debug("About to create MHEE with " + sb); mhee = new MsoHeatEnvironmentEntry(sb); StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n"); for (HeatTemplateParam parm : heatTemplate.getParameters()) { - sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired()); + sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired()); } if (!mhee.isValid()) { - sb2.append("Environment says it's not valid! " + mhee.getErrorString()); + sb2.append("Environment says it's not valid! " + mhee.getErrorString()); } else { - sb2.append("\nEnvironment:"); - sb2.append(mhee.toFullString()); + sb2.append("\nEnvironment:"); + sb2.append(mhee.toFullString()); } LOGGER.debug(sb2.toString()); } else { - LOGGER.debug("NO ENVIRONMENT for this entry"); + LOGGER.debug("NO ENVIRONMENT for this entry"); } // New for 1607 - support params of json type @@ -2034,60 +1936,60 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // handle json String parameterType = parm.getParamType(); if (parameterType == null || "".equals(parameterType.trim())) { - parameterType = "String"; + parameterType = "String"; } JsonNode jsonNode = null; if ("json".equalsIgnoreCase(parameterType) && inputs != null) { - if (inputs.containsKey(parm.getParamName()) ) { - hasJson = true; - String jsonString = null; - try { - jsonString = inputs.get(parm.getParamName()); - jsonNode = new ObjectMapper().readTree(jsonString); - } catch (JsonParseException jpe) { - //TODO - what to do here? - //for now - send the error to debug, but just leave it as a String - String errorMessage = jpe.getMessage(); - LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); - hasJson = false; - jsonNode = null; - } catch (Exception e) { - // or here? - LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e); - hasJson = false; - jsonNode = null; - } - if (jsonNode != null) { - jsonParams.put(parm.getParamName(), jsonNode); - } - } else if (inputs.containsKey(parm.getParamAlias())) { - hasJson = true; - String jsonString = null; - try { - jsonString = inputs.get(parm.getParamAlias()); - jsonNode = new ObjectMapper().readTree(jsonString); - } catch (JsonParseException jpe) { - //TODO - what to do here? - //for now - send the error to debug, but just leave it as a String - String errorMessage = jpe.getMessage(); - LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); - hasJson = false; - jsonNode = null; - } catch (Exception e) { - // or here? - LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e); - hasJson = false; - jsonNode = null; - } - if (jsonNode != null) { - // Notice here - we add it to the jsonParams hashMap with the actual name - - // then manipulate the inputs so when we check for aliases below - it will not - // get flagged. - jsonParams.put(parm.getParamName(), jsonNode); - inputs.remove(parm.getParamAlias()); - inputs.put(parm.getParamName(), jsonString); - } - } //TODO add a check for the parameter in the env file + if (inputs.containsKey(parm.getParamName()) ) { + hasJson = true; + String jsonString = null; + try { + jsonString = inputs.get(parm.getParamName()); + jsonNode = new ObjectMapper().readTree(jsonString); + } catch (JsonParseException jpe) { + //TODO - what to do here? + //for now - send the error to debug, but just leave it as a String + String errorMessage = jpe.getMessage(); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); + hasJson = false; + jsonNode = null; + } catch (Exception e) { + // or here? + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e); + hasJson = false; + jsonNode = null; + } + if (jsonNode != null) { + jsonParams.put(parm.getParamName(), jsonNode); + } + } else if (inputs.containsKey(parm.getParamAlias())) { + hasJson = true; + String jsonString = null; + try { + jsonString = inputs.get(parm.getParamAlias()); + jsonNode = new ObjectMapper().readTree(jsonString); + } catch (JsonParseException jpe) { + //TODO - what to do here? + //for now - send the error to debug, but just leave it as a String + String errorMessage = jpe.getMessage(); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); + hasJson = false; + jsonNode = null; + } catch (Exception e) { + // or here? + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e); + hasJson = false; + jsonNode = null; + } + if (jsonNode != null) { + // Notice here - we add it to the jsonParams hashMap with the actual name - + // then manipulate the inputs so when we check for aliases below - it will not + // get flagged. + jsonParams.put(parm.getParamName(), jsonNode); + inputs.remove(parm.getParamAlias()); + inputs.put(parm.getParamName(), jsonString); + } + } //TODO add a check for the parameter in the env file } if (parm.isRequired () && (inputs == null || !inputs.containsKey (parm.getParamName ()))) { @@ -2124,14 +2026,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } if (missingParams != null) { // Problem - missing one or more required parameters - if (checkRequiredParameters) { + if (checkRequiredParameters) { String error = "Update VNF: Missing Required inputs: " + missingParams; LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); throw new VnfException (error, MsoExceptionCategory.USERDATA); - } else { - LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); - } + } else { + LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); + } } else { LOGGER.debug ("No missing parameters found - ok to proceed"); } @@ -2139,7 +2041,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Just submit the envt entry as received from the database String newEnvironmentString = null; if (mhee != null) { - newEnvironmentString = mhee.getRawEntry().toString(); + newEnvironmentString = mhee.getRawEntry().toString(); } // Remove any extraneous parameters (don't throw an error) @@ -2149,23 +2051,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // This is not a valid parameter for this template extraParams.removeAll (paramList); if (!extraParams.isEmpty ()) { - LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Extra params"); + LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Extra params"); inputs.keySet ().removeAll (extraParams); } } // 1607 - when we get here - we have clean inputs. Create inputsTwo in case we have json Map<String, Object> inputsTwo = null; if (hasJson && jsonParams.size() > 0) { - inputsTwo = new HashMap<>(); - for (Map.Entry<String, String> entry : inputs.entrySet()) { - String keyParamName = entry.getKey(); - String value = entry.getValue(); - if (jsonParams.containsKey(keyParamName)) { - inputsTwo.put(keyParamName, jsonParams.get(keyParamName)); - } else { - inputsTwo.put(keyParamName, value); - } - } + inputsTwo = new HashMap<>(); + for (Map.Entry<String, String> entry : inputs.entrySet()) { + String keyParamName = entry.getKey(); + String value = entry.getValue(); + if (jsonParams.containsKey(keyParamName)) { + inputsTwo.put(keyParamName, jsonParams.get(keyParamName)); + } else { + inputsTwo.put(keyParamName, value); + } + } } // "Fix" the template if it has CR/LF (getting this from Oracle) @@ -2177,8 +2079,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // because we already checked for those. long updateStackStarttime = System.currentTimeMillis (); try { - if (!hasJson) { - heatStack = heatU.updateStack (cloudSiteId, + if (!hasJson) { + heatStack = heatU.updateStack (cloudSiteId, tenantId, vfModuleName, template, @@ -2189,9 +2091,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //heatEnvironmentString, nestedTemplatesChecked, heatFilesObjects); - LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null); - } else { - heatStack = heatU.updateStack (cloudSiteId, + LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null); + } else { + heatStack = heatU.updateStack (cloudSiteId, tenantId, vfModuleName, template, @@ -2202,9 +2104,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //heatEnvironmentString, nestedTemplatesChecked, heatFilesObjects); - LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null); + LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null); - } + } } catch (MsoException me) { me.addContext ("UpdateVFModule"); String error = "Update VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me; @@ -2226,25 +2128,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { outputs.value = copyStringOutputs (heatStack.getOutputs ()); rollback.value = vfRollback; LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully update VF Module"); - return; } private String getVfModuleNameFromModuleStackId(String vfModuleStackId) { - // expected format of vfModuleStackId is "MSOTEST51-vSAMP3_base_module-0/1fc1f86c-7b35-447f-99a6-c23ec176ae24" - // before the "/" is the vfModuleName and after the "/" is the heat stack id in Openstack - if (vfModuleStackId == null) - return null; - int index = vfModuleStackId.lastIndexOf('/'); - if (index <= 0) - return null; - String vfModuleName = null; - try { - vfModuleName = vfModuleStackId.substring(0, index); - } catch (Exception e) { - LOGGER.debug("Exception", e); - vfModuleName = null; - } - return vfModuleName; + // expected format of vfModuleStackId is "MSOTEST51-vSAMP3_base_module-0/1fc1f86c-7b35-447f-99a6-c23ec176ae24" + // before the "/" is the vfModuleName and after the "/" is the heat stack id in Openstack + if (vfModuleStackId == null) + return null; + int index = vfModuleStackId.lastIndexOf('/'); + if (index <= 0) + return null; + String vfModuleName = null; + try { + vfModuleName = vfModuleStackId.substring(0, index); + } catch (Exception e) { + LOGGER.debug("Exception", e); + vfModuleName = null; + } + return vfModuleName; } } diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java index a99bd3952c..315db2eb83 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java @@ -25,40 +25,101 @@ import java.util.Map; import javax.xml.ws.Holder; +import mockit.Mock; +import mockit.MockUp; +import org.junit.Test; import org.openecomp.mso.adapters.vnf.MsoVnfAdapter; import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl; +import org.openecomp.mso.openstack.beans.HeatStatus; +import org.openecomp.mso.openstack.beans.StackInfo; import org.openecomp.mso.openstack.beans.VnfStatus; import org.openecomp.mso.adapters.vnf.exceptions.VnfException; +import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.utils.MsoHeatUtils; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class QueryTest { - public final static void main (String args[]) - { - MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); - log ("Got a VnfAdapter"); - - String cloudId = "MT"; - String tenantId = "MSO_Test"; - String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<Boolean>(); - Holder<String> vnfId = new Holder<String>(); - Holder<VnfStatus> status = new Holder<VnfStatus>(); - Holder<Map<String,String>> outputs = new Holder<Map<String,String>>(); - - try { - vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, - vnfExists, vnfId, status, outputs); - } catch (VnfException e) { - log ("Got an Exception: " + e); - } - - if (! vnfExists.value){ - log ("VNF Not Found"); - } else { - log ("Found VNF, ID = " + vnfId.value + ", status=" + status.value); - } - } - - private static void log (String msg) { - System.out.println (msg); - } + + @Test + public void testQueryCreatedVnf() throws VnfException { + { + new MockUp<MsoHeatUtils>() { + @Mock + public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException { + StackInfo info = new StackInfo(); + info.setStatus(HeatStatus.CREATED); + return info; + } + }; + + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + String cloudId = "MT"; + String tenantId = "MSO_Test"; + String vnfName = "VNF_TEST1"; + Holder<Boolean> vnfExists = new Holder<Boolean>(); + Holder<String> vnfId = new Holder<String>(); + Holder<VnfStatus> status = new Holder<VnfStatus>(); + Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + + vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, + vnfExists, vnfId, status, outputs); + + assertTrue(vnfExists.value); + } + } + + @Test + public void testQueryNotFoundVnf() throws VnfException { + { + new MockUp<MsoHeatUtils>() { + @Mock + public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException { + StackInfo info = new StackInfo(); + info.setStatus(HeatStatus.NOTFOUND); + return info; + } + }; + + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + String cloudId = "MT"; + String tenantId = "MSO_Test"; + String vnfName = "VNF_TEST1"; + Holder<Boolean> vnfExists = new Holder<Boolean>(); + Holder<String> vnfId = new Holder<String>(); + Holder<VnfStatus> status = new Holder<VnfStatus>(); + Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + + vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, + vnfExists, vnfId, status, outputs); + + assertFalse(vnfExists.value); + } + } + + @Test(expected = VnfException.class) + public void testQueryVnfWithException() throws VnfException { + { + new MockUp<MsoHeatUtils>() { + @Mock + public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException { + throw new MsoCloudSiteNotFound(cloudSiteId); + } + }; + + MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(); + String cloudId = "MT"; + String tenantId = "MSO_Test"; + String vnfName = "VNF_TEST1"; + Holder<Boolean> vnfExists = new Holder<Boolean>(); + Holder<String> vnfId = new Holder<String>(); + Holder<VnfStatus> status = new Holder<VnfStatus>(); + Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + + vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, + vnfExists, vnfId, status, outputs); + } + } } diff --git a/aria/aria-rest-server/build.py b/aria/aria-rest-server/build.py new file mode 100644 index 0000000000..cc36d2f855 --- /dev/null +++ b/aria/aria-rest-server/build.py @@ -0,0 +1,95 @@ +# +# ============LICENSE_START=================================================== +# Copyright (c) 2017 Cloudify.co. 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==================================================== +# + +import subprocess +import os +import sys +import glob +import xml.etree.ElementTree as etree + +# create and enter venv +def create_venv( name): + if subprocess.call("virtualenv {}".format(name), shell = True): + raise Exception("virtualenv create failed") + ret = subprocess.call(". {}/bin/activate && python {} run". \ + format(name,__file__), shell = True) + sys.exit(ret) + +def init_venv(): + subprocess.call("pip install -U pip", shell = True) + subprocess.call("pip install -U setuptools", shell = True) + subprocess.call("pip install wheel", shell = True) + subprocess.call("pip install twine", shell = True) + + +if len(sys.argv) == 1: + create_venv ("mavenvenv") +else: + init_venv() + + if os.environ['MVN_PHASE'] == 'package': + wheelname = os.environ['WHEEL_NAME'] + inputdir = os.environ['INPUT_DIR'] + outputdir = os.environ['OUTPUT_DIR'] + savedir = os.getcwd() + os.chdir(inputdir) + + if subprocess.call( [ "python", + "setup.py", + "bdist_wheel", + "-d", + outputdir + ]): + sys.stderr("wheel create failed") + sys.exit(1) + f = glob.glob(outputdir+"/*.whl")[0] + os.rename(f , outputdir+"/"+ wheelname) + + elif os.environ['MVN_PHASE'] == 'deploy': + + it = etree.iterparse(os.environ['SETTINGS_FILE']) + for _, el in it: + el.tag = el.tag.split('}', 1)[1] # strip namespace + settings = it.root + + username = settings.find('.//server[id="{}"]/username'.format( + os.environ['PYPI_SERVERID'])).text + password = settings.find('.//server[id="{}"]/password'.format( + os.environ['PYPI_SERVERID'])).text + + try: + if subprocess.call( [ "twine", + "upload", + "--username", + username, + "--password", + password, + "--repository-url", + os.environ["PYPI_SERVER_BASEURL"], + os.environ["WHEEL_PATH"] + ] ): + sys.stderr.write("pypi upload failed") + sys.exit(1) + finally: + subprocess.call("rm -rf mavenvenv", shell = True) + + sys.exit(0) + else: + sys.stderr.write("Unrecognized phase '{}'\n".format( + os.environ('MVN_PHASE'))) + sys.exit(1) diff --git a/aria/aria-rest-server/pom.xml b/aria/aria-rest-server/pom.xml index 7af381c220..d7e4a49311 100644 --- a/aria/aria-rest-server/pom.xml +++ b/aria/aria-rest-server/pom.xml @@ -33,18 +33,13 @@ <version>1.1.0-SNAPSHOT</version> </parent> - <pluginRepositories> - <pluginRepository> - <id>jitpack.io</id> - <url>https://jitpack.io</url> - </pluginRepository> - </pluginRepositories> - <properties> - <python_version>2.7</python_version> + <python_version>2</python_version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <wheel.name>${project.artifactId}-${python_version}-py2-none-any.whl</wheel.name> + <wheel.name>${project.artifactId}-${project.version}-py${python_version}-none-any.whl</wheel.name> <python.sourceDirectory>${project.basedir}/src/main/python/aria-rest</python.sourceDirectory> + <onap.nexus.pypiserver.baseurl>http://192.168.33.1:8081/repository/pypi-internal/</onap.nexus.pypiserver.baseurl> + <onap.nexus.pypiserver.serverid>ecomp-snapshots</onap.nexus.pypiserver.serverid> </properties> <build> <plugins> @@ -67,48 +62,51 @@ <failIfNoMatch>false</failIfNoMatch> </configuration> </execution> - <execution> - <id>attach-artifacts</id> - <phase>package</phase> - <goals> - <goal>attach-artifact</goal> - </goals> - <configuration> - <artifacts> - <artifact> - <file>${project.build.directory}/maven-python/dist/${wheel.name}</file> - <type>whl</type> - </artifact> - </artifacts> - </configuration> - </execution> </executions> </plugin> <plugin> - <groupId>com.github.UltimateDogg</groupId> - <artifactId>maven-python-distribute-plugin</artifactId> - <version>0.2.0</version> - <configuration> - <packageVersion>${python_version}</packageVersion> - <sourceDirectory>${python.sourceDirectory}</sourceDirectory> - <distributionType>wheel</distributionType> - </configuration> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.6.0</version> <executions> <execution> - <id>package</id> - <phase>prepare-package</phase> - <goals> - <goal>package</goal> - </goals> - </execution> - <execution> - <id>process</id> - <phase>process-sources</phase> - <goals> - <goal>process-sources</goal> - </goals> + <id>package</id> + <phase>package</phase> + <goals><goal>exec</goal></goals> + <configuration> + <executable>python</executable> + <arguments> + <argument>${project.basedir}/build.py</argument> + </arguments> + <environmentVariables> + <MVN_PHASE>package</MVN_PHASE> + <WHEEL_NAME>${wheel.name}</WHEEL_NAME> + <INPUT_DIR>${project.basedir}/src/main/python/aria-rest</INPUT_DIR> + <OUTPUT_DIR>${project.build.directory}</OUTPUT_DIR> + </environmentVariables> + </configuration> </execution> - </executions> + <execution> + <id>deploy</id> + <phase>deploy</phase> + <goals><goal>exec</goal></goals> + <configuration> + <executable>python</executable> + <arguments> + <argument>${project.basedir}/build.py</argument> + </arguments> + <environmentVariables> + <MVN_PHASE>deploy</MVN_PHASE> + <PROJECT_VERSION>${project.version}</PROJECT_VERSION> + <DOCKERREGISTRY_SNAPSHOT>${onap.nexus.dockerregistry.snapshot}</DOCKERREGISTRY_SNAPSHOT> + <DOCKERREGISTRY_RELEASE>${onap.nexus.dockerregistry.release}</DOCKERREGISTRY_RELEASE> + <PYPI_SERVER_BASEURL>${onap.nexus.pypiserver.baseurl}</PYPI_SERVER_BASEURL> + <PYPI_SERVERID>${onap.nexus.pypiserver.serverid}</PYPI_SERVERID> + <WHEEL_PATH>${project.build.directory}/${wheel.name}</WHEEL_PATH> + </environmentVariables> + </configuration> + </execution> + </executions> </plugin> </plugins> </build> diff --git a/aria/aria-rest-server/src/main/python/aria-rest/setup.py b/aria/aria-rest-server/src/main/python/aria-rest/setup.py index 81beb0f9a7..84e9a19560 100644 --- a/aria/aria-rest-server/src/main/python/aria-rest/setup.py +++ b/aria/aria-rest-server/src/main/python/aria-rest/setup.py @@ -34,6 +34,7 @@ setup( license='LICENSE', description='Aria REST API for ONAP', install_requires=[ + 'distribute', 'Flask==0.12.2', 'flask-autodoc==0.1.2', 'apache-ariatosca==0.1.1' diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy index 70050422ee..3b97cad585 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts -
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
-import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.runtime.Execution
+ + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass
-import org.junit.Rule
+import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore
+import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -41,7 +41,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.patch import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*;
+import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition @@ -53,28 +53,27 @@ import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapGetter import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule
-
+import com.github.tomakehurst.wiremock.junit.WireMockRule + class CreateVcpeResCustServiceTest extends GroovyTestBase { - private static String request
-
- @Rule
+ private static String request + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) -
+ String Prefix = "CVRCS_" - String RbType = "DCRENI_"
+ String RbType = "DCRENI_" @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/request.json") } -
- @Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
+ + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public CreateVcpeResCustServiceTest() { @@ -82,19 +81,19 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { } - // ***** preProcessRequest *****
-
- @Test
- // @Ignore
- public void preProcessRequest() {
+ // ***** preProcessRequest ***** + + @Test + // @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() def map = setupMap(mex) initPreProcess(mex) -
- CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
- CreateVcpeResCustService.preProcessRequest(mex)
-
- verify(mex).getVariable(DBGFLAG)
+ + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) verify(mex).setVariable("prefix", Prefix) verify(mex).setVariable("aaiDistDelay", "aaidelay") verify(mex).setVariable("createVcpeServiceRequest", request) @@ -115,7 +114,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { def reqinfo = map.get(Prefix+"requestInfo") assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0) - assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
+ assertTrue(reqinfo.indexOf("<source>VID</") >= 0) } @Test @@ -1260,6 +1259,6 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { private initProcessJavaException(ExecutionEntity mex) { when(mex.getVariable(DBGFLAG)).thenReturn("true") - }
-
+ } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy index 65c9e456e4..af56f34bce 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts -
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
-import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.runtime.Execution
+ + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass
-import org.junit.Rule
+import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore
+import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -41,7 +41,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.patch import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*;
+import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition @@ -53,28 +53,27 @@ import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapGetter import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule
-
+import com.github.tomakehurst.wiremock.junit.WireMockRule + class DeleteVcpeResCustServiceTest extends GroovyTestBase { - private static String request
-
- @Rule
+ private static String request + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) -
+ String Prefix = "DVRCS_" - String RbType = "DCRENI_"
+ String RbType = "DCRENI_" @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() request = FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/request.json") } -
- @Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
+ + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public DeleteVcpeResCustServiceTest() { @@ -82,18 +81,18 @@ class DeleteVcpeResCustServiceTest extends GroovyTestBase { } - // ***** preProcessRequest *****
-
- @Test
-// @Ignore
- public void preProcessRequest() {
+ // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() def map = setupMap(mex) initPreProcess(mex) -
- DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService()
- DeleteVcpeResCustService.preProcessRequest(mex)
-
+ + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.preProcessRequest(mex) + verify(mex).getVariable(DBGFLAG) assertEquals(Prefix, map.get("prefix")) @@ -116,7 +115,7 @@ class DeleteVcpeResCustServiceTest extends GroovyTestBase { def reqinfo = map.get(Prefix+"requestInfo") assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0) - assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
+ assertTrue(reqinfo.indexOf("<source>VID</") >= 0) } @Test @@ -771,5 +770,5 @@ class DeleteVcpeResCustServiceTest extends GroovyTestBase { .withStatus(status) .withHeader("Content-Type", "text/xml") .withBodyFile("VCPE/DeleteVcpeResCustService/" + fileResp))); - }
+ } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy index af532e733c..bbe9d52225 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts -
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
-import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.runtime.Execution
+ + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass
-import org.junit.Rule
+import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore
+import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -39,7 +39,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse import static com.github.tomakehurst.wiremock.client.WireMock.get import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*;
+import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource @@ -47,25 +47,25 @@ import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResou import org.openecomp.mso.bpmn.core.RollbackData -import com.github.tomakehurst.wiremock.junit.WireMockRule
-
-class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
-
- @Rule
+import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) -
+ String Prefix = "DCARBRGRB_" - String RbType = "DCARBRG_"
+ String RbType = "DCARBRG_" @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() + // nothing for now } -
- @Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
+ + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public DoCreateAllottedResourceBRGRollbackTest() { @@ -73,18 +73,18 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { } - // ***** preProcessRequest *****
-
- @Test
-// @Ignore
- public void preProcessRequest() {
+ // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() initPreProcess(mex) -
- DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback()
- DoCreateAllottedResourceBRGRollback.preProcessRequest(mex)
-
- verify(mex).getVariable(DBGFLAG)
+ + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) verify(mex).setVariable("prefix", Prefix) verify(mex).setVariable("serviceInstanceId", "sii") verify(mex).setVariable("parentServiceInstanceId", "psii") @@ -99,7 +99,7 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { verify(mex).setVariable("sdncDeleteRequest", "createreq") verify(mex).setVariable("sdncUnassignRequest", "assignreq") - verify(mex, never()).setVariable("skipRollback", true)
+ verify(mex, never()).setVariable("skipRollback", true) } @Test @@ -648,6 +648,6 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { private initProcessRollbackJavaException(ExecutionEntity mex) { when(mex.getVariable(DBGFLAG)).thenReturn("true") - }
-
+ } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy index 89c13f179c..acc6970dd1 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts -
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
-import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.runtime.Execution
+ + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass
-import org.junit.Rule
+import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore
+import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -39,7 +39,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*;
+import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource @@ -49,24 +49,24 @@ import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutAllottedResourc import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule
-
+import com.github.tomakehurst.wiremock.junit.WireMockRule + class DoCreateAllottedResourceBRGTest extends GroovyTestBase { -
- @Rule
+ + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) -
- String Prefix = "DCARBRG_"
+ + String Prefix = "DCARBRG_" @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() + // nothing for now } -
- @Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
+ + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public DoCreateAllottedResourceBRGTest() { @@ -74,19 +74,19 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase { } - // ***** preProcessRequest *****
-
- @Test
-// @Ignore
- public void preProcessRequest() {
+ // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() initPreProcess(mex) -
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.preProcessRequest(mex)
-
- verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
+ + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdnc_replication_delay")) @@ -97,7 +97,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase { assertTrue(checkMissingPreProcessRequest("vgmuxBearerIP")) assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) - assertTrue(checkMissingPreProcessRequest("allottedResourceType"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceType")) } @@ -992,6 +992,6 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase { private initUpdateAaiAROrchStatus(ExecutionEntity mex) { when(mex.getVariable(DBGFLAG)).thenReturn("true") when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - }
-
+ } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy index e5635deba7..02352cf6af 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy @@ -59,7 +59,7 @@ class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase { @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() + // nothing for now } @Before diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy index b27e368316..2de6e44a2f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts -
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
-import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.runtime.Execution
+ + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass
-import org.junit.Rule
+import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore
+import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -39,7 +39,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*;
+import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource @@ -51,28 +51,24 @@ import java.util.Map import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule
-
-class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
-
- @Rule
+import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceTXCTest extends GroovyTestBase { + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) -
- String Prefix = "DCARTXC_"
+ + String Prefix = "DCARTXC_" @BeforeClass public static void setUpBeforeClass() { - def fr = new FileReader("src/test/resources/mso.bpmn.urn.properties") - urnProps.load(fr) - fr.close() - - aaiUriPfx = urnProps.get("aai.endpoint") + // nothing for now } -
- @Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
+ + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public DoCreateAllottedResourceTXCTest() { @@ -80,19 +76,19 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase { } - // ***** preProcessRequest *****
-
- @Test
- // @Ignore
- public void preProcessRequest() {
+ // ***** preProcessRequest ***** + + @Test + // @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() initPreProcess(mex) -
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.preProcessRequest(mex)
-
- verify(mex).getVariable(DBGFLAG)
- verify(mex).setVariable("prefix", Prefix)
+ + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdnc_replication_delay")) @@ -101,7 +97,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase { assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo")) assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) - assertTrue(checkMissingPreProcessRequest("allottedResourceType"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceType")) } @@ -950,6 +946,6 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase { private initUpdateAaiAROrchStatus(ExecutionEntity mex) { when(mex.getVariable(DBGFLAG)).thenReturn("true") when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - }
-
+ } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy index ec65347f5e..4e62a566a7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts -
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
-import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.runtime.Execution
+ + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass
-import org.junit.Rule
+import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore
+import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -42,7 +42,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.patch import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*;
+import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource @@ -54,24 +54,24 @@ import java.util.Map import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule
-
-class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
-
- @Rule
+import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoDeleteAllottedResourceBRGTest extends GroovyTestBase { + + @Rule public WireMockRule wireMockRule = new WireMockRule(PORT) -
- String Prefix = "DDARBRG_"
+ + String Prefix = "DDARBRG_" @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() + // nothing for now } -
- @Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
+ + @Before + public void init() + { + MockitoAnnotations.initMocks(this) } public DoDeleteAllottedResourceBRGTest() { @@ -79,24 +79,24 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase { } - // ***** preProcessRequest *****
-
- @Test
-// @Ignore
- public void preProcessRequest() {
+ // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { ExecutionEntity mex = setupMock() initPreProcess(mex) -
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
- DoDeleteAllottedResourceBRG.preProcessRequest(mex)
-
- verify(mex).getVariable(DBGFLAG)
+ + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("sdncCallbackUrl", "sdncurn")
+ verify(mex).setVariable("sdncCallbackUrl", "sdncurn") assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) - assertTrue(checkMissingPreProcessRequest("allottedResourceId"))
+ assertTrue(checkMissingPreProcessRequest("allottedResourceId")) } @Test @@ -599,6 +599,6 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase { when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers") when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) - }
-
+ } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy index adf6313a2a..33273c55a6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy @@ -65,7 +65,7 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase { @BeforeClass public static void setUpBeforeClass() { - super.setUpBeforeClass() + // nothing for now } @Before diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy index 121583ec10..01ca53ba97 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ package org.openecomp.mso.bpmn.vcpe.scripts -
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
-import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.runtime.Execution
+ + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution import org.junit.Before -import org.junit.BeforeClass
-import org.junit.Rule
+import org.junit.BeforeClass +import org.junit.Rule import org.junit.Test -import org.junit.Ignore
+import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.BpmnError import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil @@ -41,14 +41,14 @@ import static com.github.tomakehurst.wiremock.client.WireMock.patch import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*;
+import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter -import com.github.tomakehurst.wiremock.junit.WireMockRule
-
+import com.github.tomakehurst.wiremock.junit.WireMockRule + class GroovyTestBase { static final int PORT = 28090 @@ -60,20 +60,24 @@ class GroovyTestBase { static final String ARID = "arId-1" static final String VERS = "myvers" - static final String DBGFLAG = "isDebugLogEnabled"
+ static final String DBGFLAG = "isDebugLogEnabled" static Properties urnProps = new Properties() static String aaiUriPfx - String processName
+ String processName - public static void setUpBeforeClass() { + static { def fr = new FileReader("src/test/resources/mso.bpmn.urn.properties") urnProps.load(fr) fr.close() - + aaiUriPfx = urnProps.get("aai.endpoint") } + + public static void setUpBeforeClass() { + // moved to the above static block to get the static aaiUriPfx assignment correctly. + } public GroovyTestBase(String processName) { this.processName = processName @@ -88,37 +92,37 @@ class GroovyTestBase { } catch(BpmnError e) { return true; } - }
-
- public ExecutionEntity setupMock() {
-
- ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
- when(mockProcessDefinition.getKey()).thenReturn(processName)
- RepositoryService mockRepositoryService = mock(RepositoryService.class)
- when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
- when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(processName)
- when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
- ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
- when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
-
- ExecutionEntity mex = mock(ExecutionEntity.class)
-
- when(mex.getId()).thenReturn("100")
- when(mex.getProcessDefinitionId()).thenReturn(processName)
- when(mex.getProcessInstanceId()).thenReturn(processName)
- when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ } + + public ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn(processName) + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(processName) + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mex = mock(ExecutionEntity.class) + + when(mex.getId()).thenReturn("100") + when(mex.getProcessDefinitionId()).thenReturn(processName) + when(mex.getProcessInstanceId()).thenReturn(processName) + when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices) when(mex.getProcessEngineServices().getRepositoryService().getProcessDefinition(mex.getProcessDefinitionId())).thenReturn(mockProcessDefinition) when(mex.getVariable("isAsyncProcess")).thenReturn("true") - when(mex.getVariable(processName+"WorkflowResponseSent")).thenReturn("false")
-
- return mex
+ when(mex.getVariable(processName+"WorkflowResponseSent")).thenReturn("false") + + return mex } public Map<String,Object> setupMap(ExecutionEntity mex) { MapSetter mapset = new MapSetter(); doAnswer(mapset).when(mex).setVariable(any(), any()) return mapset.getMap(); - }
-
+ } + } diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.aria b/packages/docker/src/main/docker/docker-files/Dockerfile.aria index ee16d73733..26f672e51d 100644 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.aria +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.aria @@ -15,15 +15,30 @@ # the License. # ============LICENSE_END==================================================== # - FROM httpd:alpine +ARG aria_rest_url +ARG aria_rest_branch RUN apk update RUN apk add python2 py2-pip gcc python2-dev linux-headers musl-dev git curl - -RUN pip install apache-ariatosca==0.2.0 jinja2==2.8 aria-extension-cloudify==4.1 -RUN curl -sL http://github.com/dfilppi/aria-rest/archive/master.tar.gz|tar xzf - -WORKDIR aria-rest-master +WORKDIR /tmp +RUN git clone -b 0.1.1 https://github.com/cloudify-cosmo/aria-extension-cloudify +WORKDIR /tmp/aria-extension-cloudify +RUN pip install -U setuptools +RUN pip install . +RUN pip install apache-ariatosca==0.1.1 jinja2==2.8 +WORKDIR /tmp +RUN git clone -b ${aria_rest_branch} ${aria_rest_url} +WORKDIR /tmp/so/aria/aria-rest-server/src/main/python/aria-rest RUN pip install . +WORKDIR /tmp +RUN git clone -b 2.0.1 https://github.com/cloudify-cosmo/cloudify-openstack-plugin +RUN wagon create ./cloudify-openstack-plugin +RUN aria plugins install cloudify_openstack_plugin-2.0.1-py27-none-linux_x86_64.wgn +RUN rm cloudify_openstack_plugin-2.0.1-py27-none-linux_x86_64.wgn +RUN git clone -b 1.4.10 https://github.com/cloudify-cosmo/cloudify-aws-plugin +RUN wagon create ./cloudify-aws-plugin +RUN aria plugins install cloudify_aws_plugin-1.4.10-py27-none-linux_x86_64.wgn +RUN rm cloudify_aws_plugin-1.4.10-py27-none-linux_x86_64.wgn CMD aria-rest @@ -32,6 +32,7 @@ <module>status-control</module> <module>bpmn</module> <module>packages</module> + <!-- <module>aria/aria-rest-server</module> --> </modules> <properties> <project.mso.base.folder>.</project.mso.base.folder> |