Code

Updated opsi stuff to gain more speed
[gosa.git] / gosa-si / contrib / 90_gosa.conf
1 ''' Add a couple of additional functions to retrieve needed information with
2     just one call. '''
4 def getClientsInformation_listOfHashes(self, serverId=None, depotIds=[], groupId=None, productId=None, installationStatus=None, actionRequest=None, productVersion=None, packageVersion=None):
6     # Get backend instance and load client list
7     bi= self.backends[self.clientManagingBackend]['instance']
8     clients= bi.getClients_listOfHashes(serverId, depotIds, groupId, productId, installationStatus, actionRequest, productVersion, packageVersion)
10     # Get MAC and IP for every client
11     for client in clients:
12         client['macAddress']= bi.getMacAddress(client['hostId'])
14     return clients
17 def getProductHostInformation_list(self, objectId=None, installationStatus=None, type='localboot'):
18     result = []
20     # Generate a dictionary for faster lookup of product IDs
21     products= {}
22     productIds= self.getProductIds_list(type, objectId, installationStatus)
23     for productId in productIds:
24         products[productId]= 1
26     # Load product states
27     productStates= self.getProductStates_hash(objectId)
29     # Extend every entry by name and description
30     for product in productStates[objectId]:
31         if not products.has_key(product['productId']):
32             continue
34          # Add missing information to the productInfo
35         if product['installationStatus'] != "not_installed" or product['actionRequest'] == "setup":
36             productInfo= self.getProduct_hash(product['productId'])
37             productInfo['installationStatus']= product['installationStatus']
38             productInfo['actionRequest']= product['actionRequest']
39             productInfo['productId']= product['productId']
40             result.append(productInfo)
42     return result
45 def getProductInformation_list(self, installationStatus=None, type='localboot'):
46     result = []
48     # Generate a dictionary for faster lookup of product IDs
49     productIds= self.getProductIds_list(type, None, installationStatus)
51     # Extend every entry by name and description
52     for productId in productIds:
54          # Add missing information to the productInfo
55          productInfo= self.getProduct_hash(productId)
56          productInfo['productId']= productId
57          result.append(productInfo)
59     return result