X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fcontrib%2F90_gosa.conf;h=72ae8b088c717a075ebaadfacd0a33c0e2b14265;hb=5eee3c19adca35c713624bf74c5e13a6c9fc6d28;hp=cb957c94a98cc859d894f9dbf92916940aed8316;hpb=9c643be6bc7e7eaadeb5d7af6628e64db170a4c0;p=gosa.git diff --git a/gosa-si/contrib/90_gosa.conf b/gosa-si/contrib/90_gosa.conf index cb957c94a..72ae8b088 100644 --- a/gosa-si/contrib/90_gosa.conf +++ b/gosa-si/contrib/90_gosa.conf @@ -1,6 +1,9 @@ -''' Override built in function to get clients ''' +''' Add a couple of additional functions to retrieve needed information with + just one call. ''' -def getClients_listOfHashes(self, serverId=None, depotIds=[], groupId=None, productId=None, installationStatus=None, actionRequest=None, productVersion=None, packageVersion=None): +logger= Logger() + +def getClientsInformation_listOfHashes(self, serverId=None, depotIds=[], groupId=None, productId=None, installationStatus=None, actionRequest=None, productVersion=None, packageVersion=None): # Get backend instance and load client list bi= self.backends[self.clientManagingBackend]['instance'] @@ -11,3 +14,133 @@ def getClients_listOfHashes(self, serverId=None, depotIds=[], groupId=None, prod client['macAddress']= bi.getMacAddress(client['hostId']) return clients + + + +def getProductHostInformation_list(self, objectId=None, installationStatus=None, type='localboot'): + result = [] + + # Generate a dictionary for faster lookup of product IDs + products= {} + productIds= self.getProductIds_list(type, objectId, installationStatus) + for productId in productIds: + products[productId]= 1 + + # Load product states + productStates= self.getProductStates_hash(objectId) + + # Extend every entry by name and description + for product in productStates[objectId]: + if not products.has_key(product['productId']): + continue + + # Add missing information to the productInfo + if product['installationStatus'] != "not_installed" or product['actionRequest'] == "setup": + productInfo= self.getProduct_hash(product['productId']) + productInfo['installationStatus']= product['installationStatus'] + productInfo['actionRequest']= product['actionRequest'] + productInfo['productId']= product['productId'] + result.append(productInfo) + + return result + + + +def getProductInformation_list(self, installationStatus=None, type='localboot'): + result = [] + + # Generate a dictionary for faster lookup of product IDs + productIds= self.getProductIds_list(type, None, installationStatus) + + # Extend every entry by name and description + for productId in productIds: + + # Add missing information to the productInfo + productInfo= self.getProduct_hash(productId) + productInfo['productId']= productId + result.append(productInfo) + + return result + + +def getFullProductHostInformation_list(self, objectId=None, installationStatus=None): + result = [] + + types = ['localboot','netboot'] + for type in types: + + # Load product ids + productIds= self.getProductIds_list(type, None, installationStatus) + + # Load product states + if objectId != None: + productStates= self.getProductStates_hash(objectId) + + # Extend every entry by name and description + for productId in productIds: + + # Add missing information to the productInfo + productInfo= self.getProduct_hash(productId) + productInfo['productId']= productId + productInfo['type']= type; + + # Find product entry + currentState= None + if objectId != None: + for state in productStates[objectId]: + if state['productId'] == productId: + currentState= state + break + else: + state = {} + state['installationStatus'] = "not_installed" + state['actionRequest'] = "none" + currentState= state + + # Add missing information to the productInfo + if currentState['installationStatus'] != "not_installed" or \ + currentState['actionRequest'] == "setup": + + # Add state for enabled products + productInfo['installationStatus']= currentState['installationStatus'] + productInfo['actionRequest']= currentState['actionRequest'] + + # Add properties + productInfo['action']= self.getPossibleProductActions_list(productId) + + # Load actual property values + propertyDefinitions= self.getProductPropertyDefinitions_listOfHashes(productId) + propertyValues= dict() + propertyDescriptions= dict() + propertyDefaults= dict() + + for property in propertyDefinitions: + if property.has_key('values'): + propertyValues[property['name']]= property['values'] + if property.has_key('description'): + propertyDescriptions[property['name']]= property['description'] + if property.has_key('default'): + propertyDefaults[property['name']]= property['default'] + + # Load all properties and complete with values/descriptions + combinedProperties= dict() + productProperties= self.getProductProperties_hash(productId, objectId) + properties= productProperties.keys() + for property in properties: + combinedProperties[property]= dict() + if propertyDescriptions.has_key(property): + combinedProperties[property]['description']= propertyDescriptions[property] + if propertyValues.has_key(property): + combinedProperties[property]['values']= propertyValues[property] + if propertyDefaults.has_key(property): + combinedProperties[property]['default']= propertyDefaults[property] + combinedProperties[property]['current']= productProperties[property] + + # Add product properties to current product info + productInfo['properties']= combinedProperties + + # Push information + result.append(productInfo) + + return result +