Community
Zenoss Newsletter

Monitored by Zenoss
SourceForge.net Logo
Views

Edit history

Edit: -1 of 1
Time: 2008-09-18 07:29:45
Note: /production/www/portal/public-website/community/manage_importObject

changed:
-
<h1>Updating Zenoss with CIM Functionality</h1>
<h2>Notes</h2>
<ul>
<li>This should be able to be created using the instructions in the Zope Book for creating a product, but this functionality appears to be broken.  Hence this workaround.</li>
<li>All of the comments are with regards to the VMWare image.</li>
<li>The brief synopsis: create a tarball, untar it, restart Zope/ Zenoss</p>
</li>
<li>There's a good article at <a href="http://www.linuxjournal.com/article/5761"> Linux Journal</a> which describes some of the details of Zope's product process.  In addition, the <a href="http://www.zope.org/Members/maxm/HowTo/minimal_01" >Resources</a> section of the article has an excellent discussion of the basics of ins and outs of Zope products.</li>
<li><b>NB: The tarball is for the 2.1 beta!</b></li>
</ul>

<h1>Creating the New Zope Product</h1>
<h2>Create a Products Directory</h2>
<p><pre>mkdir -p Products/ZenModel/skins/zenmodel
mkdir Products/ZenModel/help
mkdir Products/ZenModel/dtml </pre></p>

<h2>Copy in Zenoss Standard Files</h2>
<p><pre>cp trunk/Products/ZenModel/skins/zenmodel/leftPane.pt Products/ZenModel/skins/zenmodel
cp trunk/Products/ZenModel/__init__.py Products/ZenModel
cp trunk/Products/ZenModel/DmdBuilder.py Products/ZenModel</pre></p>
<p>The leftPane.pt file contains the Navigation bar, and the other two files control what python files are executed at Zope startup to add base classes.</p>

