Example #1
0
 def delAppBizSource(self, appBiz, appInstance):
     #get relationship between CMDB_AppInstance and CMDB_AppBiz
     conditionDict = {}
     conditionDict['force'] = appInstance.id
     conditionDict['force_table'] = appInstance.tableName()
     conditionDict['source_id'] = appBiz.id
     conditionDict['source_table'] = appBiz.tableName()
     bizRelationshipList = RelationshipManager().getRelationship(
         conditionDict)
     if not bizRelationshipList:
         #add logging
         pass
     else:
         RelationshipManager().disMountSource(appInstance, appBiz)
Example #2
0
    def __getRelationshipListByEnv(self, envValue, appValue, appTypeValue):
        conditionDict = {
            'env': envValue,
            'app': appValue,
            'app_type': appTypeValue
        }
        appBizList = AppBizManager.getAppBizByCondition(conditionDict)
        if not appBizList:
            #add logging
            return

        appInstance = CMDB_AppInstance()
        relationshipList = []
        for appBiz in appBizList:
            conditionDict['source'] = appBiz.id
            conditionDict['source_table'] = appBiz.tableName()
            conditionDict['force_table'] = appInstance.tableName()
            relationshipList2 = RelationshipManager().getRelationship(
                conditionDict)
            if not relationshipList2:
                #add logging
                pass
            else:
                relationshipList += relationshipList2

        return relationshipList
Example #3
0
    def getAppBizListByAppInstance(self, appInstance):
        appBiz = CMDB_AppBiz()
        conditionDict = {}
        conditionDict['force'] = appInstance.id
        conditionDict['force_table'] = appInstance.tableName()
        conditionDict['source_table'] = appBiz.tableName()

        bizRelationshipList = RelationshipManager().getRelationship(
            conditionDict)
        if not bizRelationshipList:
            #add logging
            return
        conditionDict.clear()
        conditionDict['id'] = bizRelationshipList[0].source
        appBizList = AppBizManager().getAppBizByCondition(conditionDict)

        return appBizList
Example #4
0
    def __getRelationshipByIp(self, ip):
        conditionDict = {'ip': ip}
        ipSourceList = IpSourceManager().getIpSourceInfo(conditionDict)
        if not ipSourceList:
            #add logging
            return

        ipSource = ipSourceList[0]
        appInstance = CMDB_AppInstance()
        conditionDict['source'] = ipSource.id
        conditionDict['source_table'] = ipSource.tableName()
        conditionDict['force_table'] = appInstance.tableName()
        relationshipList = RelationshipManager().getRelationship(conditionDict)
        if not relationshipList:
            return

        return relationshipList[0]
Example #5
0
    def getIpSourceByAppInstance(self, appInstance):
        ipSource = CMDB_Ip_Source()
        conditionDict = {}
        conditionDict['force'] = appInstance.id
        conditionDict['force_table'] = appInstance.tableName()
        conditionDict['source_table'] = ipSource.tableName()

        ipRelationshipList = RelationshipManager().getRelationship(
            conditionDict)
        if not ipRelationshipList:
            #add logging
            return
        conditionDict.clear()
        conditionDict['id'] = ipRelationshipList[0].source
        ipSourceList = IpSourceManager().getIpSourceInfo(conditionDict)
        if not ipSourceList:
            #add logging
            return

        return ipSourceList[0]
Example #6
0
    def modifyAppBizSource(self, appBizList, appInstance):
        conditionDict = {}
        conditionDict['force'] = appInstance.id
        appInstance = CMDB_AppInstance()
        appBiz = CMDB_AppBiz()
        conditionDict['force_table'] = appInstance.tableName()
        conditionDict['source_table'] = appBiz.tableName()
        bizRelationshipList = RelationshipManager().getRelationship(
            conditionDict)
        if not bizRelationshipList:
            for appBiz in appBizList:
                self.createAndMountAppBizSource(appBiz, appInstance)
        else:
            existAppBizIdList = []
            for bizRelationship in bizRelationshipList:
                existAppBizIdList.append(bizRelationship.source)

            for appBiz in appBizList:
                if appBiz.id in existAppBizIdList:
                    self.updateAppBizSource(appBiz, appInstance)
                else:
                    self.createAndMountAppBizSource(appBiz, appInstance)
Example #7
0
 def createAndMountAppBizSource(self, appBiz, appInstance):
     RelationshipManager().mountAndInsertSource(appInstance, appBiz)