aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2019-05-15 14:19:49 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-05-15 14:19:58 -0400
commite4687eeb77d9fddf14935894026aec0b1c9e3ac9 (patch)
tree47c85cd95c71d36a404da6c83fbbb5d11fb0fb2c
parentf9c309fb9e789225ccd6b02ec9ab4777bbd4021c (diff)
store openstack request status in requestdb
Openstack request status now stored in request db Change-Id: Ida8f4f613d406c2b834ab190e01d5aaf2f16dd3d Issue-ID: SO-1867 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneAuthHolder.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientException.java34
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java100
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientException.java34
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java84
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/HeatClientException.java37
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java129
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java174
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientException.java33
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java113
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientException.java33
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java186
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java43
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java2
-rw-r--r--adapters/mso-adapters-rest-interface/pom.xml15
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java5
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java19
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql5
-rw-r--r--adapters/mso-openstack-adapters/pom.xml30
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java21
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java32
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java52
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java26
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java32
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java32
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java4
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java23
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java7
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java2
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json4
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json4
-rw-r--r--adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java34
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java17
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java3
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java15
36 files changed, 1137 insertions, 251 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneAuthHolder.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneAuthHolder.java
index 4df8a91515..eadbc511d0 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneAuthHolder.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneAuthHolder.java
@@ -51,7 +51,7 @@ public class KeystoneAuthHolder implements Serializable {
return serviceUrl;
}
- public void setHeatUrl(String serviceUrl) {
+ public void setServiceUrl(String serviceUrl) {
this.serviceUrl = serviceUrl;
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
index 35c928c3b5..42d200a130 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
@@ -85,7 +85,7 @@ public class KeystoneV3Authentication {
KeystoneAuthHolder result = new KeystoneAuthHolder();
result.setId(id);
result.setexpiration(token.getExpiresAt());
- result.setHeatUrl(findEndpointURL(token.getCatalog(), type, region, "public"));
+ result.setServiceUrl(findEndpointURL(token.getCatalog(), type, region, "public"));
return result;
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientException.java
new file mode 100644
index 0000000000..f7f521e6f7
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientException.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.onap.so.openstack.utils;
+
+public class CinderClientException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6865047344405492982L;
+
+ public CinderClientException(String errorMessage, Exception e) {
+ super(errorMessage, e);
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
new file mode 100644
index 0000000000..567f849b36
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.onap.so.openstack.utils;
+
+import org.onap.so.cloud.authentication.KeystoneAuthHolder;
+import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import com.woorea.openstack.base.client.OpenStackRequest;
+import com.woorea.openstack.cinder.Cinder;
+import com.woorea.openstack.cinder.model.Volume;
+import com.woorea.openstack.cinder.model.Volumes;
+
+
+
+@Component
+public class CinderClientImpl extends MsoCommonUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(CinderClientImpl.class);
+
+ /**
+ * Gets the Cinder client.
+ *
+ * @param cloudSite the cloud site
+ * @param tenantId the tenant id
+ * @return the glance client
+ * @throws MsoException the mso exception
+ */
+ private Cinder getCinderClient(String cloudSiteId, String tenantId) throws MsoException {
+ KeystoneAuthHolder keystone = getKeystoneAuthHolder(cloudSiteId, tenantId, "volumev2");
+ Cinder cinderClient = new Cinder(keystone.getServiceUrl());
+ cinderClient.token(keystone.getId());
+ return cinderClient;
+ }
+
+
+ /**
+ * Query images
+ *
+ *
+ * @param cloudSiteId the cloud site id
+ * @param tenantId the tenant id
+ * @param limit limits the number of records returned
+ * @param visibility visibility in the image in openstack
+ * @param marker the last viewed record
+ * @param name the image names
+ * @return the list of images in openstack
+ * @throws MsoCloudSiteNotFound the mso cloud site not found
+ * @throws CinderClientException the glance client exception
+ */
+ public Volumes queryVolumes(String cloudSiteId, String tenantId, int limit, String marker)
+ throws MsoCloudSiteNotFound, CinderClientException {
+ try {
+ Cinder cinderClient = getCinderClient(cloudSiteId, tenantId);
+ // list is set to false, otherwise an invalid URL is appended
+ OpenStackRequest<Volumes> request =
+ cinderClient.volumes().list(false).queryParam("limit", limit).queryParam("marker", marker);
+ return executeAndRecordOpenstackRequest(request);
+ } catch (MsoException e) {
+ logger.error("Error building Cinder Client", e);
+ throw new CinderClientException("Error building Cinder Client", e);
+ }
+ }
+
+
+ public Volume queryVolume(String cloudSiteId, String tenantId, String volumeId)
+ throws MsoCloudSiteNotFound, CinderClientException {
+ try {
+ Cinder cinderClient = getCinderClient(cloudSiteId, tenantId);
+ // list is set to false, otherwise an invalid URL is appended
+ OpenStackRequest<Volume> request = cinderClient.volumes().show(volumeId);
+ return executeAndRecordOpenstackRequest(request);
+ } catch (MsoException e) {
+ logger.error("Error building Cinder Client", e);
+ throw new CinderClientException("Error building Cinder Client", e);
+ }
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientException.java
new file mode 100644
index 0000000000..065fb83844
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientException.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.onap.so.openstack.utils;
+
+public class GlanceClientException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5202512087480589226L;
+
+ public GlanceClientException(String errorMessage, Exception e) {
+ super(errorMessage, e);
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java
new file mode 100644
index 0000000000..57faaac717
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.onap.so.openstack.utils;
+
+import org.onap.so.cloud.authentication.KeystoneAuthHolder;
+import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import com.woorea.openstack.base.client.OpenStackRequest;
+import com.woorea.openstack.glance.Glance;
+import com.woorea.openstack.glance.model.Images;
+
+
+@Component
+public class GlanceClientImpl extends MsoCommonUtils {
+
+ /** The Constant logger. */
+ private static final Logger logger = LoggerFactory.getLogger(GlanceClientImpl.class);
+
+ /**
+ * Gets the glance client.
+ *
+ * @param cloudSite the cloud site
+ * @param tenantId the tenant id
+ * @return the glance client
+ * @throws MsoException the mso exception
+ */
+ private Glance getGlanceClient(String cloudSiteId, String tenantId) throws MsoException {
+ KeystoneAuthHolder keystone = getKeystoneAuthHolder(cloudSiteId, tenantId, "image");
+ Glance glanceClient = new Glance(keystone.getServiceUrl() + "/v2.0/");
+ glanceClient.token(keystone.getId());
+ return glanceClient;
+ }
+
+
+ /**
+ * Query images
+ *
+ *
+ * @param cloudSiteId the cloud site id
+ * @param tenantId the tenant id
+ * @param limit limits the number of records returned
+ * @param visibility visibility in the image in openstack
+ * @param marker the last viewed record
+ * @param name the image names
+ * @return the list of images in openstack
+ * @throws MsoCloudSiteNotFound the mso cloud site not found
+ * @throws GlanceClientException the glance client exception
+ */
+ public Images queryImages(String cloudSiteId, String tenantId, int limit, String visibility, String marker,
+ String name) throws MsoCloudSiteNotFound, GlanceClientException {
+ try {
+ Glance glanceClient = getGlanceClient(cloudSiteId, tenantId);
+ // list is set to false, otherwise an invalid URL is appended
+ OpenStackRequest<Images> request = glanceClient.images().list(false).queryParam("visibility", visibility)
+ .queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
+ return executeAndRecordOpenstackRequest(request);
+ } catch (MsoException e) {
+ logger.error("Error building Glance Client", e);
+ throw new GlanceClientException("Error building Glance Client", e);
+ }
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/HeatClientException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/HeatClientException.java
new file mode 100644
index 0000000000..b49d632fdb
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/HeatClientException.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.onap.so.openstack.utils;
+
+public class HeatClientException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3143699004848022343L;
+
+ public HeatClientException(String errorMessage, Exception e) {
+ super(errorMessage, e);
+ }
+
+ public HeatClientException(String error) {
+ super(error);
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
index 79c042b10b..a6a2f8402f 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
@@ -24,24 +24,23 @@
package org.onap.so.openstack.utils;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.woorea.openstack.base.client.OpenStackBaseException;
-import com.woorea.openstack.base.client.OpenStackConnectException;
-import com.woorea.openstack.base.client.OpenStackRequest;
-import com.woorea.openstack.base.client.OpenStackResponseException;
-import com.woorea.openstack.heat.model.CreateStackParam;
-import com.woorea.openstack.heat.model.Explanation;
-import com.woorea.openstack.keystone.model.Error;
-import com.woorea.openstack.quantum.model.NeutronError;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import org.onap.so.cloud.CloudConfig;
+import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
+import org.onap.so.cloud.authentication.KeystoneAuthHolder;
+import org.onap.so.cloud.authentication.KeystoneV3Authentication;
+import org.onap.so.cloud.authentication.ServiceEndpointNotFoundException;
import org.onap.so.config.beans.PoConfig;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.ServerType;
import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.onap.so.openstack.exceptions.MsoAdapterException;
+import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
import org.onap.so.openstack.exceptions.MsoIOException;
@@ -50,15 +49,48 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.woorea.openstack.base.client.OpenStackBaseException;
+import com.woorea.openstack.base.client.OpenStackConnectException;
+import com.woorea.openstack.base.client.OpenStackRequest;
+import com.woorea.openstack.base.client.OpenStackResponseException;
+import com.woorea.openstack.heat.model.CreateStackParam;
+import com.woorea.openstack.heat.model.Explanation;
+import com.woorea.openstack.keystone.Keystone;
+import com.woorea.openstack.keystone.model.Access;
+import com.woorea.openstack.keystone.model.Authentication;
+import com.woorea.openstack.keystone.model.Error;
+import com.woorea.openstack.keystone.utils.KeystoneUtils;
+import com.woorea.openstack.quantum.model.NeutronError;
@Component("CommonUtils")
public class MsoCommonUtils {
private static Logger logger = LoggerFactory.getLogger(MsoCommonUtils.class);
+ /** The Constant TOKEN_AUTH. */
+ protected static final String TOKEN_AUTH = "TokenAuth";
+ /** The cloud config. */
@Autowired
- private PoConfig poConfig;
+ protected CloudConfig cloudConfig;
+
+ /** The authentication method factory. */
+ @Autowired
+ protected AuthenticationMethodFactory authenticationMethodFactory;
+
+ /** The tenant utils factory. */
+ @Autowired
+ protected MsoTenantUtilsFactory tenantUtilsFactory;
+
+ /** The keystone V 3 authentication. */
+ @Autowired
+ protected KeystoneV3Authentication keystoneV3Authentication;
+
+ @Autowired
+ protected PoConfig poConfig;
+
/*
* Method to execute an Openstack command and track its execution time. For the metrics log, a category of
* "Openstack" is used along with a sub-category that identifies the specific call (using the real
@@ -401,4 +433,79 @@ public class MsoCommonUtils {
return stack;
}
+
+ /**
+ * Gets the Nova client
+ *
+ * @param cloudSite the cloud site
+ * @param tenantId the tenant id
+ * @return the Neutron client
+ * @throws MsoException the mso exception
+ */
+ protected KeystoneAuthHolder getKeystoneAuthHolder(String cloudSiteId, String tenantId, String serviceName)
+ throws MsoException {
+ CloudSite cloudSite =
+ cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
+ String cloudId = cloudSite.getId();
+ String region = cloudSite.getRegionId();
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
+ MsoTenantUtils tenantUtils =
+ tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
+ String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
+ try {
+ if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) {
+ Access access = getKeystone(tenantId, cloudIdentity, keystoneUrl);
+ try {
+ KeystoneAuthHolder keystoneAuthV2 = new KeystoneAuthHolder();
+ keystoneAuthV2.setServiceUrl(
+ KeystoneUtils.findEndpointURL(access.getServiceCatalog(), serviceName, region, "public"));
+ keystoneAuthV2.setId(access.getToken().getId());
+ return keystoneAuthV2;
+ } catch (RuntimeException e) {
+ String error = "Openstack did not match an orchestration service for: region=" + region + ",cloud="
+ + cloudIdentity.getIdentityUrl();
+ throw new MsoAdapterException(error, e);
+ }
+ } else if (ServerType.KEYSTONE_V3.equals(cloudIdentity.getIdentityServerType())) {
+ try {
+ return keystoneV3Authentication.getToken(cloudSite, tenantId, serviceName);
+ } catch (ServiceEndpointNotFoundException e) {
+ String error = "cloud did not match an orchestration service for: region=" + region + ",cloud="
+ + cloudIdentity.getIdentityUrl();
+ throw new MsoAdapterException(error, e);
+ }
+ } else {
+ throw new MsoAdapterException("Unknown Keystone Server Type");
+ }
+ } catch (OpenStackResponseException e) {
+ if (e.getStatus() == 401) {
+ String error = "Authentication Failure: tenant=" + tenantId + ",cloud=" + cloudIdentity.getId();
+ throw new MsoAdapterException(error);
+ } else {
+ throw keystoneErrorToMsoException(e, TOKEN_AUTH);
+ }
+ } catch (OpenStackConnectException e) {
+ MsoIOException me = new MsoIOException(e.getMessage(), e);
+ me.addContext(TOKEN_AUTH);
+ throw me;
+ } catch (RuntimeException e) {
+ throw runtimeExceptionToMsoException(e, TOKEN_AUTH);
+ }
+ }
+
+ /**
+ * @param tenantId
+ * @param cloudIdentity
+ * @param keystoneUrl
+ * @return
+ */
+ protected Access getKeystone(String tenantId, CloudIdentity cloudIdentity, String keystoneUrl) {
+ Keystone keystoneTenantClient = new Keystone(keystoneUrl);
+ Access access = null;
+ Authentication credentials = authenticationMethodFactory.getAuthenticationFor(cloudIdentity);
+ OpenStackRequest<Access> request =
+ keystoneTenantClient.tokens().authenticate(credentials).withTenantId(tenantId);
+ access = executeAndRecordOpenstackRequest(request);
+ return access;
+ }
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index 8093f045eb..376ed20ed0 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -23,26 +23,9 @@
package org.onap.so.openstack.utils;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.woorea.openstack.base.client.OpenStackConnectException;
-import com.woorea.openstack.base.client.OpenStackRequest;
-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.Resources;
-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;
-import com.woorea.openstack.keystone.model.Authentication;
-import com.woorea.openstack.keystone.utils.KeystoneUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -92,6 +75,22 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.woorea.openstack.base.client.OpenStackConnectException;
+import com.woorea.openstack.base.client.OpenStackRequest;
+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.Events;
+import com.woorea.openstack.heat.model.Resources;
+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;
+import com.woorea.openstack.keystone.model.Authentication;
+import com.woorea.openstack.keystone.utils.KeystoneUtils;
@Primary
@Component
@@ -130,6 +129,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
@Autowired
RequestsDbClient requestDBClient;
+ @Autowired
+ StackStatusHandler statusHandler;
+
private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtils.class);
// Properties names and variables (with default values)
@@ -317,6 +319,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
while (true) {
try {
heatStack = queryHeatStack(heatClient, canonicalName);
+ statusHandler.updateStackStatus(heatStack, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
logger.debug("{} ({})", heatStack.getStackStatus(), canonicalName);
try {
logger.debug("Current stack {}", this.getOutputsAsStringBuilder(heatStack).toString());
@@ -358,6 +361,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
while (!deleted) {
try {
heatStack = queryHeatStack(heatClient, canonicalName);
+ statusHandler.updateStackStatus(heatStack, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
if (heatStack != null) {
logger.debug(heatStack.getStackStatus());
if ("DELETE_IN_PROGRESS".equals(heatStack.getStackStatus())) {
@@ -579,24 +583,15 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
*/
public StackInfo deleteStack(String tenantId, String cloudOwner, String cloudSiteId, String stackName,
boolean pollForCompletion) throws MsoException {
- // Obtain the cloud site information where we will create the stack
CloudSite cloudSite =
cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- logger.debug(FOUND, cloudSite.toString());
-
- // Get a Heat client. They are cached between calls (keyed by tenantId:cloudId)
Heat heatClient = null;
try {
heatClient = getHeatClient(cloudSite, tenantId);
- if (heatClient != null) {
- logger.debug(FOUND, heatClient.toString());
- }
} catch (MsoTenantNotFound e) {
- // Tenant doesn't exist, so stack doesn't either
logger.debug("Tenant with id " + tenantId + "not found.", e);
return new StackInfo(stackName, HeatStatus.NOTFOUND);
} catch (MsoException me) {
- // Got an Openstack error. Propagate it
logger.error("{} {} Openstack Exception on Token request: ", MessageEnum.RA_CONNECTION_EXCEPTION,
ErrorCode.AvailabilityError.getValue(), me);
me.addContext(DELETE_STACK);
@@ -610,8 +605,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
return new StackInfo(stackName, HeatStatus.NOTFOUND);
}
- // Delete the stack.
-
// Use canonical name "<stack name>/<stack-id>" to delete.
// Otherwise, deletion by name returns a 302 redirect.
// NOTE: This is specific to the v1 Orchestration API.
@@ -624,7 +617,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
} else {
logger.debug("Heat Client is NULL");
}
-
executeAndRecordOpenstackRequest(request);
} catch (OpenStackResponseException e) {
if (e.getStatus() == 404) {
@@ -645,15 +637,13 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Requery the stack for current status.
// It will probably still exist with "DELETE_IN_PROGRESS" status.
heatStack = queryHeatStack(heatClient, canonicalName);
-
+ statusHandler.updateStackStatus(heatStack, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
if (pollForCompletion) {
- // Set a timeout on polling
-
int pollInterval = Integer
.parseInt(this.environment.getProperty(deletePollIntervalProp, "" + DELETE_POLL_INTERVAL_DEFAULT));
int pollTimeout = Integer
.parseInt(this.environment.getProperty(deletePollTimeoutProp, "" + DELETE_POLL_INTERVAL_DEFAULT));
-
+ statusHandler.updateStackStatus(heatStack, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
// When querying by canonical name, Openstack returns DELETE_COMPLETE status
// instead of "404" (which would result from query by stack name).
while (heatStack != null && !"DELETE_COMPLETE".equals(heatStack.getStackStatus())) {
@@ -698,11 +688,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// The stack is gone when this point is reached
return new StackInfo(stackName, HeatStatus.NOTFOUND);
}
-
// Return the current status (if not polling, the delete may still be in progress)
StackInfo stackInfo = new StackInfoMapper(heatStack).map();
stackInfo.setName(stackName);
-
return stackInfo;
}
@@ -841,7 +829,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
logger.debug("keystoneUrl={}", keystoneUrl);
String heatUrl = null;
String tokenId = null;
-
try {
if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) {
Keystone keystoneTenantClient = new Keystone(keystoneUrl);
@@ -855,19 +842,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
access = executeAndRecordOpenstackRequest(request);
try {
- // Isolate trying to printout the region IDs
- try {
- logger.debug("access={}", access.toString());
- for (Access.Service service : access.getServiceCatalog()) {
- List<Access.Service.Endpoint> endpoints = service.getEndpoints();
- for (Access.Service.Endpoint endpoint : endpoints) {
- logger.debug("AIC returned region={}", endpoint.getRegion());
- }
- }
- } catch (Exception e) {
- logger.debug("Encountered an error trying to printout Access object returned from AIC. {}",
- e.getMessage(), e);
- }
+ logger.debug("access={}", access.toString());
heatUrl = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "orchestration", region,
"public");
logger.debug("heatUrl={}, region={}", heatUrl, region);
@@ -878,12 +853,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
throw new MsoAdapterException(error, e);
}
tokenId = access.getToken().getId();
-
} else if (ServerType.KEYSTONE_V3.equals(cloudIdentity.getIdentityServerType())) {
try {
KeystoneAuthHolder holder = keystoneV3Authentication.getToken(cloudSite, tenantId, "orchestration");
tokenId = holder.getId();
-
heatUrl = holder.getServiceUrl();
} catch (ServiceEndpointNotFoundException e) {
// This comes back for not found (probably an incorrect region ID)
@@ -933,7 +906,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
*
* @throws MsoOpenstackException Thrown if the Openstack API call returns an exception
*/
- protected Stack queryHeatStack(Heat heatClient, String stackName) throws MsoException {
+ public Stack queryHeatStack(Heat heatClient, String stackName) throws MsoException {
if (stackName == null) {
return null;
}
@@ -1364,77 +1337,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
return keystoneUrl;
}
- /*
- * Create a string suitable for being dumped to a debug log that creates a pseudo-JSON request dumping what's being
- * sent to Openstack API in the create or update request
- */
-
- private String printStackRequest(String tenantId, Map<String, Object> heatFiles,
- Map<String, Object> nestedTemplates, String environment, Map<String, Object> inputs, String vfModuleName,
- String template, int timeoutMinutes, boolean backout, String cloudSiteId) {
- StringBuilder sb = new StringBuilder();
- sb.append("CREATE STACK REQUEST (formatted for readability)\n");
- sb.append("tenant=" + tenantId + ", cloud=" + cloudSiteId);
- sb.append("{\n");
- sb.append(" \"stack_name\": \"" + vfModuleName + "\",\n");
- sb.append(" \"disable_rollback\": " + backout + ",\n");
- sb.append(" \"timeout_mins\": " + timeoutMinutes + ",\n");
- sb.append(" \"template\": {\n");
- sb.append(template);
- sb.append(" },\n");
- sb.append(" \"environment\": {\n");
- if (environment == null)
- sb.append("<none>");
- else
- sb.append(environment);
- sb.append(" },\n");
- sb.append(" \"files\": {\n");
- int filesCounter = 0;
- if (heatFiles != null) {
- for (String key : heatFiles.keySet()) {
- filesCounter++;
- if (filesCounter > 1) {
- sb.append(",\n");
- }
- sb.append(" \"" + key + "\": {\n");
- sb.append(heatFiles.get(key).toString() + "\n }");
- }
- }
- if (nestedTemplates != null) {
- for (String key : nestedTemplates.keySet()) {
- filesCounter++;
- if (filesCounter > 1) {
- sb.append(",\n");
- }
- sb.append(" \"" + key + "\": {\n");
- sb.append(nestedTemplates.get(key).toString() + "\n }");
- }
- }
- sb.append("\n },\n");
- sb.append(" \"parameters\": {\n");
- int paramCounter = 0;
- for (String name : inputs.keySet()) {
- paramCounter++;
- if (paramCounter > 1) {
- sb.append(",\n");
- }
- Object o = inputs.get(name);
- if (o instanceof java.lang.String) {
- sb.append(" \"" + name + "\": \"" + inputs.get(name).toString() + "\"");
- } else if (o instanceof Integer) {
- sb.append(" \"" + name + "\": " + inputs.get(name).toString());
- } else if (o instanceof ArrayList) {
- sb.append(" \"" + name + "\": " + inputs.get(name).toString());
- } else if (o instanceof Boolean) {
- sb.append(" \"" + name + "\": " + inputs.get(name).toString());
- } else {
- sb.append(" \"" + name + "\": " + "\"(there was an issue trying to dump this value...)\"");
- }
- }
- sb.append("\n }\n}\n");
-
- return sb.toString();
- }
/*******************************************************************************
*
@@ -1613,6 +1515,32 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
return executeAndRecordOpenstackRequest(request);
}
+ public Events queryStackEvents(String cloudSiteId, String tenantId, String stackName, String stackId,
+ int nestedDepth) throws MsoException {
+ CloudSite cloudSite =
+ cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
+ Heat heatClient = getHeatClient(cloudSite, tenantId);
+ OpenStackRequest<Events> request =
+ heatClient.getEvents().listEvents(stackName, stackId).queryParam("nested_depth", nestedDepth);
+ return executeAndRecordOpenstackRequest(request);
+ }
+
+ public Stacks queryStacks(String cloudSiteId, String tenantId, int limit, String marker)
+ throws MsoCloudSiteNotFound, HeatClientException {
+ CloudSite cloudSite =
+ cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
+ Heat heatClient;
+ try {
+ heatClient = getHeatClient(cloudSite, tenantId);
+ } catch (MsoException e) {
+ logger.error("Error Creating Heat Client", e);
+ throw new HeatClientException("Error Creating Heat Client", e);
+ }
+ OpenStackRequest<Stacks> request =
+ heatClient.getStacks().list().queryParam("limit", limit).queryParam("marker", marker);
+ return executeAndRecordOpenstackRequest(request);
+ }
+
public <R> R executeHeatClientRequest(String url, String cloudSiteId, String tenantId, Class<R> returnType)
throws MsoException {
CloudSite cloudSite =
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientException.java
new file mode 100644
index 0000000000..e2c917c6eb
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientException.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.onap.so.openstack.utils;
+
+public class NeutronClientException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -9047340957886416022L;
+
+ public NeutronClientException(String error, Exception e) {
+ super(error, e);
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java
new file mode 100644
index 0000000000..93745de54a
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.onap.so.openstack.utils;
+
+import org.onap.so.cloud.authentication.KeystoneAuthHolder;
+import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import com.woorea.openstack.base.client.OpenStackRequest;
+import com.woorea.openstack.quantum.Quantum;
+import com.woorea.openstack.quantum.model.Networks;
+import com.woorea.openstack.quantum.model.Subnets;
+
+
+
+@Component
+public class NeutronClientImpl extends MsoCommonUtils {
+
+ /** The Constant logger. */
+ private static final Logger logger = LoggerFactory.getLogger(NeutronClientImpl.class);
+
+ /**
+ * Gets the Neutron client, using old object named Quantum, now renamed Neutron
+ *
+ * @param cloudSite the cloud site
+ * @param tenantId the tenant id
+ * @return the Neutron client
+ * @throws MsoException the mso exception
+ */
+ private Quantum getNeutronClient(String cloudSiteId, String tenantId) throws MsoException {
+ KeystoneAuthHolder keystone = getKeystoneAuthHolder(cloudSiteId, tenantId, "network");
+ Quantum neutronClient = new Quantum(keystone.getServiceUrl() + "/v2.0/");
+ neutronClient.token(keystone.getId());
+ return neutronClient;
+ }
+
+
+ /**
+ * Query Networks
+ *
+ *
+ * @param cloudSiteId the cloud site id
+ * @param tenantId the tenant id
+ * @param limit limits the number of records returned
+ * @param marker the last viewed record
+ * @param name of the newtork
+ * @param id of the network
+ * @return the list of networks in openstack
+ * @throws MsoCloudSiteNotFound the mso cloud site not found
+ * @throws NeutronClientException if the client cannot be built this is thrown
+ */
+ public Networks queryNetworks(String cloudSiteId, String tenantId, int limit, String marker, String name, String id)
+ throws MsoCloudSiteNotFound, NeutronClientException {
+ try {
+ Quantum neutronClient = getNeutronClient(cloudSiteId, tenantId);
+ OpenStackRequest<Networks> request = neutronClient.networks().list().queryParam("id", id)
+ .queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
+ return executeAndRecordOpenstackRequest(request);
+ } catch (MsoException e) {
+ logger.error("Error building Neutron Client", e);
+ throw new NeutronClientException("Error building Neutron Client", e);
+ }
+ }
+
+
+ /**
+ * Query Networks
+ *
+ *
+ * @param cloudSiteId the cloud site id
+ * @param tenantId the tenant id
+ * @param limit limits the number of records returned
+ * @param marker the last viewed record
+ * @param name of the subnet
+ * @param id of the subnet
+ * @return the list of subnets in openstack
+ * @throws MsoCloudSiteNotFound the mso cloud site not found
+ * @throws NeutronClientException if the client cannot be built this is thrown
+ */
+ public Subnets querySubnets(String cloudSiteId, String tenantId, int limit, String marker, String name, String id)
+ throws MsoCloudSiteNotFound, NeutronClientException {
+ try {
+ Quantum neutronClient = getNeutronClient(cloudSiteId, tenantId);
+ OpenStackRequest<Subnets> request = neutronClient.subnets().list().queryParam("id", id)
+ .queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
+ return executeAndRecordOpenstackRequest(request);
+ } catch (MsoException e) {
+ logger.error("Error building Neutron Client", e);
+ throw new NeutronClientException("Error building Neutron Client", e);
+ }
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientException.java
new file mode 100644
index 0000000000..c5b6563dff
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientException.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.onap.so.openstack.utils;
+
+public class NovaClientException extends Exception {
+
+ public NovaClientException(String error, Exception e) {
+ super(error, e);
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1920095376579954885L;
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java
new file mode 100644
index 0000000000..a342f770ef
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java
@@ -0,0 +1,186 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.onap.so.openstack.utils;
+
+import org.onap.so.cloud.authentication.KeystoneAuthHolder;
+import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import com.woorea.openstack.base.client.OpenStackRequest;
+import com.woorea.openstack.nova.Nova;
+import com.woorea.openstack.nova.model.Flavor;
+import com.woorea.openstack.nova.model.Flavors;
+import com.woorea.openstack.nova.model.HostAggregate;
+import com.woorea.openstack.nova.model.HostAggregates;
+import com.woorea.openstack.nova.model.QuotaSet;
+
+
+@Component
+public class NovaClientImpl extends MsoCommonUtils {
+
+
+ /** The logger. */
+ private static final Logger logger = LoggerFactory.getLogger(NovaClientImpl.class);
+
+ /**
+ * Gets the Nova client
+ *
+ * @param cloudSiteId id of the cloud site
+ * @param tenantId the tenant id
+ * @return the Nova client
+ * @throws MsoException the mso exception
+ */
+ private Nova getNovaClient(String cloudSiteId, String tenantId) throws MsoException {
+ KeystoneAuthHolder keystone = getKeystoneAuthHolder(cloudSiteId, tenantId, "compute");
+ Nova novaClient = new Nova(keystone.getServiceUrl());
+ novaClient.token(keystone.getId());
+ return novaClient;
+ }
+
+
+ /**
+ * Query Networks
+ *
+ *
+ * @param cloudSiteId the cloud site id
+ * @param tenantId the tenant id
+ * @param limit limits the number of records returned
+ * @param marker the last viewed record
+ * @param name of the newtork
+ * @param id of the network
+ * @return the list of networks in openstack
+ * @throws MsoCloudSiteNotFound the mso cloud site not found
+ * @throws NeutronClientException if the client cannot be built this is thrown
+ */
+ public Flavors queryFlavors(String cloudSiteId, String tenantId, int limit, String marker)
+ throws MsoCloudSiteNotFound, NovaClientException {
+ try {
+ Nova novaClient = getNovaClient(cloudSiteId, tenantId);
+ OpenStackRequest<Flavors> request =
+ novaClient.flavors().list(false).queryParam("limit", limit).queryParam("marker", marker);
+ return executeAndRecordOpenstackRequest(request);
+ } catch (MsoException e) {
+ logger.error("Error building Nova Client", e);
+ throw new NovaClientException("Error building Nova Client", e);
+ }
+
+ }
+
+ /**
+ * Query Networks
+ *
+ *
+ * @param cloudSiteId the cloud site id
+ * @param tenantId the tenant id
+ * @param id of the network
+ * @return the the flavor from openstack
+ * @throws MsoCloudSiteNotFound the mso cloud site not found
+ * @throws NeutronClientException if the client cannot be built this is thrown
+ */
+ public Flavor queryFlavorById(String cloudSiteId, String tenantId, String id)
+ throws MsoCloudSiteNotFound, NovaClientException {
+ try {
+ Nova novaClient = getNovaClient(cloudSiteId, tenantId);
+ novaClient = getNovaClient(cloudSiteId, tenantId);
+ OpenStackRequest<Flavor> request = novaClient.flavors().show(id);
+ return executeAndRecordOpenstackRequest(request);
+ } catch (MsoException e) {
+ logger.error("Error building Nova Client", e);
+ throw new NovaClientException("Error building Nova Client", e);
+ }
+ }
+
+ /**
+ * Query Host Aggregates
+ *
+ *
+ * @param cloudSiteId the cloud site id
+ * @param tenantId the tenant id
+ * @param limit limits the number of records returned
+ * @param marker the last viewed record
+ * @return the list of host aggregates found in openstack
+ * @throws MsoCloudSiteNotFound the mso cloud site not found
+ * @throws NeutronClientException if the client cannot be built this is thrown
+ */
+ public HostAggregates queryHostAggregates(String cloudSiteId, String tenantId, int limit, String marker)
+ throws MsoCloudSiteNotFound, NovaClientException {
+ try {
+ Nova novaClient = getNovaClient(cloudSiteId, tenantId);
+ OpenStackRequest<HostAggregates> request =
+ novaClient.aggregates().list().queryParam("limit", limit).queryParam("marker", marker);
+ return executeAndRecordOpenstackRequest(request);
+ } catch (MsoException e) {
+ logger.error("Error building Nova Client", e);
+ throw new NovaClientException("Error building Nova Client", e);
+ }
+ }
+
+ /**
+ * Query Host Aggregate
+ *
+ *
+ * @param cloudSiteId the cloud site id
+ * @param tenantId the tenant id
+ * @param limit limits the number of records returned
+ * @param marker the last viewed record
+ * @return a host aggregate
+ * @throws MsoCloudSiteNotFound the mso cloud site not found
+ * @throws NeutronClientException if the client cannot be built this is thrown
+ */
+ public HostAggregate queryHostAggregateById(String cloudSiteId, String tenantId, String id)
+ throws MsoCloudSiteNotFound, NovaClientException {
+ try {
+ Nova novaClient = getNovaClient(cloudSiteId, tenantId);
+ OpenStackRequest<HostAggregate> request = novaClient.aggregates().showAggregate(id);
+ return executeAndRecordOpenstackRequest(request);
+ } catch (MsoException e) {
+ logger.error("Error building Nova Client", e);
+ throw new NovaClientException("Error building Nova Client", e);
+ }
+ }
+
+ /**
+ * Query OS Quota Set
+ *
+ *
+ * @param cloudSiteId the cloud site id
+ * @param tenantId the tenant id
+ * @param limit limits the number of records returned
+ * @param marker the last viewed record
+ * @return a host aggregate
+ * @throws MsoCloudSiteNotFound the mso cloud site not found
+ * @throws NeutronClientException if the client cannot be built this is thrown
+ */
+ public QuotaSet queryOSQuotaSet(String cloudSiteId, String tenantId)
+ throws MsoCloudSiteNotFound, NovaClientException {
+ try {
+ Nova novaClient = getNovaClient(cloudSiteId, tenantId);
+ OpenStackRequest<QuotaSet> request = novaClient.quotaSets().showQuota(tenantId);
+ return executeAndRecordOpenstackRequest(request);
+ } catch (MsoException e) {
+ logger.error("Error building Nova Client", e);
+ throw new NovaClientException("Error building Nova Client", e);
+ }
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java
new file mode 100644
index 0000000000..990e9a4543
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java
@@ -0,0 +1,43 @@
+package org.onap.so.openstack.utils;
+
+
+import org.onap.so.db.request.beans.RequestProcessingData;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.woorea.openstack.heat.model.Stack;
+
+@Component
+public class StackStatusHandler {
+
+ private static final Logger logger = LoggerFactory.getLogger(StackStatusHandler.class);
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @Autowired
+ private RequestsDbClient requestDBClient;
+
+ @Async
+ public void updateStackStatus(Stack stack, String requestId) {
+ try {
+ String stackStatus = mapper.writeValueAsString(stack);
+ RequestProcessingData requestProcessingData =
+ requestDBClient.getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId, stack.getId(),
+ stack.getStackName());
+ if (requestProcessingData == null) {
+ requestProcessingData = new RequestProcessingData();
+ requestProcessingData.setGroupingId(stack.getId());
+ requestProcessingData.setName(stack.getStackName());
+ requestProcessingData.setTag("StackInformation");
+ requestProcessingData.setSoRequestId(requestId);
+ }
+ requestProcessingData.setValue(stackStatus);
+ requestDBClient.saveRequestProcessingData(requestProcessingData);
+ } catch (Exception e) {
+ logger.warn("Error adding stack status to request database", e);
+ }
+ }
+}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java
index 5bd77d8e10..0137148835 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java
@@ -65,7 +65,7 @@ public class KeystoneAuthHolderTest {
@Test
public void testGetServiceUrl() {
- keystoneAuthHolder.setHeatUrl("testURL");
+ keystoneAuthHolder.setServiceUrl("testURL");
assertEquals("testURL", keystoneAuthHolder.getServiceUrl());
}
diff --git a/adapters/mso-adapters-rest-interface/pom.xml b/adapters/mso-adapters-rest-interface/pom.xml
index 17d4bc1e35..5f987e61ce 100644
--- a/adapters/mso-adapters-rest-interface/pom.xml
+++ b/adapters/mso-adapters-rest-interface/pom.xml
@@ -51,6 +51,21 @@
<version>${openstack.version}</version>
</dependency>
<dependency>
+ <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
+ <artifactId>glance-client</artifactId>
+ <version>${openstack.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
+ <artifactId>cinder-client</artifactId>
+ <version>${openstack.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
+ <artifactId>nova-client</artifactId>
+ <version>${openstack.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.onap.so.libs.openstack-java-sdk.client-connectors</groupId>
<artifactId>http-connector</artifactId>
<version>${openstack.version}</version>
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
index 0e526e59fb..79aad1ad1a 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
@@ -44,10 +44,9 @@ public class JerseyConfiguration extends ResourceConfig {
register(ServiceRestImpl.class);
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.2");
- beanConfig.setSchemes(new String[] {"http"});
- beanConfig.setHost("localhost:8080");
+ beanConfig.setSchemes(new String[] {"https"});
beanConfig.setBasePath("/ecomp/mso/catalog");
- beanConfig.setResourcePackage("org.onap.so.adapters.catalogdb");
+ beanConfig.setResourcePackage("org.onap.so.adapters.catalogdb.rest");
beanConfig.setPrettyPrint(true);
beanConfig.setScan(true);
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
index 1ca8998396..520de4d38c 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
@@ -28,16 +28,18 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.onap.so.db.catalog.data.repository.ServiceRepository;
import org.onap.so.rest.catalog.beans.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.google.common.base.Strings;
+import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
-@Path("/v1/")
+@Api(value = "/v1/services", tags = "model")
+@Path("/v1/services")
@Component
public class ServiceRestImpl {
@@ -48,7 +50,7 @@ public class ServiceRestImpl {
private ServiceMapper serviceMapper;
@GET
- @Path("/services/{modelUUID}")
+ @Path("/{modelUUID}")
@Produces({MediaType.APPLICATION_JSON})
@Transactional(readOnly = true)
public Service findService(@PathParam("modelUUID") String modelUUID, @QueryParam("depth") int depth) {
@@ -57,12 +59,15 @@ public class ServiceRestImpl {
}
@GET
- @Path("/services")
- @ApiOperation(value = "Find Service Models", response = Service.class, responseContainer = "List")
+ @ApiOperation(value = "Find Service Models", response = Service.class, responseContainer = "List",
+ notes = "If no query parameters are sent an empty list will be returned")
@Produces({MediaType.APPLICATION_JSON})
@Transactional(readOnly = true)
- public List<Service> queryServices(@QueryParam("modelName") String modelName,
- @QueryParam("distributionStatus") String distributionStatus, @QueryParam("depth") int depth) {
+ public List<Service> queryServices(
+ @ApiParam(value = "modelName", required = false) @QueryParam("modelName") String modelName,
+ @ApiParam(value = "distributionStatus",
+ required = false) @QueryParam("distributionStatus") String distributionStatus,
+ @ApiParam(value = "depth", required = false) @QueryParam("depth") int depth) {
List<Service> services = new ArrayList<>();
List<org.onap.so.db.catalog.beans.Service> serviceFromDB = new ArrayList<>();
if (!Strings.isNullOrEmpty(modelName) && !Strings.isNullOrEmpty(distributionStatus)) {
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
index 238c4cf467..0f46e91311 100644
--- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
@@ -776,4 +776,7 @@ UPDATE rainy_day_handler_macro SET Secondary_Policy = 'Rollback' WHERE FLOW_NAME
INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY)
VALUES
('GenericVnfHealthCheckBB', '*', '*', '*', "*" , 'Retry'),
-('ConfigurationScaleOutBB', '*', '*', '*', "*" , 'Retry'); \ No newline at end of file
+('ConfigurationScaleOutBB', '*', '*', '*', "*" , 'Retry');
+
+
+UPDATE rainy_day_handler_macro SET reg_ex_error_message = '*' WHERE reg_ex_error_message IS null; \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml
index d174de7e2f..922716425b 100644
--- a/adapters/mso-openstack-adapters/pom.xml
+++ b/adapters/mso-openstack-adapters/pom.xml
@@ -147,13 +147,22 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>original</id>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings
- only. It has no influence on the Maven build itself. -->
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build
+ itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
@@ -164,14 +173,14 @@
<pluginExecution>
<pluginExecutionFilter>
<groupId>
- org.jvnet.jax-ws-commons
- </groupId>
+ org.jvnet.jax-ws-commons
+ </groupId>
<artifactId>
- jaxws-maven-plugin
- </artifactId>
+ jaxws-maven-plugin
+ </artifactId>
<versionRange>
- [2.3,)
- </versionRange>
+ [2.3,)
+ </versionRange>
<goals>
<goal>wsgen</goal>
</goals>
@@ -219,11 +228,6 @@
<version>${cxf.version}</version>
</dependency>
<dependency>
- <groupId>org.webjars</groupId>
- <artifactId>swagger-ui</artifactId>
- <version>3.5.0</version>
- </dependency>
- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
index 2e62beb083..5060e554eb 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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.onap.so.adapters.audit;
import java.util.Optional;
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java
index b12d2397f9..df2c3a2973 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java
@@ -24,11 +24,6 @@
package org.onap.so.adapters.network;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -47,6 +42,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.ws.Holder;
import org.apache.http.HttpStatus;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.network.exceptions.NetworkException;
import org.onap.so.adapters.nwrest.ContrailNetwork;
import org.onap.so.adapters.nwrest.CreateNetworkError;
@@ -74,9 +70,15 @@ import org.onap.so.openstack.beans.RouteTarget;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
@Path("/v1/networks")
@Api(value = "/v1/networks", description = "root of network adapters restful web service")
@@ -160,6 +162,11 @@ public class NetworkAdapterRest {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("CreateNetworkTask start");
try {
// Synchronous Web Service Outputs
@@ -317,6 +324,11 @@ public class NetworkAdapterRest {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("DeleteNetworkTask start");
try {
Holder<Boolean> networkDeleted = new Holder<>();
@@ -462,6 +474,11 @@ public class NetworkAdapterRest {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getNetworkRollback().getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("RollbackNetworkTask start");
try {
NetworkRollback nwr = req.getNetworkRollback();
@@ -550,6 +567,11 @@ public class NetworkAdapterRest {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("UpdateNetworkTask start");
try {
Holder<Map<String, String>> subnetIdMap = new Holder<>();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java
index 20ce4170af..686410f14c 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java
@@ -41,6 +41,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.ws.Holder;
import org.apache.http.HttpStatus;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
import org.onap.so.adapters.vnfrest.CreateVfModuleResponse;
@@ -61,6 +62,7 @@ import org.onap.so.openstack.beans.VnfStatus;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -86,19 +88,10 @@ public class VnfAdapterRest {
@Autowired
private MsoVnfAdapterImpl vnfAdapter;
- // TODO Logging, SkipAAI, CREATED flags, Integrate with BPEL, Auth,
@Autowired
private Provider<BpelRestClient> bpelRestClientProvider;
-
- /*
- * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules/<aaimodid> REQUEST: {"deleteVfModuleRequest":
- * {"cloudSiteId": "DAN", "tenantId": "214b428a1f554c02935e66330f6a5409", "vnfId": "somevnfid", "vfModuleId":
- * "somemodid", "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73", "messageId": "ra.1", "notificationUrl":
- * "http://localhost:8089/vnfmock", "skipAAI": true, "msoRequest": { "requestId": "ra1", "serviceInstanceId": "sa1"
- * }} }
- */
@DELETE
@Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@@ -176,11 +169,14 @@ public class VnfAdapterRest {
@Override
public void run() {
try {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
String cloudsite = req.getCloudSiteId();
Holder<Map<String, String>> outputs = new Holder<>();
if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) {
- // vnfAdapter.deleteVnf (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(),
- // req.getMsoRequest());
vnfAdapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
req.getVfModuleStackId(), req.getMsoRequest(), outputs);
}
@@ -200,13 +196,7 @@ public class VnfAdapterRest {
}
}
- /*
- * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaiVnfId>/vf-modules/<aaiVfModuleId>?cloudSiteId=DAN&tenantId=
- * vfModule?&skipAAI=TRUE&msoRequest.requestId=ra1&msoRequest.serviceInstanceId=si1&vfModuleName=T2N2S1 RESP:
- * {"queryVfModuleResponse": { "vfModuleId": "AvfmodId", "vfModuleOutputs": {"entry": { "key":
- * "server_private_ip_1", "value": "10.100.1.25" }}, "vfModuleStackId":
- * "RaaVnf1/abfa8a6d-feb1-40af-aea3-109403b1cf6b", "vnfId": "AvnfID", "vnfStatus": "ACTIVE" }}
- */
+
@GET
@Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@@ -340,6 +330,11 @@ public class VnfAdapterRest {
public void run() {
logger.debug("CreateVfModuleTask start");
try {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
// Synchronous Web Service Outputs
Holder<String> vfModuleStackId = new Holder<>();
Holder<Map<String, String>> outputs = new Holder<>();
@@ -449,9 +444,11 @@ public class VnfAdapterRest {
@Override
public void run() {
try {
- // MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
-
- // Synchronous Web Service Outputs
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
Holder<String> vfModuleStackId = new Holder<>();
Holder<Map<String, String>> outputs = new Holder<>();
Holder<VnfRollback> vnfRollback = new Holder<>();
@@ -481,13 +478,7 @@ public class VnfAdapterRest {
}
}
- /*
- * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules/<aaimodid>/rollback REQUEST:
- * {"deleteVfModuleRequest": {"cloudSiteId": "DAN", "tenantId": "214b428a1f554c02935e66330f6a5409", "vnfId":
- * "somevnfid", "vfModuleId": "somemodid", "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73", "messageId":
- * "ra.1", "notificationUrl": "http://localhost:8089/vnfmock", "skipAAI": true, "msoRequest": { "requestId": "ra1",
- * "serviceInstanceId": "sa1" }} }
- */
+
@DELETE
@Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback")
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@@ -557,6 +548,11 @@ public class VnfAdapterRest {
@Override
public void run() {
try {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVfModuleRollback().getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
VfModuleRollback vmr = req.getVfModuleRollback();
VnfRollback vrb = new VnfRollback(vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudOwner(),
vmr.getCloudSiteId(), true, true, vmr.getMsoRequest(), null, null, null, null);
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java
index 7c6d251263..5b831047ad 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java
@@ -40,6 +40,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.ws.Holder;
import org.apache.http.HttpStatus;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
import org.onap.so.adapters.vnfrest.CreateVfModuleResponse;
@@ -60,6 +61,7 @@ import org.onap.so.openstack.beans.VnfStatus;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import io.swagger.annotations.Api;
@@ -132,6 +134,7 @@ public class VnfAdapterRestV2 {
// This is an asynchronous request
try {
Thread t1 = new Thread(task);
+ MDC.getCopyOfContextMap();
t1.start();
} catch (Exception e) {
// problem handling delete, send generic failure as sync resp to caller
@@ -178,6 +181,11 @@ public class VnfAdapterRestV2 {
@Override
public void run() {
try {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
String cloudsite = req.getCloudSiteId();
Holder<Map<String, String>> outputs = new Holder<>();
if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) {
@@ -201,6 +209,7 @@ public class VnfAdapterRestV2 {
bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
}
logger.debug("Delete vfModule exit: code=" + getStatusCode() + RESP + getResponse());
+ MDC.clear();
}
}
@@ -353,6 +362,11 @@ public class VnfAdapterRestV2 {
public void run() {
logger.debug("CreateVfModuleTask start");
try {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
// Synchronous Web Service Outputs
Holder<String> vfModuleStackId = new Holder<>();
Holder<Map<String, String>> outputs = new Holder<>();
@@ -467,8 +481,11 @@ public class VnfAdapterRestV2 {
@Override
public void run() {
try {
- // MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
-
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
// Synchronous Web Service Outputs
Holder<String> vfModuleStackId = new Holder<>();
Holder<Map<String, String>> outputs = new Holder<>();
@@ -577,6 +594,11 @@ public class VnfAdapterRestV2 {
@Override
public void run() {
try {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVfModuleRollback().getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
VfModuleRollback vmr = req.getVfModuleRollback();
VnfRollback vrb = new VnfRollback(vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudOwner(),
vmr.getCloudSiteId(), true, vmr.isVfModuleCreated(), vmr.getMsoRequest(), null, null, null,
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java
index c02a872a85..87df7fdc37 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java
@@ -25,11 +25,6 @@
package org.onap.so.adapters.vnf;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Provider;
@@ -47,6 +42,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.ws.Holder;
import org.apache.http.HttpStatus;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
@@ -67,8 +63,14 @@ import org.onap.so.openstack.beans.VnfStatus;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
/**
* This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups) Both
@@ -155,6 +157,11 @@ public class VolumeAdapterRest {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("CreateVFModule VolumesTask start");
try {
// Synchronous Web Service Outputs
@@ -302,6 +309,11 @@ public class VolumeAdapterRest {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("DeleteVNFVolumesTask start");
try {
if (!req.getCloudSiteId().equals(TESTING_KEYWORD)) {
@@ -394,6 +406,11 @@ public class VolumeAdapterRest {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVolumeGroupRollback().getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("DeleteVNFVolumesTask start");
try {
VolumeGroupRollback vgr = req.getVolumeGroupRollback();
@@ -487,6 +504,11 @@ public class VolumeAdapterRest {
public void run() {
logger.debug("UpdateVNFVolumesTask start");
try {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
Holder<Map<String, String>> outputs = new Holder<>();
Holder<VnfRollback> vnfRollback = new Holder<>();
String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java
index 0ceba20051..77c9b1e2f5 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java
@@ -24,11 +24,6 @@
package org.onap.so.adapters.vnf;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Provider;
@@ -46,6 +41,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.ws.Holder;
import org.apache.http.HttpStatus;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
@@ -66,8 +62,14 @@ import org.onap.so.openstack.beans.VnfStatus;
import org.onap.so.openstack.exceptions.MsoExceptionCategory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
/**
* This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups) Both
@@ -158,6 +160,11 @@ public class VolumeAdapterRestV2 {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("CreateVFModule VolumesTask start");
try {
// Synchronous Web Service Outputs
@@ -288,6 +295,11 @@ public class VolumeAdapterRestV2 {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("DeleteVNFVolumesTask start");
String cloudSiteId = req.getCloudSiteId();
try {
@@ -383,6 +395,11 @@ public class VolumeAdapterRestV2 {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVolumeGroupRollback().getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("RollbackVNFVolumesTask start");
try {
VolumeGroupRollback vgr = req.getVolumeGroupRollback();
@@ -480,6 +497,11 @@ public class VolumeAdapterRestV2 {
@Override
public void run() {
+ try {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId());
+ } catch (Exception e) {
+ logger.error("Error adding RequestId to MDC", e);
+ }
logger.debug("UpdateVNFVolumesTask start");
try {
Holder<Map<String, String>> outputs = new Holder<>();
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java
index e481f0d03f..1a44934187 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java
@@ -67,7 +67,7 @@ public class TenantAdapterRestTest extends BaseRestTestUtils {
public void testCreateTenantCreated() throws JsonParseException, JsonMappingException, IOException {
CreateTenantRequest request = new CreateTenantRequest();
- String cloudSiteId = "MTN13";
+ String cloudSiteId = "mtn13";
String requestId = "62265093-277d-4388-9ba6-449838ade586";
String serviceInstanceId = "4147e06f-1b89-49c5-b21f-4faf8dc9805a";
String tenantName = "testingTenantName";
@@ -117,7 +117,7 @@ public class TenantAdapterRestTest extends BaseRestTestUtils {
public void testCreateTenantExists() throws JsonParseException, JsonMappingException, IOException {
CreateTenantRequest request = new CreateTenantRequest();
- String cloudSiteId = "MTN13";
+ String cloudSiteId = "mtn13";
String requestId = "62265093-277d-4388-9ba6-449838ade586";
String serviceInstanceId = "4147e06f-1b89-49c5-b21f-4faf8dc9805a";
String tenantName = "testingTenantName";
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java
index 102d748d56..92bac7a14b 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java
@@ -30,7 +30,6 @@ import java.io.IOException;
import javax.ws.rs.core.MediaType;
import org.apache.http.HttpStatus;
import org.junit.Before;
-import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.openstack.MsoOpenstackAdaptersApplication;
import org.onap.so.cloud.CloudConfig;
@@ -39,7 +38,6 @@ import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.ServerType;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -70,7 +68,6 @@ public abstract class BaseRestTestUtils {
CloudConfig cloudConfig;
@Autowired
- @Qualifier("JettisonStyle")
protected TestRestTemplate restTemplate;
protected HttpHeaders headers = new HttpHeaders();
@@ -118,9 +115,10 @@ public abstract class BaseRestTestUtils {
wireMockServer.resetAll();
mapper = new ObjectMapper();
CloudIdentity identity = new CloudIdentity();
- identity.setId("MTN13");
+ identity.setId("DEFAULT");
identity.setMsoId("m93945");
- identity.setMsoPass("93937EA01B94A10A49279D4572B48369");
+ identity.setMsoPass(
+ "89C9F27833AC49FE4164F3608CADE7BCF40357977607A7E4B899F9A046C0071C75F7347A47308EF9FB6620214264B1");
identity.setAdminTenant("admin");
identity.setMemberRole("admin");
identity.setTenantMetadata(new Boolean(true));
@@ -137,29 +135,14 @@ public abstract class BaseRestTestUtils {
identity.setIdentityServerType(ServerType.KEYSTONE);
cloudSite.setIdentityService(identity);
- wireMockServer.stubFor(get(urlPathEqualTo("/cloudSite/MTN13"))
- .willReturn(aResponse().withBody(getBody(mapper.writeValueAsString(cloudSite), wireMockPort, ""))
- .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withStatus(HttpStatus.SC_OK)));
wireMockServer.stubFor(get(urlPathEqualTo("/cloudSite/DEFAULT"))
.willReturn(aResponse().withBody(getBody(mapper.writeValueAsString(cloudSite), wireMockPort, ""))
.withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withStatus(HttpStatus.SC_OK)));
- wireMockServer.stubFor(get(urlPathEqualTo("/cloudIdentity/MTN13"))
- .willReturn(aResponse().withBody(getBody(mapper.writeValueAsString(identity), wireMockPort, ""))
- .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .withStatus(HttpStatus.SC_OK)));
- cloudConfig.getCloudSite("MTN13").get().getIdentityService()
- .setIdentityUrl("http://localhost:" + wireMockPort + cloudEndpoint);
}
protected static String getBody(String body, int port, String urlPath) throws IOException {
return body.replaceAll("port", "http://localhost:" + port + urlPath);
}
- @Test
- public void testNothing() {
-
- }
-
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
index 0c56222558..651e2c9a73 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
@@ -36,12 +36,10 @@ import java.util.Map;
import java.util.Set;
import javax.xml.ws.Holder;
import org.apache.http.HttpStatus;
-import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.mockito.MockitoAnnotations;
import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists;
import org.onap.so.adapters.vnf.exceptions.VnfException;
import org.onap.so.adapters.vnf.exceptions.VnfNotFound;
@@ -58,7 +56,6 @@ import org.onap.so.openstack.beans.VnfRollback;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.utils.MsoHeatUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import com.github.tomakehurst.wiremock.client.WireMock;
public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
@@ -92,7 +89,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
- instance.createVfModule("MTN13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "",
+ instance.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", vnfName, "",
"VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
new Holder<Map<String, String>>(), new Holder<VnfRollback>());
@@ -514,7 +511,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
vfModuleCustomization.getVfModule().getModuleHeatTemplate().setParameters(new HashSet<>());
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
- instance.updateVfModule("MTN13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
+ instance.updateVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD",
"volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId",
"b4ea86b4-253f-11e7-93ae-92361f002671", map, msoRequest, new Holder<Map<String, String>>(),
new Holder<VnfRollback>());
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
index be565deb9e..7ec8e51892 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
@@ -93,7 +93,7 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
MsoRequest msoRequest = getMsoRequest();
Map<String, Object> map = new HashMap<>();
map.put("key1", "value1");
- msoVnfPluginAdapter.createVfModule("MTN13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
+ msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "",
vnfName, "", "VFMOD", null, "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map,
Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(),
new Holder<Map<String, String>>(), new Holder<VnfRollback>());
diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json
index b78f700fd9..934e075220 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json
+++ b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json
@@ -1,11 +1,11 @@
{
"createTenantResponse": {
- "cloudSiteId": "MTN13",
+ "cloudSiteId": "mtn13",
"tenantId": "tenantId",
"tenantCreated": true,
"tenantRollback": {
"tenantId": "tenantId",
- "cloudId": "MTN13",
+ "cloudId": "mtn13",
"tenantCreated": true,
"msoRequest": {
"requestId": "62265093-277d-4388-9ba6-449838ade586",
diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json
index 977aa542b3..6f81ebcd36 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json
+++ b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json
@@ -1,10 +1,10 @@
{
"createTenantResponse": {
- "cloudSiteId": "MTN13",
+ "cloudSiteId": "mtn13",
"tenantId": "tenantId",
"tenantCreated": false,
"tenantRollback": {
- "cloudId": "MTN13",
+ "cloudId": "mtn13",
"tenantCreated": false,
"msoRequest": {
"requestId": "62265093-277d-4388-9ba6-449838ade586",
diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
index 03df115574..711606cfa1 100644
--- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
+++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java
@@ -20,6 +20,17 @@
package org.onap.so.adapters.requestsdb.client;
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,21 +43,10 @@ import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
import org.onap.so.db.request.beans.RequestProcessingData;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
-import java.util.List;
-import java.util.UUID;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static com.shazam.shazamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertFalse;
public class RequestsDbClientTest extends RequestsAdapterBase {
@@ -232,6 +232,7 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
assertEquals(2, requestProcessingDataList.size());
}
+
@Test
public void findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdTest() {
OperationalEnvServiceModelStatus operationalEnvServiceModelStatus =
@@ -268,4 +269,13 @@ public class RequestsDbClientTest extends RequestsAdapterBase {
assertEquals("ERROR", operationalEnvDistributionStatus.getDistributionIdErrorReason());
assertEquals("00032ab7-3fb3-42e5-965d-8ea592502017", operationalEnvDistributionStatus.getRequestId());
}
+
+ @Test
+ public void getRequestProcessingDataBySoRequestIdAndName() {
+ RequestProcessingData requestProcessingData = requestsDbClient
+ .getRequestProcessingDataBySoRequestIdAndNameAndGrouping("00032ab7-na18-42e5-965d-8ea592502018",
+ "requestAction", "7d2e8c07-4d10-456d-bddc-37abf38ca714");
+ assertNotNull(requestProcessingData);
+
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java
new file mode 100644
index 0000000000..12ab165c3a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java
@@ -0,0 +1,17 @@
+package org.onap.so.client.exception;
+
+
+public class ExpectedDataException extends Exception {
+
+ public ExpectedDataException() {}
+
+ public ExpectedDataException(String message, String system) {
+ super("Expected data not found in " + system + ". " + message);
+ }
+
+ public ExpectedDataException(String message) {
+ super("Expected data not found. " + message);
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java
index b1abda3b6f..1abc21dfc8 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java
@@ -31,5 +31,8 @@ public interface RequestProcessingDataRepository extends JpaRepository<RequestPr
RequestProcessingData findOneBySoRequestIdAndGroupingIdAndNameAndTag(@Param("SO_REQUEST_ID") String soRequestId,
@Param("GROUPING_ID") String groupingId, @Param("NAME") String name, @Param("TAG") String tag);
+ RequestProcessingData findOneBySoRequestIdAndGroupingIdAndName(@Param("SO_REQUEST_ID") String soRequestId,
+ @Param("GROUPING_ID") String groupingId, @Param("NAME") String name);
+
List<RequestProcessingData> findBySoRequestIdOrderByGroupingIdDesc(@Param("SO_REQUEST_ID") String soRequestId);
}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
index 103410701c..ca2f52690c 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
@@ -67,6 +67,8 @@ public class RequestsDbClient {
private static final String SERVICE_ID = "SERVICE_ID";
private static final String OPERATION_ID = "OPERATION_ID";
private static final String SO_REQUEST_ID = "SO_REQUEST_ID";
+ private static final String NAME = "NAME";
+ private static final String GROUPING_ID = "GROUPING_ID";
private static final String REQUEST_ID = "REQUEST_ID";
private static final String OPERATIONAL_ENVIRONMENT_ID = "OPERATIONAL_ENV_ID";
private static final String SERVICE_MODEL_VERSION_ID = "SERVICE_MODEL_VERSION_ID";
@@ -104,7 +106,10 @@ public class RequestsDbClient {
private String requestProcessingDataURI = "/requestProcessingData";
- private final String findBySoRequestIdOrderByGroupingIdDesc =
+ private static final String findBySoRequestIdAndGroupIdAndName =
+ "/requestProcessingData/search/findOneBySoRequestIdAndGroupingIdAndName";
+
+ private static final String findBySoRequestIdOrderByGroupingIdDesc =
"/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc";
@@ -339,6 +344,14 @@ public class RequestsDbClient {
.queryParam(SO_REQUEST_ID, soRequestId).build().toString()));
}
+ public RequestProcessingData getRequestProcessingDataBySoRequestIdAndNameAndGrouping(String soRequestId,
+ String name, String groupingId) {
+ return getClientFactory().create(RequestProcessingData.class)
+ .get(getUri(UriBuilder.fromUri(endpoint + findBySoRequestIdAndGroupIdAndName)
+ .queryParam(SO_REQUEST_ID, soRequestId).queryParam(NAME, name)
+ .queryParam(GROUPING_ID, groupingId).build().toString()));
+ }
+
private List<RequestProcessingData> getRequestProcessingData(URI uri) {
Iterable<RequestProcessingData> requestProcessingDataIterator =
getClientFactory().create(RequestProcessingData.class).getAll(uri);