From d41551fe316a74335fed27fc9a23e09690f6fb8b Mon Sep 17 00:00:00 2001 From: Larry O'Leary Date: Mon, 27 Apr 2015 09:27:47 -0500 Subject: [PATCH] BZ-1203469: Fail to manually import JBoss EAP based products when product slot is unknown If a JBoss EAP 6/AS 7 instance does not include a bin/product.conf file, it is assumed to be an AS 7 instance. However, if it does include a product.conf file but the slot value is unknown by the as-7 plug-in, an attempt is made to determine its type from its home directory name. If this does not work, discovery is aborted and the JBoss EAP 6 / AS 7 instance can not be imported into inventory. Even when an AS7 resource is manually added, this same problem occurs. This fix allows a manual import to be successful even if the product type can not be determined. A warning is now logged to identify that an unsupported product was found and the product type falls back to AS. (cherry picked from commit 0226e3c1164a696da127ba7a1eaf4d80c013216c) Conflicts: modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java See [BZ 1300727] for more details, but this commit squashes the following four commits and cherry-picks from 3.1.x->3.3.x 0b4745e8a6c48943fcb821c5cd557bc7f03678bd 5bcfe335ca257bcc142d9ac74103e1b5f911b61e 0a9a4eee63ca268da106bd6d20b1c0dc4252e645 181b92a192b9b09c96d2ebaf62424944a969880c Conflicts: modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java --- .../plugins/jbossas7/BaseProcessDiscovery.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java index 30993ee4e3e..90eb16c4429 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright (C) 2005-2014 Red Hat, Inc. + * Copyright (C) 2011-2015 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -222,6 +222,12 @@ protected DiscoveredResourceDetails buildResourceDetails(ResourceDiscoveryContex serverPluginConfig.setNativeLocalAuth(hostConfig.isNativeLocalOnly()); pluginConfig.setSimpleValue("realm", hostConfig.getManagementSecurityRealm()); String apiVersion = hostConfig.getDomainApiVersion(); + JBossProductType productType = JBossProductType.AS; + try { + productType = JBossProductType.determineJBossProductType(homeDir, apiVersion); + } catch (Exception e) { + log.warn("Managed product type for [" + homeDir + "] could not be determined or is unsupported: " + e.getMessage(), e); //$NON-NLS-1$ //$NON-NLS-2$ + } JBossProductType productType = JBossProductType.determineJBossProductType(homeDir, apiVersion); if(productType == JBossProductType.EAP7) { // Ignore here, use EAP7 / Wildfly 10 plugin to do the detection @@ -872,7 +878,15 @@ public ProductInfo getFromRemote() { try { String productName = getServerAttribute(connection, "product-name"); if ((productName != null) && !productName.isEmpty()) - productType = JBossProductType.getValueByProductName(productName); + try { + productType = JBossProductType.getValueByProductName(productName); + } catch (Exception e) { + // if the product type can not be determined, log a warning + // to indicate that the product may not be supported and + // fall back to a product type of AS. + log.warn("Unknown or unsupported product type for product [" + productName + "]: " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ + productType = JBossProductType.AS; + } else { Integer apiVersion = getServerAttribute(connection, "management-major-version"); if (apiVersion == 1) {