Skip Menu |

This queue is for tickets about the Zenoss CPAN distribution.

Report information
The Basics
Id: 70769
Status: stalled
Priority: 0/
Queue: Zenoss

People
Owner: patricksbaker [...] gmail.com
Requestors: lmacinnes [...] stargate.ca
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in:
  • 1.04
  • 1.05
  • 1.06
  • 1.07
  • 1.08
  • 1.09
  • 1.10
Fixed in: (no value)



Subject: Model an existing Device
There doesn't seem to be an API call to model an existing device. I'm running into an issue where I need to delete interfaces add a second device then remodel the original device but can't seem to find a method to remodel. There seems to be a "collectDevice()" method in ZenOSS but I'm unsure of how to modify your package to talk to it grep 'def collectDevice' * -R DataCollector/zenmodeler.py: def collectDevice(self, device): ZenModel/PerformanceConf.py: def collectDevice(self, device=None, setlog=True, REQUEST=None, ZenModel/Device.py: def collectDevice(self, setlog=True, REQUEST=None, generateEvents=False, ZenModel/DeviceOrganizer.py: def collectDevice(self, REQUEST=None): Is there any chance that this functionality could be added?
On Tue Sep 06 15:38:08 2011, Liam wrote:
Show quoted text
> There doesn't seem to be an API call to model an existing device.
>
> I'm running into an issue where I need to delete interfaces add a
> second device then remodel
> the original device but can't seem to find a method to remodel.
>
> There seems to be a "collectDevice()" method in ZenOSS but I'm unsure
> of how to modify your
> package to talk to it
>
> grep 'def collectDevice' * -R
> DataCollector/zenmodeler.py: def collectDevice(self, device):
> ZenModel/PerformanceConf.py: def collectDevice(self, device=None,
> setlog=True,
> REQUEST=None,
> ZenModel/Device.py: def collectDevice(self, setlog=True,
> REQUEST=None,
> generateEvents=False,
> ZenModel/DeviceOrganizer.py: def collectDevice(self, REQUEST=None):
>
>
> Is there any chance that this functionality could be added?

This might not be possible, yet.  From using FireBug with Zenoss, I was unable to see a JSON request when modeling a device; it appears to be a url encoded POST.  It would appear that they, Zenoss, havent created a Zuul resource for it.

I will review this more in depth in the coming days to see if there is something I can implement.

Thanks,

Patrick

After more review it appears Zenoss has added this ability in Zenoss 4.0 with the JSON API called named 'remodel' on the Device Router.  There is a back port that will allow this to work with Zenoss 3.X; patch attached.  Please note that I make no guarantees that the patch will work successfully on your system.

The patch can be applied with the command: patch -p4 < changeset_r40190.diff

From the Perl interface side of things, this brings up an interesting topic.  I believe I'm going to have to start updating the Zenoss Perl interface to work with the latest version of Zenoss, which has new features such as remodel (however most just came out).  If a user doesn't have the appropriate version to execute the call, then I will have to Carp with an error.  Given that this is open source, I really dont want to get into maintaining documentation for the rapid development of the Zenoss Monitoring Solution across multiple versions.  With that said, some thought process will need to go into the method call validation.

For the impatient, you can add the following block of code to Zenoss::Router::Device (Device.pm) that will allow you to execute the requested remodel command via the Zenoss module; $api->device_remodel({deviceUid => '/Servers/Linux/DeviceName})

Note, I havent tested this!

Show quoted text
#======================================================================
# device_remodel
#======================================================================
sub device_remodel {
    my ($self, $args) = @_;
    $args = {} if !$args;

    # Argument definition
    my $definition = {
        required    => ['deviceUid'],
    };

    # Check the args
    $self->_check_args($args, $definition);

    # Route the request
    $self->_router_request(
        {
            location    => $self->DEVICE_LOCATION,
            action      => $self->DEVICE_ACTION,
            method      => 'remodel',
            data        => [$args],
        }
    );
} # END device_remodel
Subject: changeset_r40190.diff
Index: /trunk/core/Products/Zuul/routers/device.py =================================================================== --- /trunk/core/Products/Zuul/routers/device.py (revision 39869) +++ /trunk/core/Products/Zuul/routers/device.py (revision 40190) @@ -1228,4 +1228,18 @@ return DirectResponse.succeed(jobId=jobStatus.id) + @require('Manage Device') + def remodel(self, deviceUid): + """ + Submit a job to have a device remodeled. + + @type deviceUid: string + @param deviceUid: Device uid to have local template + @rtype: DirectResponse + @return: B{Properties}: + - jobId: (string) ID of the add device job + """ + jobStatus = self._getFacade().remodel(deviceUid) + return DirectResponse.succeed(jobId=jobStatus.id) + @require('Edit Local Templates') def addLocalTemplate(self, deviceUid, templateId): Index: /trunk/core/Products/Zuul/facades/devicefacade.py =================================================================== --- /trunk/core/Products/Zuul/facades/devicefacade.py (revision 39524) +++ /trunk/core/Products/Zuul/facades/devicefacade.py (revision 40190) @@ -279,4 +279,10 @@ return jobStatus + def remodel(self, deviceUid): + fake_request = {'CONTENT_TYPE': 'xml'} + device = self._getObject(deviceUid) + return device.getPerformanceServer().collectDevice( + device, background=True, REQUEST=fake_request) + def addLocalTemplate(self, deviceUid, templateId): """
I've released version 1.11 which now checks if the API call is available on the Zenoss server.  I'm attempting to gather what the deal is with version 4.X of Zenoss and if its publicly available.  Until I find that out, I will keep the remodel API call omitted.  On a happier note, I've updated some of the Routers to support new methods in version 3.2 of Zenoss.

Stalling this require for now until I figure out when Zenoss 4.X  core is going to be released.