示例#1
0
    def build(self, domain):
        if domain is None:
            raise ValueError("domain is None")
        ldomConfigOsh = ObjectStateHolder('ldom_config')
        ldomConfigOsh.setAttribute('name', "LDOM Config")

        if domain.getName() is not None:
            ldomConfigOsh.setStringAttribute('ldom_name', domain.getName())

        if domain.getMac() is not None:
            ldomConfigOsh.setStringAttribute('ldom_mac', domain.getMac())
            
        if domain.hostId:
            ldomConfigOsh.setStringAttribute('ldom_hostid', domain.hostId)
            
        if domain.getUuid():
            ldomConfigOsh.setStringAttribute('ldom_uuid', domain.getUuid())
        
        ldomConfigOsh.setStringAttribute('ldom_state', domain.state.value().value())
        ldomConfigOsh.setIntegerAttribute('ldom_ncpu', domain.ncpu.value())
        if domain.memorySize.value() is not None:
            memorySizeMegabytes = int(domain.memorySize.value() / (1024*1024))
            ldomConfigOsh.setIntegerAttribute('ldom_memory_size', int(memorySizeMegabytes))
        if domain.roles.has(ldom.Domain.ROLE_CONTROL):
            ldomConfigOsh.setBoolAttribute("ldom_is_control", 1)
        if domain.roles.has(ldom.Domain.ROLE_IO):
            ldomConfigOsh.setBoolAttribute("ldom_is_io", 1)
            
        if domain.failurePolicy:
            ldomConfigOsh.setStringAttribute("ldom_failure_policy", domain.failurePolicy)
        
        return ldomConfigOsh
示例#2
0
def buildGenericHostObject(host_class, hostDo,  report_serial = True):
    if not host_class:
        raise ValueError('Failed to create Node no host class passed')
    
    host_osh = ObjectStateHolder(host_class)
    
    if hostDo.hostname:
        host_osh.setStringAttribute('name', hostDo.hostname)
        
    host_osh.setBoolAttribute('host_iscomplete', 1)
    key = hostDo.hostname or hostDo.ipList
    if hostDo.domain_name:
        host_osh.setStringAttribute('domain_name', hostDo.domain_name)
    
    if hostDo.is_virtual:
        host_osh.setBoolAttribute('host_isvirtual', 1)
    
    if hostDo.serial and report_serial:
        host_osh.setStringAttribute('serial_number', hostDo.serial)

    if hostDo.model:
        host_osh.setStringAttribute('discovered_model', hostDo.model)
    
    if hostDo.vendor:
        host_osh.setStringAttribute('discovered_vendor', hostDo.vendor)

    if hostDo.sys_obj_id:
        host_osh.setStringAttribute('sys_object_id', hostDo.sys_obj_id)
        
    if hostDo.architecture and ARCHITECTURE_TRANSFORMATION.get(hostDo.architecture):
        host_osh.setStringAttribute('os_architecture', ARCHITECTURE_TRANSFORMATION.get(hostDo.architecture))
        
    return host_osh
示例#3
0
文件: jdbc.py 项目: deezeesms/dd-git
 def buildDataSourceOsh(self, datasource):
     r'@types: jdbc.Datasource'
     datasourceOsh = ObjectStateHolder("jdbcdatasource")
     datasourceOsh.setAttribute('data_name', datasource.getName())
     if datasource.jndiName is not None:
         datasourceOsh.setAttribute('jdbcdatasource_jndiname',
                                    datasource.jndiName)
     if datasource.driverClass is not None:
         datasourceOsh.setStringAttribute('jdbcdatasource_drivername',
                                          datasource.driverClass)
     initialCapacity = datasource.initialCapacity
     maxCapacity = datasource.maxCapacity
     capacityIncrement = datasource.capacityIncrement
     if initialCapacity and initialCapacity.value() is not None:
         datasourceOsh.setIntegerAttribute('jdbcdatasource_initialcapacity',
                                           initialCapacity.value())
     if maxCapacity and maxCapacity.value() is not None:
         datasourceOsh.setIntegerAttribute('jdbcdatasource_maxcapacity',
                                           maxCapacity.value())
     if capacityIncrement and capacityIncrement.value() is not None:
         datasourceOsh.setIntegerAttribute(
             'jdbcdatasource_capacityincrement', capacityIncrement.value())
     if datasource.testOnRelease is not None:
         datasourceOsh.setBoolAttribute(
             'jdbcdatasource_testconnectionsonrelease',
             datasource.testOnRelease)
     logger.debug('Found datasource ', datasource.getName())
     if datasource.url:
         datasourceOsh.setAttribute('jdbcdatasource_url', datasource.url)
         datasourceOsh.setAttribute("jdbcdatasource_poolname",
                                    datasource.url)
     else:
         datasourceOsh.setAttribute("jdbcdatasource_poolname", 'None')
     return datasourceOsh
示例#4
0
 def build_vm(self, vm):
     vmOsh = ObjectStateHolder('host_node')
     vmOsh.setStringAttribute('bios_uuid', vm.uuid)
     vmOsh.setStringAttribute('serial_number', vm.uuid)
     vmOsh.setBoolAttribute('host_isvirtual', True)
     vmOsh.setStringAttribute('description', vm.getLabel())
     return vmOsh
