Last active
May 29, 2016 23:28
-
-
Save cristianzamar/fc07d0b9c88665fa709e to your computer and use it in GitHub Desktop.
Actualiza capas de GeoServer cargadas desde WMS en cascada. IMPORTANTE: las capas de origen y destino deben tener los mismos nombres. Requiere **gsconfig** --------//------- Updates GeoServer cascaded WMS layers attributes from multiple WMS origins. IMPORTANT: Origin and destination layers must have the same names. Requires **gsconfig** tool.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from geoserver.catalog import Catalog | |
origins = [ | |
["http://idef.formosa.gob.ar/mce/servicios/rest","admin","***"], | |
["http://idef.formosa.gob.ar/dpv/servicios/rest","admin","***"] | |
] | |
cat_dest = Catalog("http://localhost:8080/servicios/rest", | |
username="admin", password="***") | |
res_dest = cat_dest.get_resources() | |
count = 0 | |
for orig in origins: | |
cat_orig = Catalog(orig[0], username=orig[1], password=orig[2]) | |
for rd in res_dest: | |
#only wms layers | |
if rd.resource_type != "wmsLayer": continue | |
#looking for same name | |
ro = cat_orig.get_resource(rd.name) | |
if ro is not None: | |
rd.title = ro.title | |
rd.abstract = ro.abstract | |
rd.keywords = ro.keywords | |
rd.projection = ro.projection | |
rd.native_bbox = ro.native_bbox | |
rd.latlon_bbox = ro.latlon_bbox | |
rd.projection_policy = ro.projection_policy | |
rd.enabled = ro.enabled | |
rd.advertised = ro.advertised | |
rd.metadata_links = ro.metadata_links or [] | |
cat_dest.save(rd) | |
cat_dest.reload() | |
print "Updated layer: " + rd.name | |
count += 1 | |
print "Total updated layers: " + str(count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment