Skip to content

Commit

Permalink
Merge pull request #6 from GeoNode/master
Browse files Browse the repository at this point in the history
Merge changes from GeoNode/geonode
  • Loading branch information
Jonathan Doig authored May 16, 2019
2 parents 8c4d195 + c2f0e6d commit e6aa6a7
Show file tree
Hide file tree
Showing 27 changed files with 724 additions and 201 deletions.
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.. raw:: html
.. code:: html

<div align="right">
<a href="http://travis-ci.org/GeoNode/geonode"><img src="https://secure.travis-ci.org/GeoNode/geonode.png"></a> <a href="https://codecov.io/gh/GeoNode/geonode"><img src="https://codecov.io/gh/GeoNode/geonode/branch/master/graph/badge.svg"></a> <a href="https://www.gnu.org/licenses/gpl-3.0.en.html"><img src="docs/img/gpl.png" alt="GPL badge"></a></div><img src="docs/img/geonode-logo_for_readme.gif" alt="GeoNode Logo" width="450px"/><div style="text-align:center"><hr><b>A powerful yet easy to use web-based application and platform for deploying spatial data infrastructures (SDI).</b><hr></div>



Table of Contents
----------------
-----------------

- `What is GeoNode? <#what-is-geonode>`__
- `Try out GeoNode <#try-out-geonode>`__
Expand Down Expand Up @@ -53,11 +53,11 @@ Workshop <http://docs.geonode.org/en/master/tutorials/users/index.html>`__.
Install
-------

The latest official release is 2.8!
The latest official release is 2.8.2!

GeoNode can be setup in different ways, flavors and plattforms. If
you´re planning to do development or install for production please visit
the offical GeoNode installation documentation:
the offical GeoNode installation documentation:

- `Docker <http://docs.geonode.org/en/master/tutorials/install_and_admin/running_docker/index.html>`__
- `VM Setup with VirtualBox <http://docs.geonode.org/en/master/tutorials/install_and_admin/vm_setup_virtualbox.html>`__
Expand All @@ -78,7 +78,7 @@ and configuration settings.
Development
-----------

.. raw:: html
.. code:: html

<img src="docs/img/opensource.png">

Expand Down
52 changes: 52 additions & 0 deletions docs/tutorials/admin/admin_mgmt_commands/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,55 @@ Usage::

# remove layers which are broken
python manage.py find_geoserver_broken_layers --remove


set_layers_permissions
======================

Set/Unset permissions on layers for users and groups.

Usage::

python manage.py set_layers_permissions [-h] [--version] [-v {0,1,2,3}]
[--settings SETTINGS]
[--pythonpath PYTHONPATH]
[--traceback] [--no-color]
[-r [RESOURCES [RESOURCES ...]]]
[-p PERMISSION]
[-u [USERS [USERS ...]]]
[-g [GROUPS [GROUPS ...]]]
[-d]

At least one user or one group is required.
If no resources are typed all the layers will be considered.
At least one permission must be typed.
Multiple inputs can be typed with white space separator.
To unset permissions use the '--delete (-d)' option.


Arguments::

-h, --help show this help message and exit
--version show program's version number and exit
-v {0,1,2,3}, --verbosity {0,1,2,3}
Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
--settings SETTINGS The Python path to a settings module, e.g. "myproject.settings.main".
If this isn't provided, the DJANGO_SETTINGS_MODULE environment variable will be used.
--pythonpath PYTHONPATH
A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
--traceback Raise on CommandError exceptions
--no-color Don't colorize the command output.
-r [RESOURCES [RESOURCES ...]], --resources [RESOURCES [RESOURCES ...]]
Resources names for which permissions will be assigned to.
Default value: None (all the layers will be considered).
Multiple choices can be typed with white space separator.
A Note: names with white spaces must be typed inside quotation marks.
-p PERMISSION, --permission PERMISSION
Permissions to be assigned. Allowed values are: read (r), write (w), download (d) and owner (o).
-u [USERS [USERS ...]], --users [USERS [USERS ...]]
Users for which permissions will be assigned to.
Multiple choices can be typed with white space separator.
-g [GROUPS [GROUPS ...]], --groups [GROUPS [GROUPS ...]]
Groups for which permissions will be assigned to.
Multiple choices can be typed with white space separator.
-d, --delete Delete permission if it exists.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Launch the stack with the build of GeoNode so any changes you did will be immedi
docker-compose -f docker-compose.yml -f docker-compose.override.localhost.yml up --build

