/** * Checks that the transformed model is the same as the model built up in the legacy subsystem controller via the transformed operations, * and that the transformed model is valid according to the resource definition in the legacy subsystem controller. * * @param kernelServices the main kernel services * @param modelVersion the model version of the targetted legacy subsystem * @param legacyModelFixer use to touch up the model read from the legacy controller, use sparingly when the legacy model is just wrong. May be {@code null} * @return the whole model of the legacy controller */ ModelNode checkSubsystemModelTransformation(KernelServices kernelServices, ModelVersion modelVersion, ModelFixer legacyModelFixer) throws IOException { KernelServices legacy = kernelServices.getLegacyServices(modelVersion); ModelNode legacyModel = legacy.readWholeModel(); ModelNode legacySubsystem = legacyModel.require(SUBSYSTEM); legacySubsystem = legacySubsystem.require(mainSubsystemName); if (legacyModelFixer != null) { legacySubsystem = legacyModelFixer.fixModel(legacySubsystem); } //1) Check that the transformed model is the same as the whole model read from the legacy controller. //The transformed model is done via the resource transformers //The model in the legacy controller is built up via transformed operations ModelNode transformed = kernelServices.readTransformedModel(modelVersion).get(SUBSYSTEM, mainSubsystemName); ModelTestUtils.compare(legacySubsystem, transformed, true); //2) Check that the transformed model is valid according to the resource definition in the legacy subsystem controller ResourceDefinition rd = TransformerRegistry.loadSubsystemDefinitionFromFile(this.getClass(), mainSubsystemName, modelVersion); Assert.assertNotNull("Could not load legacy dmr for subsystem '" + mainSubsystemName + "' version: '" + modelVersion + "' please add it", rd); ManagementResourceRegistration rr = ManagementResourceRegistration.Factory.create(rd); ModelTestUtils.checkModelAgainstDefinition(transformed, rr); return legacyModel; }
final ServiceTarget target = context.getChildTarget(); final ExecutorService executorService = injectedExecutorService.getOptionalValue(); ManagementResourceRegistration rootResourceRegistration = rootDescriptionProvider != null ? ManagementResourceRegistration.Factory.create(rootDescriptionProvider) : ManagementResourceRegistration.Factory.create(rootResourceDefinition); final ModelControllerImpl controller = new ModelControllerImpl(container, target, rootResourceRegistration,
authorizerConfig.reset(); ManagementResourceRegistration rootResourceRegistration = rootDescriptionProvider != null ? ManagementResourceRegistration.Factory.create(rootDescriptionProvider, authorizerConfig) : ManagementResourceRegistration.Factory.create(rootResourceDefinition, authorizerConfig); final ModelControllerImpl controller = new ModelControllerImpl(container, target, rootResourceRegistration,
@Override public void transformResource(final ResourceTransformationContext context, final PathAddress address, final Resource resource) { // Transform the model recursively final ModelNode recursive = Resource.Tools.readModel(resource); final ModelNode result = transformModel(context, recursive); // Create the target registration based on the old resource definition final TransformationTarget target = context.getTarget(); final ResourceDefinition definition = loader.load(target); final ManagementResourceRegistration targetDefinition = ManagementResourceRegistration.Factory.create(definition); final Resource transformed = TransformationUtils.modelToResource(address, targetDefinition, result, false); // Add the model recursively context.addTransformedRecursiveResource(PathAddress.EMPTY_ADDRESS, transformed); }
@Override public void transformResource(final ResourceTransformationContext context, final PathAddress address, final Resource resource) { // Transform the model recursively final ModelNode recursive = Resource.Tools.readModel(resource); final ModelNode result = transformModel(context, recursive); // Create the target registration based on the old resource definition final TransformationTarget target = context.getTarget(); final ResourceDefinition definition = loader.load(target); final ManagementResourceRegistration targetDefinition = ManagementResourceRegistration.Factory.create(definition); final Resource transformed = TransformationUtils.modelToResource(address, targetDefinition, result, false); // Add the model recursively context.addTransformedRecursiveResource(PathAddress.EMPTY_ADDRESS, transformed); }
/** * Create a new root model node registration. * * @param rootModelDescriptionProvider the model description provider for the root model node * @return the new root model node registration * * @throws SecurityException if the caller does not have {@link ImmutableManagementResourceRegistration#ACCESS_PERMISSION} */ public static ManagementResourceRegistration create(final DescriptionProvider rootModelDescriptionProvider) { return create(rootModelDescriptionProvider, null); }
/** * Create a new root model node registration. * * @param resourceDefinition the facotry for the model description provider for the root model node * @return the new root model node registration * * @throws SecurityException if the caller does not have {@link ImmutableManagementResourceRegistration#ACCESS_PERMISSION} */ public static ManagementResourceRegistration create(final ResourceDefinition resourceDefinition) { return create(resourceDefinition, null); }
private ManagementResourceRegistration getDummyRegistration() { return ManagementResourceRegistration.Factory.create(new DescriptionProvider() { @Override public ModelNode getModelDescription(Locale locale) { return new ModelNode(); } }); }
private ManagementResourceRegistration getDummyRegistration() { return ManagementResourceRegistration.Factory.create(new DescriptionProvider() { @Override public ModelNode getModelDescription(Locale locale) { return new ModelNode(); } }); }