@@ -77,12 +77,28 @@ def get_logging_config(self):
7777 return self .main_config .get_dict_config ('logging' , True )
7878
7979 def get_umapi_options (self ):
80+ '''
81+ Read and return the primary and secondary umapi connector configs.
82+ The primary is a singleton, the secondaries are a map from name to config.
83+ The syntax in the config file is rather complex, which makes this code a bit complex;
84+ be sure you read the detailed docs before trying to read this function.
85+ We also check for and err out gracefully if it's a v1-style config file.
86+ :return: tuple: (primary, secondary_map)
87+ '''
88+ if self .main_config .get_dict_config ('dashboard' , True ):
89+ raise AssertionException ("Your main configuration file is still in v1 format. Please convert it to v2." )
8090 adobe_users_config = self .main_config .get_dict_config ('adobe_users' , True )
81- connector_config = adobe_users_config and adobe_users_config .get_dict_config ('connectors' , True )
82- if connector_config :
83- umapi_config = connector_config .get_list ('umapi' , True )
91+ if not adobe_users_config :
92+ return {}, {}
93+ connector_config = adobe_users_config .get_dict_config ('connectors' , True )
94+ if not connector_config :
95+ return {}, {}
96+ umapi_config = connector_config .get_list ('umapi' , True )
97+ if not umapi_config :
98+ return {}, {}
8499 # umapi_config is a list of strings (primary umapi source files) followed by a
85- # list of dicts (secondary umapi source specifications, which are lists of strings)
100+ # list of dicts (secondary umapi source specifications, whose keys are umapi names
101+ # and whose values are a list of config file strings)
86102 secondary_config_sources = {}
87103 primary_config_sources = []
88104 for item in umapi_config :
@@ -140,7 +156,8 @@ def get_directory_groups(self):
140156 :rtype dict(str, list(user_sync.rules.AdobeGroup))
141157 '''
142158 adobe_groups_by_directory_group = {}
143-
159+ if self .main_config .get_dict_config ('directory' , True ):
160+ raise AssertionException ("Your main configuration file is still in v1 format. Please convert it to v2." )
144161 groups_config = None
145162 directory_config = self .main_config .get_dict_config ('directory_users' , True )
146163 if (directory_config != None ):
@@ -174,10 +191,10 @@ def get_directory_extension_options(self):
174191 if directory_config :
175192 sources = directory_config .get_list ('extension' , True )
176193 if sources :
177- options = self .get_dict_from_sources (directory_config and sources )
194+ options = DictConfig ( 'extension' , self .get_dict_from_sources (sources ) )
178195 if options :
179- after_mapping_hook_text = options .get ('after_mapping_hook' )
180- if not after_mapping_hook_text :
196+ after_mapping_hook_text = options .get_string ('after_mapping_hook' , True )
197+ if after_mapping_hook_text is None :
181198 raise AssertionError ("No after_mapping_hook found in extension configuration" )
182199 return options
183200
@@ -293,15 +310,15 @@ def get_rule_options(self):
293310 # now get the directory extension, if any
294311 after_mapping_hook = None
295312 extended_attributes = None
296- extension_options = self .get_directory_extension_options ()
297- if extension_options :
298- after_mapping_hook_text = extension_options .get_string ('after_mapping_hook' )
313+ extension_config = self .get_directory_extension_options ()
314+ if extension_config :
315+ after_mapping_hook_text = extension_config .get_string ('after_mapping_hook' )
299316 after_mapping_hook = compile (after_mapping_hook_text , '<per-user after-mapping-hook>' , 'exec' )
300- extended_attributes = extension_options .get_list ('extended_attributes' )
317+ extended_attributes = extension_config .get_list ('extended_attributes' )
301318 # declaration of extended adobe groups: this is needed for two reasons:
302319 # 1. it allows validation of group names, and matching them to adobe groups
303320 # 2. it allows removal of adobe groups not assigned by the hook
304- for extended_adobe_group in extension_options .get_list ('extended_adobe_groups' ):
321+ for extended_adobe_group in extension_config .get_list ('extended_adobe_groups' ):
305322 group = user_sync .rules .AdobeGroup .create (extended_adobe_group )
306323 if group is None :
307324 message = 'Extension contains illegal extended_adobe_group spec: ' + str (extended_adobe_group )
0 commit comments