Пример #1
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
Пример #2
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
Пример #3
0
 def getAppBizByCondition(self,conditionDict):
     condition = Q(flag = True)
     appBiz = CMDB_AppBiz()
     
     if conditionDict.has_key('env') and conditionDict['env'] is not None:
         envValue = appBiz.getEnv(conditionDict['env'])
         condition.add(Q(env = envValue.id), Q.AND)
     if conditionDict.has_key('app') and conditionDict['app'] is not None:
         appValue = appBiz.getApp(conditionDict['app'])
         condition.add(Q(app = appValue.id), Q.AND)
     if conditionDict.has_key('app_type') and conditionDict['app_type'] is not None:
         appTypeValue = appBiz.getAppType(conditionDict['app_type'])
         condition.add(Q(app_type = appTypeValue.id), Q.AND)
     if conditionDict.has_key('app_port') and conditionDict['app_port'] is not None:
         condition.add(Q(app_port = conditionDict['app_port']), Q.AND)
     if conditionDict.has_key('app_source') and conditionDict['app_source'] is not None:
         condition.add(Q(app_source__contains = conditionDict['app_source']), Q.AND)
     
     return CMDB_AppBiz.objects.filter(condition)
Пример #4
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)
Пример #5
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)