Need write to standalone.xml after parsing

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Need write to standalone.xml after parsing

Stan Silvert
The Keycloak server is currently configured via a keycloak-server.json
file.  We are converting this to configuration through
standalone.xml/domain.xml.

To automatically upgrade, I need to read keycloak-server.json and write
back to standalone.xml.  I can easily add the operations to do this at
parse time.  The parser has this method:

@Override
public void readElement(final XMLExtendedStreamReader reader, final
List<ModelNode> list) throws XMLStreamException

So one way to do this is to parse keycloak-server.json at this time and
add operations to the list.

That puts everything into the management model.  But nothing will be
written to standalone.xml unless someone manually does a write operation
from CLI.

So my question is, what is the best way to accomplish this?  Is there a
good, safe way to manually trigger a flush to standalone.xml at this
point or at some later point during startup?

Stan
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need write to standalone.xml after parsing

Ken Wills
On Wed, Aug 3, 2016 at 2:02 PM, Stan Silvert <[hidden email]> wrote:
On 8/3/2016 2:49 PM, Ken Wills wrote:
On Wed, Aug 3, 2016 at 8:53 AM, Stan Silvert <[hidden email]> wrote:
The Keycloak server is currently configured via a keycloak-server.json
file.  We are converting this to configuration through
standalone.xml/domain.xml.

To automatically upgrade, I need to read keycloak-server.json and write
back to standalone.xml.  I can easily add the operations to do this at
parse time.  The parser has this method:

@Override
public void readElement(final XMLExtendedStreamReader reader, final
List<ModelNode> list) throws XMLStreamException

So one way to do this is to parse keycloak-server.json at this time and
add operations to the list.

That puts everything into the management model.  But nothing will be
written to standalone.xml unless someone manually does a write operation
from CLI.


Not sure if this is exactly what you're looking for, but subsystems / extensions usually register an XMLElementWriter for themselves to handle this, see for exmaple:


Ken 

My problem is that the XMLElementWriter is never called during startup.   I would like it to be called after the management model is read from standalone.xml but before deployments are handled.

Hmm. Not sure about that one, I"ll have a look. 

PS: Sorry for replying only to you, I mean't to include the list too. [cc: wildfly-dev added back.]


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need write to standalone.xml after parsing

James Perkins
In reply to this post by Stan Silvert


On Wed, Aug 3, 2016 at 6:53 AM, Stan Silvert <[hidden email]> wrote:
The Keycloak server is currently configured via a keycloak-server.json
file.  We are converting this to configuration through
standalone.xml/domain.xml.

To automatically upgrade, I need to read keycloak-server.json and write
back to standalone.xml.  I can easily add the operations to do this at
parse time.  The parser has this method:

@Override
public void readElement(final XMLExtendedStreamReader reader, final
List<ModelNode> list) throws XMLStreamException

Reading an external resource from the subsystem parsing doesn't feel right to me. Is the goal to move away from the keycloak-server.json to using the management model?

If that is the goal then a better solution might be to have some sort of migration operation that would read the file and create the subsystem model. Then after that the keycloak-server.json is ignored and the *.xml file will be used.
 

So one way to do this is to parse keycloak-server.json at this time and
add operations to the list.

That puts everything into the management model.  But nothing will be
written to standalone.xml unless someone manually does a write operation
from CLI.

A write will be triggered if you make a change to the management model.
 

So my question is, what is the best way to accomplish this?  Is there a
good, safe way to manually trigger a flush to standalone.xml at this
point or at some later point during startup?

Not really an answer, but I hope there is not a way to trigger a write :)
 

Stan
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev



--
James R. Perkins
JBoss by Red Hat

_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need write to standalone.xml after parsing

James Perkins


On Wed, Aug 3, 2016 at 12:58 PM, James Perkins <[hidden email]> wrote:


On Wed, Aug 3, 2016 at 6:53 AM, Stan Silvert <[hidden email]> wrote:
The Keycloak server is currently configured via a keycloak-server.json
file.  We are converting this to configuration through
standalone.xml/domain.xml.

