Source:
<code>static void updateOptionsAttribute(final OperationContext context, final ModelNode operation, final String type) throws OperationFailedException { final PathAddress operationAddress = PathAddress.pathAddress(operation.get(OP_ADDR)); final PathAddress discoveryOptionsAddress = operationAddress.subAddress(0, operationAddress.size() - 1); final ModelNode discoveryOptions = Resource.Tools.readModel(context.readResourceFromRoot(discoveryOptionsAddress)); final ModelNode node = new ModelNode(); if(ModelDescriptionConstants.CUSTOM_DISCOVERY.equals(type)) { node.get(ModelDescriptionConstants.NAME).set(operationAddress.getLastElement().getValue()); for (final AttributeDefinition attribute : DiscoveryOptionResourceDefinition.DISCOVERY_ATTRIBUTES) { attribute.validateAndSet(operation, node); } } else if(ModelDescriptionConstants.STATIC_DISCOVERY.equals(type)) { node.get(ModelDescriptionConstants.NAME).set(operationAddress.getLastElement().getValue()); for (final AttributeDefinition attribute : StaticDiscoveryResourceDefinition.STATIC_DISCOVERY_ATTRIBUTES) { attribute.validateAndSet(operation, node); } } else { throw new OperationFailedException(HostControllerLogger.ROOT_LOGGER.invalidDiscoveryType(type)); } final ModelNode list = discoveryOptions.get(ModelDescriptionConstants.OPTIONS).clone(); if (!list.isDefined()) { list.setEmptyList(); } <START> list.add(type, node); <END> final ModelNode writeOp = Util.getWriteAttributeOperation(discoveryOptionsAddress, ModelDescriptionConstants.OPTIONS, list); final OperationStepHandler writeHandler = context.getRootResourceRegistration().getSubModel(discoveryOptionsAddress).getOperationHandler(PathAddress.EMPTY_ADDRESS, WRITE_ATTRIBUTE_OPERATION); context.addStep(writeOp, writeHandler, OperationContext.Stage.MODEL, true); }</code><technical_language>This produces a list of ModelType.PROPERTY instead of list of ModelType.OBJECT ModelNode element = new ModelNode(); element.get(type).set(node); list.add(element); produce expected structure</technical_language>

Target:
static void updateOptionsAttribute(final OperationContext context, final ModelNode operation, final String type) throws OperationFailedException { final PathAddress operationAddress = PathAddress.pathAddress(operation.get(OP_ADDR)); final PathAddress discoveryOptionsAddress = operationAddress.subAddress(0, operationAddress.size() - 1); final ModelNode discoveryOptions = Resource.Tools.readModel(context.readResourceFromRoot(discoveryOptionsAddress)); final ModelNode element = new ModelNode(); if(ModelDescriptionConstants.CUSTOM_DISCOVERY.equals(type)) { final ModelNode node = element.get(ModelDescriptionConstants.CUSTOM_DISCOVERY); node.get(ModelDescriptionConstants.NAME).set(operationAddress.getLastElement().getValue()); for (final AttributeDefinition attribute : DiscoveryOptionResourceDefinition.DISCOVERY_ATTRIBUTES) { attribute.validateAndSet(operation, node); } } else if(ModelDescriptionConstants.STATIC_DISCOVERY.equals(type)) { final ModelNode node = element.get(ModelDescriptionConstants.STATIC_DISCOVERY); node.get(ModelDescriptionConstants.NAME).set(operationAddress.getLastElement().getValue()); for (final AttributeDefinition attribute : StaticDiscoveryResourceDefinition.STATIC_DISCOVERY_ATTRIBUTES) { attribute.validateAndSet(operation, node); } } else { throw new OperationFailedException(HostControllerLogger.ROOT_LOGGER.invalidDiscoveryType(type)); } final ModelNode list = discoveryOptions.get(ModelDescriptionConstants.OPTIONS).clone(); if (!list.isDefined()) { list.setEmptyList(); } list.add(element); final ModelNode writeOp = Util.getWriteAttributeOperation(discoveryOptionsAddress, ModelDescriptionConstants.OPTIONS, list); final OperationStepHandler writeHandler = context.getRootResourceRegistration().getSubModel(discoveryOptionsAddress).getOperationHandler(PathAddress.EMPTY_ADDRESS, WRITE_ATTRIBUTE_OPERATION); context.addStep(writeOp, writeHandler, OperationContext.Stage.MODEL, true); }