def createCimOsh(ipAddress, containerOsh, credentialId, category=None): ''' Builds a CIM OSH representing successful connection. @param ipAddress: string @param containerOsh: corresponding container OSH @param credentialId: protocol entry @raise ValueError: no credential or no IP. @return: OSH ''' if not credentialId: raise ValueError('CredentialsId must be set') if not netutils.isValidIp(ipAddress): raise ValueError('IP Address must be set') cimOsh = ObjectStateHolder('cim') cimOsh.setAttribute('data_name', Protocol.FULL) cimOsh.setAttribute('credentials_id', credentialId) cimOsh.setAttribute('application_ip', ipAddress) cimOsh.setContainer(containerOsh) if category: list_ = StringVector((category,)) categoryAttribute = AttributeStateHolder('cim_category', list_) cimOsh.addAttributeToList(categoryAttribute) return cimOsh
def __buildJmsDestination(self, destination, destinationType): '@types: jms.Destination, str -> ObjectStateHolder' osh = ObjectStateHolder('jmsdestination') osh.setAttribute('name', destination.getName()) if destination.getObjectName(): osh.setAttribute('j2eemanagedobject_objectname', destination.getObjectName()) if destination.getJndiName(): osh.setAttribute('j2eemanagedobject_jndiname', destination.getJndiName()) if destinationType: osh.setAttribute('jmsdestination_type', destinationType) messagescurrent = destination.messagesCurrentCount.value() if messagescurrent is not None: osh.setIntegerAttribute('jmsdestination_messagescurrent', messagescurrent) messagespending = destination.messagesPendingCount.value() if messagespending is not None: osh.setIntegerAttribute('jmsdestination_messagespending', messagespending) messagesreceived = destination.messagesReceivedCount.value() if messagesreceived is not None: osh.setIntegerAttribute('jmsdestination_messagesreceived', messagesreceived) consumerscurrent = destination.consumersCurrentCount.value() if consumerscurrent is not None: osh.setIntegerAttribute('jmsdestination_consumerscurrent', consumerscurrent) subscribers = destination.getDurableSubscribers() if subscribers: vectorOfNames = StringVector() for subscriber in subscribers: vectorOfNames.add(subscriber.getName()) ash = AttributeStateHolder('jmsdestination_durablesubscribers', vectorOfNames) osh.addAttributeToList(ash) return osh
def createCimOsh(ipAddress, containerOsh, credentialId, category=None): ''' Builds a CIM OSH representing successful connection. @param ipAddress: string @param containerOsh: corresponding container OSH @param credentialId: protocol entry @raise ValueError: no credential or no IP. @return: OSH ''' if not credentialId: raise ValueError('CredentialsId must be set') if not netutils.isValidIp(ipAddress): raise ValueError('IP Address must be set') cimOsh = ObjectStateHolder('cim') cimOsh.setAttribute('data_name', Protocol.FULL) cimOsh.setAttribute('credentials_id', credentialId) cimOsh.setAttribute('application_ip', ipAddress) cimOsh.setContainer(containerOsh) if category: list_ = StringVector((category, )) categoryAttribute = AttributeStateHolder('cim_category', list_) cimOsh.addAttributeToList(categoryAttribute) return cimOsh