To automatically upgrade, I need to read keycloak-server.json and write
back to standalone.xml.  I can easily add the operations to do this at
parse time.  The parser has this method:

@Override
public void readElement(final XMLExtendedStreamReader reader, final
List<ModelNode> list) throws XMLStreamException

Reading an external resource from the subsystem parsing doesn't feel right to me. Is the goal to move away from the keycloak-server.json to using the management model?

If that is the goal then a better solution might be to have some sort of migration operation that would read the file and create the subsystem model. Then after that the keycloak-server.json is ignored and the *.xml file will be used.
 

So one way to do this is to parse keycloak-server.json at this time and
add operations to the list.

That puts everything into the management model.  But nothing will be
written to standalone.xml unless someone manually does a write operation
from CLI.

A write will be triggered if you make a change to the management model.

I need to correct myself here. Persistence won't happen during a boot. So when I say the management model needs to change what I mean is after boot it needs to change for the write to persistent storage will be invoked.
 
 

So my question is, what is the best way to accomplish this?  Is there a
good, safe way to manually trigger a flush to standalone.xml at this
point or at some later point during startup?

Not really an answer, but I hope there is not a way to trigger a write :)
 

Stan
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev



--
James R. Perkins
JBoss by Red Hat



--
James R. Perkins
JBoss by Red Hat

_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need write to standalone.xml after parsing

Stan Silvert
In reply to this post by James Perkins
On 8/3/2016 3:58 PM, James Perkins wrote:


On Wed, Aug 3, 2016 at 6:53 AM, Stan Silvert <[hidden email]> wrote:
The Keycloak server is currently configured via a keycloak-server.json
file.  We are converting this to configuration through
standalone.xml/domain.xml.

To automatically upgrade, I need to read keycloak-server.json and write
back to standalone.xml.  I can easily add the operations to do this at
parse time.  The parser has this method:

@Override
public void readElement(final XMLExtendedStreamReader reader, final
List<ModelNode> list) throws XMLStreamException

Reading an external resource from the subsystem parsing doesn't feel right to me. Is the goal to move away from the keycloak-server.json to using the management model?
Yes, that's the goal.  I'd like it to happen automatically when the server is upgraded to a new version of the Keycloak subsystem.  So we need to read keyclaok-server.json and write to standalone.xml/domain.xml.

If that is the goal then a better solution might be to have some sort of migration operation that would read the file and create the subsystem model. Then after that the keycloak-server.json is ignored and the *.xml file will be used.
That's exactly what I am trying to accomplish.  I can create the subsystem model easily.  But a write to standalone.xml doesn't happen during server startup.
 

So one way to do this is to parse keycloak-server.json at this time and
add operations to the list.

That puts everything into the management model.  But nothing will be
written to standalone.xml unless someone manually does a write operation
from CLI.

A write will be triggered if you make a change to the management model.
 

So my question is, what is the best way to accomplish this?  Is there a
good, safe way to manually trigger a flush to standalone.xml at this
point or at some later point during startup?

Not really an answer, but I hope there is not a way to trigger a write :)
This could be done without harm as long as it is managed properly. 

If there is no way to do it then I'll have to make it a separate operation that the administrator has to run using offline CLI.  That's far from ideal as I would rather it happen automatically as part of the upgrade.
 

Stan
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev



--
James R. Perkins
JBoss by Red Hat


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need write to standalone.xml after parsing

James Perkins


On Thu, Aug 4, 2016 at 4:22 AM, Stan Silvert <[hidden email]> wrote:
On 8/3/2016 3:58 PM, James Perkins wrote:


On Wed, Aug 3, 2016 at 6:53 AM, Stan Silvert <[hidden email]> wrote:
The Keycloak server is currently configured via a keycloak-server.json
file.  We are converting this to configuration through
standalone.xml/domain.xml.