示例#5
0
    def build(self, domain):
        if domain is None:
            raise ValueError("domain is None")
        ldomConfigOsh = ObjectStateHolder("ldom_config")
        ldomConfigOsh.setAttribute("name", "LDOM Config")

        if domain.getName() is not None:
            ldomConfigOsh.setStringAttribute("ldom_name", domain.getName())

        if domain.getMac() is not None:
            ldomConfigOsh.setStringAttribute("ldom_mac", domain.getMac())

        if domain.hostId:
            ldomConfigOsh.setStringAttribute("ldom_hostid", domain.hostId)

        if domain.getUuid():
            ldomConfigOsh.setStringAttribute("ldom_uuid", domain.getUuid())

        ldomConfigOsh.setStringAttribute("ldom_state", domain.state.value().value())
        ldomConfigOsh.setIntegerAttribute("ldom_ncpu", domain.ncpu.value())
        if domain.memorySize.value() is not None:
            memorySizeMegabytes = int(domain.memorySize.value() / (1024 * 1024))
            ldomConfigOsh.setIntegerAttribute("ldom_memory_size", int(memorySizeMegabytes))
        if domain.roles.has(ldom.Domain.ROLE_CONTROL):
            ldomConfigOsh.setBoolAttribute("ldom_is_control", 1)
        if domain.roles.has(ldom.Domain.ROLE_IO):
            ldomConfigOsh.setBoolAttribute("ldom_is_io", 1)

        if domain.failurePolicy:
            ldomConfigOsh.setStringAttribute("ldom_failure_policy", domain.failurePolicy)

        return ldomConfigOsh
示例#6
0
 def buildDataSourceOsh(self, datasource):
     r'@types: jdbc.Datasource'
     datasourceOsh = ObjectStateHolder("jdbcdatasource")
     datasourceOsh.setAttribute('data_name', datasource.getName())
     if datasource.jndiName is not None:
         datasourceOsh.setAttribute('jdbcdatasource_jndiname', datasource.jndiName)
     if datasource.driverClass is not None:
         datasourceOsh.setStringAttribute('jdbcdatasource_drivername', datasource.driverClass)
     initialCapacity = datasource.initialCapacity
     maxCapacity = datasource.maxCapacity
     capacityIncrement = datasource.capacityIncrement
     if initialCapacity and initialCapacity.value() is not None:
         datasourceOsh.setIntegerAttribute('jdbcdatasource_initialcapacity', initialCapacity.value())
     if maxCapacity and maxCapacity.value() is not None:
         datasourceOsh.setIntegerAttribute('jdbcdatasource_maxcapacity',maxCapacity.value())
     if capacityIncrement and capacityIncrement.value() is not None:
         datasourceOsh.setIntegerAttribute('jdbcdatasource_capacityincrement', capacityIncrement.value())
     if datasource.testOnRelease is not None:
         datasourceOsh.setBoolAttribute('jdbcdatasource_testconnectionsonrelease', datasource.testOnRelease)
     logger.debug('Found datasource ', datasource.getName())
     if datasource.url:
         datasourceOsh.setAttribute('jdbcdatasource_url', datasource.url)
         datasourceOsh.setAttribute("jdbcdatasource_poolname", datasource.url)
     else:
         datasourceOsh.setAttribute("jdbcdatasource_poolname", 'None')
     return datasourceOsh
def createResourcePoolObjects(resourcePoolsByName, globalZoneOsh, resultsVector):
    for resourcePool in resourcePoolsByName.values():
        resourcePoolOsh = ObjectStateHolder('solaris_resource_pool')
        resourcePoolOsh.setAttribute('data_name', resourcePool.name)
        if resourcePool.isDefault is not None:
            resourcePoolOsh.setBoolAttribute('is_default', resourcePool.isDefault)
        if resourcePool.isActive is not None:
            resourcePoolOsh.setBoolAttribute('is_active', resourcePool.isActive)
        if resourcePool.scheduler:
            resourcePoolOsh.setAttribute('scheduler', resourcePool.scheduler)
        if resourcePool.importance is not None:
            resourcePoolOsh.setIntegerAttribute('importance', resourcePool.importance)
        pset = resourcePool.pset
        if pset is not None:
            resourcePoolOsh.setAttribute('pset_name', pset.name)
            if pset.minCpus is not None:
                resourcePoolOsh.setIntegerAttribute('pset_min_cpus', pset.minCpus)
            if pset.maxCpus is not None:
                resourcePoolOsh.setIntegerAttribute('pset_max_cpus', pset.maxCpus)
            if pset.objectives:
                resourcePoolOsh.setAttribute('pset_objectives', pset.objectives)


        resourcePoolOsh.setContainer(globalZoneOsh)
        resultsVector.add(resourcePoolOsh)
        resourcePool.osh = resourcePoolOsh
示例#8
0
 def build(self):
     osh = ObjectStateHolder('host_node')
     osh.setAttribute('host_key', self.hostId)
     osh.setBoolAttribute('host_iscomplete', 1)
     setAttribute(osh, 'name', self.__hostname)
     setAttribute(osh, 'primary_dns_name', self.__fqdn)
     return osh
示例#9
0
def reportRemotePeer(remote_peer, localInterfaceOsh, local_mac):
    vector = ObjectStateHolderVector()
    if remote_peer.peer_ips:
        hostOsh = modeling.createHostOSH(str(remote_peer.peer_ips[0]))
    if remote_peer.platform in VIRTUAL_HOST_PLATFORMS:
        hostOsh.setBoolAttribute('host_isvirtual', 1)
        vector.add(hostOsh)
        for ip in remote_peer.peer_ips:
            ipOsh = modeling.createIpOSH(ip)
            linkOsh = modeling.createLinkOSH('containment', hostOsh, ipOsh)
            vector.add(ipOsh)
            vector.add(linkOsh)
    else:
        hostOsh = ObjectStateHolder('node')
        hostOsh.setBoolAttribute('host_iscomplete', 1)
        hostOsh.setStringAttribute('name', remote_peer.system_name)
        if remote_peer.platform in VIRTUAL_HOST_PLATFORMS:
            hostOsh.setBoolAttribute('host_isvirtual', 1)
        vector.add(hostOsh)
    
    if remote_peer.interface_name or remote_peer.interface_mac:
        remoteInterfaceOsh = modeling.createInterfaceOSH(mac = remote_peer.interface_mac, hostOSH = hostOsh, name = remote_peer.interface_name)
        if not remoteInterfaceOsh:
            return ObjectStateHolderVector()
        if remote_peer.interface_name:
            remoteInterfaceOsh.setStringAttribute('name', remote_peer.interface_name)
        vector.add(remoteInterfaceOsh)
        l2id = str(hash(':'.join([remote_peer.interface_mac or remote_peer.interface_name, local_mac])))
        vector.addAll(reportLayer2Connection(localInterfaceOsh, remoteInterfaceOsh, l2id))
    return vector
