- @staticmethod
- def _check_configuration_equal(current_config, new_config):
- # TODO compare and return True if equal
- return True
+ def _check_configuration_equal(self, current_config, expected_config):
+ try:
+ # self.logger.debug("Comparing current_config='{}' with expected_config='{}'".format(current_config,
+ # expected_config))
+ current_config_yaml = yaml.safe_load(current_config['data']['yaml'])
+ current_jobs = [j["job_name"] for j in current_config_yaml["scrape_configs"]]
+ expected_jobs = [j["job_name"] for j in expected_config["scrape_configs"]]
+ if current_jobs == expected_jobs:
+ return True
+ else:
+ self.logger.error("Not all jobs have been loaded. Target jobs: {} Loaded jobs: {}".format(
+ expected_jobs, current_jobs))
+ return False
+ except Exception as e:
+ self.logger.error("Invalid obtained status from server. Error: '{}'. Obtained data: '{}'".format(
+ e, current_config))
+ # if format is not understood, cannot be compared, assume it is ok
+ return True