[openstack-dev] Horizon customization_module feature doesn't work

Daniel McDougall daniel.mcdougall at liftoffsoftware.com
Tue Nov 13 02:07:04 UTC 2012


I finally got it to work:  The key was adding the 'customization_module'
setting to /opt/stack/openstack_dashboard/local/local_settings.py instead
of /opt/stack/openstack_dashboard/settings.py.  The documentation should be
updated to reflect this since it specifically states,
"settings.HORIZON_CONFIG" when it probably should read
"local_settings.HORIZON_CONFIG" or at the very least clarify that somehow.


On Mon, Nov 12, 2012 at 8:09 PM, Daniel McDougall <
daniel.mcdougall at liftoffsoftware.com> wrote:

> OK, after trying again and again it is still not working.  I have exactly
> what is described in the documentation (here:
> http://docs.openstack.org/developer/horizon/topics/customizing.html).
>  Here's the filesystem layout:
>
> (Note: I also tried placing 'my_project' inside the openstack_dashboards
> directory but it made no difference)
> /opt/stack/horizon/my_project/overrides.py # The contents of this file was
> copied & pasted from the documentation example ("Rename "OpenStack
> Credentials" to "OS Credentials")
> /opt/stack/horizon/my_project/__init__.py # Whether or not this file
> exists makes no difference
>
> ...and /opt/stack/horizon/openstack_dashboard/settings.py has been
> modified as exactly described in the documentation.  HORIZON_CONFIG has had
> the following key/value added:
>
> 'customization_module': 'my_project.overrides'
>
> This does not rename anything as far as I can tell.  Also, there are no
> .pyc files being generated so it seems obvious that the files in question
> are not being imported.  Perhaps my layout is incorrect?  Maybe I'm adding
> the 'customization_module' to the wrong settings.py?
>
>
> On Sun, Nov 11, 2012 at 5:35 PM, Gabriel Hurley <Gabriel.Hurley at nebula.com
> > wrote:
>
>>  While I agree there ought to be a unit test for it, I can tell you
>> definitively that it **does** work since I have internal projects using
>> it (not public). As to why it’s not working for you… without seeing code I
>> can tell you about how it works and perhaps you can make some deducations
>> from there. For reference, the code is here:
>> https://github.com/openstack/horizon/blob/master/horizon/base.py#L743****
>>
>> ** **
>>
>> First, the code looks to see if a customization_module has been
>> specified. If not, it moves on. If there is one, it tries to split the
>> dotted python path string into a package and a module name that can be
>> imported. It then tries to import the module from the package. If this
>> succeeds then all the code in the module is executed (as part of Python’s
>> import process). If it fails there are two code paths:****
>>
>> ** **
>>
>> **1.       **It failed because it was able to import the module from the
>> package but there was some other error, in which case it should re-raise
>> that error.****
>>
>> **2.       **It failed because it could not import either the package or
>> the module, in which case it puts things back as it was and moves along.*
>> ***
>>
>> ** **
>>
>> Case #2 should probably have better debugging facilities, and it sounds
>> like that’s what’s happening to you. Why it’s unable to locate/import your
>> module I don’t know. There are all the innumerable common path problems,
>> missing __init__.py files, etc. which could be to blame. Python path issues
>> are always a nuisance.****
>>
>> ** **
>>
>> If you want to post your code explicitly somewhere then the community can
>> help review/debug. If you’d like to work on the ticket for improving
>> testing/debugging around the customization_module code the ticket is here:
>> https://bugs.launchpad.net/horizon/+bug/1077744****
>>
>> ** **
>>
>> Hopefully all that helps,****
>>
>> ** **
>>
>> **-          **Gabriel****
>>
>> ** **
>>
>> *From:* Daniel McDougall [mailto:daniel.mcdougall at liftoffsoftware.com]
>> *Sent:* Saturday, November 10, 2012 6:51 PM
>> *To:* openstack-dev at lists.openstack.org
>> *Subject:* [openstack-dev] Horizon customization_module feature doesn't
>> work****
>>
>> ** **
>>
>> I am developing a Gate One (https://github.com/liftoff/GateOne/) module
>> for Horizon (so you can get a real terminal instead of the
>> can't-copy-and-paste VNC one). I've got it working great if I manually make
>> changes to tabs.py, tables.py, views.py, and urls.py inside of
>> openstack_dashboard/dashboards/project/.  This adds a tab to the 'Instance
>> Detail' page alongside 'Log' and 'VNC' named, 'SSH' that instantly connects
>> you to your instance when you click on it; providing a really nice HTML5
>> terminal interface for your instance (that you can, you know, copy & paste
>> in and out of =).****
>>
>> ** **
>>
>> However, I don't like the idea of modifying the code in place (upgrading
>> Horizon would overwrite my changes).  Along these lines I tried to use the
>> customization_module feature described here:
>> http://docs.openstack.org/developer/horizon/topics/customizing.html****
>>
>> ** **
>>
>> ...but it doesn't work.  I literally copied & pasted the example and I
>> get nothing (the /settings/ page still shows the name as "OpenStack API").
>>  Not even an error message in the Apache logs or on the page.  Zero
>> changes.  I've restarted apache and whatnot.  Making changes to other
>> sections of the settings.py take effect just fine (e.g. SITE_BRANDING).  I
>> even did this to see if I could get it to generate an error:****
>>
>> ** **
>>
>> HORIZON_CONFIG = {****
>>
>>     <all the normal stuff>,****
>>
>>     'customization_module': 'nonexistent.override'****
>>
>> }****
>>
>> ** **
>>
>> ...but I get no error from that.  Nothing at all, in fact.  The setting
>> doesn't appear to do anything at all.  I've tried placing the overrides.py
>> file all over the place.  Inside of openstack_dashboard (as
>> openstack_dashboard.overrides), myproject, etc etc.  No matter what I try
>> it seems to have no impact.****
>>
>> ** **
>>
>> My conclusion is that this feature just plain doesn't work.  There is no
>> existing tests for it and despite much googling I couldn't find a single
>> example of it in use.  There is literally not a single .py file indexed in
>> Google that has 'customization_module' in it except for Horizon's on
>> base.py.****
>>
>> ** **
>>
>> Maybe the customization_module feature is the wrong way to go about this;
>> I'm just getting started with Horizon.  Any suggestions or ideas are
>> appreciated.****
>>
>> ** **
>>
>> -- ****
>>
>> Dan McDougall - Chief Executive Officer and Developer****
>>
>> Liftoff Software ✈ Your flight to the cloud is now boarding.****
>>
>> 904-446-8323****
>>
>> ** **
>>
>> _______________________________________________
>> OpenStack-dev mailing list
>> OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>>
>
>
> --
> Dan McDougall - Chief Executive Officer and Developer
> Liftoff Software ✈ Your flight to the cloud is now boarding.
> 904-446-8323
>
>


-- 
Dan McDougall - Chief Executive Officer and Developer
Liftoff Software ✈ Your flight to the cloud is now boarding.
904-446-8323
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20121112/5feb75ca/attachment.html>


More information about the OpenStack-dev mailing list