diff options
17 files changed, 480 insertions, 331 deletions
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 14aee2f4f2..20498cb694 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 @@ -103,13 +103,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ protected static final String CREATE_STACK = "CreateStack"; - // Cache Heat Clients statically. Since there is just one MSO user, there is no - // benefit to re-authentication on every request (or across different flows). The - // token will be used until it expires. - // - // The cache key is "tenantId:cloudId" - private static Map <String, HeatCacheEntry> heatClientCache = new HashMap <> (); - // Fetch cloud configuration each time (may be cached in CloudConfig class) @Autowired protected CloudConfig cloudConfig; @@ -859,19 +852,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ String cloudId = cloudSite.getId(); // For DCP/LCP, the region should be the cloudId. String region = cloudSite.getRegionId (); - - // Check first in the cache of previously authorized clients - String cacheKey = cloudId + ":" + tenantId; - if (heatClientCache.containsKey (cacheKey)) { - if (!heatClientCache.get (cacheKey).isExpired ()) { - LOGGER.debug ("Using Cached HEAT Client for " + cacheKey); - return heatClientCache.get (cacheKey).getHeatClient (); - } else { - // Token is expired. Remove it from cache. - heatClientCache.remove (cacheKey); - LOGGER.debug ("Expired Cached HEAT Client for " + cacheKey); - } - } // Obtain an MSO token for the tenant CloudIdentity cloudIdentity = cloudSite.getIdentityService(); @@ -946,38 +926,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ // Catch-all throw runtimeExceptionToMsoException (e, TOKEN_AUTH); } - Heat heatClient = new Heat (heatUrl); heatClient.token (tokenId); - - heatClientCache.put (cacheKey, - new HeatCacheEntry (heatUrl, - tokenId, - expiration)); - LOGGER.debug ("Caching HEAT Client for " + cacheKey); - return heatClient; } - /** - * Forcibly expire a HEAT client from the cache. This call is for use by - * the KeystoneClient in case where a tenant is deleted. In that case, - * all cached credentials must be purged so that fresh authentication is - * done if a similarly named tenant is re-created. - * <p> - * Note: This is probably only applicable to dev/test environments where - * the same Tenant Name is repeatedly used for creation/deletion. - * <p> - * - */ - public void expireHeatClient (String tenantId, String cloudId) { - String cacheKey = cloudId + ":" + tenantId; - if (heatClientCache.containsKey (cacheKey)) { - heatClientCache.remove (cacheKey); - LOGGER.debug ("Deleted Cached HEAT Client for " + cacheKey); - } - } - /* * Query for a Heat Stack. This function is needed in several places, so * a common method is useful. This method takes an authenticated Heat Client diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java index 3936ae6496..0bd2a3931f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java @@ -59,12 +59,6 @@ import com.woorea.openstack.keystone.utils.KeystoneUtils; @Component public class MsoKeystoneUtils extends MsoTenantUtils { - // Cache the Keystone Clients statically. Since there is just one MSO user, there is no - // benefit to re-authentication on every request (or across different flows). The - // token will be used until it expires. - // - // The cache key is "cloudId" - private static Map <String, KeystoneCacheEntry> adminClientCache = new HashMap<>(); private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoKeystoneUtils.class); @@ -316,10 +310,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils { OpenStackRequest <Void> request = keystoneAdminClient.tenants ().delete (tenant.getId ()); executeAndRecordOpenstackRequest (request); LOGGER.debug ("Deleted Tenant " + tenant.getId () + " (" + tenant.getName () + ")"); - - // Clear any cached clients. Not really needed, ID will not be reused. - msoHeatUtils.expireHeatClient (tenant.getId (), cloudSiteId); - msoNeutronUtils.expireNeutronClient (tenant.getId (), cloudSiteId); } catch (OpenStackBaseException e) { // Convert Keystone OpenStackResponseException to MsoOpenstackException throw keystoneErrorToMsoException (e, "Delete Tenant"); @@ -369,9 +359,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils { LOGGER.debug ("Deleted Tenant " + tenant.getId () + " (" + tenant.getName () + ")"); - // Clear any cached clients. Not really needed, ID will not be reused. - msoHeatUtils.expireHeatClient (tenant.getId (), cloudSiteId); - msoNeutronUtils.expireNeutronClient (tenant.getId (), cloudSiteId); } catch (OpenStackBaseException e) { // Note: It doesn't seem to matter if tenant doesn't exist, no exception is thrown. // Convert Keystone OpenStackResponseException to MsoOpenstackException @@ -407,16 +394,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils { String adminTenantName = cloudIdentity.getAdminTenant (); String region = cloudSite.getRegionId (); - // Check first in the cache of previously authorized clients - KeystoneCacheEntry entry = adminClientCache.get (cloudId); - if (entry != null) { - if (!entry.isExpired ()) { - return entry.getKeystoneClient (); - } else { - // Token is expired. Remove it from cache. - adminClientCache.remove (cloudId); - } - } MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType()); final String keystoneUrl = tenantUtils.getKeystoneUrl(region, cloudIdentity); Keystone keystone = new Keystone(keystoneUrl); @@ -462,11 +439,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils { // Note: this doesn't go back to Openstack, it's just a local object. keystone = new Keystone (adminUrl); keystone.token (token); - - // Cache to avoid re-authentication for every call. - KeystoneCacheEntry cacheEntry = new KeystoneCacheEntry (adminUrl, token, access.getToken ().getExpires ()); - adminClientCache.put (cloudId, cacheEntry); - return keystone; } @@ -636,32 +608,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils { return null; } - private static class KeystoneCacheEntry implements Serializable { - - private static final long serialVersionUID = 1L; - - private String keystoneUrl; - private String token; - private Calendar expires; - - public KeystoneCacheEntry (String url, String token, Calendar expires) { - this.keystoneUrl = url; - this.token = token; - this.expires = expires; - } - - public Keystone getKeystoneClient () { - Keystone keystone = new Keystone (keystoneUrl); - keystone.token (token); - return keystone; - } - - public boolean isExpired () { - // adding arbitrary guard timer of 5 minutes - return expires == null || System.currentTimeMillis() > (expires.getTimeInMillis() - 1800000); - } - } - @Override public String getKeystoneUrl(String regionId, CloudIdentity cloudIdentity) throws MsoException { return cloudIdentity.getIdentityUrl(); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java index 7b82ad62ff..785e8606d3 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java @@ -67,12 +67,6 @@ import com.woorea.openstack.quantum.model.Segment; @Component public class MsoNeutronUtils extends MsoCommonUtils { - // Cache Neutron Clients statically. Since there is just one MSO user, there is no - // benefit to re-authentication on every request (or across different flows). The - // token will be used until it expires. - // - // The cache key is "tenantId:cloudId" - private static Map<String,NeutronCacheEntry> neutronClientCache = new HashMap<>(); // Fetch cloud configuration each time (may be cached in CloudConfig class) @Autowired @@ -364,24 +358,8 @@ public class MsoNeutronUtils extends MsoCommonUtils private Quantum getNeutronClient(CloudSite cloudSite, String tenantId) throws MsoException { String cloudId = cloudSite.getId(); - String region = cloudSite.getRegionId(); - - // Check first in the cache of previously authorized clients - String cacheKey = cloudId + ":" + tenantId; - if (neutronClientCache.containsKey(cacheKey)) { - if (! neutronClientCache.get(cacheKey).isExpired()) { - LOGGER.debug ("Using Cached HEAT Client for " + cacheKey); - NeutronCacheEntry cacheEntry = neutronClientCache.get(cacheKey); - Quantum neutronClient = new Quantum(cacheEntry.getNeutronUrl()); - neutronClient.token(cacheEntry.getToken()); - return neutronClient; - } - else { - // Token is expired. Remove it from cache. - neutronClientCache.remove(cacheKey); - LOGGER.debug ("Expired Cached Neutron Client for " + cacheKey); - } - } + String region = cloudSite.getRegionId(); + // Obtain an MSO token for the tenant from the identity service CloudIdentity cloudIdentity = cloudSite.getIdentityService(); @@ -454,31 +432,9 @@ public class MsoNeutronUtils extends MsoCommonUtils Quantum neutronClient = new Quantum(neutronUrl); neutronClient.token(tokenId); - - neutronClientCache.put(cacheKey, new NeutronCacheEntry(neutronUrl, tokenId, expiration)); - LOGGER.debug ("Caching Neutron Client for " + cacheKey); - return neutronClient; } - /** - * Forcibly expire a Neutron client from the cache. This call is for use by - * the KeystoneClient in case where a tenant is deleted. In that case, - * all cached credentials must be purged so that fresh authentication is - * done on subsequent calls. - * <p> - * @param tenantName - * @param cloudId - */ - public void expireNeutronClient (String tenantId, String cloudId) { - String cacheKey = cloudId + ":" + tenantId; - if (neutronClientCache.containsKey(cacheKey)) { - neutronClientCache.remove(cacheKey); - LOGGER.debug ("Deleted Cached Neutron Client for " + cacheKey); - } - } - - /* * Find a tenant (or query its existence) by its Name or Id. Check first against the * ID. If that fails, then try by name. diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java index 974315374a..dfe5912fbf 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java @@ -25,6 +25,8 @@ import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -174,11 +176,13 @@ public class HeatStackAudit { return vserversToAudit; } - protected Optional<String> extractResourcePathFromHref(String href) { - URI uri; + protected Optional<String> extractResourcePathFromHref(String href) { try { - uri = new URI(href); - return Optional.of(uri.getPath().replaceFirst("/v\\d+", "")+RESOURCES); + Optional<String> stackPath = extractStackPathFromHref(href); + if (stackPath.isPresent()){ + return Optional.of(stackPath.get()+RESOURCES); + }else + return Optional.empty(); } catch (Exception e) { logger.error("Error parsing URI", e); } @@ -186,10 +190,14 @@ public class HeatStackAudit { } protected Optional<String> extractStackPathFromHref(String href) { - URI uri; try { - uri = new URI(href); - return Optional.of(uri.getPath().replaceFirst("/v\\d+", "")); + URI uri = new URI(href); + Pattern p = Pattern.compile("/stacks.*"); + Matcher m = p.matcher(uri.getPath()); + if (m.find()){ + return Optional.of(m.group()); + }else + return Optional.empty(); } catch (Exception e) { logger.error("Error parsing URI", e); } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java index c5b93a7cb9..b3cdd467bb 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java @@ -80,19 +80,19 @@ public class HeatStackAuditTest extends HeatStackAudit { @Test public void extract_proper_path_Test(){ - Optional<String> actualResult = extractStackPathFromHref("https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81"); - assertEquals("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81", actualResult.get()); + Optional<String> actualResult = extractStackPathFromHref("https://orchestration.com:8004/v1/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81"); + assertEquals("/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81", actualResult.get()); } @Test public void extract_proper_resources_path_Test(){ - Optional<String> actualResult = extractResourcePathFromHref("https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81"); - assertEquals("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81/resources", actualResult.get()); + Optional<String> actualResult = extractResourcePathFromHref("https://orchestration.com:8004/v1/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81"); + assertEquals("/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81/resources", actualResult.get()); } @Test public void extract_invalid_uri_Test(){ - Optional<String> actualResult = extractStackPathFromHref("orchestrn.com:8004/v18b44d60a6f94bdcb2738f9e/stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81"); + Optional<String> actualResult = extractStackPathFromHref("orchestrn.com:8004/v18b44d60a6f94bdcb2738f9e//stacks/test_stack/f711be16-2654-4a09-b89d-0511fda20e81"); assertEquals(false, actualResult.isPresent()); } @@ -114,6 +114,8 @@ public class HeatStackAuditTest extends HeatStackAudit { ssc_1_trusted_port_0.setInterfaceId("d2f51f82-0ec2-4581-bd1a-d2a82073e52b"); vServer1.getLInterfaces().getLInterface().add(ssc_1_trusted_port_0); + + LInterface ssc_1_mgmt_port_1 = new LInterface(); ssc_1_mgmt_port_1.setInterfaceId("07f5b14c-147a-4d14-8c94-a9e94dbc097b"); vServer1.getLInterfaces().getLInterface().add(ssc_1_mgmt_port_1); @@ -156,33 +158,34 @@ public class HeatStackAuditTest extends HeatStackAudit { expectedVservers.add(vServer1); + Resources service1QueryResponse = objectMapper.readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class); - doReturn(service1QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672/resources", cloudRegion, tenantId, Resources.class); + doReturn(service1QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672/resources", cloudRegion, tenantId, Resources.class); Resources service2QueryResponse =objectMapper.readValue(new File("src/test/resources/Service2ResourceGroupResponse.json"), Resources.class); - doReturn(service2QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst/447a9b41-714e-434b-b1d0-6cce8d9f0f0c/resources", cloudRegion, tenantId, Resources.class); + doReturn(service2QueryResponse).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst/447a9b41-714e-434b-b1d0-6cce8d9f0f0c/resources", cloudRegion, tenantId, Resources.class); Stack service2StackQuerySubInt = stackObjectMapper.readValue(new File("src/test/resources/Service2SubInterface0.json"), Stack.class); - doReturn(service2StackQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", cloudRegion,tenantId, Stack.class); + doReturn(service2StackQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", cloudRegion,tenantId, Stack.class); Resources service2ResourceQuerySubInt = objectMapper.readValue(new File("src/test/resources/Service2SubInterface1Resources.json"), Resources.class); - doReturn(service2ResourceQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources", cloudRegion,tenantId, Resources.class); + doReturn(service2ResourceQuerySubInt).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources", cloudRegion,tenantId, Resources.class); Stack service1StackQuerySubInt1 =stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface0.json"), Stack.class); - doReturn(service1StackQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb", cloudRegion,tenantId, Stack.class); + doReturn(service1StackQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb", cloudRegion,tenantId, Stack.class); Resources service1ResourceQuerySubInt1 = objectMapper.readValue(new File("src/test/resources/Service1SubInterface0Resources.json"), Resources.class); - doReturn(service1ResourceQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb/resources", cloudRegion,tenantId, Resources.class); + doReturn(service1ResourceQuerySubInt1).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb/resources", cloudRegion,tenantId, Resources.class); Stack service1StackQuerySubInt2 =stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface1.json"), Stack.class); - doReturn(service1StackQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a", cloudRegion,tenantId, Stack.class); + doReturn(service1StackQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a", cloudRegion,tenantId, Stack.class); Resources service1ResourceQuerySubInt2 = objectMapper.readValue(new File("src/test/resources/Service1SubInterface1Resources.json"), Resources.class); - doReturn(service1ResourceQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a/resources", cloudRegion,tenantId, Resources.class); + doReturn(service1ResourceQuerySubInt2).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a/resources", cloudRegion,tenantId, Resources.class); Stack service1StackQuerySubInt3 =stackObjectMapper.readValue(new File("src/test/resources/Service1SubInterface2.json"), Stack.class); - doReturn(service1StackQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c", cloudRegion,tenantId, Stack.class); + doReturn(service1StackQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c", cloudRegion,tenantId, Stack.class); Resources service1ResourceQuerySubInt3 = objectMapper.readValue(new File("src/test/resources/Service1SubInterface2Resources.json"), Resources.class); - doReturn(service1ResourceQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest("/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c/resources", cloudRegion,tenantId, Resources.class); + doReturn(service1ResourceQuerySubInt3).when(msoHeatUtilsMock).executeHeatClientRequest("/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c/resources", cloudRegion,tenantId, Resources.class); Set<Vserver> vServersToAudit = heatStackAudit.createVserverSet(resources, novaResources); Set<Vserver> vserversWithSubInterfaces = heatStackAudit.processSubInterfaces(cloudRegion,tenantId,resourceGroups, vServersToAudit); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java index 70d94052e1..4e0bf02685 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java @@ -20,12 +20,10 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; -import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; - import org.onap.aai.domain.yang.Pnf; import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; import org.springframework.context.annotation.Primary; @@ -39,9 +37,10 @@ public class AaiConnectionTestImpl implements AaiConnection { public static final String ID_WITH_ENTRY = "idWithEntryNoIp"; private Map<String, Pnf> created = new HashMap<>(); + private Map<String, String> serviceAndPnfRelationMap = new HashMap<>(); @Override - public Optional<Pnf> getEntryFor(String correlationId) throws IOException { + public Optional<Pnf> getEntryFor(String correlationId) { if (Objects.equals(correlationId, ID_WITH_ENTRY)) { return Optional.of(new Pnf()); } else { @@ -50,15 +49,25 @@ public class AaiConnectionTestImpl implements AaiConnection { } @Override - public void createEntry(String correlationId, Pnf entry) throws IOException { + public void createEntry(String correlationId, Pnf entry) { created.put(correlationId, entry); } + @Override + public void createRelation(String serviceInstanceId, String pnfName) { + serviceAndPnfRelationMap.put(serviceInstanceId, pnfName); + } + public Map<String, Pnf> getCreated() { return created; } + public Map<String, String> getServiceAndPnfRelationMap() { + return serviceAndPnfRelationMap; + } + public void reset() { created.clear(); + serviceAndPnfRelationMap.clear(); } } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java index 2d0d4b51a9..db6cbe06ae 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java @@ -31,15 +31,19 @@ import java.util.Map; import java.util.UUID; import org.assertj.core.api.Assertions; +import org.assertj.core.data.MapEntry; import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.springframework.beans.factory.annotation.Autowired; public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { - private static final String TIMEOUT_10_S = "PT10S"; private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString(); + private static final String SERVICE_INSTANCE_ID = "serviceForInstance"; + + private Map<String, Object> variables; @Autowired private AaiConnectionTestImpl aaiConnection; @@ -47,14 +51,18 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { @Autowired private DmaapClientTestImpl dmaapClientTestImpl; + @Before + public void setup() { + aaiConnection.reset(); + variables = new HashMap<>(); + variables.put("serviceInstanceId", SERVICE_INSTANCE_ID); + variables.put(PNF_UUID, VALID_UUID); + } + @Test public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() { // given - aaiConnection.reset(); - Map<String, Object> variables = new HashMap<>(); - variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITH_ENTRY); - variables.put(PNF_UUID, VALID_UUID); // when ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); @@ -70,19 +78,17 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { "AaiEntryExists", "InformDmaapClient", "WaitForDmaapPnfReadyNotification", + "CreateRelationId", "AaiEntryUpdated" ); + Assertions.assertThat(aaiConnection.getServiceAndPnfRelationMap()). + containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID,AaiConnectionTestImpl.ID_WITH_ENTRY)); } @Test public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() { // given - aaiConnection.reset(); - - Map<String, Object> variables = new HashMap<>(); - variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITHOUT_ENTRY); - variables.put(PNF_UUID, VALID_UUID); // when ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); @@ -99,8 +105,11 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { "AaiEntryExists", "InformDmaapClient", "WaitForDmaapPnfReadyNotification", + "CreateRelationId", "AaiEntryUpdated" ); Assertions.assertThat(aaiConnection.getCreated()).containsOnlyKeys(AaiConnectionTestImpl.ID_WITHOUT_ENTRY); + Assertions.assertThat(aaiConnection.getServiceAndPnfRelationMap()). + containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID,AaiConnectionTestImpl.ID_WITHOUT_ENTRY)); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java index d57e48781d..1bf2a290cb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java @@ -23,7 +23,11 @@ package org.onap.so.bpmn.infrastructure.pnf.aai; import java.util.Optional; import org.onap.aai.domain.yang.Pnf; import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.AAIRestClientImpl; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.springframework.stereotype.Component; @Component @@ -40,4 +44,12 @@ public class AaiConnectionImpl implements AaiConnection { AAIRestClientImpl restClient = new AAIRestClientImpl(); restClient.createPnf(correlationId, entry); } + + @Override + public void createRelation(String serviceInstanceId, String pnfName) { + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + serviceInstanceId); + AAIResourceUri pnfUri = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfName); + new AAIResourcesClient().connect(serviceInstanceURI, pnfUri); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java new file mode 100644 index 0000000000..21d43964f8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Nokia. + * ================================================================================ + * 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.bpmn.infrastructure.pnf.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class CreateRelation implements JavaDelegate { + + private static final Logger logger = LoggerFactory.getLogger(CreateRelation.class); + + private AaiConnection aaiConnectionImpl; + + @Autowired + public CreateRelation(AaiConnection aaiConnectionImpl) { + this.aaiConnectionImpl = aaiConnectionImpl; + } + + @Override + public void execute(DelegateExecution delegateExecution) { + String serviceInstanceId = (String) delegateExecution.getVariable("serviceInstanceId"); + String pnfName = (String) delegateExecution.getVariable("correlationId"); + try { + aaiConnectionImpl.createRelation(serviceInstanceId, pnfName); + } catch (Exception e) { + new ExceptionUtil().buildAndThrowWorkflowException(delegateExecution, 9999, + "An exception occurred when making service and pnf relation. Exception: " + e.getMessage()); + } + logger.debug("The relation has been made between service with id: {} and pnf with name: {}", + serviceInstanceId, pnfName); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java index 5165912653..eaabb2bfbb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java @@ -29,4 +29,6 @@ public interface AaiConnection { Optional<Pnf> getEntryFor(String correlationId) throws IOException; void createEntry(String correlationId, Pnf entry) throws IOException; + + void createRelation(String serviceInstanceId, String pnfName) throws IOException; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java index 201e791a24..76b62a9cea 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java @@ -37,7 +37,7 @@ public class AaiConnectionTestImpl implements AaiConnection { private Map<String, Pnf> created = new HashMap<>(); @Override - public Optional<Pnf> getEntryFor(String correlationId) throws IOException { + public Optional<Pnf> getEntryFor(String correlationId) { if (Objects.equals(correlationId, ID_WITH_ENTRY)) { return Optional.of(new Pnf()); } else { @@ -50,6 +50,10 @@ public class AaiConnectionTestImpl implements AaiConnection { created.put(correlationId, entry); } + @Override + public void createRelation(String serviceInstanceId, String pnfName) { + } + public Map<String, Pnf> getCreated() { return created; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java index 7df6757817..300d1e4c9b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java @@ -36,4 +36,10 @@ public class AaiConnectionThrowingException implements AaiConnection { public void createEntry(String correlationId, Pnf entry) throws IOException { throw new IOException(); } + + @Override + public void createRelation(String serviceInstanceId, String pnfName) throws IOException { + throw new IOException(); + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java new file mode 100644 index 0000000000..2dd3e23828 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Nokia. + * ================================================================================ + * 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.bpmn.infrastructure.pnf.delegate; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import java.io.IOException; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.bpmn.infrastructure.pnf.aai.AaiConnectionImpl; +import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; + +public class CreateRelationTest { + + private static final String SERVICE_INSTANCE_ID = "serviceTest"; + private static final String PNF_NAME = "pnfNameTest"; + + private DelegateExecutionFake executionFake; + + @Before + public void setUp() { + executionFake = new DelegateExecutionFake(); + executionFake.setVariable("serviceInstanceId", SERVICE_INSTANCE_ID); + executionFake.setVariable("correlationId", PNF_NAME); + } + + @Test + public void createRelationSuccessful() throws IOException { + // given + AaiConnection aaiConnectionMock = mock(AaiConnectionImpl.class); + CreateRelation testedObject = new CreateRelation(aaiConnectionMock); + // when + testedObject.execute(executionFake); + // then + verify(aaiConnectionMock).createRelation(SERVICE_INSTANCE_ID, PNF_NAME); + } + + @Test + public void shouldThrowBpmnErrorWhenExceptionOccurred() { + CreateRelation testedObject = new CreateRelation(new AaiConnectionThrowingException()); + executionFake.setVariable("testProcessKey", "testProcessKeyValue"); + + assertThatThrownBy(() -> testedObject.execute(executionFake)).isInstanceOf(BpmnError.class); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn index d8079174c1..5defe2121b 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3"> <bpmn:collaboration id="Collaboration_1d0w8lf"> <bpmn:participant id="Participant_1egg397" name="SO Create and Activate Pnf Resource" processRef="CreateAndActivatePnfResource" /> <bpmn:participant id="Participant_0atuyq0" name="AAI" /> @@ -17,7 +17,7 @@ <bpmn:sequenceFlow id="SequenceFlow_0v5ffpe" name="No" sourceRef="DoesAaiContainInfoAboutPnf" targetRef="CreatePnfEntryInAai"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{!aaiContainsInfoAboutPnf}</bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_0p09qgm" sourceRef="WaitForDmaapPnfReadyNotification" targetRef="AaiEntryUpdated" /> + <bpmn:sequenceFlow id="SequenceFlow_0p09qgm" sourceRef="WaitForDmaapPnfReadyNotification" targetRef="CreateRelationId" /> <bpmn:sequenceFlow id="SequenceFlow_17s9025" sourceRef="AaiEntryExists" targetRef="InformDmaapClient" /> <bpmn:sequenceFlow id="SequenceFlow_1qr6cmf" sourceRef="CreatePnfEntryInAai" targetRef="AaiEntryExists" /> <bpmn:sequenceFlow id="SequenceFlow_1j4r3zt" sourceRef="CheckAiiForCorrelationId" targetRef="DoesAaiContainInfoAboutPnf" /> @@ -59,9 +59,6 @@ <bpmn:incoming>SequenceFlow_1miyzfe</bpmn:incoming> <bpmn:errorEventDefinition errorRef="Error_1" /> </bpmn:endEvent> - <bpmn:endEvent id="AaiEntryUpdated" name="AAI entry updated"> - <bpmn:incoming>SequenceFlow_0p09qgm</bpmn:incoming> - </bpmn:endEvent> <bpmn:receiveTask id="WaitForDmaapPnfReadyNotification" name="Wait for DMAAP pnf-ready notification" messageRef="Message_13h1tlo"> <bpmn:incoming>SequenceFlow_1o8od8e</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0p09qgm</bpmn:outgoing> @@ -77,13 +74,20 @@ <bpmn:incoming>SequenceFlow_1qr6cmf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_17s9025</bpmn:outgoing> </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0o6zhjk" sourceRef="CreateRelationId" targetRef="AaiEntryUpdated" /> + <bpmn:endEvent id="AaiEntryUpdated" name="AAI entry updated"> + <bpmn:incoming>SequenceFlow_0o6zhjk</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="CreateRelationId" name="Create Relation" camunda:delegateExpression="${CreateRelation}"> + <bpmn:incoming>SequenceFlow_0p09qgm</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0o6zhjk</bpmn:outgoing> + </bpmn:serviceTask> <bpmn:association id="Association_0d7oxnz" sourceRef="CreateAndActivatePnf_StartEvent" targetRef="TextAnnotation_1eyzes8" /> <bpmn:textAnnotation id="TextAnnotation_1eyzes8"> - <bpmn:text>Inputs: + <bpmn:text><![CDATA[Inputs: - timeoutForPnfEntryNotification - String - correlationId - String - - uuid - String -</bpmn:text> + - uuid - String]]></bpmn:text> </bpmn:textAnnotation> </bpmn:process> <bpmn:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> @@ -100,9 +104,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0k52gr7_di" bpmnElement="AaiEntryUpdated"> - <dc:Bounds x="1312" y="189" width="36" height="36" /> + <dc:Bounds x="1364" y="189" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1287" y="230" width="88" height="14" /> + <dc:Bounds x="1339" y="230" width="89" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_0j5ok9h_di" bpmnElement="CreateAndActivatePnf_StartEvent"> @@ -118,38 +122,38 @@ <dc:Bounds x="511" y="167" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1j4r3zt_di" bpmnElement="SequenceFlow_1j4r3zt"> - <di:waypoint x="319" y="207" /> - <di:waypoint x="390" y="207" /> + <di:waypoint xsi:type="dc:Point" x="319" y="207" /> + <di:waypoint xsi:type="dc:Point" x="390" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="309.5" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1l1t6ak_di" bpmnElement="SequenceFlow_1l1t6ak"> - <di:waypoint x="415" y="182" /> - <di:waypoint x="415" y="66" /> - <di:waypoint x="711" y="66" /> - <di:waypoint x="711" y="182" /> + <di:waypoint xsi:type="dc:Point" x="415" y="182" /> + <di:waypoint xsi:type="dc:Point" x="415" y="66" /> + <di:waypoint xsi:type="dc:Point" x="711" y="66" /> + <di:waypoint xsi:type="dc:Point" x="711" y="182" /> <bpmndi:BPMNLabel> <dc:Bounds x="430" y="159" width="19" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0v5ffpe_di" bpmnElement="SequenceFlow_0v5ffpe"> - <di:waypoint x="440" y="207" /> - <di:waypoint x="511" y="207" /> + <di:waypoint xsi:type="dc:Point" x="440" y="207" /> + <di:waypoint xsi:type="dc:Point" x="511" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="448" y="210" width="14" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1qr6cmf_di" bpmnElement="SequenceFlow_1qr6cmf"> - <di:waypoint x="611" y="207" /> - <di:waypoint x="686" y="207" /> + <di:waypoint xsi:type="dc:Point" x="611" y="207" /> + <di:waypoint xsi:type="dc:Point" x="686" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="605" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0j5ksz1_di" bpmnElement="SequenceFlow_0j5ksz1"> - <di:waypoint x="-18" y="207" /> - <di:waypoint x="48" y="207" /> + <di:waypoint xsi:type="dc:Point" x="-18" y="207" /> + <di:waypoint xsi:type="dc:Point" x="48" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="-30" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -158,22 +162,22 @@ <dc:Bounds x="123" y="523" width="502" height="60" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="MessageFlow_1h3xu88_di" bpmnElement="MessageFlow_1h3xu88"> - <di:waypoint x="561" y="247" /> - <di:waypoint x="561" y="523" /> + <di:waypoint xsi:type="dc:Point" x="561" y="247" /> + <di:waypoint xsi:type="dc:Point" x="561" y="523" /> <bpmndi:BPMNLabel> <dc:Bounds x="531" y="380" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="MessageFlow_09ibv5a_di" bpmnElement="MessageFlow_09ibv5a"> - <di:waypoint x="250" y="247" /> - <di:waypoint x="250" y="523" /> + <di:waypoint xsi:type="dc:Point" x="250" y="247" /> + <di:waypoint xsi:type="dc:Point" x="250" y="523" /> <bpmndi:BPMNLabel> <dc:Bounds x="220" y="380" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="MessageFlow_0vjul4t_di" bpmnElement="MessageFlow_0vjul4t"> - <di:waypoint x="289" y="523" /> - <di:waypoint x="289" y="247" /> + <di:waypoint xsi:type="dc:Point" x="289" y="523" /> + <di:waypoint xsi:type="dc:Point" x="289" y="247" /> <bpmndi:BPMNLabel> <dc:Bounds x="259" y="380" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -191,19 +195,19 @@ <dc:Bounds x="-37" y="70" width="243" height="82" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="Association_0d7oxnz_di" bpmnElement="Association_0d7oxnz"> - <di:waypoint x="-36" y="189" /> - <di:waypoint x="-36" y="152" /> + <di:waypoint xsi:type="dc:Point" x="-36" y="189" /> + <di:waypoint xsi:type="dc:Point" x="-36" y="152" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="MessageFlow_1vrcp2d_di" bpmnElement="MessageFlow_1vrcp2d"> - <di:waypoint x="1060" y="523" /> - <di:waypoint x="1060" y="247" /> + <di:waypoint xsi:type="dc:Point" x="1060" y="523" /> + <di:waypoint xsi:type="dc:Point" x="1060" y="247" /> <bpmndi:BPMNLabel> <dc:Bounds x="996" y="380" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_17s9025_di" bpmnElement="SequenceFlow_17s9025"> - <di:waypoint x="736" y="207" /> - <di:waypoint x="803" y="207" /> + <di:waypoint xsi:type="dc:Point" x="736" y="207" /> + <di:waypoint xsi:type="dc:Point" x="803" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="719" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -215,9 +219,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1kc34bc_di" bpmnElement="SequenceFlow_1kc34bc"> - <di:waypoint x="1092" y="265" /> - <di:waypoint x="1092" y="363" /> - <di:waypoint x="1145" y="363" /> + <di:waypoint xsi:type="dc:Point" x="1092" y="265" /> + <di:waypoint xsi:type="dc:Point" x="1092" y="363" /> + <di:waypoint xsi:type="dc:Point" x="1145" y="363" /> <bpmndi:BPMNLabel> <dc:Bounds x="1028" y="309" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -226,22 +230,22 @@ <dc:Bounds x="1008" y="167" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0p09qgm_di" bpmnElement="SequenceFlow_0p09qgm"> - <di:waypoint x="1108" y="207" /> - <di:waypoint x="1312" y="207" /> + <di:waypoint xsi:type="dc:Point" x="1108" y="207" /> + <di:waypoint xsi:type="dc:Point" x="1195" y="207" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1148" y="187" width="90" height="10" /> + <dc:Bounds x="1106.5" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1o8od8e_di" bpmnElement="SequenceFlow_1o8od8e"> - <di:waypoint x="903" y="207" /> - <di:waypoint x="1008" y="207" /> + <di:waypoint xsi:type="dc:Point" x="903" y="207" /> + <di:waypoint xsi:type="dc:Point" x="1008" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="893.5" y="187" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="MessageFlow_0tg4hw9_di" bpmnElement="MessageFlow_0tg4hw9"> - <di:waypoint x="853" y="247" /> - <di:waypoint x="853" y="523" /> + <di:waypoint xsi:type="dc:Point" x="853" y="247" /> + <di:waypoint xsi:type="dc:Point" x="853" y="523" /> <bpmndi:BPMNLabel> <dc:Bounds x="823" y="380" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -250,15 +254,15 @@ <dc:Bounds x="803" y="167" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1miyzfe_di" bpmnElement="SequenceFlow_1miyzfe"> - <di:waypoint x="1245" y="363" /> - <di:waypoint x="1312" y="363" /> + <di:waypoint xsi:type="dc:Point" x="1245" y="363" /> + <di:waypoint xsi:type="dc:Point" x="1312" y="363" /> <bpmndi:BPMNLabel> <dc:Bounds x="1233.5" y="343" width="90" height="10" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="MessageFlow_1py54jr_di" bpmnElement="MessageFlow_1py54jr"> - <di:waypoint x="1195" y="403" /> - <di:waypoint x="1195" y="523" /> + <di:waypoint xsi:type="dc:Point" x="1195" y="403" /> + <di:waypoint xsi:type="dc:Point" x="1195" y="523" /> <bpmndi:BPMNLabel> <dc:Bounds x="1165" y="458" width="90" height="10" /> </bpmndi:BPMNLabel> @@ -267,8 +271,8 @@ <dc:Bounds x="1145" y="323" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0967g8p_di" bpmnElement="SequenceFlow_0967g8p"> - <di:waypoint x="148" y="207" /> - <di:waypoint x="219" y="207" /> + <di:waypoint xsi:type="dc:Point" x="148" y="207" /> + <di:waypoint xsi:type="dc:Point" x="219" y="207" /> <bpmndi:BPMNLabel> <dc:Bounds x="183.5" y="187" width="0" height="10" /> </bpmndi:BPMNLabel> @@ -282,6 +286,16 @@ <dc:Bounds x="672" y="242" width="77" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0o6zhjk_di" bpmnElement="SequenceFlow_0o6zhjk"> + <di:waypoint xsi:type="dc:Point" x="1295" y="207" /> + <di:waypoint xsi:type="dc:Point" x="1364" y="207" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1329.5" y="186" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0xn3ug6_di" bpmnElement="CreateRelationId"> + <dc:Bounds x="1195" y="167" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 78a84b1772..f6c9597de8 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -41,6 +41,7 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; @@ -54,6 +55,7 @@ public class WorkflowActionBBTasks { private static final String G_ALACARTE = "aLaCarte"; private static final String G_ACTION = "requestAction"; private static final String RETRY_COUNT = "retryCount"; + protected String maxRetries = "mso.rainyDay.maxRetries"; private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class); @Autowired @@ -62,6 +64,8 @@ public class WorkflowActionBBTasks { private WorkflowAction workflowAction; @Autowired private WorkflowActionBBFailure workflowActionBBFailure; + @Autowired + private Environment environment; public void selectBB(DelegateExecution execution) { List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution @@ -215,17 +219,24 @@ public class WorkflowActionBBTasks { String requestId = (String) execution.getVariable(G_REQUEST_ID); String retryDuration = (String) execution.getVariable("RetryDuration"); int retryCount = (int) execution.getVariable(RETRY_COUNT); + int envMaxRetries; + try{ + envMaxRetries = Integer.parseInt(this.environment.getProperty(maxRetries)); + } catch (Exception ex) { + logger.error("Could not read maxRetries from config file. Setting max to 5 retries"); + envMaxRetries = 5; + } int nextCount = retryCount +1; if (handlingCode.equals("Retry")){ workflowActionBBFailure.updateRequestErrorStatusMessage(execution); try{ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); - request.setRetryStatusMessage("Retry " + nextCount + "/5 will be started in " + retryDuration); + request.setRetryStatusMessage("Retry " + nextCount + "/" + envMaxRetries + " will be started in " + retryDuration); requestDbclient.updateInfraActiveRequests(request); } catch(Exception ex){ logger.warn("Failed to update Request Db Infra Active Requests with Retry Status",ex); } - if(retryCount<5){ + if(retryCount<envMaxRetries){ int currSequence = (int) execution.getVariable("gCurrentSequence"); execution.setVariable("gCurrentSequence", currSequence-1); execution.setVariable(RETRY_COUNT, nextCount); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index f3b094f645..2fc62978fb 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -31,6 +31,7 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; +import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; import org.junit.Before; @@ -46,6 +47,7 @@ import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.springframework.core.env.Environment; public class WorkflowActionBBTasksTest extends BaseTaskTest { @@ -64,6 +66,9 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { private DelegateExecution execution; + @Mock + protected Environment environment; + @Rule public ExpectedException thrown = ExpectedException.none(); @@ -287,6 +292,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { String reqId = "reqId123"; execution.setVariable("mso-request-id", reqId); doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class)); + doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries"); execution.setVariable("handlingCode","Retry"); execution.setVariable("retryCount", 1); execution.setVariable("gCurrentSequence",1); @@ -297,6 +303,25 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void checkRetryStatusTestExceededMaxRetries(){ + String reqId = "reqId123"; + execution.setVariable("mso-request-id", reqId); + doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class)); + doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries"); + execution.setVariable("handlingCode","Retry"); + execution.setVariable("retryCount", 6); + execution.setVariable("gCurrentSequence",1); + InfraActiveRequests req = new InfraActiveRequests(); + doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); + try{ + workflowActionBBTasks.checkRetryStatus(execution); + } catch (BpmnError e) { + WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException"); + assertEquals("Exceeded maximum retries. Ending flow with status Abort",exception.getErrorMessage()); + } + } + + @Test public void checkRetryStatusNoRetryTest(){ String reqId = "reqId123"; execution.setVariable("mso-request-id", reqId); diff --git a/docs/developer_info/Working_with_SO_Docker.rst b/docs/developer_info/Working_with_SO_Docker.rst index ee958efa41..6e31d22ea8 100644 --- a/docs/developer_info/Working_with_SO_Docker.rst +++ b/docs/developer_info/Working_with_SO_Docker.rst @@ -10,177 +10,244 @@ Verify that docker images are built .. code-block:: bash - docker images openecomp/mso + docker images *Example Output:* - REPOSITORY TAG IMAGE ID CREATED SIZE - - openecomp/mso 1.1-SNAPSHOT-latest 419e9d8a17e8 3 minutes ago 1.62GB - - openecomp/mso 1.1.0-SNAPSHOT-STAGING-20170926T2015 419e9d8a17e8 3 minutes ago 1.62GB - - openecomp/mso latest 419e9d8a17e8 3 minutes ago 1.62GB - -Start the mariadb container ----------------------------- + REPOSITORY TAG IMAGE ID CREATED SIZE + onap/so/so-monitoring 1.3.0-SNAPSHOT bb8f368a3ddb 7 seconds ago 206MB + onap/so/so-monitoring 1.3.0-SNAPSHOT-20190213T0846 bb8f368a3ddb 7 seconds ago 206MB + onap/so/so-monitoring 1.3.0-SNAPSHOT-latest bb8f368a3ddb 7 seconds ago 206MB + onap/so/so-monitoring latest bb8f368a3ddb 7 seconds ago 206MB + onap/so/api-handler-infra 1.3.0-SNAPSHOT 2573165483e9 21 seconds ago 246MB + onap/so/api-handler-infra 1.3.0-SNAPSHOT-20190213T0846 2573165483e9 21 seconds ago 246MB + onap/so/api-handler-infra 1.3.0-SNAPSHOT-latest 2573165483e9 21 seconds ago 246MB + onap/so/api-handler-infra latest 2573165483e9 21 seconds ago 246MB + onap/so/bpmn-infra 1.3.0-SNAPSHOT 8b1487665f2e 38 seconds ago 324MB + onap/so/bpmn-infra 1.3.0-SNAPSHOT-20190213T0846 8b1487665f2e 38 seconds ago 324MB + onap/so/bpmn-infra 1.3.0-SNAPSHOT-latest 8b1487665f2e 38 seconds ago 324MB + onap/so/bpmn-infra latest 8b1487665f2e 38 seconds ago 324MB + onap/so/sdc-controller 1.3.0-SNAPSHOT c663bb7d7c0d About a minute ago 241MB + onap/so/sdc-controller 1.3.0-SNAPSHOT-20190213T0846 c663bb7d7c0d About a minute ago 241MB + onap/so/sdc-controller 1.3.0-SNAPSHOT-latest c663bb7d7c0d About a minute ago 241MB + onap/so/sdc-controller latest c663bb7d7c0d About a minute ago 241MB + onap/so/vfc-adapter 1.3.0-SNAPSHOT dee0005ef18b About a minute ago 212MB + onap/so/vfc-adapter 1.3.0-SNAPSHOT-20190213T0846 dee0005ef18b About a minute ago 212MB + onap/so/vfc-adapter 1.3.0-SNAPSHOT-latest dee0005ef18b About a minute ago 212MB + onap/so/vfc-adapter latest dee0005ef18b About a minute ago 212MB + onap/so/openstack-adapter 1.3.0-SNAPSHOT fe9103aa9f36 About a minute ago 235MB + onap/so/openstack-adapter 1.3.0-SNAPSHOT-20190213T0846 fe9103aa9f36 About a minute ago 235MB + onap/so/openstack-adapter 1.3.0-SNAPSHOT-latest fe9103aa9f36 About a minute ago 235MB + onap/so/openstack-adapter latest fe9103aa9f36 About a minute ago 235MB + onap/so/sdnc-adapter 1.3.0-SNAPSHOT d02d42d92b06 2 minutes ago 231MB + onap/so/sdnc-adapter 1.3.0-SNAPSHOT-20190213T0846 d02d42d92b06 2 minutes ago 231MB + onap/so/sdnc-adapter 1.3.0-SNAPSHOT-latest d02d42d92b06 2 minutes ago 231MB + onap/so/sdnc-adapter latest d02d42d92b06 2 minutes ago 231MB + onap/so/request-db-adapter 1.3.0-SNAPSHOT 5e0136f2201b 2 minutes ago 215MB + onap/so/request-db-adapter 1.3.0-SNAPSHOT-20190213T0846 5e0136f2201b 2 minutes ago 215MB + onap/so/request-db-adapter 1.3.0-SNAPSHOT-latest 5e0136f2201b 2 minutes ago 215MB + onap/so/request-db-adapter latest 5e0136f2201b 2 minutes ago 215MB + onap/so/catalog-db-adapter 1.3.0-SNAPSHOT bf1c2fe49acb 2 minutes ago 218MB + onap/so/catalog-db-adapter 1.3.0-SNAPSHOT-20190213T0846 bf1c2fe49acb 2 minutes ago 218MB + onap/so/catalog-db-adapter 1.3.0-SNAPSHOT-latest bf1c2fe49acb 2 minutes ago 218MB + onap/so/catalog-db-adapter latest bf1c2fe49acb 2 minutes ago 218MB + onap/so/base-image 1.0 1685bba9831d 3 minutes ago 108MB + openjdk 8-jdk-alpine 792ff45a2a17 7 days ago 105MB + nexus3.onap.org:10001/openjdk 8-jdk-alpine 792ff45a2a17 7 days ago 105MB + +Start the containers +--------------------- .. code-block:: bash cd $HOME/onap/workspace/SO/docker-config - MTU=1500 docker-compose up mariadb + ./deploy.sh + + This should also download & start the mariaDB docker. *Example Output:* .. code-block:: bash - . . . many lines omitted . . . - mariadb_1 | Version: '10.1.11-MariaDB-1~jessie-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution - -Log into the mariadb container and run the mysql client program ---------------------------------------------------------------- + Deploying with local images, not pulling them from Nexus. + docker command: local docker using unix socket + Removing network dockerconfig_default + Creating network "dockerconfig_default" with driver "bridge" + Pulling mariadb (mariadb:10.1.11)... + 10.1.11: Pulling from library/mariadb + 7268d8f794c4: Pull complete + a3ed95caeb02: Pull complete + e5a99361f38c: Pull complete + 20b20853e29d: Pull complete + 9dbc63cf121f: Pull complete + fdebb5c64c6c: Pull complete + 3154860d3699: Pull complete + 3cfa7ffec11c: Pull complete + 943211713cac: Pull complete + d65a44f4573e: Pull complete + Digest: sha256:3821f92155bf4311a59b7ec6219b79cbf9a42c75805000a7c8fe5d9f3ad28276 + Status: Downloaded newer image for mariadb:10.1.11 + Creating dockerconfig_mariadb_1 + Waiting for 'dockerconfig_mariadb_1' deployment to finish ... + Waiting for 'dockerconfig_mariadb_1' deployment to finish ... + Waiting for 'dockerconfig_mariadb_1' deployment to finish ... + Waiting for 'dockerconfig_mariadb_1' deployment to finish ... + Waiting for 'dockerconfig_mariadb_1' deployment to finish ... + Waiting for 'dockerconfig_mariadb_1' deployment to finish ... + dockerconfig_mariadb_1 is up-to-date + Creating dockerconfig_catalog-db-adapter_1 + Creating dockerconfig_request-db-adapter_1 + Creating dockerconfig_sdc-controller_1 + Creating dockerconfig_vfc-adapter_1 + Creating dockerconfig_openstack-adapter_1 + Creating dockerconfig_sdnc-adapter_1 + Creating dockerconfig_api-handler-infra_1 + Creating dockerconfig_so-monitoring_1 + Creating dockerconfig_bpmn-infra_1 + +Check containers are now up +---------------------------- .. code-block:: bash - docker exec -it dockerconfig_mariadb_1 /bin/bash - mysql -uroot -ppassword + docker ps -Start the mso container ------------------------ + *Example Output:* + CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES + 324ce4636285 onap/so/bpmn-infra "/app/wait-for.sh ..." 5 minutes ago Up 5 minutes 0.0.0.0:8081->8081/tcp dockerconfig_bpmn-infra_1 + 60986a742f6f onap/so/so-monitoring "/app/wait-for.sh ..." 5 minutes ago Up 5 minutes 0.0.0.0:8088->8088/tcp dockerconfig_so-monitoring_1 + ea6e3e396166 onap/so/api-handler-infra "/app/wait-for.sh ..." 5 minutes ago Up 5 minutes 0.0.0.0:8080->8080/tcp dockerconfig_api-handler-infra_1 + 473ca2dc852c onap/so/sdnc-adapter "/app/wait-for.sh ..." 5 minutes ago Up 5 minutes 0.0.0.0:8086->8086/tcp dockerconfig_sdnc-adapter_1 + 7ae53b222a39 onap/so/vfc-adapter "/app/wait-for.sh ..." 5 minutes ago Up 5 minutes 0.0.0.0:8084->8084/tcp dockerconfig_vfc-adapter_1 + 8844999c9fc8 onap/so/openstack-adapter "/app/wait-for.sh ..." 5 minutes ago Up 5 minutes 0.0.0.0:8087->8087/tcp dockerconfig_openstack-adapter_1 + d500c33665b6 onap/so/sdc-controller "/app/wait-for.sh ..." 5 minutes ago Up 5 minutes 0.0.0.0:8085->8085/tcp dockerconfig_sdc-controller_1 + 852483370df3 onap/so/request-db-adapter "/app/wait-for.sh ..." 5 minutes ago Up 5 minutes 0.0.0.0:8083->8083/tcp dockerconfig_request-db-adapter_1 + cdfa29ee96cc onap/so/catalog-db-adapter "/app/wait-for.sh ..." 5 minutes ago Up 5 minutes 0.0.0.0:8082->8082/tcp dockerconfig_catalog-db-adapter_1 + 7c7116026c07 mariadb:10.1.11 "/docker-entrypoin..." 5 minutes ago Up 5 minutes 0.0.0.0:32770->3306/tcp dockerconfig_mariadb_1 + +Check SO health +--------------- .. code-block:: bash - cd $HOME/onap/workspace/SO/docker-config - - MTU=1500 docker-compose up mso + curl http://localhost:8080/manage/health -*Example Output:* - -.. code-block:: bash + *Example Output:* - . . . many lines omitted . . . - mso_1 | 20:59:31,586 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final - (WildFly Core 2.2.0.Final) started in 59937ms - Started 2422 of 2747 services (604 services are lazy, passive or - on-demand) + {"status":"UP"} Log into the mso container -------------------------- .. code-block:: bash - docker exec -it dockerconfig_mso_1 /bin/bash + docker exec -it dockerconfig_api-handler-infra_1 sh Inspect a docker image ---------------------- -This command shows interesting information about the structure of the mso image. Note that an image is NOT a running container. It is the template that a container is created from. +This command shows interesting information about the structure of the mso image. Note that an image is NOT a running container. +It is the template that a container is created from. .. code-block:: bash - docker inspect openecomp/mso + docker inspect onap/so/api-handler-infra Example Output: [ { - "Id": "sha256:419e9d8a17e8d7e876dfc36c1f3ed946bccbb29aa6faa6cd8e32fbc77c0ef6e5", + "Id": "sha256:2573165483e9ac87826da9c08984a9d0e1d93a90c681b22d9b4f90ed579350dc", "RepoTags": [ - "openecomp/mso:1.1-SNAPSHOT-latest", - "openecomp/mso:1.1.0-SNAPSHOT-STAGING-20170926T2015", - "openecomp/mso:latest" + "onap/so/api-handler-infra:1.3.0-SNAPSHOT", + "onap/so/api-handler-infra:1.3.0-SNAPSHOT-20190213T0846", + "onap/so/api-handler-infra:1.3.0-SNAPSHOT-latest", + "onap/so/api-handler-infra:latest" ], "RepoDigests": [], - "Parent": "sha256:70f1ba3d6289411fce96ba78755a3fd6055a370d33464553d72c753889b12693", + "Parent": "sha256:66b508441811ab4ed9968f8702a0d0a697f517bbc10d8d9076e5b98ae4437344", "Comment": "", - "Created": "2017-09-26T20:40:10.179358574Z", - "Container": "284aa05909390a3c0ffc1ec6d0f6e2071799d56b08369707505897bc73d2ea30", + "Created": "2019-02-13T09:37:33.770342225Z", + "Container": "8be46c735d21935631130f9017c3747779aab26eab54a9149b1edde122f7576d", "ContainerConfig": { - "Hostname": "6397aa10f0c4", + "Hostname": "ac4a12e21390", "Domainname": "", - "User": "root", + "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, - "ExposedPorts": { - "8080/tcp": {} - }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin", + "LANG=C.UTF-8", + "JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk", + "JAVA_VERSION=8u191", + "JAVA_ALPINE_VERSION=8.191.12-r0", "HTTP_PROXY=", "HTTPS_PROXY=", "http_proxy=", - "https_proxy=", - "JBOSS_HOME=/opt/jboss", - "CHEF_REPO_NAME=chef-repo", - "CHEF_CONFIG_NAME=mso-config" + "https_proxy=" ], "Cmd": [ "/bin/sh", "-c", "#(nop) ", - "CMD [\"/opt/mso/scripts/start-jboss-server.sh\"]" + "CMD [\"/app/start-app.sh\"]" ], "ArgsEscaped": true, - "Image": "sha256:70f1ba3d6289411fce96ba78755a3fd6055a370d33464553d72c753889b12693", + "Image": "sha256:66b508441811ab4ed9968f8702a0d0a697f517bbc10d8d9076e5b98ae4437344", "Volumes": { - "/shared": {} + "/app/ca-certificates": {}, + "/app/config": {} }, - "WorkingDir": "", + "WorkingDir": "/app", "Entrypoint": null, "OnBuild": [], - "Labels": { - "Description": "This image contains the ONAP SO", - "Version": "1.0" - } + "Labels": {} }, "DockerVersion": "17.05.0-ce", - "Author": "\"The ONAP Team\"", + "Author": "", "Config": { - "Hostname": "6397aa10f0c4", + "Hostname": "ac4a12e21390", "Domainname": "", - "User": "root", + "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, - "ExposedPorts": { - "8080/tcp": {} - }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin", + "LANG=C.UTF-8", + "JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk", + "JAVA_VERSION=8u191", + "JAVA_ALPINE_VERSION=8.191.12-r0", "HTTP_PROXY=", "HTTPS_PROXY=", "http_proxy=", - "https_proxy=", - "JBOSS_HOME=/opt/jboss", - "CHEF_REPO_NAME=chef-repo", - "CHEF_CONFIG_NAME=mso-config" + "https_proxy=" ], "Cmd": [ - "/opt/mso/scripts/start-jboss-server.sh" + "/app/start-app.sh" ], "ArgsEscaped": true, - "Image": "sha256:70f1ba3d6289411fce96ba78755a3fd6055a370d33464553d72c753889b12693", + "Image": "sha256:66b508441811ab4ed9968f8702a0d0a697f517bbc10d8d9076e5b98ae4437344", "Volumes": { - "/shared": {} + "/app/ca-certificates": {}, + "/app/config": {} }, - "WorkingDir": "", + "WorkingDir": "/app", "Entrypoint": null, "OnBuild": [], - "Labels": { - "Description": "This image contains the ONAP SO", - "Version": "1.0" - } + "Labels": {} }, "Architecture": "amd64", "Os": "linux", - "Size": 1616881263, - "VirtualSize": 1616881263, + "Size": 245926705, + "VirtualSize": 245926705, "GraphDriver": { "Data": null, "Name": "aufs" @@ -188,21 +255,20 @@ This command shows interesting information about the structure of the mso image. "RootFS": { "Type": "layers", "Layers": [ - "sha256:a2022691bf950a72f9d2d84d557183cb9eee07c065a76485f1695784855c5193", - "sha256:ae620432889d2553535199dbdd8ba5a264ce85fcdcd5a430974d81fc27c02b45", - . . . many lines omitted . . . - "sha256:0f9e9dacce9191617e979f05e32ee782b1632e07130fd7fee19b0b2d635aa006", - "sha256:84572c6389f8ae41150e14a8f1a28a70720de91ab1032f8755b5449dc04449c9" + "sha256:503e53e365f34399c4d58d8f4e23c161106cfbce4400e3d0a0357967bad69390", + "sha256:744b4cd8cf79c70508aace3697b6c3b46bee2c14f1c14b6ff09fd0ba5735c6d4", + "sha256:4c6899b75fdbea2f44efe5a2f8d9f5319c1cf7e87151de0de1014aba6ce71244", + "sha256:2e076d24f6d1277456e33e58fc8adcfd69dfd9c025f61aa7b98d500e7195beb2", + "sha256:bb67f2d5f8196c22137a9e98dd4190339a65c839822d16954070eeb0b2a17aa2", + "sha256:afbbd0cc43999d5c5b0ff54dfd82365a3feb826e5c857d9b4a7cf378001cd4b3", + "sha256:1920a7ca0f8ae38a79a1339ce742aaf3d7a095922d96e37074df67cf031d5035", + "sha256:1261fbaef67c5be677dae1c0f50394587832ea9d8c7dc105df2f3db6dfb92a3a", + "sha256:a33d8ee5c18908807458ffe643184228c21d3c5d5c5df1251f0f7dfce512f7e8", + "sha256:80704fca12eddb4cc638cee105637266e04ab5706b4e285d4fc6cac990e96d63", + "sha256:55abe39073a47f29aedba790a92c351501f21b3628414fa49a073c010ee747d1", + "sha256:cc4136c2c52ad522bd492545d4dd18265676ca690aa755994adf64943b119b28", + "sha256:2163a1f989859fdb3af6e253b74094e92a0fc1ee59f5eb959971f94eb1f98094" ] } } -] - -Log into the mso image ------------------------ - -This command allows you to inspect the files inside the mso image. Note that an image is NOT a running container. It is the template that a container is created from. - -.. code-block:: bash - - docker run -it --entrypoint=/bin/bash openecomp/mso -i + ] |