def proxy_device(self): ''' Return this component's corresponding proxy device, or None if there isn't one at this time. This method will not attempt to create a new device. ''' # A claimed device already exists. device = GUIDManager(self.dmd).getObject( getattr(self, 'openstackProxyDeviceUUID', None)) if device: # Make sure that the GUID is correct in the reverse direction, # then return it. return self.ensure_valid_claim(device) # Look for device that matches our requirements device = self.find_claimable_device() # Claim it. if device: self.claim_proxy_device(device) return device # We found nothing to claim, so return None. return None
def need_maintenance(self): guid = IGlobalIdentifier(self).getGUID() device = GUIDManager(self.dmd).getObject( getattr(self, 'openstackProxyDeviceUUID', None)) if device and getattr(device, 'openstackProxyComponentUUID', None) \ and device.openstackProxyComponentUUID == guid: return False return True
def release_proxy_device(self): device = GUIDManager(self.dmd).getObject( getattr(self, 'openstackProxyDeviceUUID', None)) if device: LOG.debug("device %s is now detached from %s component '%s'" % (device.name(), self.meta_type, self.name())) device.openstackProxyComponentUUID = None self.openstackProxyDeviceUUID = None LOG.debug("%s component '%s' is now detached from any devices" % (self.meta_type, self.name()))
def setupAction(self, dmd): self.guidManager = GUIDManager(dmd) self.dmd = dmd self.zep = getFacade("zep", self.dmd) self.statuses = { "0": "New", "1": "Acknowledged", "2": "Suppressed", "3": "Closed", "4": "Cleared", "5": "Dropped", "6": "Aged", }
def onDeviceDeleted(object, event): ''' Clean up the dangling reference to a device if that device has been removed. (Note: we may re-create the device automatically next time someone calls self.ensure_proxy_device, though) ''' if not IObjectWillBeAddedEvent.providedBy( event) and not IObjectWillBeMovedEvent.providedBy(event): if hasattr(object, 'openstackProxyComponentUUID'): component = GUIDManager(object.dmd).getObject( getattr(object, 'openstackProxyComponentUUID', None)) if component: component.release_proxy_device() object.openstackProxyComponentUUID = None
def component_for_proxy_device(cls, device): ''' Given any device in the system, check if it has a DeviceProxyComponent associated with it, and if it does, return that component. ''' uuid = getattr(device, 'openstackProxyComponentUUID', None) if uuid: component = GUIDManager(device.dmd).getObject(uuid) # ensure that the component is also linked back to this device- # a uni-directional linkage (device to component, but not # component to device) is not valid. component_device_uuid = getattr(component, 'openstackProxyDeviceUUID', None) if component_device_uuid == IGlobalIdentifier(device).getGUID(): return component else: LOG.warning( "Device %s is linked to component %s, but it is not linked back. Disregarding linkage.", device, component) return None
def setupAction(self, dmd): self.guidManager = GUIDManager(dmd) self.zenossHostname = dmd.zenossHostname
def setupAction(self, dmd): self.guidManager = GUIDManager(dmd) self.dmd = dmd self.page_command = dmd.pageCommand self.zenossHostname = dmd.zenossHostname
def setupAction(self, dmd): self.guidManager = GUIDManager(dmd)
def __init__(self, dmd): self.dmd = dmd self.notification_manager = self.dmd.getDmdRoot( NotificationSubscriptionManager.root) self.guidManager = GUIDManager(dmd)
def setupAction(self, dmd): """ Configure the action with properties form the dmd. """ self.guidManager = GUIDManager(dmd) self.dmd = dmd
def setupAction(self, dmd): self.guidManager = GUIDManager(dmd) self.page_command = dmd.pageCommand
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)
def setupAction(self, dmd): log.debug('[research] setup : %s' % (self.name)) self.guidManager = GUIDManager(dmd) self.dmd = dmd