示例#10
0
 def build_vm(self, vm):
     vmOsh = ObjectStateHolder('host_node')
     vmOsh.setStringAttribute('bios_uuid', vm.uuid)
     vmOsh.setStringAttribute('serial_number', vm.uuid)
     vmOsh.setBoolAttribute('host_isvirtual', True)
     vmOsh.setStringAttribute('description', vm.getLabel())
     return vmOsh
 def create_osh(self):
     clusterResourceGroupOsh = ObjectStateHolder('cluster_resource_group')
     hostKey = "%s:%s" % (self.domainName, self.name)
     dataName = self.name
     clusterResourceGroupOsh.setAttribute('host_key', hostKey)
     clusterResourceGroupOsh.setAttribute('data_name', dataName)
     clusterResourceGroupOsh.setBoolAttribute('host_iscomplete', 1)
     return clusterResourceGroupOsh
示例#12
0
 def build(self, resourceGroup, domainName):
     clusterResourceGroupOsh = ObjectStateHolder('cluster_resource_group')
     hostKey = "%s:%s" % (domainName, resourceGroup.getName())
     dataName = resourceGroup.getName()
     clusterResourceGroupOsh.setAttribute('host_key', hostKey)
     clusterResourceGroupOsh.setAttribute('data_name', dataName)
     clusterResourceGroupOsh.setBoolAttribute('host_iscomplete', 1)
     return clusterResourceGroupOsh
示例#13
0
 def buildClusteredService(self, cluster, group):
     r'@types: Cluster, ResourceGroup -> ObjectStateHolder'
     assert cluster and group
     osh = ObjectStateHolder('clusteredservice')
     osh.setAttribute('data_name', group.name)
     osh.setAttribute('host_key', '%s:%s' % (cluster.name, group.name))
     osh.setBoolAttribute('host_iscomplete', 1)
     if group.fqdn:
         osh.setStringAttribute('primary_dns_name', group.fqdn)
     return osh
示例#14
0
 def buildClusteredService(self, cluster, group):
     r'@types: Cluster, ResourceGroup -> ObjectStateHolder'
     assert cluster and group
     osh = ObjectStateHolder('clusteredservice')
     osh.setAttribute('data_name', group.name)
     osh.setAttribute('host_key', '%s:%s' % (cluster.name, group.name))
     osh.setBoolAttribute('host_iscomplete', 1)
     if group.fqdn:
         osh.setStringAttribute('primary_dns_name', group.fqdn)
     return osh
示例#15
0
文件: ivm.py 项目: ddonnelly19/dd-git
def createVirtualServerOsh(vm, report_name=True):
    virtualServerOsh = ObjectStateHolder("host")
    if report_name:
        setStringAttribute(virtualServerOsh, "name", vm.vserver_config.name)
    setStringAttribute(virtualServerOsh, "serial_number", vm.vserver_config.serial_number)
    setStringAttribute(virtualServerOsh, "bios_uuid", vm.vserver_config.uuid and vm.vserver_config.uuid.upper())
    setStringAttribute(virtualServerOsh, "discovered_os_name", vm.vserver_config.discovered_os_name)
    virtualServerOsh.setBoolAttribute("host_iscomplete", 1)
    virtualServerOsh.setBoolAttribute("host_isvirtual", 1)
    virtualServerOsh.setStringAttribute("os_family", "unix")
    return virtualServerOsh
示例#16
0
 def build(self):
     osh = ObjectStateHolder('fcswitch')
     osh.setBoolAttribute('host_iscomplete', 1)
     setAttribute(osh, 'name', self.__hostname)
     setAttribute(osh, 'fcswitch_wwn', self.wwn)
     setAttribute(osh, 'primary_dns_name', self.__fqdn)
     setAttribute(osh, 'discovered_vendor', self.vendor)
     setAttribute(osh, 'fcswitch_version', self.fwVersion)
     setAttribute(osh, 'discovered_model', self.model)
     self.osh = osh
     return osh
示例#17
0
文件: smis.py 项目: deezeesms/dd-git
def buildCompleteHost(name):
    '''
    @param node: host name
    @return: node Osh
    '''
    if not name:
        raise ValueError('Host name must be set')
    osh = ObjectStateHolder('node')
    osh.setStringAttribute('name', name)
    osh.setBoolAttribute('host_iscomplete', 1)
    return osh
示例#18
0
文件: sap.py 项目: ddonnelly19/dd-git
 def buildCompleteHost(self, key):
     r''' Build generic host
     @types: str -> ObjectSateHolder
     @raise ValueError: Host key is not specified
     '''
     if not (key and key.strip()):
         raise ValueError("Host key is not specified")
     osh = ObjectStateHolder(self.CIT)
     osh.setAttribute('host_key', key)
     osh.setBoolAttribute('host_iscomplete', True)
     return osh
示例#19
0
 def buildCompleteHost(self, key):
     r''' Build generic host
     @types: str -> ObjectSateHolder
     @raise ValueError: Host key is not specified
     '''
     if not (key and key.strip()):
         raise ValueError("Host key is not specified")
     osh = ObjectStateHolder(self.CIT)
     osh.setAttribute('host_key', key)
     osh.setBoolAttribute('host_iscomplete', True)
     return osh
