1 ''' Add a couple of additional functions to retrieve needed information with
2 just one call. '''
4 logger= Logger()
6 def getClientsInformation_listOfHashes(self, serverId=None, depotIds=[], groupId=None, productId=None, installationStatus=None, actionRequest=None, productVersion=None, packageVersion=None):
8 # Get backend instance and load client list
9 bi= self.backends[self.clientManagingBackend]['instance']
10 clients= bi.getClients_listOfHashes(serverId, depotIds, groupId, productId, installationStatus, actionRequest, productVersion, packageVersion)
12 # Get MAC and IP for every client
13 for client in clients:
14 client['macAddress']= bi.getMacAddress(client['hostId'])
16 return clients
20 def getProductHostInformation_list(self, objectId=None, installationStatus=None, type='localboot'):
21 result = []
23 # Generate a dictionary for faster lookup of product IDs
24 products= {}
25 productIds= self.getProductIds_list(type, objectId, installationStatus)
26 for productId in productIds:
27 products[productId]= 1
29 # Load product states
30 productStates= self.getProductStates_hash(objectId)
32 # Extend every entry by name and description
33 for product in productStates[objectId]:
34 if not products.has_key(product['productId']):
35 continue
37 # Add missing information to the productInfo
38 if product['installationStatus'] != "not_installed" or product['actionRequest'] == "setup":
39 productInfo= self.getProduct_hash(product['productId'])
40 productInfo['installationStatus']= product['installationStatus']
41 productInfo['actionRequest']= product['actionRequest']
42 productInfo['productId']= product['productId']
43 result.append(productInfo)
45 return result
49 def getProductInformation_list(self, installationStatus=None, type='localboot'):
50 result = []
52 # Generate a dictionary for faster lookup of product IDs
53 productIds= self.getProductIds_list(type, None, installationStatus)
55 # Extend every entry by name and description
56 for productId in productIds:
58 # Add missing information to the productInfo
59 productInfo= self.getProduct_hash(productId)
60 productInfo['productId']= productId
61 result.append(productInfo)
63 return result
66 def getFullProductHostInformation_list(self, objectId=None, installationStatus=None):
67 result = []
69 types = ['localboot','netboot']
70 for type in types:
72 # Load product ids
73 productIds= self.getProductIds_list(type, None, installationStatus)
75 # Load product states
76 productStates= self.getProductStates_hash(objectId)
78 # Extend every entry by name and description
79 for productId in productIds:
81 # Add missing information to the productInfo
82 productInfo= self.getProduct_hash(productId)
83 productInfo['productId']= productId
84 productInfo['type']= type;
86 # Find product entry
87 currentState= None
88 for state in productStates[objectId]:
89 if state['productId'] == productId:
90 currentState= state
91 break
93 # Add missing information to the productInfo
94 if currentState['installationStatus'] != "not_installed" or \
95 currentState['actionRequest'] == "setup":
97 # Add state for enabled products
98 productInfo['installationStatus']= currentState['installationStatus']
99 productInfo['actionRequest']= currentState['actionRequest']
101 # Add properties
102 productInfo['action']= self.getPossibleProductActions_list(productId)
104 # Load actual property values
105 propertyDefinitions= self.getProductPropertyDefinitions_listOfHashes(productId)
106 propertyValues= dict()
107 propertyDescriptions= dict()
108 propertyDefaults= dict()
110 for property in propertyDefinitions:
111 if property.has_key('values'):
112 propertyValues[property['name']]= property['values']
113 if property.has_key('description'):
114 propertyDescriptions[property['name']]= property['description']
115 if property.has_key('default'):
116 propertyDefaults[property['name']]= property['default']
118 # Load all properties and complete with values/descriptions
119 combinedProperties= dict()
120 productProperties= self.getProductProperties_hash(productId, objectId)
121 properties= productProperties.keys()
122 for property in properties:
123 combinedProperties[property]= dict()
124 if propertyDescriptions.has_key(property):
125 combinedProperties[property]['description']= propertyDescriptions[property]
126 if propertyValues.has_key(property):
127 combinedProperties[property]['values']= propertyValues[property]
128 if propertyDefaults.has_key(property):
129 combinedProperties[property]['default']= propertyDefaults[property]
130 combinedProperties[property]['current']= productProperties[property]
132 # Add product properties to current product info
133 productInfo['properties']= combinedProperties
135 # Push information
136 result.append(productInfo)
138 return result