Using geonode-updateip with a custom geonode-project

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Using geonode-updateip with a custom geonode-project

davekennewell
Hi Geonode Devs, 

I'm using geonode 2.6.3 installed by apt-get on a fresh ubuntu 16.04 instance.

On top of this I install geonode-project, and customise settings.py in mygeonodeproject. 

This works fine if I use the postgres database that apt-get automatically installs locally on my geonode server. 

However, when I go to swap out this local database with a remote one (it's on AWS RDS), it's all good until the command "sudo geonode-updateip mygeonodeproject.com" tells me I don't have a superuser created (I do, but it's on the remote database, created using the manage.py command in mygeonodeproject folder). 

When I drill into this a bit deeper, it appears to come down to this line: 


This line ("from django.conf import settings") is pulling in models from the local geonode database, not the remote RDS database I'm using for mygeonodeproject. 

What am I doing wrong here, and what is the best way to import my custom project into this command rather than the globally installed geonode, when using "from django.conf import settings"? 

thanks for any help
regards
Dave


_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using geonode-updateip with a custom geonode-project

Rob Atkinson-3
Hi Dave,

FYI I'm looking at an install script to be able to inject custom modules into a base django project - with GeoNode as a target.

This will handle:
* importing custom settings for module via a template
* injection into INSTALLED_APPS and urls.py
* running migrations
* collecting static files
* installing and configuring additional resources and components used by the module (e.g. other tomcat WARs)
* performing tests (planned)

  I have an ansible version (on a private repo) but am waiting for some info from the Boundless folk about using a vanilla shell approach for improved portability, and some details on how to best run this in a docker context (as i'm a docker noob)

if you are interested happy to work with you to either;
1) explore adding modules like django-gazetteer to your project using this approach
2) refactor your project to inject your specialised extensions into a base Geonode install.


Cheers
Rob


On Fri, 8 Sep 2017 at 02:32 Dave Kennewell <[hidden email]> wrote:
Hi Geonode Devs, 

I'm using geonode 2.6.3 installed by apt-get on a fresh ubuntu 16.04 instance.

On top of this I install geonode-project, and customise settings.py in mygeonodeproject. 

This works fine if I use the postgres database that apt-get automatically installs locally on my geonode server. 

However, when I go to swap out this local database with a remote one (it's on AWS RDS), it's all good until the command "sudo geonode-updateip mygeonodeproject.com" tells me I don't have a superuser created (I do, but it's on the remote database, created using the manage.py command in mygeonodeproject folder). 

When I drill into this a bit deeper, it appears to come down to this line: 


This line ("from django.conf import settings") is pulling in models from the local geonode database, not the remote RDS database I'm using for mygeonodeproject. 

What am I doing wrong here, and what is the best way to import my custom project into this command rather than the globally installed geonode, when using "from django.conf import settings"? 

thanks for any help
regards
Dave

_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel

_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using geonode-updateip with a custom geonode-project

Simo D
In reply to this post by davekennewell
Hi Dave,

good catch, we need to fix this. I guess an approach like manage.py is using https://github.com/GeoNode/geonode-project/blob/2.6/manage.py#L10, added before the import could work but needs to be tested...

Let me know

2017-09-07 18:32 GMT+02:00 Dave Kennewell <[hidden email]>:
Hi Geonode Devs, 

I'm using geonode 2.6.3 installed by apt-get on a fresh ubuntu 16.04 instance.

On top of this I install geonode-project, and customise settings.py in mygeonodeproject. 

This works fine if I use the postgres database that apt-get automatically installs locally on my geonode server. 

However, when I go to swap out this local database with a remote one (it's on AWS RDS), it's all good until the command "sudo geonode-updateip mygeonodeproject.com" tells me I don't have a superuser created (I do, but it's on the remote database, created using the manage.py command in mygeonodeproject folder). 

When I drill into this a bit deeper, it appears to come down to this line: 


This line ("from django.conf import settings") is pulling in models from the local geonode database, not the remote RDS database I'm using for mygeonodeproject. 

What am I doing wrong here, and what is the best way to import my custom project into this command rather than the globally installed geonode, when using "from django.conf import settings"? 

thanks for any help
regards
Dave


_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel




--
Simone 

_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using geonode-updateip with a custom geonode-project

davekennewell
Hi Rob  - let me have a look at this concept once I solve this immediate challenge :)

Hi Simone, 

OK, so I tested this and 

os.environ['DJANGO_SETTINGS_MODULE'] = 'mygeonodeproject.settings'

