diff options
Diffstat (limited to 'adapters/mso-adapter-utils/src')
27 files changed, 1610 insertions, 500 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java new file mode 100644 index 0000000000..a765f8004e --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.cloud; + +/** + * This interface provides the method signature for mapping registration. + * All mappings should be registered by the implementing class. + */ +public interface CloudConfigIdentityMapper { + + public void registerAllMappings(); +} 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 a777e4133c..db6ccde46c 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 @@ -1,32 +1,56 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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 - * + * + * 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========================================================= + * ============LICENSE_END============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * */ 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; import org.openecomp.mso.logger.MsoLogger; -import com.woorea.openstack.keystone.model.authentication.RackspaceAuthentication; + import com.woorea.openstack.keystone.model.authentication.UsernamePassword; import org.openecomp.mso.utils.CryptoUtils; import com.woorea.openstack.keystone.model.Authentication; @@ -43,11 +67,39 @@ import com.woorea.openstack.keystone.model.Authentication; */ public class CloudIdentity { + // This block is needed to trigger the class loader so that static initialization + // of both inner static classes occur. This is required when the Json Deserializer + // gets called and no access to any of these inner classes happened yet. + static { + IdentityServerType.bootstrap(); + IdentityAuthenticationType.bootstrap(); + } + private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); - - public enum IdentityServerType {KEYSTONE}; - public enum IdentityAuthenticationType { USERNAME_PASSWORD, RACKSPACE_APIKEY }; + public final static class IdentityServerType extends IdentityServerTypeAbstract { + + public static final IdentityServerType KEYSTONE = new IdentityServerType("KEYSTONE", MsoKeystoneUtils.class); + + public IdentityServerType(String serverType, Class<? extends MsoTenantUtils> utilsClass) { + super(serverType, utilsClass); + } + + public static final void bootstrap() {} + } + + public static final class IdentityAuthenticationType extends IdentityAuthenticationTypeAbstract { + + public static final IdentityAuthenticationType USERNAME_PASSWORD = new IdentityAuthenticationType("USERNAME_PASSWORD", UsernamePasswordWrapper.class); + + public static final IdentityAuthenticationType RACKSPACE_APIKEY = new IdentityAuthenticationType("RACKSPACE_APIKEY", RackspaceAPIKeyWrapper.class); + + public IdentityAuthenticationType(String identityType, Class<? extends AuthenticationWrapper> wrapperClass) { + super(identityType, wrapperClass); + } + + public static final void bootstrap() {} + } @JsonProperty private String id; @@ -64,8 +116,12 @@ public class CloudIdentity { @JsonProperty("tenant_metadata") private Boolean tenantMetadata; @JsonProperty("identity_server_type") + @JsonSerialize(using=IdentityServerTypeJsonSerializer.class) + @JsonDeserialize(using=IdentityServerTypeJsonDeserializer.class) private IdentityServerType identityServerType; @JsonProperty("identity_authentication_type") + @JsonSerialize(using=IdentityAuthenticationTypeJsonSerializer.class) + @JsonDeserialize(using=IdentityAuthenticationTypeJsonDeserializer.class) private IdentityAuthenticationType identityAuthenticationType; private static String cloudKey = "aa3871669d893c7fb8abbcda31b88b4f"; @@ -92,26 +148,34 @@ public class CloudIdentity { public String getKeystoneUrl (String regionId, String msoPropID) throws MsoException { if (IdentityServerType.KEYSTONE.equals(this.identityServerType)) { return this.identityUrl; - } - else { - return null; + } else { + if (this.identityServerType == null) { + return null; + } + MsoTenantUtils tenantUtils = new MsoTenantUtilsFactory(msoPropID).getTenantUtilsByServerType(this.identityServerType.toString()); + if (tenantUtils != null) { + return tenantUtils.getKeystoneUrl(regionId, msoPropID, this); + } else { + return null; + } } } public Authentication getAuthentication () throws MsoException { - if (IdentityAuthenticationType.RACKSPACE_APIKEY.equals(this.identityAuthenticationType)) { - return new RackspaceAuthentication (this.getMsoId (),this.getMsoPass ()); - } - else { - // Use default case - return new UsernamePassword (this.getMsoId (),this.getMsoPass ()); + if (this.getIdentityAuthenticationType() != null) { + try { + return AuthenticationMethodFactory.getAuthenticationFor(this); + } catch (IllegalAccessException | InstantiationException | ClassNotFoundException | IOException | URISyntaxException e) { + throw new MsoAdapterException("Could not retrieve authentication for " + this.identityAuthenticationType, e); + } + } else { // Fallback + return new UsernamePassword(this.getMsoId(), this.getMsoPass()); } - } public void setKeystoneUrl (String url) { if (IdentityServerType.KEYSTONE.equals(this.identityServerType)) { - this.identityUrl = url; + this.identityUrl = url; } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java new file mode 100644 index 0000000000..45a79730ad --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeAbstract.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.cloud; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.openecomp.mso.cloud.authentication.AuthenticationWrapper; + +public abstract class IdentityAuthenticationTypeAbstract { + + // This map will prevent duplicates (as if it was an Enum). + // Without this, using an instance specific field for the class could allow + // different classes bound to the same entry name. + private static final Map<String, IdentityAuthenticationTypeAbstract> entries = new ConcurrentHashMap<>(); + + private String identityType; + + private Class<? extends AuthenticationWrapper> wrapperClass; + + protected IdentityAuthenticationTypeAbstract(String identityType, Class<? extends AuthenticationWrapper> wrapperClass) { + try { + this.identityType = identityType; + this.wrapperClass = wrapperClass; + entries.put(identityType, this); + AuthenticationWrapper.register(this.toString(), wrapperClass); + } catch (IllegalAccessException | InstantiationException e) { + // Do not add the class if an exception occurs as we won't get the class anyway + } + } + + public static final IdentityAuthenticationTypeAbstract valueOf(String serverType) { + return entries.get(serverType); + } + + @Override + public final String toString() { + return this.identityType; + } + + public final String name() { + return this.identityType; + } + + public static final IdentityAuthenticationTypeAbstract[] values() { + return (IdentityAuthenticationTypeAbstract[]) entries.values().stream().toArray(IdentityAuthenticationTypeAbstract[]::new); + } + + public final Class<? extends AuthenticationWrapper> getWrapperClass() { + return this.wrapperClass; + } + + @Override + public final boolean equals(Object other) { + return ((this.identityType != null) && (other != null) && (other instanceof IdentityAuthenticationTypeAbstract) && (this.identityType.equals(other.toString()))); + } + +} 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 new file mode 100644 index 0000000000..c7b2c14cb8 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonDeserializer.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.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 { + JsonToken token = jsonParser.getCurrentToken(); + if (JsonToken.VALUE_STRING.equals(token)) { + return IdentityAuthenticationTypeAbstract.valueOf(jsonParser.getText()); + } else { + return null; + } + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java new file mode 100644 index 0000000000..06d877d4fa --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.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 IdentityAuthenticationTypeJsonSerializer extends JsonSerializer<IdentityAuthenticationTypeAbstract> { + + @Override + public void serialize(IdentityAuthenticationTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) + throws IOException, JsonProcessingException { + jsonGenerator.writeObject(tmpObj.toString()); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java new file mode 100644 index 0000000000..38f1f87ddc --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeAbstract.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.cloud; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.openecomp.mso.openstack.utils.MsoTenantUtils; + + +public abstract class IdentityServerTypeAbstract { + + // This map will prevent duplicates (as if it was an Enum). + // Without this, using an instance specific field for the class could allow + // different classes bound to the same entry name. + private static final Map<String, IdentityServerTypeAbstract> entries = new ConcurrentHashMap<>(); + + private String serverType; + + private Class<? extends MsoTenantUtils> utilsClass; + + protected IdentityServerTypeAbstract(String serverType, Class<? extends MsoTenantUtils> utilsClass) { + if ((serverType == null) || (serverType.isEmpty())) { + throw new IllegalArgumentException("Server Type name cannot be null or empty, provided value was " + serverType); + } + if (entries.containsKey(serverType)) { + throw new IllegalArgumentException("Duplicate Server Type entry for registration: " + serverType); + } + this.serverType = serverType; + this.utilsClass = utilsClass; + entries.put(serverType, this); + } + + public static final IdentityServerTypeAbstract valueOf(String serverType) { + return entries.get(serverType); + } + + @Override + public final String toString() { + return this.serverType; + } + + public final String name() { + return this.serverType; + } + + public static final IdentityServerTypeAbstract[] values() { + return (IdentityServerTypeAbstract[]) entries.values().stream().toArray(IdentityServerTypeAbstract[]::new); + } + + public final Class<? extends MsoTenantUtils> getMsoTenantUtilsClass() { + return this.utilsClass; + } + + @Override + public final boolean equals(Object other) { + return ((this.serverType != null) && (other != null) && (other instanceof IdentityServerTypeAbstract) && (this.serverType.equals(other.toString()))); + } + +} 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 new file mode 100644 index 0000000000..8b9da1a3f4 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonDeserializer.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.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 { + JsonToken token = jsonParser.getCurrentToken(); + if (JsonToken.VALUE_STRING.equals(token)) { + return IdentityServerTypeAbstract.valueOf(jsonParser.getText()); + } else { + return null; + } + } +} 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 new file mode 100644 index 0000000000..c008860264 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityServerTypeJsonSerializer.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.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 { + 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 new file mode 100644 index 0000000000..feaafd3c07 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodFactory.java @@ -0,0 +1,79 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +package org.openecomp.mso.cloud.authentication; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.openecomp.mso.cloud.CloudIdentity; + +import com.woorea.openstack.keystone.model.Authentication; + +/** + * This factory manages all the wrappers associated to authentication types. + * + */ +public final class AuthenticationMethodFactory { + + private static Map<String, AuthenticationWrapper> authWrappers = new ConcurrentHashMap<>(); + + /** + * + */ + private AuthenticationMethodFactory() {} + + /** + * Function to be called by classes implementing the abstract {@link AuthenticationWrapper#register(String, Class)}. + */ + static final synchronized void register(String authenticationType, Class<? extends AuthenticationWrapper> wrapperClass) throws InstantiationException, IllegalAccessException { + if ((authenticationType == null) || ("".equals(authenticationType))) { + throw new IllegalArgumentException("Authentication Type to register cannot be null or an empty name string, provided value is " + authenticationType + "."); + } + if (wrapperClass == null) { + throw new IllegalArgumentException("Wrapper Class to register for Authentication cannot be null"); + } + + if (!authWrappers.containsKey(authenticationType)) { + authWrappers.put(authenticationType, wrapperClass.newInstance()); + } + } + + public static final synchronized Authentication getAuthenticationFor(CloudIdentity cloudIdentity) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException, URISyntaxException { + if (cloudIdentity == null) { + throw new IllegalArgumentException("Cloud identity cannot be null"); + } + if ((cloudIdentity.getIdentityAuthenticationType() == null) || ("".equals(cloudIdentity.getIdentityAuthenticationType().toString()))) { + throw new IllegalArgumentException("Cloud identity authentication type cannot be null or empty, provided value is " + cloudIdentity.getIdentityAuthenticationType() + "."); + } + String authenticationType = cloudIdentity.getIdentityAuthenticationType().toString(); + + if (authWrappers.containsKey(authenticationType)) { + return authWrappers.get(authenticationType).getAuthentication(cloudIdentity); + } else { + throw new IllegalArgumentException("Provided authentication type (" + authenticationType + ") is not implemented by any wrapper."); + } + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationWrapper.java new file mode 100644 index 0000000000..8b3725cd41 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/AuthenticationWrapper.java @@ -0,0 +1,58 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +package org.openecomp.mso.cloud.authentication; + +import org.openecomp.mso.cloud.CloudIdentity; + +import com.woorea.openstack.keystone.model.Authentication; + +/** + * This abstract class provides the necessary method for registering authentication + * types with wrapper classes, and also defines the contract for providing + * Openstack-compatible Authentication implementations for said authentication types. + * + */ +public abstract class AuthenticationWrapper { + + /** + * Registers the implementing class to the list of Authentication Wrappers. + * + * @param authenticationType The authentication type that is provided by the implementing class + * @param wrapperClass The implementing class Class object + * @throws InstantiationException If the provided implementing class cannot be instantiated + * @throws IllegalAccessException If the provided implementing class cannot be instantiated + */ + public static final void register(String authenticationType, Class<? extends AuthenticationWrapper> wrapperClass) throws InstantiationException, IllegalAccessException { + AuthenticationMethodFactory.register(authenticationType, wrapperClass); + } + + /** + * Returns an OpenStack Authentication object for the provided CloudIdentity. + * + * @param cloudIdentity The input Cloud Identity instance + * @return the OpenStack Authentication associated with this cloud identity instance + */ + protected abstract Authentication getAuthentication(CloudIdentity cloudIdentity); + +} 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 new file mode 100644 index 0000000000..2b8da9f641 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/models/RackspaceAuthentication.java @@ -0,0 +1,99 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +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; + +@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; + private String apiKey; + + /** + * @return the username + */ + public String getUsername() { + return username; + } + /** + * @param username the username to set + */ + public void setUsername(String username) { + this.username = username; + } + /** + * @return the apiKey + */ + public String getApiKey() { + return apiKey; + } + /** + * @param apiKey the apiKey to set + */ + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + } + + @JsonProperty("RAX-KSKEY:apiKeyCredentials") + private Token token = new Token(); + + public RackspaceAuthentication (String username, String apiKey) { + this.token.username = username; + this.token.apiKey = apiKey; + + } + + /** + * @return the token + */ + public Token getToken() { + return token; + } + + /** + * @param token the token to set + */ + public void setToken(Token token) { + this.token = token; + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java new file mode 100644 index 0000000000..87ff2582de --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/RackspaceAPIKeyWrapper.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +package org.openecomp.mso.cloud.authentication.wrappers; + +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.authentication.AuthenticationWrapper; +import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication; + +import com.woorea.openstack.keystone.model.Authentication; + +/** + * This class implements the authentication wrapper for Rackspace Authentication. + * + */ +public class RackspaceAPIKeyWrapper extends AuthenticationWrapper { + + /** + * + */ + public RackspaceAPIKeyWrapper() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see org.openecomp.mso.cloud.authentication.AuthenticationWrapper#getAuthentication(org.openecomp.mso.cloud.CloudIdentity) + */ + @Override + public Authentication getAuthentication(CloudIdentity cloudIdentity) { + if (cloudIdentity == null) { + throw new IllegalArgumentException("Provided cloud identity is null, cannot extract username and password"); + } + return new RackspaceAuthentication (cloudIdentity.getMsoId (), cloudIdentity.getMsoPass ()); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java new file mode 100644 index 0000000000..2eebbb7d4b --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/authentication/wrappers/UsernamePasswordWrapper.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +package org.openecomp.mso.cloud.authentication.wrappers; + +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.authentication.AuthenticationWrapper; + +import com.woorea.openstack.keystone.model.Authentication; +import com.woorea.openstack.keystone.model.authentication.UsernamePassword; + +/** + * This class implements the authentication wrapper for Openstack provided for + * user name and password authentication. + * + */ +public class UsernamePasswordWrapper extends AuthenticationWrapper { + + /** + * + */ + public UsernamePasswordWrapper() { + } + + /* (non-Javadoc) + * @see org.openecomp.mso.cloud.authentication.AuthenticationWrapper#getAuthentication(org.openecomp.mso.cloud.CloudIdentity) + */ + @Override + public Authentication getAuthentication(CloudIdentity cloudIdentity) { + if (cloudIdentity == null) { + throw new IllegalArgumentException("Provided cloud identity is null, cannot extract username and password"); + } + return new UsernamePassword (cloudIdentity.getMsoId (), cloudIdentity.getMsoPass ()); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/VnfRollback.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/VnfRollback.java index b6e4a6e855..fc148746a0 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/VnfRollback.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/VnfRollback.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. @@ -42,13 +42,14 @@ public class VnfRollback { private String baseGroupHeatStackId; private boolean isBase = false; private String vfModuleStackId; + private String modelCustomizationUuid; //NOTE: this is the vfModule's modelCustomizationUuid public VnfRollback() {} - + public VnfRollback(String vnfId, String tenantId, String cloudSiteId, boolean tenantCreated, boolean vnfCreated, MsoRequest msoRequest, - String volumeGroupName, String volumeGroupId, String requestType) { + String volumeGroupName, String volumeGroupId, String requestType, String modelCustomizationUuid) { super(); this.vnfId = vnfId; this.tenantId = tenantId; @@ -59,6 +60,7 @@ public class VnfRollback { this.volumeGroupName = volumeGroupName; this.volumeGroupId = volumeGroupId; this.requestType = requestType; + this.modelCustomizationUuid = modelCustomizationUuid; } public String getVnfId() { @@ -122,14 +124,14 @@ public class VnfRollback { public void setVolumeGroupHeatStackId(String volumeGroupHeatStackId) { this.volumeGroupHeatStackId = volumeGroupHeatStackId; } - + public String getBaseGroupHeatStackId() { return this.baseGroupHeatStackId; } public void setBaseGroupHeatStackId(String baseGroupHeatStackId) { this.baseGroupHeatStackId = baseGroupHeatStackId; } - + public boolean isBase() { return this.isBase; } @@ -142,11 +144,17 @@ public class VnfRollback { public void setVfModuleStackId(String vfModuleStackId) { this.vfModuleStackId = vfModuleStackId; } - + public String getModelCustomizationUuid() { + return this.modelCustomizationUuid; + } + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } @Override public String toString() { return "VnfRollback: cloud=" + cloudSiteId + ", tenant=" + tenantId + ", vnf=" + vnfId + ", tenantCreated=" + tenantCreated + - ", vnfCreated=" + vnfCreated + ", requestType = " + requestType; + ", vnfCreated=" + vnfCreated + ", requestType = " + requestType + + ", modelCustomizationUuid=" + this.modelCustomizationUuid; } } 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 index 3d9c23cc32..05d9a70a2d 100644 --- 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 @@ -27,6 +27,7 @@ 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; @@ -73,6 +74,21 @@ public class CloudConfigInitializer implements ServletContextListener 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/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java index 9309f05c40..99d5863819 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.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. @@ -58,6 +58,7 @@ import com.woorea.openstack.base.client.OpenStackResponseException; import com.woorea.openstack.heat.Heat; import com.woorea.openstack.heat.model.CreateStackParam; import com.woorea.openstack.heat.model.Stack; +import com.woorea.openstack.heat.model.Stack.Output; import com.woorea.openstack.heat.model.Stacks; import com.woorea.openstack.keystone.Keystone; import com.woorea.openstack.keystone.model.Access; @@ -69,7 +70,7 @@ public class MsoHeatUtils extends MsoCommonUtils { private MsoPropertiesFactory msoPropertiesFactory; private CloudConfigFactory cloudConfigFactory; - + private static final String TOKEN_AUTH = "TokenAuth"; private static final String QUERY_ALL_STACKS = "QueryAllStacks"; @@ -103,7 +104,7 @@ public class MsoHeatUtils extends MsoCommonUtils { private int deletePollIntervalDefault = 15; private int deletePollTimeoutDefault = 300; private String msoPropID; - + private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); /** @@ -127,7 +128,7 @@ public class MsoHeatUtils extends MsoCommonUtils { } cloudConfig = cloudConfigFactory.getCloudConfig (); LOGGER.debug("MsoHeatUtils:" + msoPropID); - + } @@ -201,7 +202,7 @@ public class MsoHeatUtils extends MsoCommonUtils { null, true); } - + // This method has environment, files, heatfiles public StackInfo createStack (String cloudSiteId, String tenantId, @@ -413,6 +414,11 @@ public class MsoHeatUtils extends MsoCommonUtils { try { heatStack = queryHeatStack (heatClient, canonicalName); LOGGER.debug (heatStack.getStackStatus () + " (" + canonicalName + ")"); + try { + LOGGER.debug("Current stack " + this.getOutputsAsStringBuilder(heatStack).toString()); + } catch (Exception e) { + LOGGER.debug("an error occurred trying to print out the current outputs of the stack"); + } if ("CREATE_IN_PROGRESS".equals (heatStack.getStackStatus ())) { // Stack creation is still running. @@ -443,7 +449,7 @@ public class MsoHeatUtils extends MsoCommonUtils { if (!backout) { LOGGER.warn(MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack, stack deletion suppressed"); - } + } else { try { @@ -451,7 +457,7 @@ public class MsoHeatUtils extends MsoCommonUtils { OpenStackRequest <Void> request = heatClient.getStacks ().deleteByName (canonicalName); executeAndRecordOpenstackRequest (request, msoProps); // this may be a waste of time - if we just got an exception trying to query the stack - we'll just - // get another one, n'est-ce pas? + // get another one, n'est-ce pas? boolean deleted = false; while (!deleted) { try { @@ -460,8 +466,8 @@ public class MsoHeatUtils extends MsoCommonUtils { LOGGER.debug(heatStack.getStackStatus()); if ("DELETE_IN_PROGRESS".equals(heatStack.getStackStatus())) { if (deletePollTimeout <= 0) { - LOGGER.error (MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, - heatStack.getStackStatus (), "", "", MsoLogger.ErrorCode.AvailabilityError, + LOGGER.error (MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, + heatStack.getStackStatus (), "", "", MsoLogger.ErrorCode.AvailabilityError, "Rollback: DELETE stack timeout"); break; } else { @@ -486,11 +492,11 @@ public class MsoHeatUtils extends MsoCommonUtils { deleted = true; continue; } - + } catch (Exception e3) { // Just log this one. We will report the original exception. LOGGER.error (MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack on error on query"); - + } } } catch (Exception e2) { @@ -529,8 +535,8 @@ public class MsoHeatUtils extends MsoCommonUtils { LOGGER.debug(heatStack.getStackStatus() + " (" + canonicalName + ")"); if ("DELETE_IN_PROGRESS".equals(heatStack.getStackStatus())) { if (deletePollTimeout <= 0) { - LOGGER.error (MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, - heatStack.getStackStatus (), "", "", MsoLogger.ErrorCode.AvailabilityError, + LOGGER.error (MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, stackName, + heatStack.getStackStatus (), "", "", MsoLogger.ErrorCode.AvailabilityError, "Rollback: DELETE stack timeout"); break; } else { @@ -561,13 +567,13 @@ public class MsoHeatUtils extends MsoCommonUtils { deleted = true; continue; } - + } catch (MsoException me2) { // We got an exception on the delete - don't throw this exception - throw the original - just log. LOGGER.debug("Exception thrown trying to delete " + canonicalName + " on a create->rollback: " + me2.getContextMessage()); LOGGER.warn(MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError, me2.getContextMessage()); } - + } // end while !deleted StringBuilder errorContextMessage = null; if (createTimedOut) { @@ -588,7 +594,7 @@ public class MsoHeatUtils extends MsoCommonUtils { // shouldn't happen - but handle LOGGER.error (MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack: rolling back stack"); } - } + } MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); me.addContext(CREATE_STACK); alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); @@ -949,10 +955,10 @@ public class MsoHeatUtils extends MsoCommonUtils { Access access = null; try { Authentication credentials = cloudIdentity.getAuthentication (); - + OpenStackRequest <Access> request = keystoneTenantClient.tokens () .authenticate (credentials).withTenantId (tenantId); - + access = executeAndRecordOpenstackRequest (request, msoProps); } catch (OpenStackResponseException e) { if (e.getStatus () == 401) { @@ -984,10 +990,6 @@ public class MsoHeatUtils extends MsoCommonUtils { alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error); throw new MsoAdapterException (error, e); } - // This is needed for testing in the MT cloud - if ("MT".equals (cloudId)) { - heatUrl = heatUrl.replace ("controller", "mtdnj02bh01wt.bvoip.labs.att.com"); - } Heat heatClient = new Heat (heatUrl); heatClient.token (access.getToken ().getId ()); @@ -1119,7 +1121,7 @@ public class MsoHeatUtils extends MsoCommonUtils { public static void heatCacheReset () { heatClientCache = new HashMap <String, HeatCacheEntry> (); } - + public Map<String, Object> queryStackForOutputs(String cloudSiteId, String tenantId, String stackName) throws MsoException { LOGGER.debug("MsoHeatUtils.queryStackForOutputs)"); @@ -1208,7 +1210,7 @@ public class MsoHeatUtils extends MsoCommonUtils { } return sb; } - + private String convertNode(final JsonNode node) { try { final Object obj = JSON_MAPPER.treeToValue(node, Object.class); @@ -1221,4 +1223,53 @@ public class MsoHeatUtils extends MsoCommonUtils { } return "[Error converting json to string]"; } + + + private StringBuilder getOutputsAsStringBuilder(Stack heatStack) { + // This should only be used as a utility to print out the stack outputs + // to the log + StringBuilder sb = new StringBuilder(""); + if (heatStack == null) { + sb.append("(heatStack is null)"); + return sb; + } + List<Output> outputList = heatStack.getOutputs(); + if (outputList == null || outputList.isEmpty()) { + sb.append("(outputs is empty)"); + return sb; + } + Map<String, Object> outputs = new HashMap<String,Object>(); + for (Output outputItem : outputList) { + outputs.put(outputItem.getOutputKey(), outputItem.getOutputValue()); + } + int counter = 0; + sb.append("OUTPUTS:"); + for (String key : outputs.keySet()) { + sb.append("outputs[" + counter++ + "]: " + key + "="); + Object obj = outputs.get(key); + if (obj instanceof String) { + sb.append((String)obj); + } else if (obj instanceof JsonNode) { + sb.append(this.convertNode((JsonNode)obj)); + } else if (obj instanceof java.util.LinkedHashMap) { + try { + String str = JSON_MAPPER.writeValueAsString(obj); + sb.append(str); + } catch (Exception e) { + sb.append("(a LinkedHashMap value that would not convert nicely)"); + } + } else { + String str = ""; + try { + str = (String) obj; + } catch (Exception e) { + str = "(a value unable to be cast as a String)"; + } + sb.append(str); + } + sb.append("; "); + } + sb.append("[END]"); + return sb; + } } 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 8375b973c9..e387ec4023 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 @@ -454,10 +454,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils { LOGGER.error(MessageEnum.IDENTITY_SERVICE_NOT_FOUND, region, cloudIdentity.getId(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception in findEndpointURL"); throw new MsoAdapterException (error, e); } - // The following is needed for the MT lab. - if ("MT".equals (cloudSite.getId ())) { - adminUrl = adminUrl.replace ("controller", "mtdnj02bh01wt.bvoip.labs.att.com"); - } // A new Keystone object is required for the new URL. Use the auth token from above. // Note: this doesn't go back to Openstack, it's just a local object. @@ -685,4 +681,9 @@ public class MsoKeystoneUtils extends MsoTenantUtils { public static void adminCacheReset () { adminClientCache = new HashMap <String, KeystoneCacheEntry> (); } + + @Override + public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity) throws MsoException { + return cloudIdentity.getIdentityUrl(); + } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java index f3281e3f1c..5c21913a66 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoNeutronUtils.java @@ -425,10 +425,6 @@ public class MsoNeutronUtils extends MsoCommonUtils alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error); throw new MsoAdapterException (error, e); } - // This is needed for testing in the MT cloud - if (cloudId.equals("MT")) { - neutronUrl = neutronUrl.replace("controller", "mtdnj02bh01wt.bvoip.labs.att.com"); - } Quantum neutronClient = new Quantum(neutronUrl); neutronClient.token(access.getToken().getId()); diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtils.java index 41104707cb..5af535f2b5 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtils.java @@ -28,6 +28,7 @@ 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.logger.MsoAlarmLogger; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.logger.MessageEnum; @@ -75,5 +76,8 @@ public abstract class MsoTenantUtils extends MsoCommonUtils { public abstract boolean deleteTenant (String tenantId, String cloudSiteId) throws MsoException; - + + public abstract String getKeystoneUrl (String regionId, String msoPropID, CloudIdentity cloudIdentity) + throws MsoException; + } 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 6fd7a6364a..2a5b3ad994 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 @@ -20,6 +20,7 @@ package org.openecomp.mso.openstack.utils; +import java.lang.reflect.InvocationTargetException; import org.openecomp.mso.cloud.CloudConfig; import org.openecomp.mso.cloud.CloudConfigFactory; import org.openecomp.mso.cloud.CloudIdentity; @@ -36,7 +37,7 @@ public class MsoTenantUtilsFactory { protected CloudConfig cloudConfig; protected MsoJavaProperties msoProps = null; private String msoPropID; - + public MsoTenantUtilsFactory (String msoPropID) { this.msoPropID = msoPropID; } @@ -48,10 +49,20 @@ public class MsoTenantUtilsFactory { cloudConfig = cloudConfigFactory.getCloudConfig(); CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); + return getTenantUtilsByServerType(cloudSite.getIdentityService().getIdentityServerType().toString()); + } + + public MsoTenantUtils getTenantUtilsByServerType(String serverType) { + MsoTenantUtils tenantU = null; - if (cloudSite.getIdentityService().getIdentityServerType() == CloudIdentity.IdentityServerType.KEYSTONE) - { + if (CloudIdentity.IdentityServerType.KEYSTONE.equals(serverType)) { tenantU = new MsoKeystoneUtils (msoPropID); + } else { + try { + tenantU = CloudIdentity.IdentityServerType.valueOf(serverType).getMsoTenantUtilsClass().getConstructor(String.class).newInstance(msoPropID); + } catch (InvocationTargetException | InstantiationException | NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException("Could not instantiate an MsoTenantUtils class for " + serverType, e); + } } return tenantU; } 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 8632d02164..6be668c056 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 @@ -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. @@ -39,14 +39,14 @@ import org.openecomp.mso.cloud.CloudSite; * */ public class CloudConfigTest { - + private static CloudConfig con; private static CloudConfigFactory cloudConfigFactory= new CloudConfigFactory(); - + public CloudConfigTest () { - + } - + /** * This method is called before any test occurs. * It creates a fake tree from scratch @@ -55,11 +55,11 @@ public class CloudConfigTest { public static final void prepare () { ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); String config = classLoader.getResource("cloud_config.json").toString().substring(5); - + cloudConfigFactory.initializeCloudConfig(config,1); con = cloudConfigFactory.getCloudConfig(); } - + /** * This method implements a test for the getCloudConfig method. */ @@ -79,17 +79,19 @@ public class CloudConfigTest { CloudSite site1 = siteMap.get("MT"); CloudSite site2 = siteMap.get("DAN"); CloudSite site3 = siteMap.get("MTINJVCC101"); - + CloudSite site4 = siteMap.get("MTSNJA4LCP1"); + assertEquals (site1.getRegionId(), "regionOne"); assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE"); assertEquals (site2.getRegionId(), "RegionOne"); assertEquals (site2.getIdentityServiceId(), "DAN_KEYSTONE"); assertEquals (site3.getRegionId(), "regionTwo"); assertEquals (site3.getIdentityServiceId(), "MTINJVCC101_DCP"); - + assertEquals (site4.getRegionId(), "mtsnjlcp1"); + assertEquals (site4.getIdentityServiceId(), "MTSNJA3DCP1"); } - - + + /** * This method implements a test for the getIdentityServices method. */ @@ -97,12 +99,12 @@ public class CloudConfigTest { public final void testGetIdentityServices () { Map<String,CloudIdentity> identityMap = con.getIdentityServices (); assertNotNull(identityMap); - + CloudIdentity identity1 = identityMap.get("MT_KEYSTONE"); CloudIdentity identity2 = identityMap.get("DAN_KEYSTONE"); 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"); @@ -110,7 +112,7 @@ public class CloudConfigTest { 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"); @@ -118,7 +120,7 @@ public class CloudConfigTest { 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"); @@ -126,7 +128,7 @@ public class CloudConfigTest { 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"); @@ -136,7 +138,7 @@ public class CloudConfigTest { assertEquals (identity4.hasTenantMetadata(), true); } - + /** * This method implements a test for the getCloudSite method. */ @@ -146,9 +148,6 @@ public class CloudConfigTest { assertNotNull(site1); assertEquals (site1.getRegionId(), "regionOne"); assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE"); - - - } /** @@ -165,7 +164,7 @@ public class CloudConfigTest { assertEquals (identity1.getAdminTenant(), "admin"); assertEquals (identity1.getMemberRole(), "_member_"); assertEquals (identity1.hasTenantMetadata(), false); - + CloudIdentity identity2 = con.getIdentityService("Test"); assertNull(identity2); } diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java index 6f8a6e93d8..3427e42304 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.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. @@ -47,45 +47,45 @@ public class MsoHeatUtilsTest extends MsoCommonUtils { public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); public static CloudConfigFactory cloudConfigFactory = new CloudConfigFactory(); public static MsoHeatUtils msoHeatUtils; - + @BeforeClass public static final void loadClasses() { ClassLoader classLoader = CloudConfigTest.class.getClassLoader(); String config = classLoader.getResource("cloud_config.json").toString().substring(5); cloudConfigFactory.initializeCloudConfig(config, 1); - msoHeatUtils = new MsoHeatUtils("NO_PROP",msoPropertiesFactory,cloudConfigFactory); + msoHeatUtils = new MsoHeatUtils("NO_PROP",msoPropertiesFactory,cloudConfigFactory); } - + @Test - public final void testCreateStackBadCloudConfig () { + public final void testCreateStackBadCloudConfig () throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { try { msoHeatUtils.createStack ("DOESNOTEXIST", "test", "stackName", "test", new HashMap<String,Object> (), Boolean.TRUE, 10); - } catch (MsoException e) { + } catch (MsoCloudSiteNotFound e) { + + } - } - } - + @Test public final void testCreateStackFailedConnectionHeatClient () throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { try { msoHeatUtils.createStack ("MT", "test", "stackName", "test", new HashMap<String,Object> (), Boolean.TRUE, 10); } catch (MsoIOException e) { - + } - + } - + @Test public final void testCreateStackFailedConnection () throws MsoStackAlreadyExists, MsoTenantNotFound, MsoException, MsoCloudSiteNotFound { try { msoHeatUtils.createStack ("MT", "test", "stackName", "test", new HashMap<String,Object> (), Boolean.TRUE, 10); } catch (MsoIOException e) { - + } - + } - - - + + + } diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java new file mode 100644 index 0000000000..beb85a4a8e --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/authentication/AuthenticationMethodTest.java @@ -0,0 +1,115 @@ +/* + * ============LICENSE_START========================================== + * =================================================================== + * 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============================================ + * + * ECOMP and OpenECOMP are trademarks + * and service marks of AT&T Intellectual Property. + * + */ + +package org.openecomp.mso.cloud.authentication; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.net.URISyntaxException; + +import org.junit.Test; +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.authentication.models.RackspaceAuthentication; +import org.openecomp.mso.openstack.exceptions.MsoException; + +import com.woorea.openstack.keystone.model.Authentication; +import com.woorea.openstack.keystone.model.authentication.UsernamePassword; + +/** + * A few JUnit tests to evaluate the new factory that manages authentication + * types and their associated wrapper classes. Here it is assumed that core types + * only are tested. + * + */ +public class AuthenticationMethodTest { + + /** + * + */ + public AuthenticationMethodTest() { + // TODO Auto-generated constructor stub + } + + @Test + public void testCustomRackspaceAuth() { + CloudIdentity ci = new CloudIdentity(); + ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY); + ci.setMsoPass("FD205490A48D48475607C36B9AD902BF"); + ci.setMsoId("test"); + + try { + Authentication auth = AuthenticationMethodFactory.getAuthenticationFor(ci); + assertTrue(RackspaceAuthentication.class.equals(auth.getClass())); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | IOException + | URISyntaxException e) { + e.printStackTrace(); + } + } + + @Test + public void testCoreUsernamePasswordAuth() { + CloudIdentity ci = new CloudIdentity(); + ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD); + ci.setMsoPass("FD205490A48D48475607C36B9AD902BF"); + ci.setMsoId("someuser"); + + try { + Authentication auth = AuthenticationMethodFactory.getAuthenticationFor(ci); + assertTrue(UsernamePassword.class.equals(auth.getClass())); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | IOException + | URISyntaxException e) { + e.printStackTrace(); + } + } + + @Test + public void testCustomRackspaceAuthFromCloudIdentity() { + CloudIdentity ci = new CloudIdentity(); + ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY); + ci.setMsoPass("FD205490A48D48475607C36B9AD902BF"); + ci.setMsoId("test"); + + try { + Authentication auth = ci.getAuthentication(); + assertTrue(RackspaceAuthentication.class.equals(auth.getClass())); + } catch (MsoException e) { + e.printStackTrace(); + } + } + + @Test + public void testCoreUsernamePasswordAuthFromCloudIdentity() { + CloudIdentity ci = new CloudIdentity(); + ci.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.USERNAME_PASSWORD); + ci.setMsoPass("FD205490A48D48475607C36B9AD902BF"); + ci.setMsoId("someuser"); + + try { + Authentication auth = ci.getAuthentication(); + assertTrue(UsernamePassword.class.equals(auth.getClass())); + } catch (MsoException e) { + e.printStackTrace(); + } + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java new file mode 100644 index 0000000000..1cbba3c45e --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/NewServerTypeUtils.java @@ -0,0 +1,56 @@ +/** + * + */ +package org.openecomp.mso.cloud.servertype; + +import java.util.Map; + +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.openstack.beans.MsoTenant; +import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; +import org.openecomp.mso.openstack.exceptions.MsoException; +import org.openecomp.mso.openstack.utils.MsoTenantUtils; + + +public class NewServerTypeUtils extends MsoTenantUtils { + + /** + * @param msoPropID + */ + public NewServerTypeUtils(String msoPropID) { + super(msoPropID); + } + + @Override + public String createTenant(String tenantName, String cloudSiteId, Map<String, String> metadata, boolean backout) + throws MsoException { + // TODO Auto-generated method stub + return null; + } + + @Override + public MsoTenant queryTenant(String tenantId, String cloudSiteId) throws MsoException, MsoCloudSiteNotFound { + // TODO Auto-generated method stub + return null; + } + + @Override + public MsoTenant queryTenantByName(String tenantName, String cloudSiteId) + throws MsoException, MsoCloudSiteNotFound { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean deleteTenant(String tenantId, String cloudSiteId) throws MsoException { + // TODO Auto-generated method stub + return false; + } + + @Override + public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity) + throws MsoException { + return msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl(); + } + +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java new file mode 100644 index 0000000000..e2a0f865a0 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/servertype/ServerTypeTest.java @@ -0,0 +1,63 @@ +/** + * + */ +package org.openecomp.mso.cloud.servertype; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.junit.Test; +import org.openecomp.mso.cloud.CloudIdentity; +import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType; +import org.openecomp.mso.cloud.IdentityServerTypeAbstract; +import org.openecomp.mso.openstack.exceptions.MsoException; + +public class ServerTypeTest { + + @Test + public void testKeystoneServerType() { + IdentityServerTypeAbstract keystoneServerType = IdentityServerType.valueOf("KEYSTONE"); + assertNotNull(keystoneServerType); + } + + @Test + public void testNewServerType() { + IdentityServerTypeAbstract customServerType = null; + try { + customServerType = new IdentityServerType("NewServerType", NewServerTypeUtils.class); + + } catch (IllegalArgumentException e) { + fail("An exception should not be raised when we register a new server type for the first time"); + } finally { + System.out.println(IdentityServerType.values().toString()); + assertEquals(customServerType, IdentityServerType.valueOf("NewServerType")); + } + + // Create it a second time + IdentityServerTypeAbstract customServerType2 = null; + try { + customServerType2 = new IdentityServerType("NewServerType", NewServerTypeUtils.class); + fail("An exception should be raised as server type does not exist"); + } catch (IllegalArgumentException e) { + // Fail silently -- it simply indicates we already registered it + customServerType2 = IdentityServerType.valueOf("NewServerType"); + } finally { + System.out.println(IdentityServerType.values().toString()); + assertEquals(customServerType2, IdentityServerType.valueOf("NewServerType")); + } + + // Check the KeystoneURL for this custom TenantUtils + CloudIdentity cloudIdentity = new CloudIdentity(); + cloudIdentity.setIdentityUrl("LocalIdentity"); + cloudIdentity.setIdentityAuthenticationType(CloudIdentity.IdentityAuthenticationType.RACKSPACE_APIKEY); + cloudIdentity.setIdentityServerType((CloudIdentity.IdentityServerType) CloudIdentity.IdentityServerType.valueOf("NewServerType")); + String regionId = "RegionA"; + String msoPropID = "12345"; + try { + assertEquals(cloudIdentity.getKeystoneUrl(regionId, msoPropID), msoPropID + ":" + regionId + ":NewServerTypeKeystoneURL/" + cloudIdentity.getIdentityUrl()); + } catch (MsoException e) { + fail("No MSO Exception should have occured here"); + } + } +} diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/VnfRollbackESTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/VnfRollbackESTest.java index e76ce410d4..27007a3ce1 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/VnfRollbackESTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/VnfRollbackESTest.java @@ -1,6 +1,6 @@ /* * This file was automatically generated by EvoSuite - * Mon Nov 14 08:51:17 GMT 2016 + * Fri Feb 17 16:22:30 GMT 2017 */ package org.openecomp.mso.openstack.beans; @@ -8,396 +8,424 @@ package org.openecomp.mso.openstack.beans; import org.junit.Test; import static org.junit.Assert.*; import static org.evosuite.shaded.org.mockito.Mockito.*; - -import org.openecomp.mso.entity.MsoRequest; +import static org.evosuite.runtime.MockitoExtension.*; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.evosuite.runtime.ViolatedAssumptionAnswer; import org.junit.runner.RunWith; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.VnfRollback; -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) public class VnfRollbackESTest extends VnfRollbackESTestscaffolding { - @Test(timeout = 4000) - public void test00() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setVolumeGroupName(", vnfCreated="); - vnfRollback0.getVolumeGroupName(); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test01() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setVolumeGroupId("}mvn2f6!r5FG1/_M~M"); - vnfRollback0.getVolumeGroupId(); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test02() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setVolumeGroupId(""); - vnfRollback0.getVolumeGroupId(); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test03() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setVolumeGroupHeatStackId("Z^t$4-eOKP9"); - vnfRollback0.getVolumeGroupHeatStackId(); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test04() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.getVnfId(); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test05() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setVnfId(""); - vnfRollback0.getVnfId(); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - } - - @Test(timeout = 4000) - public void test06() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setVfModuleStackId("8y*`!>A$@*l8#a>"); - vnfRollback0.getVfModuleStackId(); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getVnfCreated()); - } - - @Test(timeout = 4000) - public void test07() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setVfModuleStackId(""); - vnfRollback0.getVfModuleStackId(); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test08() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(", tenant=", ", tenant=", ", tenant=", false, false, (MsoRequest) null, ", tenant=", "f5`2h^e^.-x", ", tenant="); - String string0 = vnfRollback0.getTenantId(); - assertFalse(vnfRollback0.getVnfCreated()); - assertEquals(", tenant=", vnfRollback0.getCloudSiteId()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.isBase()); - assertEquals(", tenant=", vnfRollback0.getRequestType()); - assertEquals("f5`2h^e^.-x", vnfRollback0.getVolumeGroupId()); - assertEquals(", tenant=", vnfRollback0.getVolumeGroupName()); - assertEquals(", tenant=", vnfRollback0.getVnfId()); - assertEquals(", tenant=", string0); - } - - @Test(timeout = 4000) - public void test09() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setTenantId(""); - vnfRollback0.getTenantId(); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.getTenantCreated()); - } - - @Test(timeout = 4000) - public void test10() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - assertFalse(vnfRollback0.getTenantCreated()); - - vnfRollback0.setTenantCreated(true); - boolean boolean0 = vnfRollback0.getTenantCreated(); - assertTrue(boolean0); - } - - @Test(timeout = 4000) - public void test11() throws Throwable { - MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); - VnfRollback vnfRollback0 = new VnfRollback("", ", vnf=", "Jvr", false, false, msoRequest0, "", "f'D", "VnfRollback: cloud="); - String string0 = vnfRollback0.getRequestType(); - assertFalse(vnfRollback0.isBase()); - assertEquals("Jvr", vnfRollback0.getCloudSiteId()); - assertEquals("", vnfRollback0.getVnfId()); - assertFalse(vnfRollback0.getTenantCreated()); - assertEquals("f'D", vnfRollback0.getVolumeGroupId()); - assertEquals(", vnf=", vnfRollback0.getTenantId()); - assertEquals("VnfRollback: cloud=", string0); - assertFalse(vnfRollback0.getVnfCreated()); - assertEquals("", vnfRollback0.getVolumeGroupName()); - } - - @Test(timeout = 4000) - public void test12() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setRequestType(""); - vnfRollback0.getRequestType(); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test13() throws Throwable { - MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); - doReturn("Jvr").when(msoRequest0).toString(); - VnfRollback vnfRollback0 = new VnfRollback("", ", vnf=", "Jvr", false, false, msoRequest0, "", "f'D", "VnfRollback: cloud="); - vnfRollback0.getMsoRequest(); - assertEquals("Jvr", vnfRollback0.getCloudSiteId()); - assertEquals("", vnfRollback0.getVnfId()); - assertFalse(vnfRollback0.isBase()); - assertEquals(", vnf=", vnfRollback0.getTenantId()); - assertEquals("", vnfRollback0.getVolumeGroupName()); - assertEquals("f'D", vnfRollback0.getVolumeGroupId()); - assertEquals("VnfRollback: cloud=", vnfRollback0.getRequestType()); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.getTenantCreated()); - } - - @Test(timeout = 4000) - public void test14() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(", tenant=", ", tenant=", ", tenant=", false, false, (MsoRequest) null, ", tenant=", "f5`2h^e^.-x", ", tenant="); - String string0 = vnfRollback0.getCloudSiteId(); - assertFalse(vnfRollback0.isBase()); - assertEquals(", tenant=", string0); - assertEquals("f5`2h^e^.-x", vnfRollback0.getVolumeGroupId()); - assertFalse(vnfRollback0.getVnfCreated()); - assertEquals(", tenant=", vnfRollback0.getVnfId()); - assertFalse(vnfRollback0.getTenantCreated()); - assertEquals(", tenant=", vnfRollback0.getVolumeGroupName()); - assertEquals(", tenant=", vnfRollback0.getRequestType()); - assertEquals(", tenant=", vnfRollback0.getTenantId()); - } - - @Test(timeout = 4000) - public void test15() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setCloudSiteId(""); - vnfRollback0.getCloudSiteId(); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getTenantCreated()); - } - - @Test(timeout = 4000) - public void test16() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setBaseGroupHeatStackId("3(6Q^)Ic kf:zj"); - vnfRollback0.getBaseGroupHeatStackId(); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - } - - @Test(timeout = 4000) - public void test17() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setBaseGroupHeatStackId(""); - vnfRollback0.getBaseGroupHeatStackId(); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.getTenantCreated()); - } - - @Test(timeout = 4000) - public void test18() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - assertFalse(vnfRollback0.isBase()); - - vnfRollback0.setIsBase(true); - boolean boolean0 = vnfRollback0.isBase(); - assertTrue(boolean0); - } - - @Test(timeout = 4000) - public void test19() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.getVfModuleStackId(); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - } - - @Test(timeout = 4000) - public void test20() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.getVolumeGroupName(); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getTenantCreated()); - } - - @Test(timeout = 4000) - public void test21() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setVolumeGroupName(""); - vnfRollback0.getVolumeGroupName(); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - } - - @Test(timeout = 4000) - public void test22() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - boolean boolean0 = vnfRollback0.getTenantCreated(); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(boolean0); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test23() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - boolean boolean0 = vnfRollback0.isBase(); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(boolean0); - } - - @Test(timeout = 4000) - public void test24() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - String string0 = vnfRollback0.toString(); - assertFalse(vnfRollback0.isBase()); - assertEquals("VnfRollback: cloud=null, tenant=null, vnf=null, tenantCreated=false, vnfCreated=false, requestType = null", string0); - } - - @Test(timeout = 4000) - public void test25() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - boolean boolean0 = vnfRollback0.getVnfCreated(); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(boolean0); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test26() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.getVolumeGroupHeatStackId(); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test27() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.getBaseGroupHeatStackId(); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test28() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.getCloudSiteId(); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - } - - @Test(timeout = 4000) - public void test29() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.getTenantId(); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getVnfCreated()); - } - - @Test(timeout = 4000) - public void test30() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); - vnfRollback0.setMsoRequest(msoRequest0); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test31() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.getMsoRequest(); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test32() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - assertFalse(vnfRollback0.getVnfCreated()); - - vnfRollback0.setVnfCreated(true); - boolean boolean0 = vnfRollback0.getVnfCreated(); - assertTrue(boolean0); - } - - @Test(timeout = 4000) - public void test33() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.getVolumeGroupId(); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.isBase()); - } - - @Test(timeout = 4000) - public void test34() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.getRequestType(); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - } - - @Test(timeout = 4000) - public void test35() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(); - vnfRollback0.setVolumeGroupHeatStackId(""); - vnfRollback0.getVolumeGroupHeatStackId(); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getTenantCreated()); - assertFalse(vnfRollback0.getVnfCreated()); - } - - @Test(timeout = 4000) - public void test36() throws Throwable { - VnfRollback vnfRollback0 = new VnfRollback(", tenant=", ", tenant=", ", tenant=", false, false, (MsoRequest) null, ", tenant=", "f5`2h^e^.-x", ", tenant="); - String string0 = vnfRollback0.getVnfId(); - assertEquals(", tenant=", string0); - assertEquals(", tenant=", vnfRollback0.getTenantId()); - assertFalse(vnfRollback0.getVnfCreated()); - assertFalse(vnfRollback0.isBase()); - assertFalse(vnfRollback0.getTenantCreated()); - assertEquals(", tenant=", vnfRollback0.getCloudSiteId()); - assertEquals(", tenant=", vnfRollback0.getVolumeGroupName()); - assertEquals(", tenant=", vnfRollback0.getRequestType()); - assertEquals("f5`2h^e^.-x", vnfRollback0.getVolumeGroupId()); - } + @Test(timeout = 4000) + public void test05() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVolumeGroupHeatStackId(""); + vnfRollback0.getVolumeGroupHeatStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVnfId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVnfId()); + + vnfRollback0.setVnfId(""); + vnfRollback0.getVnfId(); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getTenantId()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.getVnfCreated(); + assertFalse(vnfRollback0.isBase()); + assertFalse(boolean0); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVfModuleStackId("VnfRollback: cloud="); + vnfRollback0.getVfModuleStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVfModuleStackId(""); + vnfRollback0.getVfModuleStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback((String) null, (String) null, ", vnf=", false, true, (MsoRequest) null, "", ", vnf=", "", ""); + String string0 = vnfRollback0.getTenantId(); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals(", vnf=", vnfRollback0.getVolumeGroupId()); + assertNull(string0); + assertEquals("", vnfRollback0.getVolumeGroupName()); + assertEquals(", vnf=", vnfRollback0.getCloudSiteId()); + assertEquals("", vnfRollback0.getRequestType()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + assertFalse(vnfRollback0.getTenantCreated()); + + vnfRollback0.setTenantCreated(true); + boolean boolean0 = vnfRollback0.getTenantCreated(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setRequestType("$W[I&I@KHseI MUVb"); + vnfRollback0.getRequestType(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback((String) null, (String) null, ", vnf=", false, true, (MsoRequest) null, "", ", vnf=", "", ""); + String string0 = vnfRollback0.getRequestType(); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("", vnfRollback0.getVolumeGroupName()); + assertNotNull(string0); + assertEquals(", vnf=", vnfRollback0.getCloudSiteId()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals("", string0); + assertEquals(", vnf=", vnfRollback0.getVolumeGroupId()); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(msoRequest0).toString(); + VnfRollback vnfRollback0 = new VnfRollback("b", "b", "b", true, false, msoRequest0, "b", "b", "*^0M|pdSi&sbx2u>4q#", (String) null); + vnfRollback0.getMsoRequest(); + assertEquals("b", vnfRollback0.getCloudSiteId()); + assertEquals("b", vnfRollback0.getTenantId()); + assertFalse(vnfRollback0.getVnfCreated()); + assertEquals("b", vnfRollback0.getVnfId()); + assertEquals("b", vnfRollback0.getVolumeGroupName()); + assertEquals("*^0M|pdSi&sbx2u>4q#", vnfRollback0.getRequestType()); + assertEquals("b", vnfRollback0.getVolumeGroupId()); + assertFalse(vnfRollback0.isBase()); + assertTrue(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getModelCustomizationUuid(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setModelCustomizationUuid("<W,?yK`bP1Yb75G%66"); + vnfRollback0.getModelCustomizationUuid(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setCloudSiteId("yqA[Rq2FB8g2"); + vnfRollback0.getCloudSiteId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + MsoRequest msoRequest0 = mock(MsoRequest.class, new ViolatedAssumptionAnswer()); + VnfRollback vnfRollback0 = new VnfRollback("", ")\"J", "", true, true, msoRequest0, "%~~n", "%~~n", (String) null, "%~~n"); + String string0 = vnfRollback0.getCloudSiteId(); + assertEquals("", string0); + assertEquals(")\"J", vnfRollback0.getTenantId()); + assertFalse(vnfRollback0.isBase()); + assertEquals("%~~n", vnfRollback0.getModelCustomizationUuid()); + assertNotNull(string0); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("%~~n", vnfRollback0.getVolumeGroupId()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("", vnfRollback0.getVnfId()); + assertEquals("%~~n", vnfRollback0.getVolumeGroupName()); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setBaseGroupHeatStackId("x|gP"); + vnfRollback0.getBaseGroupHeatStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setBaseGroupHeatStackId(""); + vnfRollback0.getBaseGroupHeatStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVolumeGroupId(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setTenantId(""); + vnfRollback0.getTenantId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getRequestType(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVolumeGroupHeatStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + String string0 = vnfRollback0.toString(); + assertEquals("VnfRollback: cloud=M+!!EJC*~uO, tenant=Q,@Ir,{J2Nuu, vnf=M+!!EJC*~uO, tenantCreated=true, vnfCreated=true, requestType = Q,@Ir,{J2Nuu, modelCustomizationUuid=", string0); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + assertFalse(vnfRollback0.isBase()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + String string0 = vnfRollback0.getTenantId(); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getRequestType()); + assertEquals("Q,@Ir,{J2Nuu", string0); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getCloudSiteId()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + assertTrue(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVnfId()); + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.setVnfCreated(false); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.isBase(); + assertFalse(boolean0); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getVfModuleStackId(); + assertFalse(vnfRollback0.getTenantCreated()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + boolean boolean0 = vnfRollback0.getTenantCreated(); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.isBase()); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + + vnfRollback0.setVolumeGroupName(""); + vnfRollback0.getVolumeGroupName(); + assertEquals("", vnfRollback0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + String string0 = vnfRollback0.getVnfId(); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getCloudSiteId()); + assertFalse(vnfRollback0.isBase()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getTenantId()); + assertEquals("M+!!EJC*~uO", string0); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getRequestType()); + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getCloudSiteId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + String string0 = vnfRollback0.getVolumeGroupName(); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getTenantId()); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getRequestType()); + assertEquals("M+!!EJC*~uO", string0); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getCloudSiteId()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVnfId()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test36() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + vnfRollback0.setMsoRequest((MsoRequest) null); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVnfId()); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getRequestType()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getTenantId()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getCloudSiteId()); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + assertFalse(vnfRollback0.isBase()); + } + + @Test(timeout = 4000) + public void test37() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback((String) null, (String) null, ", vnf=", false, true, (MsoRequest) null, "", ", vnf=", "", ""); + String string0 = vnfRollback0.getModelCustomizationUuid(); + assertEquals("", vnfRollback0.getVolumeGroupName()); + assertEquals("", vnfRollback0.getRequestType()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals(", vnf=", vnfRollback0.getCloudSiteId()); + assertNotNull(string0); + assertEquals(", vnf=", vnfRollback0.getVolumeGroupId()); + assertFalse(vnfRollback0.isBase()); + assertEquals("", string0); + assertTrue(vnfRollback0.getVnfCreated()); + } + + @Test(timeout = 4000) + public void test38() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback(); + vnfRollback0.getBaseGroupHeatStackId(); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getVnfCreated()); + assertFalse(vnfRollback0.getTenantCreated()); + } + + @Test(timeout = 4000) + public void test39() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback("M+!!EJC*~uO", "Q,@Ir,{J2Nuu", "M+!!EJC*~uO", true, true, (MsoRequest) null, "M+!!EJC*~uO", "", "Q,@Ir,{J2Nuu", ""); + vnfRollback0.getMsoRequest(); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVnfId()); + assertFalse(vnfRollback0.isBase()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getVolumeGroupName()); + assertEquals("", vnfRollback0.getVolumeGroupId()); + assertTrue(vnfRollback0.getTenantCreated()); + assertEquals("M+!!EJC*~uO", vnfRollback0.getCloudSiteId()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getTenantId()); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertTrue(vnfRollback0.getVnfCreated()); + assertEquals("Q,@Ir,{J2Nuu", vnfRollback0.getRequestType()); + } + + @Test(timeout = 4000) + public void test40() throws Throwable { + VnfRollback vnfRollback0 = new VnfRollback((String) null, (String) null, ", vnf=", false, true, (MsoRequest) null, "", ", vnf=", "", ""); + boolean boolean0 = vnfRollback0.getVnfCreated(); + assertEquals("", vnfRollback0.getVolumeGroupName()); + assertEquals(", vnf=", vnfRollback0.getCloudSiteId()); + assertEquals(", vnf=", vnfRollback0.getVolumeGroupId()); + assertEquals("", vnfRollback0.getRequestType()); + assertFalse(vnfRollback0.isBase()); + assertFalse(vnfRollback0.getTenantCreated()); + assertEquals("", vnfRollback0.getModelCustomizationUuid()); + assertTrue(boolean0); + } } diff --git a/adapters/mso-adapter-utils/src/test/resources/cloud_config.json b/adapters/mso-adapter-utils/src/test/resources/cloud_config.json index 0230a7d4bf..ee3532fe15 100644 --- a/adapters/mso-adapter-utils/src/test/resources/cloud_config.json +++ b/adapters/mso-adapter-utils/src/test/resources/cloud_config.json @@ -45,7 +45,7 @@ "identity_server_type": "KEYSTONE", "identity_authentication_type": "USERNAME_PASSWORD" } - + }, "cloud_sites": { @@ -69,12 +69,19 @@ "clli": "MTINJVCC101", "aic_version": "2.5", "identity_service_id": "MTINJVCC101_DCP" + }, + "MTSNJA4LCP1": + { + "region_id": "mtsnjlcp1", + "clli": "MTSNJA4LCP1", + "aic_version": "2.5", + "identity_service_id": "MTSNJA3DCP1" } - + } } } - - + + |