示例#20
0
 def _createFolderOsh(self, folder):
     folderOsh = ObjectStateHolder('ms_exchange_folder')
     folderOsh.setAttribute('data_name', folder._name)
     folderOsh.setAttribute('url', folder.Url)
     folderOsh.setAttribute('data_description', folder.Comment)
     folderOsh.setAttribute('friendly_url', folder.FriendlyUrl)
     folderOsh.setBoolAttribute('is_mail_enabled', folder.IsMailEnabled)
     folderOsh.setAttribute('address_book_name', folder.AddressBookName)
     folderOsh.setAttribute('administrative_note',
                            folder.AdministrativeNote)
     folderOsh.setIntegerAttribute('contact_count', folder.ContactCount)
     return folderOsh
示例#21
0
 def __buildSimpleStorageByName(self, name=None):
     osh = ObjectStateHolder('storagearray')
     osh.setBoolAttribute('host_iscomplete', 1)
     osh.setAttribute('host_key', '%s@%s' % (self.__subArrays[name].name, self.__subArrays[name].storageId))
     setAttribute(osh, 'serial_number', self.__subArrays[name].serialNumber)
     setAttribute(osh, 'name', self.__subArrays[name].name)
     setAttribute(osh, 'discovered_model', self.__subArrays[name].model)
     setAttribute(osh, 'discovered_vendor', self.__subArrays[name].vendor)
     if self.firmware:
         osh.setAttribute('hardware_version', 'Microcode %s' % self.__subArrays[name].firmware)
     self.oshs[name] = osh
     return osh
示例#22
0
 def visitAwsEbsSnapshot(self, snapshot):
     r'@types: aws_store.EbsSnapshot -> ObjectStateHolder'
     osh = ObjectStateHolder('logicalvolume_snapshot')
     osh.setAttribute('name', snapshot.getId())
     if snapshot.getStartTime():
         osh.setAttribute('snapshot_create_time', snapshot.getStartTime())
     volume = snapshot.getVolume()
     if volume:
         osh.setAttribute('data_note', "VolumeId: %s" % volume.getId())
     osh.setBoolAttribute('isvirtual', 1)
     if snapshot.description:
         osh.setAttribute('description', snapshot.description)
     return osh
示例#23
0
 def _buildUser(self, user, containerOsh):
     'User, Host osh -> User'
     osh = ObjectStateHolder('winosuser')
     osh.setAttribute('data_name', user.name)
     osh.setAttribute('winosuser_full_name', user.fullName)
     osh.setAttribute('data_note', user.description)
     osh.setAttribute('data_externalid', user.uid)
     osh.setBoolAttribute('winosuser_isdisabled', user.isDisabled)
     osh.setAttribute('winosuser_domain', user.domain)
     osh.setBoolAttribute('winosuser_islocked', user.isLocked)
     osh.setContainer(containerOsh)
     user.osh = osh
     return user
示例#24
0
 def visitAwsEbsSnapshot(self, snapshot):
     r'@types: aws_store.EbsSnapshot -> ObjectStateHolder'
     osh = ObjectStateHolder('logicalvolume_snapshot')
     osh.setAttribute('name', snapshot.getId())
     if snapshot.getStartTime():
         osh.setAttribute('snapshot_create_time', snapshot.getStartTime())
     volume = snapshot.getVolume()
     if volume:
         osh.setAttribute('data_note', "VolumeId: %s" % volume.getId())
     osh.setBoolAttribute('isvirtual', 1)
     if snapshot.description:
         osh.setAttribute('description', snapshot.description)
     return osh
示例#25
0
def createResourceGroupObject(resourceGroup, clusteredServerOsh,
                              resultsVector):
    resourceGroupOsh = ObjectStateHolder('sunresourcegroup')
    resourceGroupOsh.setAttribute('data_name', resourceGroup.name)
    resourceGroupOsh.setContainer(clusteredServerOsh)

    resourceGroupOsh.setAttribute('mode', resourceGroup.mode)
    if resourceGroup.description:
        resourceGroupOsh.setAttribute('data_description',
                                      resourceGroup.description)
    if resourceGroup.maxPrimaries is not None:
        resourceGroupOsh.setIntegerAttribute('maximum_primaries',
                                             resourceGroup.maxPrimaries)
    if resourceGroup.desiredPrimaries is not None:
        resourceGroupOsh.setIntegerAttribute('desired_primaries',
                                             resourceGroup.desiredPrimaries)
    if resourceGroup.isManaged is not None:
        resourceGroupOsh.setBoolAttribute('is_managed',
                                          resourceGroup.isManaged)
    if resourceGroup.isSystem is not None:
        resourceGroupOsh.setBoolAttribute('is_system', resourceGroup.isSystem)
    if resourceGroup.isFailback is not None:
        resourceGroupOsh.setBoolAttribute('failback', resourceGroup.isFailback)
    if resourceGroup.autoStartOnNewCluster is not None:
        resourceGroupOsh.setBoolAttribute('auto_start_on_new_cluster',
                                          resourceGroup.autoStartOnNewCluster)

    resultsVector.add(resourceGroupOsh)
    return resourceGroupOsh
示例#26
0
 def createClusteredServiceOsh(self, packageName, clusterName):
     '''
         Creates clusteredservice OSH
         @param packageName: string
         @param clusterName: string
         @returns: instance of clusteredservice OSH
     '''
     if packageName and clusterName:
         clusteredServiceOsh = ObjectStateHolder('clusteredservice')
         clusteredServiceOsh.setAttribute('data_name', packageName)
         clusteredServiceOsh.setAttribute(
             'host_key', '%s:%s' % (clusterName, packageName))
         clusteredServiceOsh.setBoolAttribute('host_iscomplete', 1)
         return clusteredServiceOsh