works to set the settings module correctly. We were correct - fixoauthuri.py was pulling settings from geonode.settings not mygeonodeproject.settings. But this doesn't solve the issue unfortunately. It's still importing the people.profile model from the local database, not the remote one. 

To further debug, I opened the django shell as my geonode user (in my case it's "ubuntu") 

python manage.py shell

from /home/ubuntu/mygeonodeproject, and ran the commands from fixoauthuri.py. This worked fine - they pick up my superuser created on the remote database.

So, this leads me to believe the problem lies with fixoauthuri.py being run as "root" user when called using "sudo geonode-updateip myIpAddress". But I'm stuck as to further reasons why this is the problem. 

To be specific:

When I use 

from geonode.people.models import Profile

as root from "sudo geonode-updateip", it imports Profile from the local database.

When I use

from geonode.people.models import Profile

as ubuntu from the shell, it imports Profile from the remote database. 


And just for completeness, when I use

from geonode.people.models import Profile

as root from the shell ("sudo python manage.py shell"), it imports Profile from the remote database. 

Any ideas how to remedy this one? 

On 8 September 2017 at 10:59, Simone Dalmasso <[hidden email]> wrote:
Hi Dave,

good catch, we need to fix this. I guess an approach like manage.py is using https://github.com/GeoNode/geonode-project/blob/2.6/manage.py#L10, added before the import could work but needs to be tested...

Let me know

2017-09-07 18:32 GMT+02:00 Dave Kennewell <[hidden email]>:
Hi Geonode Devs, 

I'm using geonode 2.6.3 installed by apt-get on a fresh ubuntu 16.04 instance.

On top of this I install geonode-project, and customise settings.py in mygeonodeproject. 

This works fine if I use the postgres database that apt-get automatically installs locally on my geonode server. 

However, when I go to swap out this local database with a remote one (it's on AWS RDS), it's all good until the command "sudo geonode-updateip mygeonodeproject.com" tells me I don't have a superuser created (I do, but it's on the remote database, created using the manage.py command in mygeonodeproject folder). 

When I drill into this a bit deeper, it appears to come down to this line: 


This line ("from django.conf import settings") is pulling in models from the local geonode database, not the remote RDS database I'm using for mygeonodeproject. 

What am I doing wrong here, and what is the best way to import my custom project into this command rather than the globally installed geonode, when using "from django.conf import settings"? 

thanks for any help
regards
Dave


_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel




--
Simone 


_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using geonode-updateip with a custom geonode-project

Simo D
Yes this is the behaviour that I would expect with the current setup.

geonode-updateip is using the geonode default settings because is in the geonode root. While python manage.py shell from your project correctly sets your project settings.

You could try to set the DJANGO_SETTINGS_MODULE as a permanent environment variable for root (added in home/root/.bashrc or bash_profile for example.



2017-09-08 14:56 GMT+02:00 Dave Kennewell <[hidden email]>:
Hi Rob  - let me have a look at this concept once I solve this immediate challenge :)

Hi Simone, 

OK, so I tested this and 

os.environ['DJANGO_SETTINGS_MODULE'] = 'mygeonodeproject.settings'

works to set the settings module correctly. We were correct - fixoauthuri.py was pulling settings from geonode.settings not mygeonodeproject.settings. But this doesn't solve the issue unfortunately. It's still importing the people.profile model from the local database, not the remote one. 

To further debug, I opened the django shell as my geonode user (in my case it's "ubuntu") 

python manage.py shell

from /home/ubuntu/mygeonodeproject, and ran the commands from fixoauthuri.py. This worked fine - they pick up my superuser created on the remote database.

So, this leads me to believe the problem lies with fixoauthuri.py being run as "root" user when called using "sudo geonode-updateip myIpAddress". But I'm stuck as to further reasons why this is the problem. 

To be specific:

When I use 

from geonode.people.models import Profile

as root from "sudo geonode-updateip", it imports Profile from the local database.

When I use

from geonode.people.models import Profile

as ubuntu from the shell, it imports Profile from the remote database. 


And just for completeness, when I use

from geonode.people.models import Profile

as root from the shell ("sudo python manage.py shell"), it imports Profile from the remote database. 

Any ideas how to remedy this one? 

On 8 September 2017 at 10:59, Simone Dalmasso <[hidden email]> wrote:
Hi Dave,

good catch, we need to fix this. I guess an approach like manage.py is using https://github.com/GeoNode/geonode-project/blob/2.6/manage.py#L10, added before the import could work but needs to be tested...

Let me know

2017-09-07 18:32 GMT+02:00 Dave Kennewell <[hidden email]>:
Hi Geonode Devs, 

I'm using geonode 2.6.3 installed by apt-get on a fresh ubuntu 16.04 instance.

On top of this I install geonode-project, and customise settings.py in mygeonodeproject. 

This works fine if I use the postgres database that apt-get automatically installs locally on my geonode server. 

However, when I go to swap out this local database with a remote one (it's on AWS RDS), it's all good until the command "sudo geonode-updateip mygeonodeproject.com" tells me I don't have a superuser created (I do, but it's on the remote database, created using the manage.py command in mygeonodeproject folder). 

When I drill into this a bit deeper, it appears to come down to this line: 


This line ("from django.conf import settings") is pulling in models from the local geonode database, not the remote RDS database I'm using for mygeonodeproject. 

What am I doing wrong here, and what is the best way to import my custom project into this command rather than the globally installed geonode, when using "from django.conf import settings"? 

thanks for any help
regards
Dave


_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel




--
Simone 




--
Simone 

_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using geonode-updateip with a custom geonode-project

davekennewell
OK, I think I got to the bottom of this issue. 

Setting DJANGO_SETTINGS_MODULE variable wasn't working because python's sys.path first looks for modules in the current working directory, then looks to system-wide modules on PYTHONPATH. DJANGO_SETTINGS_MODULE is found on PYTHONPATH.

In the current working directory for the geonode-updateip command (/usr/sbin) is a script called "geonode" which sys.path is finding first. This sets the settings to geonode.settings rather than mygeonodeproject.settings, before django ever looks on PYTHONPATH. This one: 

I modified this file to use mygeonodeproject.settings and everything works as expected now, thanks for the help. 

I don't know how to structure a Pull Request to address this when using geonode-project. I've simply updated my deployment scripts to do this at build-time. Thoughts welcome here. 

regards
Dave



On 8 September 2017 at 17:11, Simone Dalmasso <[hidden email]> wrote:
Yes this is the behaviour that I would expect with the current setup.

geonode-updateip is using the geonode default settings because is in the geonode root. While python manage.py shell from your project correctly sets your project settings.

You could try to set the DJANGO_SETTINGS_MODULE as a permanent environment variable for root (added in home/root/.bashrc or bash_profile for example.



2017-09-08 14:56 GMT+02:00 Dave Kennewell <[hidden email]>:
Hi Rob  - let me have a look at this concept once I solve this immediate challenge :)

Hi Simone, 

OK, so I tested this and 

os.environ['DJANGO_SETTINGS_MODULE'] = 'mygeonodeproject.settings'

works to set the settings module correctly. We were correct - fixoauthuri.py was pulling settings from geonode.settings not mygeonodeproject.settings. But this doesn't solve the issue unfortunately. It's still importing the people.profile model from the local database, not the remote one. 

To further debug, I opened the django shell as my geonode user (in my case it's "ubuntu") 

python manage.py shell

from /home/ubuntu/mygeonodeproject, and ran the commands from fixoauthuri.py. This worked fine - they pick up my superuser created on the remote database.

So, this leads me to believe the problem lies with fixoauthuri.py being run as "root" user when called using "sudo geonode-updateip myIpAddress". But I'm stuck as to further reasons why this is the problem. 

To be specific:

When I use 

from geonode.people.models import Profile

as root from "sudo geonode-updateip", it imports Profile from the local database.

When I use

from geonode.people.models import Profile

as ubuntu from the shell, it imports Profile from the remote database. 


And just for completeness, when I use

from geonode.people.models import Profile

as root from the shell ("sudo python manage.py shell"), it imports Profile from the remote database. 

Any ideas how to remedy this one? 

On 8 September 2017 at 10:59, Simone Dalmasso <[hidden email]> wrote:
Hi Dave,

good catch, we need to fix this. I guess an approach like manage.py is using https://github.com/GeoNode/geonode-project/blob/2.6/manage.py#L10, added before the import could work but needs to be tested...

Let me know

2017-09-07 18:32 GMT+02:00 Dave Kennewell <[hidden email]>:
Hi Geonode Devs, 

I'm using geonode 2.6.3 installed by apt-get on a fresh ubuntu 16.04 instance.

On top of this I install geonode-project, and customise settings.py in mygeonodeproject. 

This works fine if I use the postgres database that apt-get automatically installs locally on my geonode server. 

However, when I go to swap out this local database with a remote one (it's on AWS RDS), it's all good until the command "sudo geonode-updateip mygeonodeproject.com" tells me I don't have a superuser created (I do, but it's on the remote database, created using the manage.py command in mygeonodeproject folder). 

When I drill into this a bit deeper, it appears to come down to this line: 


This line ("from django.conf import settings") is pulling in models from the local geonode database, not the remote RDS database I'm using for mygeonodeproject. 

What am I doing wrong here, and what is the best way to import my custom project into this command rather than the globally installed geonode, when using "from django.conf import settings"? 

thanks for any help
regards
Dave


_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel




--
Simone 




--
Simone 


_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using geonode-updateip with a custom geonode-project

Simo D
Thanks for the feedback, I think could make the geonode-updateip and the geonode commands to accept a --settings flag like django-admin.py can do.
Could you please file a ticket with your issue?

Ragards

2017-09-13 11:10 GMT+02:00 Dave Kennewell <[hidden email]>:
OK, I think I got to the bottom of this issue. 

Setting DJANGO_SETTINGS_MODULE variable wasn't working because python's sys.path first looks for modules in the current working directory, then looks to system-wide modules on PYTHONPATH. DJANGO_SETTINGS_MODULE is found on PYTHONPATH.

In the current working directory for the geonode-updateip command (/usr/sbin) is a script called "geonode" which sys.path is finding first. This sets the settings to geonode.settings rather than mygeonodeproject.settings, before django ever looks on PYTHONPATH. This one: 

I modified this file to use mygeonodeproject.settings and everything works as expected now, thanks for the help. 

I don't know how to structure a Pull Request to address this when using geonode-project. I've simply updated my deployment scripts to do this at build-time. Thoughts welcome here. 

regards
Dave



On 8 September 2017 at 17:11, Simone Dalmasso <[hidden email]> wrote:
Yes this is the behaviour that I would expect with the current setup.

geonode-updateip is using the geonode default settings because is in the geonode root. While python manage.py shell from your project correctly sets your project settings.

You could try to set the DJANGO_SETTINGS_MODULE as a permanent environment variable for root (added in home/root/.bashrc or bash_profile for example.



2017-09-08 14:56 GMT+02:00 Dave Kennewell <[hidden email]>:
Hi Rob  - let me have a look at this concept once I solve this immediate challenge :)

Hi Simone, 

OK, so I tested this and 

os.environ['DJANGO_SETTINGS_MODULE'] = 'mygeonodeproject.settings'

works to set the settings module correctly. We were correct - fixoauthuri.py was pulling settings from geonode.settings not mygeonodeproject.settings. But this doesn't solve the issue unfortunately. It's still importing the people.profile model from the local database, not the remote one. 

To further debug, I opened the django shell as my geonode user (in my case it's "ubuntu") 

python manage.py shell

from /home/ubuntu/mygeonodeproject, and ran the commands from fixoauthuri.py. This worked fine - they pick up my superuser created on the remote database.

So, this leads me to believe the problem lies with fixoauthuri.py being run as "root" user when called using "sudo geonode-updateip myIpAddress". But I'm stuck as to further reasons why this is the problem. 

To be specific:

When I use 

from geonode.people.models import Profile

as root from "sudo geonode-updateip", it imports Profile from the local database.

When I use

from geonode.people.models import Profile

as ubuntu from the shell, it imports Profile from the remote database. 


And just for completeness, when I use

from geonode.people.models import Profile

as root from the shell ("sudo python manage.py shell"), it imports Profile from the remote database. 

Any ideas how to remedy this one? 

On 8 September 2017 at 10:59, Simone Dalmasso <[hidden email]> wrote:
Hi Dave,

good catch, we need to fix this. I guess an approach like manage.py is using https://github.com/GeoNode/geonode-project/blob/2.6/manage.py#L10, added before the import could work but needs to be tested...

Let me know

2017-09-07 18:32 GMT+02:00 Dave Kennewell <[hidden email]>:
Hi Geonode Devs, 

I'm using geonode 2.6.3 installed by apt-get on a fresh ubuntu 16.04 instance.

On top of this I install geonode-project, and customise settings.py in mygeonodeproject. 

This works fine if I use the postgres database that apt-get automatically installs locally on my geonode server. 

However, when I go to swap out this local database with a remote one (it's on AWS RDS), it's all good until the command "sudo geonode-updateip mygeonodeproject.com" tells me I don't have a superuser created (I do, but it's on the remote database, created using the manage.py command in mygeonodeproject folder). 

When I drill into this a bit deeper, it appears to come down to this line: 


This line ("from django.conf import settings") is pulling in models from the local geonode database, not the remote RDS database I'm using for mygeonodeproject. 

What am I doing wrong here, and what is the best way to import my custom project into this command rather than the globally installed geonode, when using "from django.conf import settings"? 

thanks for any help
regards
Dave


_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel




--
Simone 




--
Simone 




--
Simone 

_______________________________________________
geonode-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-devel