in azurelinuxagent/ga/exthandlers.py [0:0]
def __get_handlers_on_file_system(self, goal_state_changed):
handlers_to_report = []
# Ignoring the `history` and `events` directories as they're not handlers and are agent-generated
for item, path in list_agent_lib_directory(skip_agent_package=True,
ignore_names=[EVENTS_DIRECTORY, ARCHIVE_DIRECTORY_NAME]):
try:
handler_instance = ExtHandlersHandler.get_ext_handler_instance_from_path(name=item,
path=path,
protocol=self.protocol)
if handler_instance is not None:
ext_handler = handler_instance.ext_handler
# For each handler we need to add extensions to report their status.
# For Single Config, we just need to add one extension with name as Handler Name
# For Multi Config, walk the config directory and find all unique extension names
# and add them as extensions to the handler.
extensions_names = set()
# Settings for Multi Config are saved as <extName>.<seqNo>.settings.
# Use this pattern to determine if Handler supports Multi Config or not and add extensions
for settings_path in glob.iglob(os.path.join(handler_instance.get_conf_dir(), "*.*.settings")):
match = re.search("(?P<extname>\\w+)\\.\\d+\\.settings", settings_path)
if match is not None:
extensions_names.add(match.group("extname"))
ext_handler.supports_multi_config = True
# If nothing found with that pattern then its a Single Config, add an extension with Handler Name
if not any(extensions_names):
extensions_names.add(ext_handler.name)
for ext_name in extensions_names:
ext = ExtensionSettings(name=ext_name)
# Fetch the last modified sequence number
seq_no, _ = handler_instance.get_status_file_path(ext)
ext.sequenceNumber = seq_no
# Append extension to the list of extensions for the handler
ext_handler.settings.append(ext)
handlers_to_report.append(ext_handler)
except Exception as error:
# Log error once per goal state
if goal_state_changed:
logger.warn("Can't fetch ExtHandler from path: {0}; Error: {1}".format(path, ustr(error)))
return handlers_to_report