[GeoNode-devel] First implementation of Layer migration scripts using JSON fixtures

Alessio Fabiani alessio.fabiani at geo-solutions.it
Wed Mar 2 07:06:07 PST 2016


Dear all,
please find here

https://github.com/GeoNode/geonode/commit/f10163a3ffdb73a4bdfdedc0308427d014354ec4

a first implementation of a script able to use the JSON fixtures backedup
by backup command, mangle them and add the layers and maps (along with
attributes and metadata) to a GeoNode instance.

The script is able to import also Layers and Maps from GeoNode 2.0
accordingly to the configuration.

Notice that the script ADDs the resources to an existing instance, even if
it has Layers and Maps already configured. Just be sure to not add
duplicates otherwise GeoNode will complain about it.

*WARNING: *Still missing the GeoServer automatic part. The GeoServer data
for the moment must be replicated manually. This is a work-in-progress.

*NOTICE:* Working on converting the script into a DJango management command
like the backup and restore ones.

How the script works
===================

1. It needs basically two things:

   a) JSON fixtures from GN 2.0 or 2.4 in a zip file (those can be obtained
using the backup command)

   b) An existing user defined into the target GeoNode which will became
the new owner of the layers.

2. Edit the settings.ini file as follows:

[targetdb]
dbname = geonode_rst
host   = localhost
port   = 5432
user   = geonode
passwd = geonode

[fixtures]
#NOTE: Order is important
apps   =
people,account,avatar.avatar,base.license,base.topiccategory,base.region,base.resourcebase,base.contactrole,base.link,base.restrictioncodetype,base.spatialrepresentationtype,guardian.userobjectpermission,guardian.groupobjectpermission,layers.uploadsession,layers.layer,layers.attribute,maps.map,maps.maplayer,documents.document,taggit

dumps  =
people,accounts,avatars,licenses,topiccategories,regions,resourcebases,contactroles,links,restrictioncodetypes,spatialrepresentationtypes,useropermissions,groupopermissions,uploadsessions,layers,attributes,maps,maplayers,documents,tags

# Migrate from GN 2.0 to GN 2.4
#migrations =
base.resourcebase,layers.layer,layers.attribute,maps.map,maps.maplayer
#manglers   =
gn20_to_24.ResourceBaseMangler,gn20_to_24.LayerMangler,gn20_to_24.LayerAttributesMangler,gn20_to_24.MapMangler,gn20_to_24.MapLayersMangler

# Migrate from GN 2.4 to GN 2.4
*migrations =
base.resourcebase,layers.layer,layers.attribute,maps.map,maps.maplayer*
*manglers   =
gn24_to_24.ResourceBaseMangler,gn24_to_24.LayerMangler,gn24_to_24.LayerAttributesMangler,gn24_to_24.DefaultMangler,gn24_to_24.MapLayersMangler*


*NOTICE* that the setting file associates specific *manglers* to the
geonode apps. They can still be customized accordingly to your needs or you
can implement your own ones.

3. Launch the migration as follows:

python migrate_layers.py <backup_zip_file> <owner>

e.g.: python migrate_layers.py backup/2016-02-25_180915.zip admin


And that's it.
If everything goes fine you will find the new Layers and Maps on GeoNode.

*NOTICE *that the script computes automatically the primary keys for the
new resources.

Best Regards,
Alessio Fabiani.

==
GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.
==

Ing. Alessio Fabiani
@alfa7691
Founder/Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax:     +39 0584 1660272
mob:   +39 331 6233686

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.



The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility  for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.

---------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-devel/attachments/20160302/6c6591b1/attachment.html>


More information about the geonode-devel mailing list