<h2>Copy and Modify Mib* Files</h2>
<p>The type of object conceptually closest to CIM is the Mib object.  So rather than figuring out absolutely everything that we need to do on our own, we'll just use the Mib files as our guide to what we need to do.</p>
<p><pre>cp trunk/Products/ZenModel/help/Device.stx Products/ZenModel/help/CIM.stx
cp trunk/Products/ZenModel/dtml/addMibOrganizer.dtml Products/ZenModel/dtml/addCIMOrganizer.dtml
cp trunk/Products/ZenModel/skins/zenmodel/*Mib* Products/ZenModel/skins/zenmodel
for i in Products/ZenModel/skins/zenmodel/* ; do mv $i `echo $i | sed -e 's/Mib/CIM/'`; done
cp trunk/Products/ZenModel/*Mib* Products/ZenModel
for i in Products/ZenModel/*Mib* ; do mv $i `echo $i | sed -e 's/Mib/CIM/'`; done
 </pre></p>
<p>Now edit the files as appropriate.  Yes, this is definitely the hard part.</p>

<h2>Create the Menu Definitions</h2>
<p>These new menu definitions will <b>NOT</b> be loaded by default.  We'll need some other trickery in order to get it loaded.  Copy the <pre>Products/ZenModel/migrate/menus.py</pre> file to our <pre>Products</pre> directory, remove everything except a simple dictionary that contains our menu items.</p>
<p>Here's an example:</p>
<pre>
cim_menus= {
'CIM_list': [  {  'action': 'dialog_addToZenPack',
                 'description': 'Add to ZenPack...',
                 'id': 'addToZenPack',
                 'isdialog': True,
                 'ordering': 0.0,
                 'permissions': ('View',)},
              {  'action': 'dialog_addCIMModule',
                 'description': 'Add CIM Client...',
                 'id': 'addCIMModule',
                 'isdialog': True,
                 'ordering': 90.0,
                 'permissions': ('Manage DMD',)},
              {  'action': 'dialog_removeCIMModules',
                 'description': 'Delete CIMs...',
                 'id': 'removeCIMModules',
                 'isdialog': True,
                 'ordering': 80.0,
                 'permissions': ('Manage DMD',)},
              {  'action': 'dialog_moveCIMModules',
                 'description': 'Move CIMs...',
                 'id': 'moveCIMModules',
                 'isdialog': True,
                 'ordering': 70.0,
                 'permissions': ('Manage DMD',)}],
}
</pre>

<h2>Create the tarball</h2>
<p>Tar up the project directory</p>
<p><pre>tar cf cim_mgmt.tar Products</pre></p>
<p>You will now be able to move around the cim_mgmt.tar file for installation to VMWare systems.</p>


<h1>Installation</h1>
<h2>Install the pre-requisite Python package pywbem</h2>
<p>Download and install pywbem</p>
<h3>Step-by-step Instructions</h3>
<ol>
<li>Log onto the VMWare image as 'root' with no password.</li>
<li>Use 'wget' to obtain the pywbem package</p>
<pre>
cd /tmp
wget http://downloads.sourceforge.net/pywbem/pywbem-0.5.tar.gz</pre></li>
<li><p>Untar the file:</p>
<p><pre>tar xzf pywbem-0.5.tar.gz</pre></p></li>
<li><p>Install the package</p>
<p><pre>cd pywbem-0.5
python setup.py build
python setup.py install
</pre></p></li>
</ol>

<h2>Install on the VMWare Image</h2>
<p>Untar the tar file on the VMWare image in the zenoss user's home directory and restart.<p>
<h3>Step-by-step Instructions</h3>
<ol>
<li>Log onto the VMWare image as 'root' with no password.</li>
<li><p>Become the zenoss user:</p>
<p><pre>su - zenoss</pre></p></li>
<li><p>Copy over the tar file from your system:</p>
<p><pre>scp username@sourcesystem:path/to/file .</pre></p>
<p>For instance:</p>
<p><pre>scp kells@neurotoxin:~/cim_mgmt.tar .</pre></p>
<p>NB: The host 'neurotoxin' was added to the /etc/hosts file</p>
</li>
<li><p>Make backup copies of system files:</p>
<p><pre>mkdir pre_cim_mgr_backup
cp Products/ZenModel/skins/zenmodel/leftPane.pt pre_cim_mgr_backup
cp Products/ZenModel/__init__.py pre_cim_mgr_backup
cp Products/ZenModel/DmdBuilder.py pre_cim_mgr_backup
</pre></p></li>
<li><p>Untar the file:</p>
<p><pre>tar xf cim_mgmt.tar</pre></p></li>
<li><p>Restart the Zope server from the Zope Management Interface (ZMI):</p>
<ol>
<li><p>Log into the ZMI</p>
<p>In the URL area of your browser, log into your Zenoss instance with '/manage' at the end.</p>
<p><pre>http://your_zenoss_server:8080/manage</pre></p>
<p>For instance:</p>
<p><pre>http://monitor1:8080/manage</pre></p>
</li>
<li><p>Navigate into the Control Panel</p>
<p>Click on the <pre>Control_Panel (Control Panel)</pre> link</p>
</li>
<li><p>Restart Zope</p>
<p>Click on the <pre>Restart</pre> button and wait for the screen to come back</p>
</li>
</ol>
</ol>
<h3>Debugging Tip</h3>
<p>Look for problems by logging into the VMWare console and examining the /home/zenoss/log/event.log file.  If there are any syntax issues or other problems that prevent Zope from loading the new code, there should be information about what the error is and where to find the error.</p>
<p>For instance, here's an example error from the event.log file:</p>
<pre>
------
2007-09-30T20:13:20 ERROR Zope Couldn't install ZenModel
Traceback (most recent call last):
  File "/home/marc/conary/zenoss-project/builds/zope2/_ROOT_/usr/lib/zope/lib/python/OFS/Application.py", line 773, in install_product
  File "/home/zenoss/Products/ZenModel/__init__.py", line 143, in initialize
    if not confmonModules: loadConfmonModules()
  File "/home/zenoss/Products/ZenModel/__init__.py", line 132, in loadConfmonModules
    mod = __import__(product, globals(), locals(), [])
  File "/home/zenoss/Products/ZenModel/CIMModule.py", line 22, in ?
    class CIMModule(CIMBase):
  File "/home/zenoss/Products/ZenModel/CIMModule.py", line 26, in CIMModule
    _relations = ZenPackable._relations + (
NameError: name 'ZenPackable' is not defined
------
2007-09-30T20:13:20 INFO Zope Ready to handle requests
------
2007-09-30T20:13:45 WARNING ZODB Could not import class 'CIMOrganizer' from module 'Products.ZenModel.CIMOrganizer'
------
</pre>
<p>In the above example, we notice (from the last error to the first error) that the class 'CIMOrganizer' was unable to be loaded.  We can take a reasonable guess that the reason that 'CIMOrganizer' was unable to be loaded might be related to the earlier error.</p>
<p>When we open the 'CIMOrganizer.py' file, we find that it indeed imports the CIMModule.py module.  So, the reason that CIMOrganizer module couldn't be loaded is due to an issue with CIMModule.py.
The error in CIMMOdule.py tells us that the 'import' statement which defines the 'ZenPackable' module is missing.
</p>

<h2>Create the 'CIM' Organizer</h2>
<p>We've moved all of the logic and presentation information into the VMWare image, so it's almost ready to use.  If you log into Zenoss, you'll notice that a new button is on the bottom of the Navigation pane, right underneath 'Mibs'.  If you click on it, you'll receive an error message because one final step needs to be completed.</p>
<p>Log into the Zope Management Interface (ZMI) and create the 'CIM' organizer.</p>
<h3>Step-by-step Instructions</h3>
<ol>
<li><p>Log into the ZMI</p>
<p>In the URL area of your browser, log into your Zenoss instance with '/manage' at the end.</p>
<p><pre>http://your_zenoss_server:8080/zport/dmd/manage</pre></p>
<p>For instance:</p>
<p><pre>http://monitor1:8080/zport/dmd/manage</pre></p>
</li>
<li><p>At the top right-hand side (right beside the 'Add' button), there is a pull-down list.  Select 'CIMOrganizer' from the pull-down list and then click the 'Add' button.</p>
</li>
</ol>
<p>You should now see a new entry in the ZMI with the name 'CIM'.  At this point the navigation bar entry for 'CIM' should work.</p>

<h2>Add Menus to the 'CIM' Organizer</h2>
<p>Now we can add our menu items to the CIM organizer.  I've edited the  menus.xml file (which doesn't seem to get referenced except in menus.py -- which doesn't use it) and the menus.py file, but even a restart of the VMWare image won't load these menu hierarchies.  We'll need to do something a little more intense.</p>
<p>In the tarball there's a file ('cim_menus.py') in the Products directory which contains the basic menus that we need to get started.  Once this step is done, then we can modify everything else from within Zope (through the ZMI) and through Zenoss (through 'Settings' -> 'Menus').  What we need to do is load the new file and get the running Zenoss instance to use that new file's data.</p>
<h3>Step-by-step Instructions</h3>
<ol>
<li>Log onto the VMWare image as 'root' with no password.</li>
<li><p>Become the zenoss user:</p>
<p><pre>su - zenoss</pre></p></li>
<li><p>Run the zendmd command, which allows you to attach to the running Zenoss server:</p>
<p><pre>zendmd</pre></p></li>
<li><p>Access the new menu definitions and load them into memory</p>
<p><pre>import Products.cim_menus</pre></p></li>
<li><p>Add the new menu items to the running Zenoss server</p>
<p><pre>dmd.buildMenus( Products.cim_menus.cim_menus )
commit()
</pre></p></li>
<li><p>Exit from zendmd by typing ctl + d (the Unix end-of-file character)</p></li>
<ol>