To automatically upgrade, I need to read keycloak-server.json and write
back to standalone.xml.  I can easily add the operations to do this at
parse time.  The parser has this method:

@Override
public void readElement(final XMLExtendedStreamReader reader, final
List<ModelNode> list) throws XMLStreamException

Reading an external resource from the subsystem parsing doesn't feel right to me. Is the goal to move away from the keycloak-server.json to using the management model?
Yes, that's the goal.  I'd like it to happen automatically when the server is upgraded to a new version of the Keycloak subsystem.  So we need to read keyclaok-server.json and write to standalone.xml/domain.xml.

If that is the goal then a better solution might be to have some sort of migration operation that would read the file and create the subsystem model. Then after that the keycloak-server.json is ignored and the *.xml file will be used.
That's exactly what I am trying to accomplish.  I can create the subsystem model easily.  But a write to standalone.xml doesn't happen during server startup.

It's designed to never write at startup because during boot the the configuration is read and we shouldn't modify without the user acknowledging there is going to be a change. That's why a migration operation would be preferred as it's explicit.
 

 

So one way to do this is to parse keycloak-server.json at this time and
add operations to the list.

That puts everything into the management model.  But nothing will be
written to standalone.xml unless someone manually does a write operation
from CLI.

A write will be triggered if you make a change to the management model.
 

So my question is, what is the best way to accomplish this?  Is there a
good, safe way to manually trigger a flush to standalone.xml at this
point or at some later point during startup?

Not really an answer, but I hope there is not a way to trigger a write :)
This could be done without harm as long as it is managed properly. 

The only time this would ever be needed is during a boot. I really think it's a bad idea to modify persistent configuration during a boot. The user has no idea this is being done.
 


If there is no way to do it then I'll have to make it a separate operation that the administrator has to run using offline CLI.  That's far from ideal as I would rather it happen automatically as part of the upgrade.

IMO an upgrade or patch is an explicit action. It requires some kind of interaction and expecting a user to execute an operation after a component upgrade doesn't seem unreasonable to me.

An option for the future will be to use the new provisioning [1].

 

 

Stan
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev



--
James R. Perkins
JBoss by Red Hat




--
James R. Perkins
JBoss by Red Hat

_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need write to standalone.xml after parsing

Stuart Douglas
In reply to this post by Stan Silvert
Longer term we have started looking at a provisioning system that should (hopefully) handle the problem of making management model changes on upgrade.

I don't really understand why you need this functionality anyway, as you will already have to issue management ops to actually add the new subsystem to the server. Whatever is responsible for this could already read the json file and issue the appropriate management operations.

Stuart

On Thu, Aug 4, 2016 at 9:22 PM, Stan Silvert <[hidden email]> wrote:
On 8/3/2016 3:58 PM, James Perkins wrote:


On Wed, Aug 3, 2016 at 6:53 AM, Stan Silvert <[hidden email]> wrote:
The Keycloak server is currently configured via a keycloak-server.json
file.  We are converting this to configuration through
standalone.xml/domain.xml.

To automatically upgrade, I need to read keycloak-server.json and write
back to standalone.xml.  I can easily add the operations to do this at
parse time.  The parser has this method:

@Override
public void readElement(final XMLExtendedStreamReader reader, final
List<ModelNode> list) throws XMLStreamException

Reading an external resource from the subsystem parsing doesn't feel right to me. Is the goal to move away from the keycloak-server.json to using the management model?
Yes, that's the goal.  I'd like it to happen automatically when the server is upgraded to a new version of the Keycloak subsystem.  So we need to read keyclaok-server.json and write to standalone.xml/domain.xml.

If that is the goal then a better solution might be to have some sort of migration operation that would read the file and create the subsystem model. Then after that the keycloak-server.json is ignored and the *.xml file will be used.
That's exactly what I am trying to accomplish.  I can create the subsystem model easily.  But a write to standalone.xml doesn't happen during server startup.
 

So one way to do this is to parse keycloak-server.json at this time and
add operations to the list.