.. note::
**docker-compose.override.localhost.yml** containse environment variables to allow you run the instances on *localhost*. You can use this file as template in order to run on other public addresses.
**docker-compose.override.localhost.yml** contains environment variables to allow you run the instances on *localhost*. You can use this file as template in order to run on other public addresses.

.. note::
**For Windows users**: In case you're using the native Docker for Windows (on Hyper-V) you will probably be affected by an error related to mounting the /var/run/docker.sock volume. It's due to a `problem with the current version of Docker Compose <https://github.com/docker/for-win/issues/1829>`_ for Windows.
Expand Down
9 changes: 6 additions & 3 deletions geonode/base/management/commands/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def create_geoserver_backup(self, settings, target_folder):

gs_bk_exec_id = gs_backup['backup']['execution']['id']
r = requests.get(url + 'rest/br/backup/' + str(gs_bk_exec_id) + '.json',
auth=HTTPBasicAuth(user, passwd))
auth=HTTPBasicAuth(user, passwd),
timeout=10)
if (r.status_code == 200):

try:
Expand All @@ -130,7 +131,8 @@ def create_geoserver_backup(self, settings, target_folder):

gs_bk_exec_id = gs_backup['backup']['execution']['id']
r = requests.get(url + 'rest/br/backup/' + str(gs_bk_exec_id) + '.json',
auth=HTTPBasicAuth(user, passwd))
auth=HTTPBasicAuth(user, passwd),
timeout=10)
if (r.status_code == 200):
gs_bk_exec_status = gs_backup['backup']['execution']['status']
gs_bk_exec_progress = gs_backup['backup']['execution']['progress']
Expand All @@ -139,7 +141,8 @@ def create_geoserver_backup(self, settings, target_folder):
if (gs_bk_exec_progress != gs_bk_exec_progress_updated):
gs_bk_exec_progress_updated = gs_bk_exec_progress
r = requests.get(url + 'rest/br/backup/' + str(gs_bk_exec_id) + '.json',
auth=HTTPBasicAuth(user, passwd))
auth=HTTPBasicAuth(user, passwd),
timeout=10)
if (r.status_code == 200):