示例#27
0
 def createClusteredServiceOsh(self, packageName, clusterName):
     '''
         Creates clusteredservice OSH
         @param packageName: string
         @param clusterName: string
         @returns: instance of clusteredservice OSH
     '''
     if packageName and clusterName:
         clusteredServiceOsh = ObjectStateHolder('clusteredservice')
         clusteredServiceOsh.setAttribute('data_name', packageName)
         clusteredServiceOsh.setAttribute('host_key', '%s:%s' %
                                         (clusterName, packageName))
         clusteredServiceOsh.setBoolAttribute('host_iscomplete', 1)
         return clusteredServiceOsh
示例#28
0
文件: ivm.py 项目: deezeesms/dd-git
def createVirtualServerOsh(vm, report_name=True):
    virtualServerOsh = ObjectStateHolder("host")
    if report_name:
        setStringAttribute(virtualServerOsh, "name", vm.vserver_config.name)
    setStringAttribute(virtualServerOsh, "serial_number",
                       vm.vserver_config.serial_number)
    setStringAttribute(
        virtualServerOsh, "bios_uuid", vm.vserver_config.uuid
        and vm.vserver_config.uuid.upper())
    setStringAttribute(virtualServerOsh, "discovered_os_name",
                       vm.vserver_config.discovered_os_name)
    virtualServerOsh.setBoolAttribute('host_iscomplete', 1)
    virtualServerOsh.setBoolAttribute('host_isvirtual', 1)
    virtualServerOsh.setStringAttribute("os_family", 'unix')
    return virtualServerOsh
示例#29
0
def buildAggrBackendSwitch(data):
    switch = ObjectStateHolder('switch')
    if data.name:
        switch.setStringAttribute('name', data.name)
    if data.serialNumber:   
        switch.setStringAttribute('serial_number', data.serialNumber)
    if data.description:
        switch.setStringAttribute('discovered_description', data.serialNumber)
    if data.model:
        switch.setStringAttribute('discovered_model', data.model)
    if data.swRev:
        switch.setStringAttribute('discovered_os_version', data.swRev)
    if data.vendor:
        switch.setStringAttribute('discovered_vendor', data.vendor)
    switch.setBoolAttribute('host_iscomplete', 1)
    return switch
示例#30
0
    def build(self, catalog):
        if catalog is None: raise ValueError("Catalog is None")
        
        catalogOsh = ObjectStateHolder('vcloud_catalog')
        catalogOsh.setStringAttribute('name', catalog.getName())
        
        if catalog.uuid:
            catalogOsh.setStringAttribute('vcloud_uuid', catalog.uuid.upper())
        
        if catalog.description:
            catalogOsh.setStringAttribute('description', catalog.description)

        if catalog.isPublished is not None:
            catalogOsh.setBoolAttribute('is_published', catalog.isPublished)
        
        return catalogOsh
示例#31
0
    def report(self, region_osh, openstack_osh):
        vector = ObjectStateHolderVector()
        networkOsh = ObjectStateHolder("openstack_network")
        networkOsh.setAttribute("network_id", self.id)
        networkOsh.setAttribute("name", self.name)
        networkOsh.setAttribute("physical_network", self.physicalNetworkName)
        networkOsh.setBoolAttribute("external_network", self.external)

        tenant_osh = ObjectStateHolder('openstack_tenant')
        tenant_osh.setStringAttribute('tenant_id', self.tenant_id)
        networkOsh.setContainer(tenant_osh)
        vector.add(tenant_osh)
        vector.add(networkOsh)
        vector.add(modeling.createLinkOSH('composition', openstack_osh, tenant_osh))
        vector.add(modeling.createLinkOSH('membership', region_osh, networkOsh))
        return networkOsh, vector
示例#32
0
def createIF_OSH(physicalAddress, hostOSH, description, macHostMap, hostedOnId, concentrator=0):
	ifOSH = ObjectStateHolder()
	if macHostMap.has_key(physicalAddress) and macHostMap[physicalAddress][0] == hostedOnId and concentrator == 0:
		#logger.debug ('Found existing interface OSH on host [%s]- %s' % (macHostMap[physicalAddress][0], macHostMap[physicalAddress][1]))
		if notNull(macHostMap[physicalAddress][1]):
			return macHostMap[physicalAddress][1]
	else:
		name = description
		ifOSH = modeling.createInterfaceOSH(physicalAddress, hostOSH, description, None, None, None, None, None, name)
		if ifOSH:
			if physicalAddress[0:4] == _MAC_PREFIX:		# create pseudo interfaces. these have no MAC addresses, so use the the key - 'ZZZZ' + NNM_INTERFACE_UID
				ifOSH.setBoolAttribute('isPseudo', 1)
			else:
				ifOSH.setBoolAttribute('isPseudo', 0)
			macHostMap[physicalAddress] = [hostedOnId, ifOSH]
	return ifOSH
示例#33
0
    def build(self, catalog):
        if catalog is None: raise ValueError("Catalog is None")

        catalogOsh = ObjectStateHolder('vcloud_catalog')
        catalogOsh.setStringAttribute('name', catalog.getName())

        if catalog.uuid:
            catalogOsh.setStringAttribute('vcloud_uuid', catalog.uuid.upper())

        if catalog.description:
            catalogOsh.setStringAttribute('description', catalog.description)

        if catalog.isPublished is not None:
            catalogOsh.setBoolAttribute('is_published', catalog.isPublished)

        return catalogOsh
示例#34
0
    def createDpmHostConfig(self, dpmHostSettings):
        dpmHostConfigOsh = ObjectStateHolder('vmware_dpm_config')
        dpmHostConfigOsh.setStringAttribute('data_name', 'VMware DPM Config')

        _ccHelper = self.getCrossClientHelper()

        enabled = _ccHelper.getBooleanValue(dpmHostSettings, 'enabled')
        if enabled is not None:
            dpmHostConfigOsh.setBoolAttribute('enabled', enabled)

        behavior = dpmHostSettings.getBehavior()
        behavior = behavior and self.getCrossClientHelper().getEnumValue(behavior)
        if behavior:
            dpmHostConfigOsh.setStringAttribute('behavior', behavior)

        return dpmHostConfigOsh
