-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
# Geoserver STUFF | ||
|
||
## scripting | ||
Using this librairie : https://pypi.org/project/gsconfig/ | ||
|
||
But there is only few functionality | ||
|
||
```commandline | ||
# create datastore from csv | ||
python3 create_datastore_from_csv.py | ||
# publish layer from existing datastore and existing data in database | ||
python3 create_layers_from_csv.py | ||
``` | ||
|
||
## usefull commands | ||
|
||
|
||
To change all urls store in the datadir : | ||
|
||
`sed -e "s#mel.integration.apps.gs-fr-prod.camptocamp.com#data.lillemetropole.fr#g" -i $(grep mel.integration.apps * -r -l)` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from geoserver.catalog import Catalog | ||
import csv | ||
|
||
cat = Catalog("https://georchestra-127-0-1-1.traefik.me/geoserver/rest", "admin", "password") | ||
|
||
|
||
with open('list_datastore.csv', newline='') as csvfile: | ||
|
||
spamreader = csv.reader(csvfile, delimiter=',', quotechar='|') | ||
|
||
for row in spamreader: | ||
schema = row[0] | ||
|
||
print(schema) | ||
print(', '.join(row)) | ||
|
||
|
||
url = "https://georchestra-127-0-1-1.traefik.me/geoserver/" + schema +"/" | ||
print(url) | ||
try: | ||
cat.create_workspace(name=schema, uri=url) | ||
except: | ||
print("Probably already exist") | ||
pass | ||
|
||
try: | ||
ds = cat.create_datastore(name=name_suffix, workspace=schema) | ||
ds.connection_parameters.update( | ||
host="localhost", | ||
port="5432", | ||
database="gis", | ||
user="postgres", | ||
password="", | ||
dbtype="postgis", schema=schema) | ||
cat.save(ds) | ||
|
||
|
||
except: | ||
print("Error creating the datastore") | ||
pass |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from geoserver.catalog import Catalog | ||
import csv | ||
|
||
cat = Catalog("https://georchestra-127-0-1-1.traefik.me/geoserver/rest", "admin", "admin") | ||
|
||
|
||
with open('list_layers.csv', newline='') as csvfile: | ||
|
||
spamreader = csv.reader(csvfile, delimiter=',', quotechar='|') | ||
|
||
for row in spamreader: | ||
# url,schema,table_name,gs_store | ||
url = row[0] | ||
schema = row[1] | ||
table_name = row[2] | ||
gs_store = row[3] | ||
|
||
print(url, schema, table_name, gs_store) | ||
try: | ||
workspace = cat.get_workspace(name=schema) | ||
# print(workspace) | ||
datastore = cat.get_store(name=gs_store, workspace=workspace) | ||
# print(datastore) | ||
cat.publish_featuretype(name=table_name, store=datastore, native_crs='EPSG:4326', srs='EPSG:4326') | ||
except: | ||
print("already exist or not exist in DB") | ||
pass |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Schemas ,owner schema, admin_db,descriptions | ||
test,test,admin, | ||
test2,test,admin, | ||
test3,test,admin, |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
url,test,test,test | ||
url2,test,test2,test |