Examples of VirtualHostLegacyResourceKeyUtil


Examples of org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil

        ApacheServerComponent component = setup.withApacheSetup().getServerComponent();
        ApacheDirectiveTree config = component.parseRuntimeConfiguration(false);

        DeploymentConfig deployConfig = setup.getDeploymentConfig();

        VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config);

        Map<String, String> replacements = deployConfig.getTokenReplacements();

        testConfig.defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey());

        if (deployConfig.vhost1 != null) {
            testConfig.defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements)));
        }

        if (deployConfig.vhost2 != null) {
            testConfig.defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements)));
        }

        if (deployConfig.vhost3 != null) {
            testConfig.defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements)));
        }

        if (deployConfig.vhost4 != null) {
            testConfig.defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements)));
        }

        setup.withDefaultOverrides(testConfig.defaultOverrides);
    }
View Full Code Here

Examples of org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil

        ApacheServerComponent serverComponent = inventoriedResource.getParentResourceComponent();

        ApacheDirectiveTree tree = serverComponent.parseRuntimeConfiguration(false);

        List<VHostSpec> vhosts = VHostSpec.detect(tree);
        VirtualHostLegacyResourceKeyUtil legacyResourceKeyUtil =
            new VirtualHostLegacyResourceKeyUtil(serverComponent, tree);

        //first, let's see if the inventoried resource has the snmpWwwServiceIndex property set
        //if it does, use that to determine what vhost this corresponds to.
        String snmpServiceIndexString =
            inventoriedResource.getPluginConfiguration().getSimpleValue(LEGACY_SNMP_SERVICE_INDEX_CONFIG_PROP, null);
        if (snmpServiceIndexString != null) {
            Integer snmpServiceIndex = null;
            try {
                snmpServiceIndex = Integer.parseInt(snmpServiceIndexString);
            } catch (NumberFormatException e) {
                log.warn("Invalid format of the " + LEGACY_SNMP_SERVICE_INDEX_CONFIG_PROP
                    + " property value. It should be an integer but is '" + snmpServiceIndexString
                    + "'. The upgrade will continue using the resource key matching.", e);
            }

            if (snmpServiceIndex != null) {
                if (snmpServiceIndex > 0) {
                    //yay, we can use the snmpService index to determine which vhost we're dealing with
                    if (snmpServiceIndex == 1) {
                        //k, looks the vhost was representing the main server. Let's do a cross-check.
                        Set<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyMainServerResourceKeys();
                        if (legacyResourceKeys.contains(resourceKey)) {
                            newResourceKey = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
                        } else {
                            log.debug("The cross-check of the SNMP WWW Service Index value and resource key failed for virtual host with old resource key: "
                                + resourceKey + ". The upgrade will continue using resource key matching.");
                        }
                    } else {
                        if (vhosts.size() + 1 < snmpServiceIndex) {
                            log.debug("The "
                                + LEGACY_SNMP_SERVICE_INDEX_CONFIG_PROP
                                + " property contains incorrect value ("
                                + snmpServiceIndex
                                + "), which is larger than the total number of active virtual hosts in the configuration files ("
                                + (vhosts.size() + 1) + ". The upgrade will continue using the resource key matching.");
                        } else {
                            //k, this seems to be a correct value
                            //the SNMP indices are in the reverse order of the definitions in the config files
                            //+1, where the main server is always on index 1.
                            VHostSpec vhost = vhosts.get(vhosts.size() - snmpServiceIndex + 1);

                            //right, let's do a cross-check before we actually create the resource key so
                            //that we catch user-generated errors.
                            Set<String> legacyResourceKeys =
                                legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);
                            if (legacyResourceKeys.contains(resourceKey)) {
                                newResourceKey = createResourceKey(vhost.serverName, vhost.hosts);
                            } else {
                                log.debug("The cross-check of the SNMP WWW Service Index value and resource key failed for virtual host with old resource key: "
                                    + resourceKey + ". The upgrade will continue using resource key matching.");
                            }
                        }
                    }
                } else {
                    log.warn("The " + LEGACY_SNMP_SERVICE_INDEX_CONFIG_PROP
                        + " property should be a positive integer greater than zero but is " + snmpServiceIndex
                        + " instead. The upgrade will continue using the resource key matching.");
                }
            }
        }

        if (newResourceKey != null) {
            ResourceUpgradeReport report = new ResourceUpgradeReport();
            report.setNewResourceKey(newResourceKey);

            return report;
        }

        Map<String, Set<VHostSpec>> possibleMatchesPerRK = new HashMap<String, Set<VHostSpec>>();
        for (VHostSpec vhost : vhosts) {
            Set<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);

            for (String legacyRK : legacyResourceKeys) {
                addPossibleRKMatch(legacyRK, vhost, possibleMatchesPerRK);
            }
        }

        for (String legacyRK : legacyResourceKeyUtil.getLegacyMainServerResourceKeys()) {
            addPossibleRKMatch(legacyRK, null, possibleMatchesPerRK);
        }

        Set<VHostSpec> matchingVhosts = possibleMatchesPerRK.get(resourceKey);
        if (matchingVhosts == null || matchingVhosts.isEmpty()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.