示例#35
0
文件: tibco.py 项目: deezeesms/dd-git
 def buildAdapter(self, adapter, binding):
     r'@types: Adapter, AdapterBinding -> ObjectStateHolder'
     assertFunc(adapter, ValueError('adapter is none'))
     assertFunc(binding, ValueError('binding is none'))
     adapterName = "%s\%s" % (adapter.getName(), binding.getName())
     osh = ObjectStateHolder("tibco_adapter")
     osh.setAttribute('name', adapterName)
     osh.setAttribute('vendor', "tibco")
     osh.setAttribute('application_category', "Enterprise App")
     osh.setAttribute('discovered_product_name', 'Tibco Adapter')
     osh.setAttribute('application_path', binding.getProduct().getLocation())
     osh.setAttribute('type', binding.getProduct().getType())
     osh.setAttribute('binding_name', binding.getName())
     osh.setBoolAttribute('enabled', Boolean.valueOf(adapter.isEnabled()))
     osh.setAttribute('version', binding.getProduct().getVersion())
     osh.setAttribute("application_ip", binding.getMachineName())
     return osh
示例#36
0
    def createDpmHostConfig(self, dpmHostSettings):
        dpmHostConfigOsh = ObjectStateHolder('vmware_dpm_config')
        dpmHostConfigOsh.setStringAttribute('data_name', 'VMware DPM Config')

        _ccHelper = self.getCrossClientHelper()

        enabled = _ccHelper.getBooleanValue(dpmHostSettings, 'enabled')
        if enabled is not None:
            dpmHostConfigOsh.setBoolAttribute('enabled', enabled)

        behavior = dpmHostSettings.getBehavior()
        behavior = behavior and self.getCrossClientHelper().getEnumValue(
            behavior)
        if behavior:
            dpmHostConfigOsh.setStringAttribute('behavior', behavior)

        return dpmHostConfigOsh
示例#37
0
    def build(self, certificate):
        '''
            Build ssl_certificate OSH from X509Certificate
            @types: X509Certificate -> ObjectStateHolderVector
        '''
        certOsh = ObjectStateHolder('digital_certificate')
        certOsh.setDateAttribute("valid_to", certificate.expiresOn)
        certOsh.setDateAttribute("create_on", certificate.createOn)
        certOsh.setStringAttribute("issuer", unicode(certificate.issuer.raw))
        certOsh.setStringAttribute("subject", unicode(certificate.subject.raw))
        certOsh.setStringAttribute("serial_number", certificate.sn)

        if certificate.version:
            certOsh.setIntegerAttribute("version", certificate.version)

        if certificate.signatureAlgorithm:
            certOsh.setStringAttribute("signature_algorithm", certificate.signatureAlgorithm)

        if certificate.type:
            certOsh.setStringAttribute("type", certificate.type)

        organization = certificate.subject.dn.find_first('O')
        if organization:
            certOsh.setStringAttribute("organization", organization.value)

        organization_unit = certificate.subject.dn.lookup('OU')
        if organization_unit:
            ou = map(lambda obj: str(obj.value), organization_unit)
            certOsh.setListAttribute("organization_unit", ou)

        cnSubject = certificate.subject.dn.find_first('CN')
        if cnSubject and cnSubject.value:
            certOsh.setStringAttribute("common_name", cnSubject.value)

        cnIssuer = certificate.issuer.dn.find_first('CN')
        oIssuer = certificate.issuer.dn.find_first('O')
        issuerName = None
        if cnIssuer and cnIssuer.value:
            issuerName = cnIssuer.value
        else:
            issuerName = oIssuer and oIssuer.value
        certOsh.setStringAttribute("issuer_name", issuerName)

        isSelfSigned = certificate.subject.raw == certificate.issuer.raw
        certOsh.setBoolAttribute("is_self_signed", isSelfSigned)
        return certOsh
示例#38
0
 def visitRdsDbInstanceNode(self, node):
     r''' Creates complete host where host_key value is DB server address
     @types: aws_rds.Builder.InstanceNode -> ObjectStateHolder'''
     instance = node.instance
     osh = ObjectStateHolder('node')
     address = instance.getServer().address
     if not address:
         raise ValueError("Node address is not specified")
     osh.setAttribute("host_key", '%s' % address)
     hostname = address.split('.', 1)[0]
     osh.setAttribute('name', hostname)
     osh.setBoolAttribute('host_iscomplete', 1)
     # PrimaryDnsName
     osh.setAttribute("primary_dns_name", address)
     # NodeRole | Is Virtual
     builder = modeling.HostBuilder(osh)
     builder.setAsVirtual(1)
     return builder.build()
示例#39
0
 def build(self, vapp):
     if vapp is None: raise ValueError("vapp is None")
     
     vappOsh = ObjectStateHolder('vcloud_vapp')
     vappOsh.setStringAttribute('name', vapp.getName())
     
     if vapp.description:
         vappOsh.setStringAttribute('description', vapp.description)
     
     if vapp.isDeployed is not None:
         vappOsh.setBoolAttribute('is_deployed', vapp.isDeployed)
     
     if vapp.status.value() is not None:
         statusValue = VappBuilder._STATUS_TO_VALUE.get(vapp.status.value())
         if statusValue:
             vappOsh.setStringAttribute('status', statusValue)
     
     return vappOsh
