Package org.rhq.core.domain.resource

Examples of org.rhq.core.domain.resource.Resource


        List<ResourceWithType> ret = new ArrayList<ResourceWithType>();

        MediaType mediaType = httpHeaders.getAcceptableMediaTypes().get(0);
        for (Integer id : favIds) {
            try {
                Resource res = resourceManager.getResource(caller, id);

                ResourceWithType rwt = fillRWT(res, uriInfo);
                ret.add(rwt);
            } catch (Exception e) {
                if (e instanceof ResourceNotFoundException) {
View Full Code Here


                public void onSuccess(PageList<Resource> result) {
                    if (result.isEmpty()) {
                        throw new IllegalArgumentException("Entity not found [" + context + "]");
                    }

                    Resource resource = result.get(0);
                    showWizard(context, resource.getResourceType().getId(), table);
                }

                public void onFailure(Throwable caught) {
                    CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_loadFailed(), caught);
                }
View Full Code Here

    // lifted from ResourceManagerBeanTest, with the addition of adding bundle config to the type
    private ResourceGroup createTestResourceGroup() throws Exception {
        getTransactionManager().begin();

        ResourceGroup resourceGroup = null;
        Resource resource;

        try {
            // Naming this with TEST_PREFIX allows cleanupDatabase to blow away these test resources along
            // with the bundle resource type
            ResourceType resourceType = new ResourceType(TEST_PREFIX + "-platform-" + System.currentTimeMillis(),
                "test", ResourceCategory.PLATFORM, null);

            // we need to make this test type bundle targetable
            ConfigurationDefinition pcDef = new ConfigurationDefinition(TEST_PREFIX + "-testdef", "bundle test");
            PropertyDefinitionSimple propDef = new PropertyDefinitionSimple(TEST_BUNDLE_DESTBASEDIR_PROP, "", true,
                PropertySimpleType.STRING);
            propDef.setDisplayName(TEST_BUNDLE_DESTBASEDIR_PROP);
            pcDef.put(propDef);
            em.persist(pcDef);

            ResourceTypeBundleConfiguration rtbc = new ResourceTypeBundleConfiguration(new Configuration());
            rtbc.addBundleDestinationBaseDirectory(TEST_DESTBASEDIR_NAME,
                ResourceTypeBundleConfiguration.BundleDestinationBaseDirectory.Context.pluginConfiguration.name(),
                TEST_BUNDLE_DESTBASEDIR_PROP, null);
            resourceType.setResourceTypeBundleConfiguration(rtbc);
            resourceType.setPluginConfigurationDefinition(pcDef);

            em.persist(resourceType);

            // make sure the bundle config is ok
            rtbc = resourceType.getResourceTypeBundleConfiguration();
            assert rtbc != null;
            assert rtbc.getBundleDestinationBaseDirectories().size() == 1;
            BundleDestinationBaseDirectory bdbd = rtbc.getBundleDestinationBaseDirectories().iterator().next();
            assert bdbd.getName().equals(TEST_DESTBASEDIR_NAME);
            assert bdbd.getValueContext() == ResourceTypeBundleConfiguration.BundleDestinationBaseDirectory.Context.pluginConfiguration;
            assert bdbd.getValueName().equals(TEST_BUNDLE_DESTBASEDIR_PROP);

            Agent agent = new Agent(TEST_PREFIX + "-testagent", "testaddress", 1, "", "testtoken");
            em.persist(agent);
            em.flush();

            Configuration rc = new Configuration();
            rc.put(new PropertySimple(TEST_BUNDLE_DESTBASEDIR_PROP, TEST_BUNDLE_DESTBASEDIR_PROP_VALUE));
            em.persist(rc);

            resource = new Resource("reskey" + System.currentTimeMillis(), TEST_PREFIX + "-resname", resourceType);
            resource.setUuid("" + System.currentTimeMillis());
            resource.setInventoryStatus(InventoryStatus.COMMITTED);
            resource.setAgent(agent);
            resource.setResourceConfiguration(rc);
            em.persist(resource);

            resourceGroup = new ResourceGroup(TEST_PREFIX + "-group-" + System.currentTimeMillis());
            resourceGroup.addExplicitResource(resource);
            resourceGroup.addImplicitResource(resource);
View Full Code Here

            package5.addVersion(package5Installed);

            em.persist(package5);

            // Create resource against which we'll merge the discovery report
            resource1 = new Resource("parent" + System.currentTimeMillis(), "name", resourceType1);
            resource1.setUuid("" + new Random().nextInt());
            em.persist(resource1);

            // Install packages on the resource
            installedPackage1 = new InstalledPackage();
View Full Code Here

        return;
    }

    @Test(enabled = ENABLE_TESTS)
    public void testInvalidPluginConfigurationUpdate() throws Exception {
        Resource resource = newResource1;

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        Configuration configuration1 = new Configuration();
        configuration1.put(new PropertySimple("fakeReadOnly", "1"));

        Configuration configuration2 = new Configuration();
        configuration2.put(new PropertySimple("fakeReadOnly", "2"));

        Configuration current;

        current = configurationManager.getPluginConfiguration(overlord, resource.getId());
        assert current != null;
        assert current.getProperties().size() == 0 : current; // there is no plugin config settings yet

        configurationManager.updatePluginConfiguration(overlord, resource.getId(), configuration1);
        current = configurationManager.getPluginConfiguration(overlord, resource.getId());
        assert current != null;
        assert current.getProperties().size() == 1 : current;
        assert current.getSimple("fakeReadOnly").getIntegerValue() == 1 : current;

        try {
            configurationManager.updatePluginConfiguration(overlord, resource.getId(), configuration2);
            fail("Should have thrown BadArgumentException when trying to change readOnly property.");
        } catch (BadArgumentException e) {
            // expected
        }
    }
View Full Code Here

        em.persist(agent);

        platformType = new ResourceType("testplatAB", "p", ResourceCategory.PLATFORM, null);
        em.persist(platformType);

        platform = new Resource("platform1", "testAutoBaseline Platform One", platformType);
        platform.setUuid("" + new Random().nextInt());
        platform.setInventoryStatus(InventoryStatus.COMMITTED);
        em.persist(platform);
        platform.setAgent(agent);

        platform2 = new Resource("platform2", "testAutoBaseline Platform Two", platformType);
        platform2.setUuid("" + new Random().nextInt());
        platform2.setInventoryStatus(InventoryStatus.COMMITTED);
        // deleteResource removes the agent, so we can't have two direct platforms for it, make one a child of the other
        platform.addChildResource(platform2);
        em.persist(platform2);
View Full Code Here

        System.out.println("Populating test inventory with [" + resourceCount + "] resources.");

        agent = new Agent("test-agent", "localhost", 1234, "", "randomToken");
        em.persist(agent);

        Resource root = null;
        for (int r = 0; r < resourceCount; r++) {
            Resource resource = new Resource(String.valueOf(r), "testAutoBaselineResource" + r, platformType);
            resource.setUuid("" + new Random().nextInt());
            if (root == null) {
                root = resource;
            } else {
                root.addChildResource(resource);
            }
            em.persist(resource);
            allResources.add(resource);
            resource.setAgent(agent);

            for (MeasurementDefinition def : allDefs) {
                MeasurementSchedule sched = new MeasurementSchedule(def, resource);
                sched.setEnabled(true);
                resource.addSchedule(sched);
                def.addSchedule(sched);
                em.persist(sched);
                allScheds.add(sched);
            }
View Full Code Here

        }
        return null;
    }

    private void loadTraitValues() {
        final Resource resource = resourceComposite.getResource();
        GWTServiceLookup.getMeasurementDataService().findCurrentTraitsForResource(resource.getId(),
            DisplayType.SUMMARY, new AsyncCallback<List<MeasurementDataTrait>>() {
                public void onFailure(Throwable caught) {
                }

                public void onSuccess(List<MeasurementDataTrait> result) {
                    String productName = "";
                    String productVersion = resource.getVersion();

                    if ("JBossAS7".equals(resource.getResourceType().getPlugin())) {
                        // for EAP6-based products we rely on trait values
                        for (MeasurementDataTrait trait : result) {
                            Log.info(trait.getName());
                            if (trait.getName().equals("Product Version")) {
                                productVersion = trait.getValue();
                                Log.info(trait.getValue());
                            }
                            if (trait.getName().equals("Product Name")) {
                                productName = trait.getValue();
                                Log.info(trait.getValue());
                            }
                        }

                        if ("EAP".equals(productName)) {
                            productName = "Red Hat JBoss Enterprise Application Platform";
                            String dv = workaroundDetectingDV6(resource);
                            if (dv != null) {
                                productName = dv;
                                if (productVersion.startsWith("6.1.1")) {
                                    // DV 6 is laid down on EAP 6.1.1
                                    productVersion = "6.0.0";
                                }
                            }
                        }
                        if ("Data Grid".equals(productName)) {
                            productName = "Red Hat JBoss Data Grid";
                        }
                        if ("BRMS".equals(productName)) {
                            productName = "Red Hat JBoss BRMS";
                        }
                        if ("Portal".equals(productName)) {
                            productName = "Red Hat JBoss Portal";
                        }
                        // we need to strip down .GA suffix, since it is not present in RHA
                        productVersion = productVersion.replaceAll("\\.GA.*", "");
                    }
                    if ("JBossFuse".equals(resource.getResourceType().getPlugin())) {
                        if ("JBoss Fuse Container".equals(resource.getResourceType().getName())) {
                            productName = "Red Hat JBoss Fuse";
                            productVersion = productVersion.replaceAll("\\.redhat.*", "");
                        }
                    }
                    if ("Tomcat".equals(resource.getResourceType().getPlugin())) {
                        if ("Tomcat Server".equals(resource.getResourceType().getName())) {
                            productName = "Red Hat JBoss Web Server";
                            productVersion = ""; // we can't really detect EWS version from tomcat instance
                        }
                    }

View Full Code Here

                }
            }
            commit();

            // delete the resources which will cascade delete all schedules
            Resource root = allResources.get(0);
            // perform in-band and out-of-band work in quick succession
            // this also deletes the agent
            List<Integer> deletedIds = resourceManager.uninventoryResource(overlord, root.getId());
            for (Integer deletedResourceId : deletedIds) {
                resourceManager.uninventoryResourceAsyncWork(overlord, deletedResourceId);
            }

            begin();
View Full Code Here

            PageList<MeasurementDataTrait> results = dataManager.findTraitsByCriteria(getSessionSubject(), criteria);
            if (!results.isEmpty() && null != results.get(0).getSchedule()
                && null != results.get(0).getSchedule().getResource()) {
                List<Resource> resources = new ArrayList<Resource>(results.size());
                for (MeasurementDataTrait result : results) {
                    Resource res = result.getSchedule().getResource();
                    if (null != res) {
                        resources.add(res);
                    }
                }
                ObjectFilter.filterFieldsInCollection(resources, ResourceGWTServiceImpl.importantFieldsSet);
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.Resource

Copyright © 2018 www.massapicom. 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.