diff options
9 files changed, 47 insertions, 18 deletions
diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index 933077b59a..9cee2882be 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -260,10 +260,24 @@ </dependency> <dependency> <groupId>org.pacesys.openstack4j.connectors</groupId> - <artifactId>openstack4j-httpclient</artifactId> + <artifactId>openstack4j-jersey2</artifactId> <version>3.2.0</version> </dependency> - + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + <version>2.22.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-jackson</artifactId> + <version>2.22.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + <version>2.22.1</version> + </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index 32cd92d70e..53736e912f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -145,7 +145,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { logger.trace("Keystone Version: {} ", keystoneVersion); this.osClient = new MsoCloudClientFactoryImpl(new OpenstackClientFactoryImpl()).getOpenstackClient( cloudIdentity.getIdentityUrl(), cloudIdentity.getMsoId(), cloudIdentity.getMsoPass(), regionId, - tenantId, keystoneVersion); + tenantId, keystoneVersion, cloudIdentity.getUserDomainName(), cloudIdentity.getProjectDomainName()); logger.trace("Successfully authenticated with keystone for tenant: {} and region: {}", tenantId, regionId); return osClient; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java index a9a63b312d..3c209314f3 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java @@ -55,5 +55,5 @@ public interface MsoCloudClientFactory { OpenstackClient getOpenstackClient(String url, String msoId, String msoPass, String regionId, String tenantId, - String keystoneVersion) throws HeatBridgeException; + String keystoneVersion, String userDomainName, String projectDomainName) throws HeatBridgeException; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java index 88a7d3dbbc..e299f6ffb8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java @@ -64,21 +64,26 @@ public class MsoCloudClientFactoryImpl implements MsoCloudClientFactory { @Override public OpenstackClient getOpenstackClient(@Nonnull String url, @Nonnull String msoId, @Nonnull String msoPass, - @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion) - throws HeatBridgeException { + @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion, String userDomainName, + String projectDomainName) throws HeatBridgeException { Objects.requireNonNull(url, "Null openstack url!"); Objects.requireNonNull(msoId, "Null openstack user id!"); Objects.requireNonNull(msoPass, "Null openstack password!"); Objects.requireNonNull(regionId, "Null regionId ID!"); Objects.requireNonNull(tenantId, "Null tenant ID!"); - Objects.requireNonNull(tenantId, "Null keystone version"); + Objects.requireNonNull(keystoneVersion, "Null keystone version"); + if (userDomainName == null) { + userDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME; + } + if (projectDomainName == null) { + projectDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME; + } try { final OpenstackAccess osAccess = new OpenstackAccessBuilder().setBaseUrl(url) // keystone URL .setUser(msoId) // keystone username .setPassword(CryptoUtils.decryptCloudConfigPassword(msoPass)) // keystone decrypted password .setRegion(regionId) // openstack region - .setDomainName(HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME) // hardcode to "default" - .setTenantId(tenantId) // tenantId + .setDomainName(userDomainName).setProjectName(projectDomainName).setTenantId(tenantId) // tenantId .build(); // Identify the Keystone version diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java index 69c76fad84..d8f2ee7273 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java @@ -88,6 +88,10 @@ public class OpenstackAccess { return projectName; } + public Identifier getProjectNameIdentifier() { + return Identifier.byName(projectName); + } + public static class OpenstackAccessBuilder { private String baseUrl; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java index bbcd54e6f8..8829c702cf 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java @@ -62,8 +62,8 @@ public class OpenstackClientFactoryImpl implements OpenstackClientFactory { try { client = OSFactory.builderV3().endpoint(osAccess.getUrl()) .credentials(osAccess.getUser(), osAccess.getPassword(), osAccess.getDomainNameIdentifier()) - .scopeToProject(Identifier.byId(osAccess.getTenantId())).authenticate() - .useRegion(osAccess.getRegion()); + .scopeToProject(Identifier.byId(osAccess.getTenantId()), osAccess.getProjectNameIdentifier()) + .authenticate().useRegion(osAccess.getRegion()); return new OpenstackV3ClientImpl(client); } catch (AuthenticationException exception) { throw new OpenstackClientException("Failed to authenticate with Keystone-v3: " + osAccess.getUrl(), diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java index 86400c2190..9b5e1e85cd 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java @@ -40,6 +40,8 @@ public class MsoCloudClientFactoryImplTest { private static final String ENCRYPTED_PASSWORD = CryptoUtils.encryptCloudConfigPassword("testPassword"); private static final String REGION_ID = "testCloudRegionId"; private static final String TENANT_ID = "testTenantId"; + private static final String USER_DOMAIN_NAME = "userDomainName"; + private static final String PROJECT_DOMAIN_NAME = "projectDomainName"; private MsoCloudClientFactoryImpl testedObject; private OpenstackClientFactory openstackClientFactoryMock; @@ -52,20 +54,21 @@ public class MsoCloudClientFactoryImplTest { @Test public void getOpenstackClientWithVersion2() throws Exception { - testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v2.0"); + testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v2.0", null, null); verify(openstackClientFactoryMock).createOpenstackV2Client(any(OpenstackAccess.class)); } @Test public void getOpenstackClientWithVersion3() throws Exception { - testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v3"); + testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v3", + USER_DOMAIN_NAME, PROJECT_DOMAIN_NAME); verify(openstackClientFactoryMock).createOpenstackV3Client(any(OpenstackAccess.class)); } @Test(expected = HeatBridgeException.class) public void getOpenstackClient_unsupportedVersion() throws Exception { testedObject.getOpenstackClient(URL_WITH_UNSUPPORTED_VERSION, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, - "UNKNOWN"); + "UNKNOWN", USER_DOMAIN_NAME, PROJECT_DOMAIN_NAME); } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index b8977f05d8..4ad32909b0 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -24,7 +24,6 @@ package org.onap.so.adapters.sdnc.impl; - import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStream; @@ -65,7 +64,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - @Component public class SDNCRestClient { @@ -153,10 +151,15 @@ public class SDNCRestClient { String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); con.setRequestProperty("Authorization", basicAuth); con.setRequestMethod(rt.getReqMethod()); + String msoAction = rt.getMsoAction(); // Add request headers if ("POST".equals(rt.getReqMethod()) || "PUT".equals(rt.getReqMethod())) { - con.setRequestProperty("Content-type", "application/xml"); + if (Constants.MSO_ACTION_MDONS.equals(msoAction)) { + con.setRequestProperty("Content-type", "application/json"); + } else { + con.setRequestProperty("Content-type", "application/xml"); + } con.setRequestProperty("Content-length", String.valueOf(sdncReqBody.length())); con.setDoOutput(true); out = new DataOutputStream(con.getOutputStream()); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy index 21fc50c9b6..0a7753e9e5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy @@ -450,6 +450,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("serviceModelInfo", serviceDecomposition.getModelInfo()) List<Resource> deleteResourceList = serviceDecomposition.getServiceResources() + List<ImmutablePair<Resource, List<Resource>>> deleteRealResourceList = new ArrayList<ImmutablePair<Resource, List<Resource>>>() if (serviceDecomposition.getServiceType().equals("MDONS_OTN")){ for (Resource resource : deleteResourceList) { String serviceName = execution.getVariable("serviceInstanceName") @@ -469,7 +470,6 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { relationShipList = jsonSlurper.parseText(serviceRelationShip) } - List<ImmutablePair<Resource, List<Resource>>> deleteRealResourceList = new ArrayList<ImmutablePair<Resource, List<Resource>>>() //Set the real resource instance id to the decomosed resource list //reset the resource instance id , because in the decompose flow ,its a random one. |