Search in sources :

Example 11 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class DomainAdjuster method removeProfile.

private void removeProfile(final DomainClient client, final String name) throws Exception {
    // TODO replace everything below with this one line once WFCORE-808 is integrated:
    //executeForResult(Util.createRemoveOperation(PathAddress.pathAddress(PROFILE, name)), client);
    //The profile does not allow deletion unless all child resources have been removed, so remove all the subsystems
    //individually
    final PathAddress profileAddress = PathAddress.pathAddress(PROFILE, name);
    final List<String> subsystems = getAllChildrenOfType(client, profileAddress, SUBSYSTEM);
    final ModelNode compositeOp = Util.createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS);
    final ModelNode steps = compositeOp.get(STEPS);
    for (String subsystem : subsystems) {
        steps.add(Util.createRemoveOperation(profileAddress.append(SUBSYSTEM, subsystem)));
    }
    executeForResult(compositeOp, client);
    executeForResult(Util.createRemoveOperation(profileAddress), client);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 12 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class DomainAdjuster method addJaspiTestSecurityDomain.

private void addJaspiTestSecurityDomain(final DomainClient client) throws Exception {
    //Before when this test was configured via xml, there was an extra security domain for testing jaspi.
    final PathAddress domain = PathAddress.pathAddress(PROFILE, FULL_HA).append(SUBSYSTEM, SecurityExtension.SUBSYSTEM_NAME).append("security-domain", "jaspi-test");
    DomainTestUtils.executeForResult(Util.createAddOperation(domain), client);
    final PathAddress auth = domain.append(AUTHENTICATION, "jaspi");
    DomainTestUtils.executeForResult(Util.createAddOperation(auth), client);
    final PathAddress stack = auth.append("login-module-stack", "lm-stack");
    DomainTestUtils.executeForResult(Util.createAddOperation(stack), client);
    final ModelNode addLoginModule = Util.createAddOperation(stack.append("login-module", "lm"));
    addLoginModule.get("code").set("UsersRoles");
    addLoginModule.get("flag").set("required");
    addLoginModule.get("module").set("test-jaspi");
    final ModelNode options = addLoginModule.get("module-options");
    options.setEmptyList();
    options.add(new ModelNode().set("usersProperties", "${jboss.server.config.dir:}/application-users.properties"));
    options.add(new ModelNode().set("rolesProperties", "${jboss.server.config.dir:}/application-roles.properties"));
    DomainTestUtils.executeForResult(addLoginModule, client);
    final ModelNode addAuthModule = Util.createAddOperation(auth.append("auth-module", getJaspiTestAuthModuleName()));
    addAuthModule.get("code").set(getJaspiTestAuthModuleName());
    addAuthModule.get("login-module-stack-ref").set("lm-stack");
    addAuthModule.get("flag").set("${test.prop:optional}");
    DomainTestUtils.executeForResult(addAuthModule, client);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 13 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class DomainAdjuster method removeServerGroups.

private ModelNode removeServerGroups(final DomainClient client) throws Exception {
    final ModelNode op = Util.createEmptyOperation(READ_RESOURCE_OPERATION, PathAddress.pathAddress(PathElement.pathElement(SERVER_GROUP)));
    final ModelNode results = executeForResult(op, client);
    ModelNode group = null;
    for (ModelNode result : results.asList()) {
        String groupName = PathAddress.pathAddress(result.get(ADDRESS)).getLastElement().getValue();
        if (groupName.equals(OTHER_SERVER_GROUP)) {
            group = result.get(RESULT);
        } else {
            ModelNode remove = Util.createRemoveOperation(PathAddress.pathAddress(result.get(ADDRESS)));
            executeForResult(remove, client);
        }
    }
    Assert.assertNotNull(group);
    //Add main-server-group as a copy of other-server-group (cuts down on the amount of profiles needed)
    final ModelNode addMain = group.clone();
    final PathAddress mainServerGroupAddress = PathAddress.pathAddress(SERVER_GROUP, MAIN_SERVER_GROUP);
    addMain.get(OP).set(ADD);
    addMain.get(OP_ADDR).set(mainServerGroupAddress.toModelNode());
    executeForResult(addMain, client);
    return group;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 14 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class DomainAdjuster640 method replaceActiveMqWithMessaging.

private Collection<? extends ModelNode> replaceActiveMqWithMessaging(PathAddress subsystem) throws Exception {
    final List<ModelNode> list = new ArrayList<>();
    //messaging-activemq does not exist, remove it and the extension
    list.add(createRemoveOperation(subsystem));
    list.add(createRemoveOperation(PathAddress.pathAddress(EXTENSION, "org.wildfly.extension.messaging-activemq")));
    //Add legacy messaging extension
    list.add(createAddOperation(PathAddress.pathAddress(EXTENSION, "org.jboss.as.messaging")));
    //Get the subsystem add operations (since the subsystem is huge, and there is a template, use the util)
    LegacySubsystemConfigurationUtil util = new LegacySubsystemConfigurationUtil(new org.jboss.as.messaging.MessagingExtension(), "messaging", "ha", "subsystem-templates/messaging.xml");
    list.addAll(util.getSubsystemOperations());
    //Now adjust the things from the template which are not available in the legacy server
    //http acceptors and connectors are not available
    PathAddress messaging = PathAddress.pathAddress(PROFILE, "full-ha").append(SUBSYSTEM, "messaging");
    PathAddress server = messaging.append("hornetq-server", "default");
    list.add(createRemoveOperation(server.append("http-acceptor", "http-acceptor")));
    list.add(createRemoveOperation(server.append("http-acceptor", "http-acceptor-throughput")));
    list.add(createRemoveOperation(server.append("http-connector", "http-connector")));
    list.add(createRemoveOperation(server.append("http-connector", "http-connector-throughput")));
    //TODO here we should add a remote connector, for now use the in-vm one
    list.add(getWriteAttributeOperation(server.append("broadcast-group", "bg-group1"), "connectors", new ModelNode().add("in-vm")));
    return list;
}
Also used : LegacySubsystemConfigurationUtil(org.jboss.as.test.integration.domain.mixed.LegacySubsystemConfigurationUtil) PathAddress(org.jboss.as.controller.PathAddress) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode)

Example 15 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class DomainAdjuster640 method replaceUndertowWithWeb.

private Collection<? extends ModelNode> replaceUndertowWithWeb(final PathAddress subsystem) {
    final List<ModelNode> list = new ArrayList<>();
    //Undertow does not exist, remove it and the extension
    list.add(createRemoveOperation(subsystem));
    list.add(createRemoveOperation(PathAddress.pathAddress(EXTENSION, "org.wildfly.extension.undertow")));
    //Add JBoss Web extension and subsystem
    list.add(createAddOperation(PathAddress.pathAddress(EXTENSION, "org.jboss.as.web")));
    final PathAddress web = subsystem.getParent().append(SUBSYSTEM, "web");
    final ModelNode addWeb = Util.createAddOperation(web);
    addWeb.get("default-virtual-server").set("default-host");
    addWeb.get("native").set("false");
    list.add(addWeb);
    list.add(createAddOperation(web.append("configuration", "container")));
    list.add(createAddOperation(web.append("configuration", "static-resources")));
    list.add(createAddOperation(web.append("configuration", "jsp-configuration")));
    ModelNode addHttp = Util.createAddOperation(web.append("connector", "http"));
    addHttp.get("protocol").set("HTTP/1.1");
    addHttp.get("scheme").set("http");
    addHttp.get("socket-binding").set("http");
    list.add(addHttp);
    ModelNode addAjp = Util.createAddOperation(web.append("connector", "ajp"));
    addAjp.get("protocol").set("AJP/1.3");
    addAjp.get("scheme").set("http");
    addAjp.get("socket-binding").set("ajp");
    list.add(addAjp);
    ModelNode addVirtualServer = Util.createAddOperation(web.append("virtual-server", "default-host"));
    addVirtualServer.get("enable-welcome-root").set(true);
    addVirtualServer.get("alias").add("localhost").add("example.com");
    list.add(addVirtualServer);
    return list;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)644 ModelNode (org.jboss.dmr.ModelNode)492 Resource (org.jboss.as.controller.registry.Resource)70 Test (org.junit.Test)66 PathElement (org.jboss.as.controller.PathElement)63 KernelServices (org.jboss.as.subsystem.test.KernelServices)51 ServiceName (org.jboss.msc.service.ServiceName)51 OperationFailedException (org.jboss.as.controller.OperationFailedException)43 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)35 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)35 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)34 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)33 ServiceTarget (org.jboss.msc.service.ServiceTarget)32 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)31 Map (java.util.Map)30 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)29 IOException (java.io.IOException)28 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)26 ArrayList (java.util.ArrayList)25 OperationContext (org.jboss.as.controller.OperationContext)23