示例#40
0
def osh_createIBMframeOsh(lparOsh, cecTable):
    str_name = 'name'
    str_discovered_model = 'discovered_model'
    str_serial_number = 'serial_number'
    isComplete = 1
    _vector = ObjectStateHolderVector()
    cecOsh = ObjectStateHolder('ibm_pseries_frame')  # iSeries CEC
    cecOsh.setAttribute(str_name, 'CEC' + cecTable[0][2])
    cecOsh.setBoolAttribute('host_iscomplete', isComplete)
    cecOsh.setAttribute(str_discovered_model, cecTable[0][1])  # CPC SI
    cecOsh.setAttribute('host_key', cecTable[0][2])
    cecOsh.setAttribute(str_serial_number, cecTable[0][2])
    str_membership = 'membership'
    membershipOsh = modeling.createLinkOSH(str_membership, cecOsh, lparOsh)
    _vector.add(cecOsh)
    _vector.add(lparOsh)
    _vector.add(membershipOsh)
    return _vector
示例#41
0
def osh_createIBMframeOsh(lparOsh ,cecTable):
    str_name = 'name'    
    str_discovered_model = 'discovered_model'
    str_serial_number = 'serial_number'     
    isComplete = 1 
    _vector = ObjectStateHolderVector()
    cecOsh = ObjectStateHolder('ibm_pseries_frame')                          # iSeries CEC
    cecOsh.setAttribute(str_name, 'CEC'+cecTable[0][2])                            
    cecOsh.setBoolAttribute('host_iscomplete', isComplete)
    cecOsh.setAttribute( str_discovered_model, cecTable[0][1])                  # CPC SI    
    cecOsh.setAttribute('host_key', cecTable[0][2])
    cecOsh.setAttribute( str_serial_number , cecTable[0][2])   
    str_membership = 'membership'        
    membershipOsh = modeling.createLinkOSH(str_membership, cecOsh, lparOsh)
    _vector.add(cecOsh)
    _vector.add(lparOsh)
    _vector.add(membershipOsh)
    return _vector
示例#42
0
    def build(self, vapp):
        if vapp is None: raise ValueError("vapp is None")

        vappOsh = ObjectStateHolder('vcloud_vapp')
        vappOsh.setStringAttribute('name', vapp.getName())

        if vapp.description:
            vappOsh.setStringAttribute('description', vapp.description)

        if vapp.isDeployed is not None:
            vappOsh.setBoolAttribute('is_deployed', vapp.isDeployed)

        if vapp.status.value() is not None:
            statusValue = VappBuilder._STATUS_TO_VALUE.get(vapp.status.value())
            if statusValue:
                vappOsh.setStringAttribute('status', statusValue)

        return vappOsh
示例#43
0
 def buildCluster(self, cluster):
     r'@types: Cluster -> ObjectStateHolder'
     assert cluster
     osh = ObjectStateHolder('mscluster')
     osh.setAttribute('data_name', cluster.name)
     modeling.setAppSystemVendor(osh)
     if cluster.version:
         osh.setAttribute('version', cluster.version)
     details = cluster.details
     if details:
         if details.defaultNetworkRole:
             osh.setAttribute('defaultNetworkRole',
                              details.defaultNetworkRole)
         if details.enableEventLogReplication is not None:
             osh.setBoolAttribute('enableEventLogReplication',
                                  details.enableEventLogReplication)
         if details.quorumArbitrationTimeMax is not None:
             osh.setAttribute('quorumArbitrationTimeMax',
                              int(details.quorumArbitrationTimeMax))
         if details.quorumArbitrationTimeMin is not None:
             osh.setAttribute('quorumArbitrationTimeMin',
                              int(details.quorumArbitrationTimeMin))
         if details.enableResourceDllDeadlockDetection is not None:
             osh.setBoolAttribute(
                 'enableResourceDllDeadlockDetection',
                 details.enableResourceDllDeadlockDetection)
         if details.resourceDllDeadlockTimeout is not None:
             osh.setAttribute('resourceDllDeadlockTimeout',
                              int(details.resourceDllDeadlockTimeout))
         if details.resourceDllDeadlockThreshold is not None:
             osh.setAttribute('resourceDllDeadlockThreshold',
                              int(details.resourceDllDeadlockThreshold))
         if details.resourceDllDeadlockPeriod is not None:
             osh.setAttribute('resourceDllDeadlockPeriod',
                              int(details.resourceDllDeadlockPeriod))
         if details.clusSvcHeartbeatTimeout is not None:
             osh.setAttribute('clusSvcHeartbeatTimeout',
                              int(details.clusSvcHeartbeatTimeout))
         if details.hangRecoveryAction:
             osh.setAttribute('hangRecoveryAction',
                              details.hangRecoveryAction)
     return osh
示例#44
0
 def buildCluster(self, cluster):
     r'@types: Cluster -> ObjectStateHolder'
     assert cluster
     osh = ObjectStateHolder('mscluster')
     osh.setAttribute('data_name', cluster.name)
     modeling.setAppSystemVendor(osh)
     if cluster.version:
         osh.setAttribute('version', cluster.version)
     details = cluster.details
     if details:
         if details.defaultNetworkRole:
             osh.setAttribute('defaultNetworkRole',
                              details.defaultNetworkRole)
         if details.enableEventLogReplication is not None:
             osh.setBoolAttribute('enableEventLogReplication',
                                  details.enableEventLogReplication)
         if details.quorumArbitrationTimeMax is not None:
             osh.setAttribute('quorumArbitrationTimeMax',
                              int(details.quorumArbitrationTimeMax))
         if details.quorumArbitrationTimeMin is not None:
             osh.setAttribute('quorumArbitrationTimeMin',
                              int(details.quorumArbitrationTimeMin))
         if details.enableResourceDllDeadlockDetection is not None:
             osh.setBoolAttribute('enableResourceDllDeadlockDetection',
                              details.enableResourceDllDeadlockDetection)
         if details.resourceDllDeadlockTimeout is not None:
             osh.setAttribute('resourceDllDeadlockTimeout',
                              int(details.resourceDllDeadlockTimeout))
         if details.resourceDllDeadlockThreshold is not None:
             osh.setAttribute('resourceDllDeadlockThreshold',
                              int(details.resourceDllDeadlockThreshold))
         if details.resourceDllDeadlockPeriod is not None:
             osh.setAttribute('resourceDllDeadlockPeriod',
                              int(details.resourceDllDeadlockPeriod))
         if details.clusSvcHeartbeatTimeout is not None:
             osh.setAttribute('clusSvcHeartbeatTimeout',
                              int(details.clusSvcHeartbeatTimeout))
         if details.hangRecoveryAction:
             osh.setAttribute('hangRecoveryAction',
                              details.hangRecoveryAction)
     return osh
