Examples of InventoryReport


Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

            serviceType1.getId(), true);
        resourceTypeManager.setResourceTypeIgnoreFlagAndUninventoryResources(subjectManager.getOverlord(),
            serviceType2.getId(), true);

        // create an inventory report with just a platform and a server
        InventoryReport inventoryReport = new InventoryReport(agent);
        Resource platform = new Resource(prefix("platform"), prefix("platform"), platformType);
        platform.setUuid(String.valueOf(new Random().nextInt()));
        Resource server = new Resource(prefix("server0"), prefix("server0"), serverType);
        server.setUuid(String.valueOf(new Random().nextInt()));
        platform.addChildResource(server);
        inventoryReport.addAddedRoot(platform);

        // Merge this inventory report
        MergeInventoryReportResults mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        PlatformSyncInfo platformSyncInfo = mergeResults.getPlatformSyncInfo();
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

    @Test(groups = "integration.ejb3")
    public void testIgnoreResourceTypeAndUninventoryResources() throws Exception {

        // First create an inventory report for a new platform with servers - nothing is ignored yet
        InventoryReport inventoryReport = new InventoryReport(agent);
        Resource platform = new Resource(prefix("platform"), prefix("platform"), platformType);
        platform.setUuid(String.valueOf(new Random().nextInt()));
        for (int i = 0; i < 17; i++) {
            String serverString = prefix("server " + String.valueOf(i));
            Resource server = new Resource(serverString, serverString, serverType);
            server.setUuid(String.valueOf(new Random().nextInt()));
            platform.addChildResource(server);
        }
        inventoryReport.addAddedRoot(platform);

        // Merge this inventory report to get platform and servers in NEW state
        MergeInventoryReportResults mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        assert checkIgnoredTypes(mergeResults) : "nothing should have been ignored: "
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

    @Test(groups = "integration.ejb3")
    public void testAutoImportStorageNode() throws Exception {

        // create an inventory report for a storage node
        InventoryReport inventoryReport = new InventoryReport(agent);

        Resource storagePlatform = new Resource(prefix("storagePlatform"), prefix("storagePlatform"),
            storagePlatformType);
        storagePlatform.setUuid(String.valueOf(new Random().nextInt()));

        Resource storageNode = new Resource(prefix("storageNode"), prefix("storageNode"), storageServerType);
        storageNode.setUuid(String.valueOf(new Random().nextInt()));
        storagePlatform.addChildResource(storageNode);

        storageNode.setPluginConfiguration(Configuration.builder().addSimple("nativeTransportPort", 9142)
            .addSimple("storagePort", 7100).addSimple("host", "localhost").build());

        inventoryReport.addAddedRoot(storagePlatform);

        // Merge this inventory report
        MergeInventoryReportResults mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        assert checkIgnoredTypes(mergeResults) : "nothing should have been ignored: "
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

    @Test(groups = "integration.ejb3")
    public void testPersistUserSuppliedResourceNameOnCreatedResource() throws Exception {

        // First inventory the platform and the server
        InventoryReport inventoryReport = new InventoryReport(agent);

        Resource platform = new Resource(prefix("userPlatform"), prefix("platform"), platformType);
        platform.setUuid(String.valueOf(new Random().nextInt()));
        Resource server = new Resource(prefix("userServer"), prefix("server"), serverType);
        server.setUuid(String.valueOf(new Random().nextInt()));
        platform.addChildResource(server);

        inventoryReport.addAddedRoot(platform);

        MergeInventoryReportResults results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assertNotNull(results);
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test "
            + results.getIgnoredResourceTypes();
        final PlatformSyncInfo firstDiscoverySyncInfo = results.getPlatformSyncInfo();
        assertNotNull(firstDiscoverySyncInfo);

        // Then simulate a create resource request
        final String userSuppliedResourceName = prefix("User Supplied Resource Name");
        final String newResourceKey = prefix("Created Resource Key");
        final int serverResourceId = firstDiscoverySyncInfo.getTopLevelServerIds().iterator().next();

        executeInTransaction(false, new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                Resource serverResource = getEntityManager().find(Resource.class, serverResourceId);
                CreateResourceHistory createResourceHistory = new CreateResourceHistory(serverResource, serviceType1,
                    subjectManager.getOverlord().getName(), new Configuration());
                createResourceHistory.setCreatedResourceName(userSuppliedResourceName);
                createResourceHistory.setNewResourceKey(newResourceKey);
                createResourceHistory.setStatus(SUCCESS);
                getEntityManager().persist(createResourceHistory);
                serverResource.addCreateChildResourceHistory(createResourceHistory);
                getEntityManager().flush();
            }
        });

        // Eventually inventory the newly discovered service

        inventoryReport = new InventoryReport(agent);
        Resource service1 = new Resource(newResourceKey, prefix("Plugin Computed Resource Name"), serviceType1);
        service1.setUuid(String.valueOf(new Random().nextInt()));
        server.setId(serverResourceId);
        server.addChildResource(service1);
        inventoryReport.addAddedRoot(server);

        results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assertNotNull(results);
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test "
            + results.getIgnoredResourceTypes();
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

        }
    }

    @Test(groups = "integration.ejb3")
    public void testBasicInventoryReport() throws Exception {
        InventoryReport inventoryReport = new InventoryReport(agent);

        Resource platform = new Resource(prefix("alpha"), prefix("platform"), platformType);
        Resource server = new Resource(prefix("bravo"), prefix("server"), serverType);
        platform.addChildResource(server);
        Resource service1 = new Resource(prefix("charlie"), prefix("service 1"), serviceType1);
        Resource service2 = new Resource(prefix("delta"), prefix("service 2"), serviceType2);
        server.addChildResource(service1);
        server.addChildResource(service2);

        platform.setUuid(String.valueOf(new Random().nextInt()));
        server.setUuid(String.valueOf(new Random().nextInt()));
        service1.setUuid(String.valueOf(new Random().nextInt()));
        service2.setUuid(String.valueOf(new Random().nextInt()));

        inventoryReport.addAddedRoot(platform);

        MergeInventoryReportResults results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert results != null;
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test";
        assertNotNull(results.getPlatformSyncInfo());
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

    }

    @Test(groups = "integration.ejb3")
    public void testUpdateInventoryReport() throws Exception {
        // First just submit the platform
        InventoryReport inventoryReport = new InventoryReport(agent);
        Resource platform = new Resource(prefix("alpha"), prefix("platform"), platformType);
        platform.setUuid(String.valueOf(new Random().nextInt()));
        inventoryReport.addAddedRoot(platform);
        MergeInventoryReportResults results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert results != null;
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test";
        assertNotNull(results.getPlatformSyncInfo());
        Collection<ResourceSyncInfo> syncInfos = discoveryBoss.getResourceSyncInfo(results.getPlatformSyncInfo()
            .getPlatform().getId());
        assert syncInfos != null;
        assert !syncInfos.isEmpty();

        platform.setId(results.getPlatformSyncInfo().getPlatform().getId());

        // Now submit the server and its children as an update report
        inventoryReport = new InventoryReport(agent);
        Resource server = new Resource(prefix("bravo"), prefix("server"), serverType);
        platform.addChildResource(server);
        Resource service1 = new Resource(prefix("charlie"), prefix("service 1"), serviceType1);
        Resource service2 = new Resource(prefix("delta"), prefix("service 2"), serviceType2);
        server.addChildResource(service1);
        server.addChildResource(service2);

        server.setUuid(String.valueOf(new Random().nextInt()));
        service1.setUuid(String.valueOf(new Random().nextInt()));
        service2.setUuid(String.valueOf(new Random().nextInt()));

        inventoryReport.addAddedRoot(server);

        results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert results != null;
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test";
        assertNotNull(results.getPlatformSyncInfo());
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

        return expectedNumberOfIgnoredTypes == numberOfRelevantIgnoredTypes;
    }

    @Test(groups = "integration.ejb3")
    public void testManuallyAddResource() throws Exception {
        InventoryReport inventoryReport = new InventoryReport(agent);

        Resource platform = new Resource(prefix("alpha"), prefix("platform"), platformType);
        Resource server = new Resource(prefix("bravo"), prefix("server"), serverType);
        platform.addChildResource(server);
        Resource service2 = new Resource(prefix("delta"), prefix("service 2"), serviceType2);
        server.addChildResource(service2);

        platform.setUuid(String.valueOf(new Random().nextInt()));
        server.setUuid(String.valueOf(new Random().nextInt()));
        service2.setUuid(String.valueOf(new Random().nextInt()));

        inventoryReport.addAddedRoot(platform);

        MergeInventoryReportResults results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert results != null;
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test";
        assertNotNull(results.getPlatformSyncInfo());
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

    @Test(groups = "integration.ejb3")
    public void testIgnoreUnignoreAndImportResources() throws Exception {

        // First create an inventory report for a new platform with servers

        InventoryReport inventoryReport = new InventoryReport(agent);

        Resource platform = new Resource(prefix("platform"), prefix("platform"), platformType);
        platform.setUuid(String.valueOf(new Random().nextInt()));
        for (int i = 0; i < 17; i++) {
            String serverString = prefix("server " + String.valueOf(i));
            Resource server = new Resource(serverString, serverString, serverType);
            server.setUuid(String.valueOf(new Random().nextInt()));
            platform.addChildResource(server);
        }

        inventoryReport.addAddedRoot(platform);

        // Merge this inventory report
        MergeInventoryReportResults mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        assert checkIgnoredTypes(mergeResults) : "nothing should have been ignored: "
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

        // ignore the server type immediately
        resourceTypeManager.setResourceTypeIgnoreFlagAndUninventoryResources(subjectManager.getOverlord(),
            serverType.getId(), true);

        // create an inventory report with a platform and a server - the server will be of the ignored type
        InventoryReport inventoryReport = new InventoryReport(agent);
        Resource platform = new Resource(prefix("platform"), prefix("platform"), platformType);
        platform.setUuid(String.valueOf(new Random().nextInt()));
        Resource server = new Resource(prefix("server0"), prefix("server0"), serverType);
        server.setUuid(String.valueOf(new Random().nextInt()));
        platform.addChildResource(server);
        inventoryReport.addAddedRoot(platform);

        // Merge this inventory report
        MergeInventoryReportResults mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        PlatformSyncInfo platformSyncInfo = mergeResults.getPlatformSyncInfo();
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

                .getResourceTypeBlacklist();
            if (!blacklist.isEmpty()) {
                out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_BLACKLISTED_TYPES, blacklist));
            }
            long start = System.currentTimeMillis();
            InventoryReport scan1 = inventoryManager.executeServerScanImmediately();
            InventoryReport scan2 = inventoryManager.executeServiceScanImmediately();
            out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_FULL_RUN, (System.currentTimeMillis() - start)));
            printInventoryReport(scan1, out, verbose);
            printInventoryReport(scan2, out, verbose);
        } else {
            try {
                if (resourceId == null) {
                    discovery(pcName, out, pluginName, resourceTypeName, verbose);
                } else {
                    // specifying a resource ID implies we must ignore -r and -p (since type/plugin is determined by the resource)
                    InventoryManager im = PluginContainer.getInstance().getInventoryManager();
                    ResourceContainer resourceContainer = im.getResourceContainer(resourceId);
                    if (resourceContainer != null) {
                        Resource resource = resourceContainer.getResource();
                        PluginContainerConfiguration pcc = agentConfig.getPluginContainerConfiguration();
                        RuntimeDiscoveryExecutor scanner = new RuntimeDiscoveryExecutor(im, pcc, resource);
                        InventoryReport report = scanner.call();
                        out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_RESOURCE_SERVICES, resource.getName()));
                        printInventoryReport(report, out, verbose);
                    } else {
                        out.println(MSG.getMsg(AgentI18NResourceKeys.DISCOVERY_RESOURCE_ID_INVALID, resourceId));
                    }
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.