Nov 16, 2009 1:23 PM
Help with Custom Map Zenpack
-
Like (0)
The actual implementation of the portlet and the map editor is fairly solid right now. We are currently monitoring about 1800 devices, most of which have placed into these hand-drawn maps. The individual maps load very quickly, and the portlet updates the map image seamlessly every 30 seconds.
I am not very familiar with zope, and the more I try to learn, the less it makes sense to me. There are a number of issues I am trying to solve that I would love some help with:
rians:
The work sounds interesting. Is it possible for you to post the source?
Rians:
I'm making progrress, but would it be possible to post the source of .CustomMap.py.swo? There is some static pathing fopr /usr/local/zenoss... that will break the pack.
Thanks!
Rians:
Acctually, what is the file?
Feel free to email me when you're getting closer to having a ZenPack ready to post, or if you need some assistance. I may be able to help you if you run into any blockers.
Thanks,
Matt Ray
Zenoss Community Manager
Hi,
I would be interested to help as an tester if You like.
The code is posted above. The best way to make use of it is probably to create a zenpack called ZenPacks.USU.Map, unzip the tarball into it, and restart zope by executing zopectl restart. Currently, the most broken bits of my code are the ones that set everything up (in the __init__.py). You should be able to create the initial custom map tab by doing the following in zendmd:
from ZenPacks.USU.Map import CustomMap
dmd.Locations.custom_map = CustomMap.CustomMapObject(dmd.Locations)
dmd.Locations.custom_map._registerCustomMapTab()
commit()
This should make it so that if you go to the Locations section, the root location should have an extra tab called Custom Map. From there you should be able to draw an arbitrary map.
For some reason, the _registerCustomMapTab() function doesn't always work. You may need to restart zendmd and try it a couple of times.
Hi Rians and thanks for reply,
I managed to install your code attached to thread yesterday after minor annoyances, but that _registerCustomMapTab() -function truly gave (and gives) me some headache
On the whole code seems to work, but still I would like to ask some features and clarifications:
- I was not able to figure any other way inserting an background image than creating/uploading an image (for example an floorplan) type of object directly to ZODB via Zope manage. Is there any better way to do this?
- Would it be possible that custom maps could (optionally?) be seen as portlet at the locations status tab?
- Automatically scaling background image (which is linked to full size map-page or submap) wouldn't hurt in that statuspage portlet.
- Should "add link" button do something else than lightly change the backgroundcolor of the browser?
- Adding objects confuses me, I have built my location hierarchy by the scheme "Locations/City/Factory/Server or network rack" and when I added Factory A floorplan map to level "Factory" I thought that it would be possible to add the server rooms / network racks as an sublocations/submaps, but it seems that it is not working that way because I can't see any other available nodes than "factory" level?
- Could the previous problem be caused by error below what I get when I try to run dmd.Locations.custom_map = CustomMap.CustomMapObject(dmd.Locations.City.Factory.network.rack) at zendmd:
>>> dmd.Locations.custom_map = CustomMap.CustomMapObject(dmd.Locations.City.Factory.81.6)
File "<console>", line 1
dmd.Locations.custom_map = CustomMap.CustomMapObject(dmd.Locations.City.Factory.81.6)
(the name of the "outer" location is "81.6")
- And referring to previous, is your code able to handle the location names that have an dot? I have lots of those because of networking racks and it seems that it's causing problems, which you probably noticed all ready... Just noticed this and dunno yet that if some escape char or equivalent input do the trick.
Sorry my stupid questions, but my knowledge in www and python is marginal at most, but hey... Most of the other users are as stupid as I
Next thing that I noticed was that when I add map image to level /Locations/City1/FactoryA and then /Locations/City1/FactoryB, both of the factories shows same image, FactoryB.
Any Idea why? Is this intented functionality?
No problem. I'm glad somebody has taken an interest in this. It is always nice to have somebody else's eyes on the code.
The _registerCustomMapTab() method is the biggest headache I've encountered thus far. Sometimes it works, sometimes it doesn't. If anybody can show me a better way to insert a tab into the Locations screen, please let me know.
Uploading an image via zope manage, or by including the files in a zenpack are the only ways i know of to get map backgrounds into zope. If somebody knows how to upload files into zope interactively, please let me know.
I'm not sure how to include a portlet under the status tab. I did create a portlet for the dashboard page, but, due to namespace conflicts, you will need a customized version of the python imaging library to use it. I have attached the version of PIL that i used. You should be able to install it by unzipping it, changing to the Imaging-1.1.6 directory, becoming the zenoss user, and running the python build script:
sudo su zenoss
tar -xzf Imaging-zope-1.1.6.tar.gz
cd Imaging-1.1.6
python setup.py build
python setup.py install
zopectl restart
after that, you should be able to add the zenoss portlet to the dashboard page. One of the things I am working on is a way to include the Imaging library in a zenpack.
I like the idea of scaling the background image, and it shouldn't be that hard to accomplish...
Maybe the Add Link button needs a better name. It's not talking about html links. It's point is to specify a network link between two objects. If you click on it, and then drag the mouse from one object to another, it should draw a line to it. You can later specify properties of the line.
It is possible to add child location objects, but then the child location objects need to be given a custom map object as well. Here is some code you can run in zendmd that should recursively add a blank custom_map attribute to every location:
from ZenPacks.USU.Map import CustomMap
def walkchildren(l):
if not hasattr(l, "custom_map"):
l.custom_map = CustomMap.CustomMapObject(l)
l.custom_map._registerCustomMapTab()
l.custom_map.create()
for i in l.children():
walkchildren(i)
walkchildren(dmd.Locations)
I have found that this code (which is in the zenpack __init__.py) seems to work to add the custom map object, but not always to add the custom_map tab. At this point, you go to the location you want and use its custom_map tab to edit the location specific map.
One thing about zope that annoys me to no end is that if you create an attribute for an object, then its children have that attribute as well unless you override it. That would probably account for the bug you are seeing where two different locations appear to have the same map. The code I listed should assign a new unique custom map to every location.
Please let me know how your experience goes. If anybody has any answers to any of the problems that I have listed, please feel free to chime in.
mf2ng:
Examples:
For /Locations:
from ZenPacks.USU.Map import CustomMap
dmd.Locations.custom_map = CustomMap.CustomMapObject(dmd.Locations)
dmd.Locations.custom_map._registerCustomMapTab()
commit()
For /Locations/SA40:
from ZenPacks.USU.Map import CustomMap
dmd.Locations.SA40.custom_map = CustomMap.CustomMapObject(dmd.Locations.SA40)
dmd.Locations.SA40.custom_map._registerCustomMapTab()
commit()
For /Locations/SA40/Floor6:
from ZenPacks.USU.Map import CustomMap
dmd.Locations.SA40.Floor6.custom_map = CustomMap.CustomMapObject(dmd.Locations.SA40.Floor6)
dmd.Locations.SA40.Floor6.custom_map._registerCustomMapTab()
commit()
Also, I have a working installable Egg if anyone wants it. I'm making some updates to the engine, IE doesnt like it at all. Wonderful in FF.
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||