示例#45
0
 def buildGroup(self, group):
     r'@types: ResourceGroup -> ObjectStateHolder'
     assert group
     osh = ObjectStateHolder('mscsgroup')
     osh.setAttribute('data_name', group.name)
     if group.details:
         details = group.details
         if details.description:
             osh.setStringAttribute('data_description', details.description)
         persistentState = details.persistentState
         if persistentState is not None:
             osh.setBoolAttribute('persistentstate', persistentState)
         threshold = details.failoverThreshold
         if (threshold is not None and threshold < Integer.MAX_VALUE):
             osh.setIntegerAttribute('failoverthreshold', threshold)
         period = details.failoverPeriod
         if (period is not None and period < Integer.MAX_VALUE):
             osh.setIntegerAttribute('failoverperiod', period)
         if details.autoFailbackType is not None:
             osh.setAttribute('autofailbacktype', details.autoFailbackType)
     return osh
示例#46
0
 def buildGroup(self, group):
     r'@types: ResourceGroup -> ObjectStateHolder'
     assert group
     osh = ObjectStateHolder('mscsgroup')
     osh.setAttribute('data_name', group.name)
     if group.details:
         details = group.details
         if details.description:
             osh.setStringAttribute('data_description', details.description)
         persistentState = details.persistentState
         if persistentState is not None:
             osh.setBoolAttribute('persistentstate', persistentState)
         threshold = details.failoverThreshold
         if (threshold is not None and threshold < Integer.MAX_VALUE):
             osh.setIntegerAttribute('failoverthreshold', threshold)
         period = details.failoverPeriod
         if (period is not None and period < Integer.MAX_VALUE):
             osh.setIntegerAttribute('failoverperiod', period)
         if details.autoFailbackType is not None:
             osh.setAttribute('autofailbacktype', details.autoFailbackType)
     return osh
示例#47
0
 def buildResource(self, resource):
     r'@types: Resource -> ObjectStateHolder'
     osh = ObjectStateHolder('mscsresource')
     osh.setAttribute('data_name', resource.name)
     if resource.details:
         details = resource.details
         if details.description:
             osh.setStringAttribute('data_description', details.description)
         if details.type is not None:
             osh.setStringAttribute('type', details.type)
         if details.debugPrefix:
             osh.setStringAttribute('debugPrefix', details.debugPrefix)
         if details.separateMonitor is not None:
             osh.setBoolAttribute('separateMonitor',
                                  details.separateMonitor)
         if details.persistentState is not None:
             osh.setBoolAttribute('persistentState',
                                  details.persistentState)
         if details.looksAlivePollInterval is not None:
             osh.setStringAttribute('looksAlivePollInterval',
                                    str(details.looksAlivePollInterval))
         if details.isAlivePollInterval is not None:
             osh.setStringAttribute('isAlivePollInterval',
                                    str(details.isAlivePollInterval))
         if details.restartAction is not None:
             osh.setStringAttribute('restartAction',
                                    str(details.restartAction))
         if details.restartThreshold is not None:
             osh.setIntegerAttribute('restartThreshold',
                                     int(details.restartThreshold))
         if details.restartPeriod is not None:
             osh.setStringAttribute('restartPeriod',
                                    str(details.restartPeriod))
         if details.retryPeriodOnFailure is not None:
             osh.setStringAttribute('retryPeriodonFailure',
                                    str(details.retryPeriodOnFailure))
         if details.pendingTimeout is not None:
             osh.setStringAttribute('pendingTimeout',
                                    str(details.pendingTimeout))
     return osh
示例#48
0
def reportRemotePeer(remote_peer, localInterfaceOsh, local_mac):
    vector = ObjectStateHolderVector()
    if remote_peer.peer_ips:
        hostOsh = modeling.createHostOSH(str(remote_peer.peer_ips[0]))
    if remote_peer.platform in VIRTUAL_HOST_PLATFORMS:
        hostOsh.setBoolAttribute('host_isvirtual', 1)
        vector.add(hostOsh)
        for ip in remote_peer.peer_ips:
            ipOsh = modeling.createIpOSH(ip)
            linkOsh = modeling.createLinkOSH('containment', hostOsh, ipOsh)
            vector.add(ipOsh)
            vector.add(linkOsh)
    else:
        hostOsh = ObjectStateHolder('node')
        hostOsh.setBoolAttribute('host_iscomplete', 1)
        hostOsh.setStringAttribute('name', remote_peer.system_name)
        if remote_peer.platform in VIRTUAL_HOST_PLATFORMS:
            hostOsh.setBoolAttribute('host_isvirtual', 1)
        vector.add(hostOsh)

    if remote_peer.interface_name or remote_peer.interface_mac:
        remoteInterfaceOsh = modeling.createInterfaceOSH(
            mac=remote_peer.interface_mac,
            hostOSH=hostOsh,
            name=remote_peer.interface_name)
        if not remoteInterfaceOsh:
            return ObjectStateHolderVector()
        if remote_peer.interface_name:
            remoteInterfaceOsh.setStringAttribute('name',
                                                  remote_peer.interface_name)
        vector.add(remoteInterfaceOsh)
        l2id = str(
            hash(':'.join([
                remote_peer.interface_mac or remote_peer.interface_name,
                local_mac
            ])))
        vector.addAll(
            reportLayer2Connection(localInterfaceOsh, remoteInterfaceOsh,
                                   l2id))
    return vector