For this class, the constructor is called init(), rather than the customary .__init__(), because of the way the Singleton parent class works—it
guarantees that the constructor will be called only once.
That's an especially good idea here, because the
constructor has a lot to do. It has to rummage through
the LDAP clients tree to find all the publicly available
TCC clients (including login servers). Then it has to
query the GetHardware XML-RPC interface
for each client in order to extract and store that
client's hardware configuration data. Both operations
combined take, at this writing, on the order of half a
minute.
# - - - C l i e n t S e t . i n i t
def init(self, reportInfo, **kw):
'''Constructor for ClientSet.
'''
The work of the constructor will proceed in two phases.
In the first phase, we will extract the client list from
LDAP. In the second phase, we will use that client list
to extract configuration data from GetHardware. We need reportInfo
because it tells us which peripheral devices are of
interest to users.
So, what data structure should be passed between these
two phases? If we use the LDAP tccOfficeMachine attribute to filter out office
machines, we are left with only two items of information
for each client: its name, and its tccSpecialOS attribute, if there is one—we'll use an empty string as
the default value.
At this point, we can represent the client list as a
dictionary, where each key is the client name and the
value is the tccSpecialOS attribute.
#-- 1 --
# [ ldap0.nmt.edu contains client info ->
# ldapMap := a dictionary whose keys are the
# non-office machine names from LDAP's client tree,
# and each corresponding value is its tccSpecialOS
# attribute (defaulting to '') ]
ldapMap = self.__buildLdapMap()
That dictionary, plus the information from GetHardware, is sufficient to set up our
instance's .__clientMap.
#-- 2 --
# [ self := self with ClientConfig instances added for
# clients whose hostnames are keys of ldapMap and
# for which the GetHardware XML-RPC interface has
# client configuration data, including device types
# from reportInfo ]
self.__buildClientMap ( reportInfo, ldapMap )