SlideShare a Scribd company logo
Geoserver Shell
Administer Geoserver using a CLI

Jared Erickson
CUGOS July 2013
Outline
• What is Geoserver Shell?
• Why does Geoserver need a CLI?
• What are we administering with CLI?
• How does it work?
• What does it look like in action?
What is it?
• Administer Geoserver from a command
line interface (CLI)

• Uses Geoserver Rest interface
• Based on Spring Shell
• Uses GeoServer Manager and GeoTools
• Written in Java
• Open Source MIT License
• Hosted on Github
Why a CLI?
• Web UI is a major feature
• Non developers can load data and styles
• CLI is quick, efficient and scriptable
• Once a script is written it can be replayed

on other Geoservers (set up dev, then test,
then production)
Geoserver UI
Geoserver Catalog
• Workspace
• Namespace
• DataStore
• FeatureType
• CoverageStore
• Coverage

• Layer
• LayerGroups
• Style
• WMSStore
Geoserver Rest
•
•
•
•
•

Administer GeoServer without GUI

•

Integrate with 3rd party applications

Multiple representations: HTML, JSON, XML
HTTP Verbs: GET, POST, PUT, DELETE
HATEOS - linking
http://docs.geoserver.org/stable/en/user/rest/
index.html
Verbs
Commands

Verbs

list

GET

get

GET

create

POST

modify

PUT

delete

DELETE
Geoserver Rest UI
/geoserver/rest/layers
Client #1 = curl
•

Upload a Shapefile

curl -v -u admin:geoserver -XPUT -H "Content-type: application/zip" --data-binary
@roads.zip http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads/
file.shp

•

Create a Workspace

curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d
"<workspace><name>acme</name></workspace>" http://localhost:8080/geoserver/rest/
workspaces
Client #2 = Python
• gsconfig.py
• https://github.com/dwins/gsconfig.py/wiki
• Used by GeoNode
>>> from geoserver.catalog import Catalog
>>> cat = Catalog("http://localhost:8080/geoserver/rest", "admin",
"geoserver")
>>> cat.get_layers()
[Layer[Arc_Sample], Layer[Pk50095], Layer[Img_Sample], ...
>>> that_layer = cat.get_layer("roads")
>>> that_layer.enabled = False
>>> cat.save(that_layer)
Client #3 = Java
• Geoserver Manager Library
• https://github.com/geosolutions-it/
geoserver-manager

GeoServerRESTReader reader = new GeoServerRESTReader(url, user, password);
RESTStyleList styleList = reader.getStyles();
List<String> names = styleList.getNames();
GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(url, user, password);
publisher.createWorkspace(name);
Github

https://github.com/jericks/geoserver-shell
Install
• Download 0.1 release
• https://github.com/jericks/geoserver-shell/
releases

• Put bin directory on path
• run gs-shell
• Requires Java
Spring Shell
• Open source project from Spring Source
• Shell extracted from Spring Roo
• Spring Roo is a Java RAD tool for creating
web apps
Spring Shell
• Interactive shell environment
• Tab completion for commands, arguments,
and files

• History support (up and down arrows)
• Knows your commands and when you can
use them
Geoserver Shell
• Commands for each major Geoserver
Catalog item

• Methods in command construct a URL,

create a request body (xml, file) and make
an Http Request to Geoserver. The
Geoserver response is parsed and displayed
to the user
Commands
geoserver

datastore

ows

workspace

shapefile

settings

version

postgis

gwc

manifest

featuretype

wmsstore

namespace

coverage stores

style

coverage

template

worldimage

font

layers
Workspace Commands
• workspace list
• workspace create --name test
• workspace get --name test
• workspace delete --name test
• workspace default get
• workspace default set --name test
Workspace
gs-shell> geoserver set --url http://localhost:8080/geoserver
gs-shell> workspace create --name naturalearth
true
gs-shell> workspace list
topp
nurc
gs-shell> workspace get --name naturalearth
naturalearth
Shapefile
gs-shell> geoserver set --url http://localhost:8080/geoserver
gs-shell> workspace create --name naturalearth
true
gs-shell> shapefile zip --shapefile 110m_admin_0_countries.shp
true
gs-shell> shapefile publish --file 110m_admin_0_countries.zip -workspace naturalearth
true
PostGIS
gs-shell> geoserver set --url http://localhost:8080/geoserver
gs-shell> workspace create --name post
gs-shell> postgis datastore create --workspace post --datastore postgis -host localhost --port 5432 --database postgres --schema public --user
postgres --password postgres
true
gs-shell> featuretype list --workspace post --datastore postgis --list available
states
countries
cities
gs-shell> postgis featuretype publish --workspace post --datastore postgis -table 110m-admin-0-countries
true
GeoTiff
gs-shell> geoserver set --url http://localhost:8080/geoserver
gs-shell> coverage store upload --workspace naturalearth --file
GRAY_50M_SR_OB.zip --coveragestore world --type worldimage -configure first
true
gs-shell> coverage list --workspace naturalearth --coveragestore world
GRAY_50M_SR_OB
BLUE_MARBLE
gs-shell> coverage modify --workspace naturalearth --coveragestore world
--coverage GRAY_50M_SR_OB --srs EPSG:4326 --enabled true
true
Styles
gs-shell> style create --file 110m_admin_0_countries.sld --name
110m_admin_0_countries
true
gs-shell> layer style add --name 110m_admin_0_countries --style
110m_admin_0_countries
true
gs-shell> layer get --name 110m_admin_0_countries
110m_admin_0_countries
Title: null
Type:VECTOR
Abstract: null
Default Style: 110m_admin_0_countries
Namespace: Type String:VECTOR

gs-shell> layer modify --name 110m_admin_0_countries --defaultStyle
110m_admin_0_countries
true
Scripts
• Scripts contain the same commands entered
interactively

• History support saves session to geoservershell.log

$ gs-shell --cmdfile mycommands.gs
gs-shell> script --file naturalearth_countries.gs
Thank you!
Jared Erickson
jared.erickson@gmail.com
https://github.com/jericks

More Related Content

PPTX
Database schema
Mahmoud Almadhoun
 
PPT
Dbms presentaion
sai kumar rachakonda
 
PDF
NoSQL Database: Classification, Characteristics and Comparison
Mayuree Srikulwong
 
PDF
Hadoop architecture-tutorial
vinayiqbusiness
 
PPT
SQL subquery
Vikas Gupta
 
ODP
Architecture of Hadoop
Knoldus Inc.
 
PPTX
vm provisioning
ROSHNI PRADHAN
 
PDF
Comparisons Wiki vs CMS
krishnapriya Tadepalli
 
Database schema
Mahmoud Almadhoun
 
Dbms presentaion
sai kumar rachakonda
 
NoSQL Database: Classification, Characteristics and Comparison
Mayuree Srikulwong
 
Hadoop architecture-tutorial
vinayiqbusiness
 
SQL subquery
Vikas Gupta
 
Architecture of Hadoop
Knoldus Inc.
 
vm provisioning
ROSHNI PRADHAN
 
Comparisons Wiki vs CMS
krishnapriya Tadepalli
 

What's hot (20)

PDF
SQL Overview
Stewart Rogers
 
PPTX
Relational Algebra1.pptx
ShivaPrasad783861
 
PDF
Generative adversarial network and its applications to speech signal and natu...
宏毅 李
 
PDF
chapter 2-DATABASE SYSTEM CONCEPTS AND architecture [Autosaved].pdf
University of Gondar
 
PDF
Database System Architecture
Vignesh Saravanan
 
PPTX
Data definition language
VENNILAV6
 
PDF
Computer Science Project pdf
nickealwilliams2
 
PPTX
Nosql seminar
Shreyashkumar Nangnurwar
 
PPT
Role based access control - RBAC
Ajit Dadresa
 
PPTX
Dbms schema &amp; instance
Papan Sarkar
 
PPTX
Nosql databases
ateeq ateeq
 
PPTX
1.Introduction to virtualization
Hwanju Kim
 
PPTX
Sql server
Fajar Baskoro
 
PPTX
introduction to NOSQL Database
nehabsairam
 
PPTX
Slide 2 data models
Visakh V
 
PPTX
Apache hive introduction
Mahmood Reza Esmaili Zand
 
PPTX
Introduction to Scala
Mohammad Hossein Rimaz
 
PPTX
Database systems - Chapter 2
shahab3
 
PPTX
Data warehouse
Yogendra Uikey
 
PDF
Introduction to ETL and Data Integration
CloverDX (formerly known as CloverETL)
 
SQL Overview
Stewart Rogers
 
Relational Algebra1.pptx
ShivaPrasad783861
 
Generative adversarial network and its applications to speech signal and natu...
宏毅 李
 
chapter 2-DATABASE SYSTEM CONCEPTS AND architecture [Autosaved].pdf
University of Gondar
 
Database System Architecture
Vignesh Saravanan
 
Data definition language
VENNILAV6
 
Computer Science Project pdf
nickealwilliams2
 
Role based access control - RBAC
Ajit Dadresa
 
Dbms schema &amp; instance
Papan Sarkar
 
Nosql databases
ateeq ateeq
 
1.Introduction to virtualization
Hwanju Kim
 
Sql server
Fajar Baskoro
 
introduction to NOSQL Database
nehabsairam
 
Slide 2 data models
Visakh V
 
Apache hive introduction
Mahmood Reza Esmaili Zand
 
Introduction to Scala
Mohammad Hossein Rimaz
 
Database systems - Chapter 2
shahab3
 
Data warehouse
Yogendra Uikey
 
Introduction to ETL and Data Integration
CloverDX (formerly known as CloverETL)
 
Ad

Similar to Geo servershell (20)

PDF
WildFly v9 - State of the Union Session at Voxxed, Istanbul, May/9th 2015.
Dimitris Andreadis
 
PPTX
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
seleniumconf
 
PPTX
JSF2
Alex Tumanoff
 
PPTX
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON
 
PDF
GoDocker presentation
Olivier Sallou
 
PDF
How to Contribute to Apache Usergrid
David M. Johnson
 
PPTX
Javascript & Jquery
Gurpreet singh
 
PDF
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
J V
 
PPTX
Liberty Deep Dive
WASdev Community
 
PDF
MariaDB 10.1 what's new and what's coming in 10.2 - Tokyo MariaDB Meetup
Colin Charles
 
PDF
Module, AMD, RequireJS
偉格 高
 
PPTX
Introduction to Node (15th May 2017)
Lucas Jellema
 
PPTX
Running Airflow Workflows as ETL Processes on Hadoop
clairvoyantllc
 
PPTX
JS - The Unknown Basics.pptx
ParveenSoni21
 
PDF
JavaScript and jQuery for SharePoint Developers
Rob Windsor
 
ODP
Groovy & Grails eXchange 2012 vert.x presentation
Stuart (Pid) Williams
 
PDF
Staying Sane with Drupal NEPHP
Oscar Merida
 
KEY
Nodejs web,db,hosting
Kenu, GwangNam Heo
 
PDF
Play Framework and Activator
Kevin Webber
 
PDF
Scala at Treasure Data
Taro L. Saito
 
WildFly v9 - State of the Union Session at Voxxed, Istanbul, May/9th 2015.
Dimitris Andreadis
 
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
seleniumconf
 
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON
 
GoDocker presentation
Olivier Sallou
 
How to Contribute to Apache Usergrid
David M. Johnson
 
Javascript & Jquery
Gurpreet singh
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
J V
 
Liberty Deep Dive
WASdev Community
 
MariaDB 10.1 what's new and what's coming in 10.2 - Tokyo MariaDB Meetup
Colin Charles
 
Module, AMD, RequireJS
偉格 高
 
Introduction to Node (15th May 2017)
Lucas Jellema
 
Running Airflow Workflows as ETL Processes on Hadoop
clairvoyantllc
 
JS - The Unknown Basics.pptx
ParveenSoni21
 
JavaScript and jQuery for SharePoint Developers
Rob Windsor
 
Groovy & Grails eXchange 2012 vert.x presentation
Stuart (Pid) Williams
 
Staying Sane with Drupal NEPHP
Oscar Merida
 
Nodejs web,db,hosting
Kenu, GwangNam Heo
 
Play Framework and Activator
Kevin Webber
 
Scala at Treasure Data
Taro L. Saito
 
Ad

Recently uploaded (20)

PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
The Future of Artificial Intelligence (AI)
Mukul
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Doc9.....................................
SofiaCollazos
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 

Geo servershell

  • 1. Geoserver Shell Administer Geoserver using a CLI Jared Erickson CUGOS July 2013
  • 2. Outline • What is Geoserver Shell? • Why does Geoserver need a CLI? • What are we administering with CLI? • How does it work? • What does it look like in action?
  • 3. What is it? • Administer Geoserver from a command line interface (CLI) • Uses Geoserver Rest interface • Based on Spring Shell • Uses GeoServer Manager and GeoTools • Written in Java • Open Source MIT License • Hosted on Github
  • 4. Why a CLI? • Web UI is a major feature • Non developers can load data and styles • CLI is quick, efficient and scriptable • Once a script is written it can be replayed on other Geoservers (set up dev, then test, then production)
  • 6. Geoserver Catalog • Workspace • Namespace • DataStore • FeatureType • CoverageStore • Coverage • Layer • LayerGroups • Style • WMSStore
  • 7. Geoserver Rest • • • • • Administer GeoServer without GUI • Integrate with 3rd party applications Multiple representations: HTML, JSON, XML HTTP Verbs: GET, POST, PUT, DELETE HATEOS - linking http://docs.geoserver.org/stable/en/user/rest/ index.html
  • 11. Client #1 = curl • Upload a Shapefile curl -v -u admin:geoserver -XPUT -H "Content-type: application/zip" --data-binary @roads.zip http://localhost:8080/geoserver/rest/workspaces/acme/datastores/roads/ file.shp • Create a Workspace curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<workspace><name>acme</name></workspace>" http://localhost:8080/geoserver/rest/ workspaces
  • 12. Client #2 = Python • gsconfig.py • https://github.com/dwins/gsconfig.py/wiki • Used by GeoNode >>> from geoserver.catalog import Catalog >>> cat = Catalog("http://localhost:8080/geoserver/rest", "admin", "geoserver") >>> cat.get_layers() [Layer[Arc_Sample], Layer[Pk50095], Layer[Img_Sample], ... >>> that_layer = cat.get_layer("roads") >>> that_layer.enabled = False >>> cat.save(that_layer)
  • 13. Client #3 = Java • Geoserver Manager Library • https://github.com/geosolutions-it/ geoserver-manager GeoServerRESTReader reader = new GeoServerRESTReader(url, user, password); RESTStyleList styleList = reader.getStyles(); List<String> names = styleList.getNames(); GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(url, user, password); publisher.createWorkspace(name);
  • 15. Install • Download 0.1 release • https://github.com/jericks/geoserver-shell/ releases • Put bin directory on path • run gs-shell • Requires Java
  • 16. Spring Shell • Open source project from Spring Source • Shell extracted from Spring Roo • Spring Roo is a Java RAD tool for creating web apps
  • 17. Spring Shell • Interactive shell environment • Tab completion for commands, arguments, and files • History support (up and down arrows) • Knows your commands and when you can use them
  • 18. Geoserver Shell • Commands for each major Geoserver Catalog item • Methods in command construct a URL, create a request body (xml, file) and make an Http Request to Geoserver. The Geoserver response is parsed and displayed to the user
  • 20. Workspace Commands • workspace list • workspace create --name test • workspace get --name test • workspace delete --name test • workspace default get • workspace default set --name test
  • 21. Workspace gs-shell> geoserver set --url http://localhost:8080/geoserver gs-shell> workspace create --name naturalearth true gs-shell> workspace list topp nurc gs-shell> workspace get --name naturalearth naturalearth
  • 22. Shapefile gs-shell> geoserver set --url http://localhost:8080/geoserver gs-shell> workspace create --name naturalearth true gs-shell> shapefile zip --shapefile 110m_admin_0_countries.shp true gs-shell> shapefile publish --file 110m_admin_0_countries.zip -workspace naturalearth true
  • 23. PostGIS gs-shell> geoserver set --url http://localhost:8080/geoserver gs-shell> workspace create --name post gs-shell> postgis datastore create --workspace post --datastore postgis -host localhost --port 5432 --database postgres --schema public --user postgres --password postgres true gs-shell> featuretype list --workspace post --datastore postgis --list available states countries cities gs-shell> postgis featuretype publish --workspace post --datastore postgis -table 110m-admin-0-countries true
  • 24. GeoTiff gs-shell> geoserver set --url http://localhost:8080/geoserver gs-shell> coverage store upload --workspace naturalearth --file GRAY_50M_SR_OB.zip --coveragestore world --type worldimage -configure first true gs-shell> coverage list --workspace naturalearth --coveragestore world GRAY_50M_SR_OB BLUE_MARBLE gs-shell> coverage modify --workspace naturalearth --coveragestore world --coverage GRAY_50M_SR_OB --srs EPSG:4326 --enabled true true
  • 25. Styles gs-shell> style create --file 110m_admin_0_countries.sld --name 110m_admin_0_countries true gs-shell> layer style add --name 110m_admin_0_countries --style 110m_admin_0_countries true gs-shell> layer get --name 110m_admin_0_countries 110m_admin_0_countries Title: null Type:VECTOR Abstract: null Default Style: 110m_admin_0_countries Namespace: Type String:VECTOR gs-shell> layer modify --name 110m_admin_0_countries --defaultStyle 110m_admin_0_countries true
  • 26. Scripts • Scripts contain the same commands entered interactively • History support saves session to geoservershell.log $ gs-shell --cmdfile mycommands.gs gs-shell> script --file naturalearth_countries.gs