try:
Expand Down
31 changes: 30 additions & 1 deletion geonode/base/management/commands/fixoauthuri.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,44 @@ class Command(BaseCommand):
"""
can_import_settings = True

def add_arguments(self, parser):

# Named (optional) arguments
parser.add_argument(
'-f',
'--force',
action='store_true',
dest='force_exec',
default=False,
help='Forces the regeneration of OAUth keys.')

parser.add_argument(
'--target-address',
dest='target_address',
help='Target Address (the one to be changed e.g. http://my-public.geonode.org)')

def handle(self, *args, **options):

force_exec = options.get('force_exec')
target_address = options.get('target_address')

from django.conf import settings
client_id = None
client_secret = None

if check_ogc_backend(geoserver.BACKEND_PACKAGE):
from geonode.geoserver.helpers import ogc_server_settings
redirect_uris = '%s\n%s' % (ogc_server_settings.LOCATION, ogc_server_settings.public_url)
redirect_uris = '%s\n%s\n%s' % (
ogc_server_settings.LOCATION,
ogc_server_settings.public_url,
"{0}/geoserver/".format(target_address))
if Application.objects.filter(name='GeoServer').exists():
Application.objects.filter(name='GeoServer').update(redirect_uris=redirect_uris)
if force_exec:
Application.objects.filter(name='GeoServer').update(
client_id=generate_client_id(),
client_secret=generate_client_secret()
)
app = Application.objects.filter(name='GeoServer')[0]
client_id = app.client_id
client_secret = app.client_secret
Expand Down
9 changes: 6 additions & 3 deletions geonode/base/management/commands/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def restore_geoserver_backup(self, settings, target_folder):

gs_bk_exec_id = gs_backup['restore']['execution']['id']
r = requests.get(url + 'rest/br/restore/' + str(gs_bk_exec_id) + '.json',
auth=HTTPBasicAuth(user, passwd))
auth=HTTPBasicAuth(user, passwd),
timeout=10)
if (r.status_code == 200):

try:
Expand All @@ -143,7 +144,8 @@ def restore_geoserver_backup(self, settings, target_folder):

gs_bk_exec_id = gs_backup['restore']['execution']['id']
r = requests.get(url + 'rest/br/restore/' + str(gs_bk_exec_id) + '.json',
auth=HTTPBasicAuth(user, passwd))
auth=HTTPBasicAuth(user, passwd),
timeout=10)
if (r.status_code == 200):
gs_bk_exec_status = gs_backup['restore']['execution']['status']
gs_bk_exec_progress = gs_backup['restore']['execution']['progress']
Expand All @@ -152,7 +154,8 @@ def restore_geoserver_backup(self, settings, target_folder):
if (gs_bk_exec_progress != gs_bk_exec_progress_updated):
gs_bk_exec_progress_updated = gs_bk_exec_progress
r = requests.get(url + 'rest/br/restore/' + str(gs_bk_exec_id) + '.json',
auth=HTTPBasicAuth(user, passwd))
auth=HTTPBasicAuth(user, passwd),
timeout=10)
if (r.status_code == 200):

try:
Expand Down
4 changes: 2 additions & 2 deletions geonode/base/management/commands/updategeoip.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
except ImportError:
try:
from django.contrib.gis.geoip import GeoIP
URL = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz'
URL = 'https://build.geo-solutions.it/geonode/geoserver/latest/GeoLiteCity.dat.gz'
OLD_FORMAT = True
except:
URL = None
Expand Down Expand Up @@ -70,7 +70,7 @@ def handle(self, *args, **options):
import requests
import math
# Streaming, so we can iterate over the response.
r = requests.get(options['url'], stream=True, timeout=10)
r = requests.get(options['url'], stream=True, timeout=10, verify=False)
# Total size in bytes.
total_size = int(r.headers.get('content-length', 0))
logger.info("Requesting %s", options['url'])
Expand Down
4 changes: 2 additions & 2 deletions geonode/contrib/monitoring/service_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _collect(self, *args, **kwargs):
if not base_url:
raise ValueError("Service {} should have url provided".format(self.service.name))
url = '{}{}'.format(base_url.rstrip('/'), self.PATH)
rdata = requests.get(url)
rdata = requests.get(url, timeout=10)
if rdata.status_code != 200:
raise ValueError("Error response from api: ({}) {}".format(url, rdata))
data = rdata.json()['metrics']['metric']
Expand All @@ -206,7 +206,7 @@ def _collect(self, since, until, *args, **kwargs):
if not base_url:
raise ValueError("Service {} should have url provided".format(self.service.name))
url = '{}/monitoring/api/beacon/{}/'.format(base_url.rstrip('/'), self.service.service_type.name)
rdata = requests.get(url)
rdata = requests.get(url, timeout=10)
if rdata.status_code != 200:
raise ValueError("Error response from api: ({}) {}".format(url, rdata))
data = rdata.json()
Expand Down
41 changes: 24 additions & 17 deletions geonode/contrib/monitoring/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@
#########################################################################

import os
import re
import pytz
import threading
import traceback
import types
import Queue
import logging
import xmljson
import types
import re
from urllib import urlencode
from datetime import datetime, timedelta
from math import floor, ceil
import requests
import threading
import traceback

from xml.etree import ElementTree as etree
from math import floor, ceil
from urllib import urlencode
from urlparse import urlsplit
from bs4 import BeautifulSoup as bs
from requests.auth import HTTPBasicAuth
import requests
from datetime import datetime, timedelta
from xml.etree import ElementTree as etree

from django.conf import settings
from django.db.models.fields.related import RelatedField
Expand Down Expand Up @@ -116,11 +117,14 @@ def __init__(self, base_url):
self.base_url = base_url

def get_href(self, link, format=None):
href = link['href']
href = urlsplit(link['href'])
base_url = urlsplit(self.base_url)
if href and href.netloc != base_url.netloc:
href = href._replace(netloc=base_url.netloc)
if format is None:
return href
return href.geturl()
if format in self.REPORT_FORMATS:
href, ext = os.path.splitext(href)
href, ext = os.path.splitext(href.geturl())
return '{}.{}'.format(href, format)
return format

Expand All @@ -142,13 +146,13 @@ def get_requests(self, format=None, since=None, until=None):
print('checking', rest_url)
username = settings.OGC_SERVER['default']['USER']
password = settings.OGC_SERVER['default']['PASSWORD']
resp = requests.get(rest_url, auth=HTTPBasicAuth(username, password))
resp = requests.get(
rest_url,
auth=HTTPBasicAuth(username, password),
timeout=30)
doc = bs(resp.content)
links = doc.find_all('a')
for l in links:
# we're skipping this check, as gs can generate
# url with other base url
# if l.get('href').startswith(self.base_url):
href = self.get_href(l, format)
data = self.get_request(href, format=format)
if data:
Expand All @@ -159,7 +163,10 @@ def get_requests(self, format=None, since=None, until=None):
def get_request(self, href, format=format):
username = settings.OGC_SERVER['default']['USER']
password = settings.OGC_SERVER['default']['PASSWORD']
r = requests.get(href, auth=HTTPBasicAuth(username, password))
r = requests.get(
href,
auth=HTTPBasicAuth(username, password),
timeout=30)
if r.status_code != 200:
log.warning('Invalid response for %s: %s', href, r)
return
Expand Down
2 changes: 1 addition & 1 deletion geonode/geoserver/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def geoserver_post_save(instance, sender, **kwargs):
if instance.storeType != 'remoteStore':
logger.info("... Creating Thumbnail for Layer [%s]" % (instance.alternate))
try:
create_gs_thumbnail(instance, overwrite=True, check_bbox=True)
create_gs_thumbnail(instance, overwrite=False, check_bbox=True)
except BaseException:
logger.warn("!WARNING! - Failure while Creating Thumbnail for Layer [%s]" % (instance.alternate))

Expand Down
9 changes: 9 additions & 0 deletions geonode/geoserver/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,18 @@
downstream_path='wps'), name='wps_endpoint'),
url(r'^pdf', views.geoserver_proxy, dict(proxy_path='/gs/pdf',
downstream_path='pdf'), name='pdf_endpoint'),
url(r'^(?P<workspace>[^/]*)/(?P<layername>[^/]*)/ows',
views.geoserver_proxy,
dict(proxy_path='/gs/%s' % settings.DEFAULT_WORKSPACE, downstream_path='ows')),
url(r'^(?P<workspace>[^/]*)/(?P<layername>[^/]*)/wms',
views.geoserver_proxy,
dict(proxy_path='/gs/%s' % settings.DEFAULT_WORKSPACE, downstream_path='wms')),
url(r'^(?P<workspace>[^/]*)/(?P<layername>[^/]*)/wfs',
views.geoserver_proxy,
dict(proxy_path='/gs/%s' % settings.DEFAULT_WORKSPACE, downstream_path='wfs')),
url(r'^(?P<workspace>[^/]*)/(?P<layername>[^/]*)/wcs',
views.geoserver_proxy,
dict(proxy_path='/gs/%s' % settings.DEFAULT_WORKSPACE, downstream_path='wcs')),

url(r'^updatelayers/$',
views.updatelayers, name="updatelayers"),
Expand Down
Loading

0 comments on commit e6aa6a7

Please sign in to comment.