def apply(self, eventProxy, dmd):
        device = dmd.Devices.findDeviceByIdExact(eventProxy.device)

        if device and hasattr(device, 'openstackProxyComponentUUID'):
            LOG.debug("tagging event on %s with openstack proxy component component uuid %s",
                      eventProxy.device, device.openstackProxyComponentUUID)

            tags = [device.openstackProxyComponentUUID]

            # Also tag it with the openstack endpoint that the component is part of,
            # if possible.
            try:
                component = GUIDManager(dmd).getObject(device.openstackProxyComponentUUID)
                if component:
                    endpoint = component.device()
                    tags.append(IGlobalIdentifier(endpoint).getGUID())
            except Exception:
                LOG.debug("Unable to determine endpoint for proxy component uuid %s",
                          device.openstackProxyComponentUUID)

            # Get OSProcess component, if the event has one
            for brain in ICatalogTool(dmd).search('Products.ZenModel.OSProcess.OSProcess', query=Eq('id', eventProxy.component)):
                osprocess = brain.getObject()

                # Figure out if we have a corresponding software component:
                try:
                    for software in component.hostedSoftware():
                        if software.binary == osprocess.osProcessClass().id:
                            # Matches!
                            tags.append(IGlobalIdentifier(software).getGUID())
                except Exception:
                    LOG.debug("Unable to append event for OSProcess %s",
                              osprocess.osProcessClass().id)

            eventProxy.tags.addAll('ZenPacks.zenoss.OpenStackInfrastructure.DeviceProxyComponent', tags)
    def apply(self, eventProxy, dmd):

        # See ZPS-1677 for explanation.  This workaround will hopefully be
        # removed in the future (ZPS-1685)
        if eventProxy.eventClass == '/Status/Ping':
            return

        device = dmd.Devices.findDeviceByIdExact(eventProxy.device)

        if device and hasattr(device, 'openstackProxyComponentUUID'):
            LOG.debug("tagging event on %s with openstack proxy component component uuid %s",
                      eventProxy.device, device.openstackProxyComponentUUID)

            tags = []

            try:
                component = GUIDManager(dmd).getObject(device.openstackProxyComponentUUID)
                if component:

                    # Tag the event with the corresponding openstack component.
                    tags.append(device.openstackProxyComponentUUID)

                    # Also tag it with the openstack endpoint that the
                    # component is part of, if possible.
                    endpoint = component.device()
                    tags.append(IGlobalIdentifier(endpoint).getGUID())
            except Exception:
                LOG.debug("Unable to determine endpoint for proxy component uuid %s",
                          device.openstackProxyComponentUUID)

            # Get OSProcess component, if the event has one
            if eventProxy.component:
                for brain in ICatalogTool(dmd).search('Products.ZenModel.OSProcess.OSProcess', query=Eq('id', eventProxy.component)):
                    try:
                        osprocess = brain.getObject()
                    except Exception:
                        # ignore a stale entry
                        pass
                    else:
                        # Figure out if we have a corresponding software component:
                        try:
                            for software in component.hostedSoftware():
                                if software.binary == osprocess.osProcessClass().id:
                                    # Matches!
                                    tags.append(IGlobalIdentifier(software).getGUID())
                        except Exception:
                            LOG.debug("Unable to append event for OSProcess %s",
                                      osprocess.osProcessClass().id)

            if tags:
                eventProxy.tags.addAll('ZenPacks.zenoss.OpenStackInfrastructure.DeviceProxyComponent', tags)
Exemple #3
0
    def apply(self, eventProxy, dmd):

        # See ZPS-1677 for explanation.  This workaround will hopefully be
        # removed in the future (ZPS-1685)
        if eventProxy.eventClass == '/Status/Ping':
            return

        device = dmd.Devices.findDeviceByIdExact(eventProxy.device)

        if device and hasattr(device, 'openstackProxyComponentUUID'):
            LOG.debug(
                "tagging event on %s with openstack proxy component component uuid %s",
                eventProxy.device, device.openstackProxyComponentUUID)

            tags = []

            try:
                component = GUIDManager(dmd).getObject(
                    device.openstackProxyComponentUUID)
                if component:

                    # Tag the event with the corresponding openstack component.
                    tags.append(device.openstackProxyComponentUUID)

                    # Also tag it with the openstack endpoint that the
                    # component is part of, if possible.
                    endpoint = component.device()
                    tags.append(IGlobalIdentifier(endpoint).getGUID())
            except Exception:
                LOG.debug(
                    "Unable to determine endpoint for proxy component uuid %s",
                    device.openstackProxyComponentUUID)

            # Get OSProcess component, if the event has one
            if eventProxy.component:
                for brain in ICatalogTool(dmd).search(
                        'Products.ZenModel.OSProcess.OSProcess',
                        query=Eq('id', eventProxy.component)):
                    try:
                        osprocess = brain.getObject()
                    except Exception:
                        # ignore a stale entry
                        pass
                    else:
                        # Figure out if we have a corresponding software component:
                        try:
                            for software in component.hostedSoftware():
                                if software.binary == osprocess.osProcessClass(
                                ).id:
                                    # Matches!
                                    tags.append(
                                        IGlobalIdentifier(software).getGUID())
                        except Exception:
                            LOG.debug(
                                "Unable to append event for OSProcess %s",
                                osprocess.osProcessClass().id)

            if tags:
                eventProxy.tags.addAll(
                    'ZenPacks.zenoss.OpenStackInfrastructure.DeviceProxyComponent',
                    tags)