def __get_version_from_commitstring(self, service): """ Check RackHD version from commitstring.txt file """ commitStringPath = os.path.join(self.source_code_path, service, "commitstring.txt") result = utils.robust_open_file(commitStringPath) return result
def __get_version_from_commitstring(self, service): """ Check RackHD version from commitstring.txt file """ commitStringPath = os.path.join(self.source_code_path, service, "commitstring.txt") result = utils.robust_open_file(commitStringPath) return result
def check_service_version(self): """ Check RackHD version for each service """ for service in self.services: description = "Check service {} version".format(service) commitStringPath = os.path.join(self.source_code_path, service, "commitstring.txt") result = utils.robust_open_file(commitStringPath) Logger.record_command_result(description, "warning", result)
def validate_dhcp_config(self): """ Validate RackHD required dhcpd configurations """ dhcp_config = utils.robust_open_file(self.dhcp_config_file) if dhcp_config["exit_code"] != 0: description = "Can't open {}".format(self.dhcp_config_file) Logger.record_command_result(description, "error", dhcp_config) return # Convert useful configures to a string valid_config_lines = [] for line in dhcp_config["message"]: line = line.strip(" ").strip("\n") if not line.startswith("#") and line: valid_config_lines.append(line) valid_config_string = "".join(valid_config_lines) # Check RackHD required configure lines unconfig_keys = self.dhcp_rackhd_config.keys() subnet_match = [] for key, value in self.dhcp_rackhd_config.items(): match = re.compile(value).search(valid_config_string) if match: unconfig_keys.remove(key) if key == "subnet": # Get DHCP IP Range for IP count calculation subnet_match = match.groups() self.dhcp_ip_range["start_ip"] = subnet_match[1] self.dhcp_ip_range["end_ip"] = subnet_match[2] if not unconfig_keys: description = "RackHD required dhcpd configure is correct" Logger.record_log_message(description, "debug", "") else: for value in unconfig_keys: description = "RackHD required dhcpd configure {} is incorrect".format( value) Logger.record_log_message(description, "error", "")
def validate_dhcp_config(self): """ Validate RackHD required dhcpd configurations """ dhcp_config = utils.robust_open_file(self.dhcp_config_file) if dhcp_config["exit_code"] != 0: description = "Can't open {}".format(self.dhcp_config_file) Logger.record_command_result(description, "error", dhcp_config) return # Convert useful configures to a string valid_config_lines = [] for line in dhcp_config["message"]: line = line.strip(" ").strip("\n") if not line.startswith("#") and line: valid_config_lines.append(line) valid_config_string = "".join(valid_config_lines) # Check RackHD required configure lines unconfig_keys = self.dhcp_rackhd_config.keys() subnet_match = [] for key, value in self.dhcp_rackhd_config.items(): match = re.compile(value).search(valid_config_string) if match: unconfig_keys.remove(key) if key == "subnet": # Get DHCP IP Range for IP count calculation subnet_match = match.groups() self.dhcp_ip_range["start_ip"] = subnet_match[1] self.dhcp_ip_range["end_ip"] = subnet_match[2] if not unconfig_keys: description = "RackHD required dhcpd configure is correct" Logger.record_log_message(description, "debug", "") else: for value in unconfig_keys: description = "RackHD required dhcpd configure {} is incorrect".format(value) Logger.record_log_message(description, "error", "")