Package org.rhq.core.domain.resource.group

Examples of org.rhq.core.domain.resource.group.ResourceGroup


        Bundle b1 = createBundle("one");
        assertNotNull("Instance of newly created bundle should not be null", b1);
        BundleVersion bv1 = createBundleVersion(b1.getName() + "-1", null, b1);
        assertNotNull("Instance of newly created bundle version should not be null", bv1);

        ResourceGroup platformResourceGroup = createTestResourceGroup();
        assertNotNull("Instance of newly created resource group should not be null", platformResourceGroup);
        BundleDestination dest1 = createDestination(b1, "one", "/test", platformResourceGroup);
        assertNotNull("Instance of newly created bundle destination should not be null", dest1);

        BundleDeployment deployment1 = createDeployment("one", bv1, dest1,
View Full Code Here


    public void testCreateBundleDeployment() throws Exception {
        Bundle b1 = createBundle("one");
        assertNotNull(b1);
        BundleVersion bv1 = createBundleVersion(b1.getName() + "-1", null, b1);
        assertNotNull(bv1);
        ResourceGroup platformResourceGroup = createTestResourceGroup();
        assertNotNull(platformResourceGroup);
        BundleDestination dest1 = createDestination(b1, "one", "/test", platformResourceGroup);
        assertNotNull(dest1);
        Configuration config = new Configuration();
        try {
View Full Code Here

        assertNotNull(b1);
        BundleVersion bv1 = createBundleVersion(b1.getName() + "-1", null, b1);
        assertNotNull(bv1);
        Configuration config = new Configuration();
        config.put(new PropertySimple("bundletest.property", "bundletest.property value"));
        ResourceGroup platformResourceGroup = createTestResourceGroup();
        assertNotNull(platformResourceGroup);
        BundleDestination dest1 = createDestination(b1, "one", "/test", platformResourceGroup);
        assertNotNull(dest1);
        BundleDeployment bd1 = createDeployment("one", bv1, dest1, config);
        assertNotNull(bd1);
View Full Code Here

        // allow bundle creation in bg (has create perm)
        Bundle b1 = createBundle(subject, "one", bundleGroup.getId());
        assertNotNull(b1);
        BundleVersion bv1 = createBundleVersion(subject, b1.getName() + "-1", null, b1);
        assertNotNull(bv1);
        ResourceGroup platformResourceGroup = createTestResourceGroup();
        assertNotNull(platformResourceGroup);

        // deny destination create (no view of resource group)
        try {
            BundleDestination dest1 = createDestination(subject, b1, "one", "/test", platformResourceGroup);
            fail("Should have thrown IllegalArgumentException");
        } catch (EJBException e) {
            assert e.getCause() instanceof IllegalArgumentException
                && e.getCause().getMessage().contains("Invalid groupId") : "Should have not had group visibility";
            // expected
        }

        // deny destination create (no deploy perm)
        LookupUtil.getRoleManager().addResourceGroupsToRole(overlord, role.getId(),
            new int[] { platformResourceGroup.getId() });
        try {
            BundleDestination dest1 = createDestination(subject, b1, "one", "/test", platformResourceGroup);
            fail("Should have thrown PermissionException");
        } catch (PermissionException e) {
            // expected
View Full Code Here

        // allow bundle creation in bg (has create perm)
        Bundle b1 = createBundle(subject, "one", bundleGroup.getId());
        assertNotNull(b1);
        BundleVersion bv1 = createBundleVersion(subject, b1.getName() + "-1", null, b1);
        assertNotNull(bv1);
        ResourceGroup platformResourceGroup = createTestResourceGroup();
        assertNotNull(platformResourceGroup);
        LookupUtil.getRoleManager().addResourceGroupsToRole(overlord, role.getId(),
            new int[] { platformResourceGroup.getId() });

        // allow dest/deploy create (global)
        addRolePermissions(role, Permission.DEPLOY_BUNDLES);
        BundleDestination dest1 = createDestination(subject, b1, "one", "/test", platformResourceGroup);
        assertNotNull(dest1);
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);
            resourceGroup.setResourceType(resourceType); // need to tell the group the type it is
            em.persist(resourceGroup);

            getTransactionManager().commit();
        } catch (Exception e) {
            try {
View Full Code Here

            resourcesServiceE2.get(0));
        // Intentionally greater than 200 to test an issue with Criteria fetch defaults
        List<Resource> resourcesServiceE4 = createResources(205, "RemoveTypesPlugin", "ServiceE4",
            resourcesServiceE3.get(0));

        ResourceGroup rgRecursive = createResourceGroup("ServerE Group", "ServerE", "RemoveTypesPlugin", true);
        addResourcesToGroup(rgRecursive, resourcesServerE);

        ResourceGroup rgFlat = createResourceGroup("ServiceE4 Group", "ServiceE4", "RemoveTypesPlugin", false);
        addResourcesToGroup(rgFlat, resourcesServiceE4);

        createPlugin("remove-types-plugin", "2.0", "remove_types_v2.xml");

        //Removal of this resource type exceeds default criteria page size.
View Full Code Here

        ResourceType resourceType = resourceTypeMgr.getResourceTypeByNameAndPlugin(resourceTypeName, pluginName);

        assertNotNull("Cannot create resource group. Unable to find resource type for [name: " + resourceTypeName
            + ", plugin: " + pluginName + "]", resourceType);

        ResourceGroup resourceGroup = new ResourceGroup(groupName, resourceType);
        resourceGroup.setRecursive(recursive);
        ResourceGroup result = resourceGroupMgr.createResourceGroup(subjectMgr.getOverlord(), resourceGroup);
        groupIds.add(result.getId());
        return result;
    }
View Full Code Here

    @ApiError(code = 404, reason = "Group with passed id not found")
    public Response getGroup(@ApiParam(value = "Id of the group") @PathParam("id") int id,
                             @Context HttpHeaders headers,
                             @Context UriInfo uriInfo) {

        ResourceGroup group = fetchGroup(id, false);

        GroupRest groupRest = fillGroup(group, uriInfo);

        MediaType mediaType = headers.getAcceptableMediaTypes().get(0);
View Full Code Here

        if (group==null)
            throw new BadArgumentException("A group must be provided");
        if (group.getName()==null)
            throw new BadArgumentException("A group name is required");

        ResourceGroup newGroup = new ResourceGroup(group.getName());
        if (group.getResourceTypeId()!=null) {

            ResourceType resourceType = null;
            try {
                resourceType = resourceTypeManager.getResourceTypeById(caller,group.getResourceTypeId());
                newGroup.setResourceType(resourceType);
            } catch (ResourceTypeNotFoundException e) {
                throw new StuffNotFoundException("ResourceType with id " + group.getResourceTypeId());
            }
        }

        MediaType mediaType = headers.getAcceptableMediaTypes().get(0);
        Response.ResponseBuilder builder;
        UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/group/{id}");

        try {
            newGroup = resourceGroupManager.createResourceGroup(caller, newGroup);
            URI uri = uriBuilder.build(newGroup.getId());

            builder=Response.created(uri);
        } catch (ResourceGroupAlreadyExistsException e) {

            ResourceGroupCriteria criteria = new ResourceGroupCriteria();
            criteria.setStrict(true);
            criteria.addFilterName(newGroup.getName());
            // TODO also case sensitive?
            List<ResourceGroup> groups = resourceGroupManager.findResourceGroupsByCriteria(caller,criteria);
            newGroup = groups.get(0);

            URI uri = uriBuilder.build(newGroup.getId());

            builder=Response.ok(uri);
        } catch (Exception e) {
            builder=Response.status(Response.Status.NOT_ACCEPTABLE);
            builder.type(mediaType);
            builder.entity(e.getCause());
        }

        builder.type(mediaType);
        builder.entity(fillGroup(newGroup,uriInfo));
        putToCache(newGroup.getId(),ResourceGroup.class,newGroup);

        return builder.build();
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.group.ResourceGroup

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.