[Geoserver-devel] Need some clarification on the rest API for configuring a Geoserver

Hi all,

I have found that it is often useful to install a vanilla Geoserver on, say an Amazon instance, then configure it using REST. For some reason I don’t fully understand this is more reliable that simply copying a workspace to the instance and using that. I wish I knew why that was for sure, but I suspect that overtime if you allow users to configure Geoserver who are not experts, the configuration can begin to gather cruft and perhaps get less stable or maybe simply less portable.

So one solution I thought of is to create a little program that can read a JSON file and make all the REST requests to configure Geoserver.

Two problems:

  1. Maybe it is the wrong solution or someone has already done this
  2. The way to configure the different datastores is a little mysterious. For example if I want to configure a Postgis, I can use the Geotools connection params for most of the settings on the datastore, but some like “fetch size” are harder to figure out how to set them. Is there a place/way I can look this information up?
    Thanks,

Jesse

I’ve thought of something similar before - in fact here’s a (anonymized) script I use to copy a layergroup + styles between servers:
https://github.com/dwins/gsconfig.py/blob/master/examples/copy_layergroup.py

It expects the datastores to already be configured though.

I don’t think it’s a bad idea and I also don’t know of a general tool for doing this. However as you say the documentation around the REST API is currently not very complete. As a workaround I generally set up a single layer/store/style and then inspect the document the REST API produces for a GET request. It would be good to have more complete documentation about the details of the different datastore types.

hint: A common place to look for parameters other than the datastore connection parameters is the metadata map found on most GeoServer entities.

Another idea I had for dealing with this sort of issue is to inspect the configuration (possibly offline) and try to identify portability issues such as absolute paths before copying them around. I haven’t investigated that approach at all so I’m not sure what trouble you’d run into. If you’re going to do it, it probably it makes sense to link the GeoServer main module for parsing the config options since the config format isn’t well documented or stable either.


David Winslow
OpenGeo - http://opengeo.org/

On Tue, Nov 8, 2011 at 2:36 PM, Jesse Eichar <jesse.eichar@anonymised.com> wrote:

Hi all,

I have found that it is often useful to install a vanilla Geoserver on, say an Amazon instance, then configure it using REST. For some reason I don’t fully understand this is more reliable that simply copying a workspace to the instance and using that. I wish I knew why that was for sure, but I suspect that overtime if you allow users to configure Geoserver who are not experts, the configuration can begin to gather cruft and perhaps get less stable or maybe simply less portable.

So one solution I thought of is to create a little program that can read a JSON file and make all the REST requests to configure Geoserver.

Two problems:

  1. Maybe it is the wrong solution or someone has already done this
  2. The way to configure the different datastores is a little mysterious. For example if I want to configure a Postgis, I can use the Geotools connection params for most of the settings on the datastore, but some like “fetch size” are harder to figure out how to set them. Is there a place/way I can look this information up?
    Thanks,

Jesse


RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1


Geoserver-devel mailing list
Geoserver-devel@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Thanks for the info Dave. I just wanted to make sure I didn’t miss something obvious before going through a bunch of work to reverse engineer it.

I will try to create some docs as I create my tool and submit it to you guys when done. You happy with the page formatted in Restructured Text (.rst files)? Or do you have a preference.

Second here is the feature list of the tool I am making if anyone else is interested:

  • Read a JSON configuration file describing the geoserver configuration and configure Geoserver using REST
  • Read an existing Geoserver’s configuration (using REST) and create the JSON configuration fle
  • Perform a static check of the JSON to ensure it is well formed and links between styles, layers and layer groups are all correct.
    I am doing the work on my spare time so it will be a few weeks before it is in its first version.

Jesse

On Tue, Nov 8, 2011 at 8:48 PM, David Winslow <dwinslow@anonymised.com> wrote:

I’ve thought of something similar before - in fact here’s a (anonymized) script I use to copy a layergroup + styles between servers:
https://github.com/dwins/gsconfig.py/blob/master/examples/copy_layergroup.py

It expects the datastores to already be configured though.

I don’t think it’s a bad idea and I also don’t know of a general tool for doing this. However as you say the documentation around the REST API is currently not very complete. As a workaround I generally set up a single layer/store/style and then inspect the document the REST API produces for a GET request. It would be good to have more complete documentation about the details of the different datastore types.

hint: A common place to look for parameters other than the datastore connection parameters is the metadata map found on most GeoServer entities.

Another idea I had for dealing with this sort of issue is to inspect the configuration (possibly offline) and try to identify portability issues such as absolute paths before copying them around. I haven’t investigated that approach at all so I’m not sure what trouble you’d run into. If you’re going to do it, it probably it makes sense to link the GeoServer main module for parsing the config options since the config format isn’t well documented or stable either.


David Winslow
OpenGeo - http://opengeo.org/

On Tue, Nov 8, 2011 at 2:36 PM, Jesse Eichar <jesse.eichar@anonymised.com> wrote:

Hi all,

I have found that it is often useful to install a vanilla Geoserver on, say an Amazon instance, then configure it using REST. For some reason I don’t fully understand this is more reliable that simply copying a workspace to the instance and using that. I wish I knew why that was for sure, but I suspect that overtime if you allow users to configure Geoserver who are not experts, the configuration can begin to gather cruft and perhaps get less stable or maybe simply less portable.

So one solution I thought of is to create a little program that can read a JSON file and make all the REST requests to configure Geoserver.

Two problems:

  1. Maybe it is the wrong solution or someone has already done this
  2. The way to configure the different datastores is a little mysterious. For example if I want to configure a Postgis, I can use the Geotools connection params for most of the settings on the datastore, but some like “fetch size” are harder to figure out how to set them. Is there a place/way I can look this information up?
    Thanks,

Jesse


RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1


Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

On Tue, Nov 8, 2011 at 8:36 PM, Jesse Eichar <jesse.eichar@…1757…> wrote:

Two problems:

  1. Maybe it is the wrong solution or someone has already done this
  2. The way to configure the different datastores is a little mysterious. For example if I want to configure a Postgis, I can use the Geotools connection params for most of the settings on the datastore, but some like “fetch size” are harder to figure out how to set them. Is there a place/way I can look this information up?

As you say, not all parameters are documented. However the particular example is, just googled for “geoserver fetch size”
and the first link was:

http://docs.geoserver.org/latest/en/user/data/postgis.html

For all the other ones looking into the store factory might help a bit, but generally speaking the docs
are behind the code, sometimes significantly so.

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


Just for the record the first thing I did was create a parser that can read the full Geoserver configuration using REST (full as in what can be read with REST) and that is how I got the parameters for fetch size. The problem was when I made the request some of the parameters did not take effect. Perhaps the value was illegal, I am not looking into the issues.

Thanks for all the responses.

Jesse

On Wed, Nov 9, 2011 at 8:46 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Tue, Nov 8, 2011 at 8:36 PM, Jesse Eichar <jesse.eichar@anonymised.com…> wrote:

Two problems:

  1. Maybe it is the wrong solution or someone has already done this
  2. The way to configure the different datastores is a little mysterious. For example if I want to configure a Postgis, I can use the Geotools connection params for most of the settings on the datastore, but some like “fetch size” are harder to figure out how to set them. Is there a place/way I can look this information up?

As you say, not all parameters are documented. However the particular example is, just googled for “geoserver fetch size”
and the first link was:

http://docs.geoserver.org/latest/en/user/data/postgis.html

For all the other ones looking into the store factory might help a bit, but generally speaking the docs
are behind the code, sometimes significantly so.

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf