Skip to content

Commit

Permalink
Merge pull request #617 from kartoza/develop
Browse files Browse the repository at this point in the history
Version 4.3.0
  • Loading branch information
meomancer authored Dec 15, 2023
2 parents d45f879 + 236c441 commit 6e3b00a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
2 changes: 1 addition & 1 deletion deployment/.env
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ PYTHONPATH=/home/web/django_project:/geonode
USE_DEFAULT_GEOSERVER_STYLE=False
INITIAL_FIXTURES=True

VERSION=4.2.0
VERSION=4.3.0
ISTSOS_VERSION=2.4.1-2

# ------ GEOSERVER ------
Expand Down
51 changes: 28 additions & 23 deletions deployment/docker/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
# Setting up the context
#########################################################

import os
import requests
import datetime
import json
import os
import time
import uuid

import django
import datetime
import time
import requests

django.setup()


#########################################################
# Imports
#########################################################
Expand All @@ -36,7 +36,6 @@
admin_password = os.getenv('ADMIN_PASSWORD')
admin_email = os.getenv('ADMIN_EMAIL')


#########################################################
# 1. Waiting for PostgreSQL
#########################################################
Expand All @@ -63,7 +62,6 @@
call_command('migrate', '--noinput')
call_command('migrate', app_label='gwml2', database='gwml2')


#########################################################
# 3. Creating superuser if it doesn't exist
#########################################################
Expand All @@ -85,7 +83,6 @@
)
print('superuser successfully created')


#########################################################
# 4. Create an OAuth2 provider to use authorisations keys
#########################################################
Expand All @@ -101,8 +98,12 @@
authorization_grant_type='authorization-code',
)
app.skip_authorization = True
_host = os.getenv('HTTPS_HOST', "") if os.getenv('HTTPS_HOST', "") != "" else os.getenv('HTTP_HOST')
_port = os.getenv('HTTPS_PORT') if os.getenv('HTTPS_HOST', "") != "" else os.getenv('HTTP_PORT', '80')
_host = os.getenv('HTTPS_HOST', "") if os.getenv('HTTPS_HOST',
"") != "" else os.getenv(
'HTTP_HOST')
_port = os.getenv('HTTPS_PORT') if os.getenv('HTTPS_HOST',
"") != "" else os.getenv(
'HTTP_PORT', '80')
# default port is 80
_protocols = {
"80": "http://",
Expand All @@ -127,7 +128,6 @@
else:
print('oauth2 provider successfully updated')


#########################################################
# 5. Loading fixtures
#########################################################
Expand All @@ -138,6 +138,7 @@
# Disable fixtures loading in prod by including environment variable:
# INITIAL_FIXTURES=False
import ast

# To conform with original behaviour of GeoNode, we need to set it to True
# as default value
_load_initial_fixtures = ast.literal_eval(
Expand All @@ -146,7 +147,6 @@
call_command('loaddata', 'initial_data')
call_command('update_fixtures')


#########################################################
# 6. Running updatemaplayerip
#########################################################
Expand All @@ -172,8 +172,9 @@

print("-----------------------------------------------------")
print("8. Waiting for GeoServer")
_geoserver_host = os.getenv('GEOSERVER_LOCATION', 'http://geoserver:8080/geoserver')
for _ in range(60*5):
_geoserver_host = os.getenv('GEOSERVER_LOCATION',
'http://geoserver:8080/geoserver')
for _ in range(60 * 5):
try:
requests.head("{}".format(_geoserver_host))
break
Expand All @@ -189,31 +190,34 @@
print("-----------------------------------------------------")
print("9. Securing GeoServer")


geoserver_admin_username = os.getenv('GEOSERVER_ADMIN_USER')
geoserver_admin_password = os.getenv('GEOSERVER_ADMIN_PASSWORD')

# Getting the old password
try:
r1 = requests.get('{}/rest/security/masterpw.json'.format(_geoserver_host),
auth=(geoserver_admin_username, geoserver_admin_password))
auth=(
geoserver_admin_username, geoserver_admin_password))
except requests.exceptions.ConnectionError:
print("Unable to connect to GeoServer. Make sure GeoServer is started and accessible.")
print(
"Unable to connect to GeoServer. Make sure GeoServer is started and accessible.")
exit(1)
r1.raise_for_status()
old_password = json.loads(r1.text)["oldMasterPassword"]

if old_password == 'M(cqp{V1':
print("Randomizing master password")
new_password = uuid.uuid4().hex
data = json.dumps({"oldMasterPassword": old_password, "newMasterPassword": new_password})
r2 = requests.put('{}/rest/security/masterpw.json'.format(_geoserver_host), data=data,
headers={'Content-Type': 'application/json'}, auth=(geoserver_admin_username, geoserver_admin_password))
data = json.dumps(
{"oldMasterPassword": old_password, "newMasterPassword": new_password})
r2 = requests.put('{}/rest/security/masterpw.json'.format(_geoserver_host),
data=data,
headers={'Content-Type': 'application/json'}, auth=(
geoserver_admin_username, geoserver_admin_password))
r2.raise_for_status()
else:
print("Master password was already changed. No changes made.")


#########################################################
# 10. Test User Model
#########################################################
Expand All @@ -238,16 +242,17 @@ def make_token_expiration(seconds=86400):
token=generate_token())

#########################################################
# 11. Restart harvesters
# 11. Restart harvesters and uploads
#########################################################

try:
from gwml2.functions import Functions

print("-----------------------------------------------------")
print("11. Restart harvesters")
print("11. Restart harvesters and uploads")

Functions().restart_harvesters()
Functions().restart_uploads()
except Exception as e:
print(f'{e}')
pass
2 changes: 1 addition & 1 deletion django_project/gwml2
Submodule gwml2 updated from 9e99d8 to 94e8cf
10 changes: 8 additions & 2 deletions django_project/igrac/forms/groundwater_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ def run(self):

# Fetch xml data
xml_url = layer.resource.href
xml = requests.get(xml_url).content
xml = requests.get(
xml_url,
auth=(gs_catalog.username, gs_catalog.password)
).content

# Update xml to new data
tree = ET.ElementTree(ET.fromstring(xml))
Expand Down Expand Up @@ -250,7 +253,10 @@ def run(self):

# Fetch xml data
xml_url = layer.resource.href
xml = requests.get(xml_url).content
xml = requests.get(
xml_url,
auth=(gs_catalog.username, gs_catalog.password)
).content

# Update xml to new data
tree = ET.ElementTree(ET.fromstring(xml))
Expand Down
2 changes: 1 addition & 1 deletion django_project/version/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.0
4.3.0

0 comments on commit 6e3b00a

Please sign in to comment.