That puts everything into the management model.  But nothing will be
written to standalone.xml unless someone manually does a write operation
from CLI.

A write will be triggered if you make a change to the management model.
 

So my question is, what is the best way to accomplish this?  Is there a
good, safe way to manually trigger a flush to standalone.xml at this
point or at some later point during startup?

Not really an answer, but I hope there is not a way to trigger a write :)
This could be done without harm as long as it is managed properly. 

If there is no way to do it then I'll have to make it a separate operation that the administrator has to run using offline CLI.  That's far from ideal as I would rather it happen automatically as part of the upgrade.
 

Stan
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev



--
James R. Perkins
JBoss by Red Hat


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need write to standalone.xml after parsing

Stan Silvert
On 8/4/2016 8:22 PM, Stuart Douglas wrote:
Longer term we have started looking at a provisioning system that should (hopefully) handle the problem of making management model changes on upgrade.

I don't really understand why you need this functionality anyway, as you will already have to issue management ops to actually add the new subsystem to the server. Whatever is responsible for this could already read the json file and issue the appropriate management operations.
The subsystem already exists, but we are adding lots of attributes and resources to it.  I can add the management operations at parse time, but the new attributes and resources will not be persisted to standalone.xml.

Stuart

On Thu, Aug 4, 2016 at 9:22 PM, Stan Silvert <[hidden email]> wrote:
On 8/3/2016 3:58 PM, James Perkins wrote:


On Wed, Aug 3, 2016 at 6:53 AM, Stan Silvert <[hidden email]> wrote:
The Keycloak server is currently configured via a keycloak-server.json
file.  We are converting this to configuration through
standalone.xml/domain.xml.

To automatically upgrade, I need to read keycloak-server.json and write
back to standalone.xml.  I can easily add the operations to do this at
parse time.  The parser has this method:

@Override
public void readElement(final XMLExtendedStreamReader reader, final
List<ModelNode> list) throws XMLStreamException

Reading an external resource from the subsystem parsing doesn't feel right to me. Is the goal to move away from the keycloak-server.json to using the management model?
Yes, that's the goal.  I'd like it to happen automatically when the server is upgraded to a new version of the Keycloak subsystem.  So we need to read keyclaok-server.json and write to standalone.xml/domain.xml.

If that is the goal then a better solution might be to have some sort of migration operation that would read the file and create the subsystem model. Then after that the keycloak-server.json is ignored and the *.xml file will be used.
That's exactly what I am trying to accomplish.  I can create the subsystem model easily.  But a write to standalone.xml doesn't happen during server startup.
 

So one way to do this is to parse keycloak-server.json at this time and
add operations to the list.

That puts everything into the management model.  But nothing will be
written to standalone.xml unless someone manually does a write operation
from CLI.

A write will be triggered if you make a change to the management model.
 

So my question is, what is the best way to accomplish this?  Is there a
good, safe way to manually trigger a flush to standalone.xml at this
point or at some later point during startup?

Not really an answer, but I hope there is not a way to trigger a write :)
This could be done without harm as long as it is managed properly. 

If there is no way to do it then I'll have to make it a separate operation that the administrator has to run using offline CLI.  That's far from ideal as I would rather it happen automatically as part of the upgrade.
 

Stan
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev



--
James R. Perkins
JBoss by Red Hat


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev



_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need write to standalone.xml after parsing

Darran Lofthouse
But maybe that could be fine, on the next boot if no modifications were
made to the config you could go through the same boot process and read
the json again - if something triggered the save then the json reading
can be skipped.  I assume you already have something in place to detect
is parsing of the json is required?

There are also a group of users out there that want their configuration
to be read only so this would cover those as well.

Darran.

On 05/08/16 12:16, Stan Silvert wrote:

> On 8/4/2016 8:22 PM, Stuart Douglas wrote:
>> Longer term we have started looking at a provisioning system that
>> should (hopefully) handle the problem of making management model
>> changes on upgrade.
>>
>> I don't really understand why you need this functionality anyway, as
>> you will already have to issue management ops to actually add the new
>> subsystem to the server. Whatever is responsible for this could
>> already read the json file and issue the appropriate management
>> operations.
> The subsystem already exists, but we are adding lots of attributes and
> resources to it.  I can add the management operations at parse time, but
> the new attributes and resources will not be persisted to standalone.xml.
>>
>> Stuart
>>
>> On Thu, Aug 4, 2016 at 9:22 PM, Stan Silvert <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     On 8/3/2016 3:58 PM, James Perkins wrote:
>>>
>>>
>>>     On Wed, Aug 3, 2016 at 6:53 AM, Stan Silvert <[hidden email]
>>>     <mailto:[hidden email]>> wrote:
>>>
>>>         The Keycloak server is currently configured via a
>>>         keycloak-server.json
>>>         file.  We are converting this to configuration through
>>>         standalone.xml/domain.xml.
>>>
>>>         To automatically upgrade, I need to read keycloak-server.json
>>>         and write
>>>         back to standalone.xml.  I can easily add the operations to
>>>         do this at
>>>         parse time.  The parser has this method:
>>>
>>>         @Override
>>>         public void readElement(final XMLExtendedStreamReader reader,
>>>         final
>>>         List<ModelNode> list) throws XMLStreamException
>>>
>>>
>>>     Reading an external resource from the subsystem parsing doesn't
>>>     feel right to me. Is the goal to move away from the
>>>     keycloak-server.json to using the management model?
>>     Yes, that's the goal.  I'd like it to happen automatically when
>>     the server is upgraded to a new version of the Keycloak
>>     subsystem.  So we need to read keyclaok-server.json and write to
>>     standalone.xml/domain.xml.
>>>
>>>     If that is the goal then a better solution might be to have some
>>>     sort of migration operation that would read the file and create
>>>     the subsystem model. Then after that the keycloak-server.json is
>>>     ignored and the *.xml file will be used.
>>     That's exactly what I am trying to accomplish.  I can create the
>>     subsystem model easily.  But a write to standalone.xml doesn't
>>     happen during server startup.
>>>
>>>
>>>
>>>         So one way to do this is to parse keycloak-server.json at
>>>         this time and
>>>         add operations to the list.
>>>
>>>         That puts everything into the management model.  But nothing
>>>         will be
>>>         written to standalone.xml unless someone manually does a
>>>         write operation
>>>         from CLI.
>>>
>>>
>>>     A write will be triggered if you make a change to the management
>>>     model.
>>>
>>>
>>>
>>>         So my question is, what is the best way to accomplish this?
>>>         Is there a
>>>         good, safe way to manually trigger a flush to standalone.xml
>>>         at this
>>>         point or at some later point during startup?
>>>
>>>
>>>     Not really an answer, but I hope there is not a way to trigger a
>>>     write :)
>>     This could be done without harm as long as it is managed properly.
>>
>>     If there is no way to do it then I'll have to make it a separate
>>     operation that the administrator has to run using offline CLI.
>>     That's far from ideal as I would rather it happen automatically as
>>     part of the upgrade.
>>>
>>>
>>>
>>>         Stan
>>>         _______________________________________________
>>>         wildfly-dev mailing list
>>>         [hidden email] <mailto:[hidden email]>
>>>         https://lists.jboss.org/mailman/listinfo/wildfly-dev
>>>         <https://lists.jboss.org/mailman/listinfo/wildfly-dev>
>>>
>>>
>>>
>>>
>>>     --
>>>     James R. Perkins
>>>     JBoss by Red Hat
>>
>>
>>     _______________________________________________
>>     wildfly-dev mailing list
>>     [hidden email] <mailto:[hidden email]>
>>     https://lists.jboss.org/mailman/listinfo/wildfly-dev
>>     <https://lists.jboss.org/mailman/listinfo/wildfly-dev>
>>
>>
>
>
>
> _______________________________________________
> wildfly-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Loading...