Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | r""" |
| 4 | See class prolog below for details. |
| 5 | """ |
| 6 | |
| 7 | import os |
George Keishing | 0813e71 | 2021-07-26 08:29:20 -0500 | [diff] [blame] | 8 | import re |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 9 | import sys |
| 10 | import yaml |
George Keishing | 4885b2f | 2021-07-21 15:22:45 -0500 | [diff] [blame] | 11 | import json |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 12 | import time |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 13 | import logging |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 14 | import platform |
| 15 | from errno import EACCES, EPERM |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 16 | import subprocess |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 17 | from ssh_utility import SSHRemoteclient |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 18 | from telnet_utility import TelnetRemoteclient |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 19 | |
| 20 | |
| 21 | class FFDCCollector: |
| 22 | |
| 23 | r""" |
| 24 | Sends commands from configuration file to the targeted system to collect log files. |
| 25 | Fetch and store generated files at the specified location. |
| 26 | |
| 27 | """ |
| 28 | |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 29 | def __init__(self, |
| 30 | hostname, |
| 31 | username, |
| 32 | password, |
| 33 | ffdc_config, |
| 34 | location, |
| 35 | remote_type, |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 36 | remote_protocol, |
George Keishing | 4885b2f | 2021-07-21 15:22:45 -0500 | [diff] [blame] | 37 | env_vars, |
George Keishing | 8e94f8c | 2021-07-23 15:06:32 -0500 | [diff] [blame] | 38 | econfig, |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 39 | log_level): |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 40 | r""" |
| 41 | Description of argument(s): |
| 42 | |
George Keishing | 8e94f8c | 2021-07-23 15:06:32 -0500 | [diff] [blame] | 43 | hostname name/ip of the targeted (remote) system |
| 44 | username user on the targeted system with access to FFDC files |
| 45 | password password for user on targeted system |
| 46 | ffdc_config configuration file listing commands and files for FFDC |
| 47 | location where to store collected FFDC |
| 48 | remote_type os type of the remote host |
| 49 | remote_protocol Protocol to use to collect data |
| 50 | env_vars User define CLI env vars '{"key : "value"}' |
| 51 | econfig User define env vars YAML file |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 52 | |
| 53 | """ |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 54 | |
| 55 | self.hostname = hostname |
| 56 | self.username = username |
| 57 | self.password = password |
George Keishing | 04d2910 | 2021-07-16 02:05:57 -0500 | [diff] [blame] | 58 | # This is for the env vars a user can use in YAML to load it at runtime. |
| 59 | # Example YAML: |
| 60 | # -COMMANDS: |
| 61 | # - my_command ${hostname} ${username} ${password} |
| 62 | os.environ['hostname'] = hostname |
| 63 | os.environ['username'] = username |
| 64 | os.environ['password'] = password |
| 65 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 66 | self.ffdc_config = ffdc_config |
| 67 | self.location = location + "/" + remote_type.upper() |
| 68 | self.ssh_remoteclient = None |
| 69 | self.telnet_remoteclient = None |
| 70 | self.ffdc_dir_path = "" |
| 71 | self.ffdc_prefix = "" |
| 72 | self.target_type = remote_type.upper() |
| 73 | self.remote_protocol = remote_protocol.upper() |
| 74 | self.start_time = 0 |
| 75 | self.elapsed_time = '' |
| 76 | self.logger = None |
| 77 | |
| 78 | # Set prefix values for scp files and directory. |
| 79 | # Since the time stamp is at second granularity, these values are set here |
| 80 | # to be sure that all files for this run will have same timestamps |
| 81 | # and they will be saved in the same directory. |
| 82 | # self.location == local system for now |
| 83 | self.set_ffdc_defaults() |
| 84 | |
| 85 | # Logger for this run. Need to be after set_ffdc_defaults() |
| 86 | self.script_logging(getattr(logging, log_level.upper())) |
| 87 | |
| 88 | # Verify top level directory exists for storage |
| 89 | self.validate_local_store(self.location) |
| 90 | |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 91 | if self.verify_script_env(): |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 92 | # Load default or user define YAML configuration file. |
| 93 | with open(self.ffdc_config, 'r') as file: |
| 94 | self.ffdc_actions = yaml.load(file, Loader=yaml.FullLoader) |
| 95 | |
| 96 | if self.target_type not in self.ffdc_actions.keys(): |
| 97 | self.logger.error( |
| 98 | "\n\tERROR: %s is not listed in %s.\n\n" % (self.target_type, self.ffdc_config)) |
| 99 | sys.exit(-1) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 100 | else: |
Peter D Phan | 8462faf | 2021-06-16 12:24:15 -0500 | [diff] [blame] | 101 | sys.exit(-1) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 102 | |
George Keishing | 4885b2f | 2021-07-21 15:22:45 -0500 | [diff] [blame] | 103 | # Load ENV vars from user. |
George Keishing | aa1f848 | 2021-07-22 00:54:55 -0500 | [diff] [blame] | 104 | self.logger.info("\n\tENV: User define input YAML variables") |
| 105 | self.env_dict = {} |
| 106 | |
George Keishing | 4885b2f | 2021-07-21 15:22:45 -0500 | [diff] [blame] | 107 | try: |
| 108 | if env_vars: |
George Keishing | aa1f848 | 2021-07-22 00:54:55 -0500 | [diff] [blame] | 109 | self.env_dict = json.loads(env_vars) |
George Keishing | 4885b2f | 2021-07-21 15:22:45 -0500 | [diff] [blame] | 110 | |
| 111 | # Export ENV vars default. |
George Keishing | aa1f848 | 2021-07-22 00:54:55 -0500 | [diff] [blame] | 112 | for key, value in self.env_dict.items(): |
George Keishing | 4885b2f | 2021-07-21 15:22:45 -0500 | [diff] [blame] | 113 | os.environ[key] = value |
George Keishing | aa1f848 | 2021-07-22 00:54:55 -0500 | [diff] [blame] | 114 | |
George Keishing | 8e94f8c | 2021-07-23 15:06:32 -0500 | [diff] [blame] | 115 | if econfig: |
| 116 | with open(econfig, 'r') as file: |
| 117 | env_config_dict = yaml.load(file, Loader=yaml.FullLoader) |
| 118 | # Export ENV vars. |
| 119 | for key, value in env_config_dict['env_params'].items(): |
| 120 | os.environ[key] = str(value) |
| 121 | self.env_dict[key] = str(value) |
| 122 | |
George Keishing | 4885b2f | 2021-07-21 15:22:45 -0500 | [diff] [blame] | 123 | except json.decoder.JSONDecodeError as e: |
| 124 | self.logger.error("\n\tERROR: %s " % e) |
| 125 | sys.exit(-1) |
| 126 | |
George Keishing | aa1f848 | 2021-07-22 00:54:55 -0500 | [diff] [blame] | 127 | # Append default Env. |
| 128 | self.env_dict['hostname'] = self.hostname |
| 129 | self.env_dict['username'] = self.username |
| 130 | self.env_dict['password'] = self.password |
George Keishing | 0813e71 | 2021-07-26 08:29:20 -0500 | [diff] [blame] | 131 | # This to mask the password from displaying on the console. |
| 132 | mask_dict = self.env_dict.copy() |
| 133 | for k, v in mask_dict.items(): |
| 134 | if k.lower().find("password") != -1: |
| 135 | hidden_text = [] |
| 136 | hidden_text.append(v) |
| 137 | password_regex = '(' +\ |
| 138 | '|'.join([re.escape(x) for x in hidden_text]) + ')' |
| 139 | mask_dict[k] = re.sub(password_regex, "********", v) |
| 140 | self.logger.info(json.dumps(mask_dict, indent=8, sort_keys=True)) |
George Keishing | aa1f848 | 2021-07-22 00:54:55 -0500 | [diff] [blame] | 141 | |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 142 | def verify_script_env(self): |
| 143 | |
| 144 | # Import to log version |
| 145 | import click |
| 146 | import paramiko |
| 147 | |
| 148 | run_env_ok = True |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 149 | |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 150 | redfishtool_version = self.run_redfishtool('-V').split(' ')[2].strip('\n') |
George Keishing | 484f824 | 2021-07-27 01:42:02 -0500 | [diff] [blame^] | 151 | ipmitool_version = self.run_ipmitool('ipmitool -V').split(' ')[2] |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 152 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 153 | self.logger.info("\n\t---- Script host environment ----") |
| 154 | self.logger.info("\t{:<10} {:<10}".format('Script hostname', os.uname()[1])) |
| 155 | self.logger.info("\t{:<10} {:<10}".format('Script host os', platform.platform())) |
| 156 | self.logger.info("\t{:<10} {:>10}".format('Python', platform.python_version())) |
| 157 | self.logger.info("\t{:<10} {:>10}".format('PyYAML', yaml.__version__)) |
| 158 | self.logger.info("\t{:<10} {:>10}".format('click', click.__version__)) |
| 159 | self.logger.info("\t{:<10} {:>10}".format('paramiko', paramiko.__version__)) |
| 160 | self.logger.info("\t{:<10} {:>9}".format('redfishtool', redfishtool_version)) |
| 161 | self.logger.info("\t{:<10} {:>12}".format('ipmitool', ipmitool_version)) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 162 | |
Peter D Phan | 8462faf | 2021-06-16 12:24:15 -0500 | [diff] [blame] | 163 | if eval(yaml.__version__.replace('.', ',')) < (5, 4, 1): |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 164 | self.logger.error("\n\tERROR: Python or python packages do not meet minimum version requirement.") |
| 165 | self.logger.error("\tERROR: PyYAML version 5.4.1 or higher is needed.\n") |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 166 | run_env_ok = False |
| 167 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 168 | self.logger.info("\t---- End script host environment ----") |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 169 | return run_env_ok |
| 170 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 171 | def script_logging(self, |
| 172 | log_level_attr): |
| 173 | r""" |
| 174 | Create logger |
| 175 | |
| 176 | """ |
| 177 | self.logger = logging.getLogger() |
| 178 | self.logger.setLevel(log_level_attr) |
| 179 | log_file_handler = logging.FileHandler(self.ffdc_dir_path + "collector.log") |
| 180 | |
| 181 | stdout_handler = logging.StreamHandler(sys.stdout) |
| 182 | self.logger.addHandler(log_file_handler) |
| 183 | self.logger.addHandler(stdout_handler) |
| 184 | |
| 185 | # Turn off paramiko INFO logging |
| 186 | logging.getLogger("paramiko").setLevel(logging.WARNING) |
| 187 | |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 188 | def target_is_pingable(self): |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 189 | r""" |
| 190 | Check if target system is ping-able. |
| 191 | |
| 192 | """ |
George Keishing | 0662e94 | 2021-07-13 05:12:20 -0500 | [diff] [blame] | 193 | response = os.system("ping -c 1 %s 2>&1 >/dev/null" % self.hostname) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 194 | if response == 0: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 195 | self.logger.info("\n\t[Check] %s is ping-able.\t\t [OK]" % self.hostname) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 196 | return True |
| 197 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 198 | self.logger.error( |
George Keishing | 7bf5509 | 2021-07-22 12:33:34 -0500 | [diff] [blame] | 199 | "\n\tERROR: %s is not ping-able. FFDC collection aborted.\n" % self.hostname) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 200 | sys.exit(-1) |
| 201 | |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 202 | def collect_ffdc(self): |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 203 | r""" |
| 204 | Initiate FFDC Collection depending on requested protocol. |
| 205 | |
| 206 | """ |
| 207 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 208 | self.logger.info("\n\t---- Start communicating with %s ----" % self.hostname) |
Peter D Phan | 7610bc4 | 2021-07-06 06:31:05 -0500 | [diff] [blame] | 209 | self.start_time = time.time() |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 210 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 211 | # Find the list of target and protocol supported. |
| 212 | check_protocol_list = [] |
| 213 | config_dict = self.ffdc_actions |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 214 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 215 | for target_type in config_dict.keys(): |
| 216 | if self.target_type != target_type: |
| 217 | continue |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 218 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 219 | for k, v in config_dict[target_type].items(): |
| 220 | if config_dict[target_type][k]['PROTOCOL'][0] not in check_protocol_list: |
| 221 | check_protocol_list.append(config_dict[target_type][k]['PROTOCOL'][0]) |
Peter D Phan | bff617a | 2021-07-22 08:41:35 -0500 | [diff] [blame] | 222 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 223 | self.logger.info("\n\t %s protocol type: %s" % (self.target_type, check_protocol_list)) |
Peter D Phan | bff617a | 2021-07-22 08:41:35 -0500 | [diff] [blame] | 224 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 225 | verified_working_protocol = self.verify_protocol(check_protocol_list) |
Peter D Phan | bff617a | 2021-07-22 08:41:35 -0500 | [diff] [blame] | 226 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 227 | if verified_working_protocol: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 228 | self.logger.info("\n\t---- Completed protocol pre-requisite check ----\n") |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 229 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 230 | # Verify top level directory exists for storage |
| 231 | self.validate_local_store(self.location) |
| 232 | |
| 233 | if ((self.remote_protocol not in verified_working_protocol) and (self.remote_protocol != 'ALL')): |
| 234 | self.logger.info("\n\tWorking protocol list: %s" % verified_working_protocol) |
| 235 | self.logger.error( |
| 236 | '\tERROR: Requested protocol %s is not in working protocol list.\n' |
| 237 | % self.remote_protocol) |
| 238 | sys.exit(-1) |
| 239 | else: |
| 240 | self.generate_ffdc(verified_working_protocol) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 241 | |
| 242 | def ssh_to_target_system(self): |
| 243 | r""" |
| 244 | Open a ssh connection to targeted system. |
| 245 | |
| 246 | """ |
| 247 | |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 248 | self.ssh_remoteclient = SSHRemoteclient(self.hostname, |
| 249 | self.username, |
| 250 | self.password) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 251 | |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 252 | if self.ssh_remoteclient.ssh_remoteclient_login(): |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 253 | self.logger.info("\n\t[Check] %s SSH connection established.\t [OK]" % self.hostname) |
Peter D Phan | 733df63 | 2021-06-17 13:13:36 -0500 | [diff] [blame] | 254 | |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 255 | # Check scp connection. |
| 256 | # If scp connection fails, |
| 257 | # continue with FFDC generation but skip scp files to local host. |
| 258 | self.ssh_remoteclient.scp_connection() |
| 259 | return True |
| 260 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 261 | self.logger.info("\n\t[Check] %s SSH connection.\t [NOT AVAILABLE]" % self.hostname) |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 262 | return False |
| 263 | |
| 264 | def telnet_to_target_system(self): |
| 265 | r""" |
| 266 | Open a telnet connection to targeted system. |
| 267 | """ |
| 268 | self.telnet_remoteclient = TelnetRemoteclient(self.hostname, |
| 269 | self.username, |
| 270 | self.password) |
| 271 | if self.telnet_remoteclient.tn_remoteclient_login(): |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 272 | self.logger.info("\n\t[Check] %s Telnet connection established.\t [OK]" % self.hostname) |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 273 | return True |
| 274 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 275 | self.logger.info("\n\t[Check] %s Telnet connection.\t [NOT AVAILABLE]" % self.hostname) |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 276 | return False |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 277 | |
George Keishing | 772c977 | 2021-06-16 23:23:42 -0500 | [diff] [blame] | 278 | def generate_ffdc(self, working_protocol_list): |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 279 | r""" |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 280 | Determine actions based on remote host type |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 281 | |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 282 | Description of argument(s): |
| 283 | working_protocol_list list of confirmed working protocols to connect to remote host. |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 284 | """ |
| 285 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 286 | self.logger.info("\n\t---- Executing commands on " + self.hostname + " ----") |
| 287 | self.logger.info("\n\tWorking protocol list: %s" % working_protocol_list) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 288 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 289 | config_dict = self.ffdc_actions |
| 290 | for target_type in config_dict.keys(): |
| 291 | if self.target_type != target_type: |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 292 | continue |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 293 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 294 | self.logger.info("\n\tFFDC Path: %s " % self.ffdc_dir_path) |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 295 | self.logger.info("\tSystem Type: %s" % target_type) |
| 296 | for k, v in config_dict[target_type].items(): |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 297 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 298 | if self.remote_protocol not in working_protocol_list \ |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 299 | and self.remote_protocol != 'ALL': |
| 300 | continue |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 301 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 302 | protocol = config_dict[target_type][k]['PROTOCOL'][0] |
| 303 | |
| 304 | if protocol not in working_protocol_list: |
| 305 | continue |
| 306 | |
| 307 | if protocol == 'SSH' or protocol == 'SCP': |
| 308 | if 'SSH' in working_protocol_list or 'SCP' in working_protocol_list: |
| 309 | self.protocol_ssh(target_type, k) |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 310 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 311 | self.logger.error("\n\tERROR: SSH or SCP is not available for %s." % self.hostname) |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 312 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 313 | if protocol == 'TELNET': |
| 314 | if protocol in working_protocol_list: |
| 315 | self.protocol_telnet(target_type, k) |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 316 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 317 | self.logger.error("\n\tERROR: TELNET is not available for %s." % self.hostname) |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 318 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 319 | if protocol == 'REDFISH': |
| 320 | if protocol in working_protocol_list: |
| 321 | self.protocol_redfish(target_type, k) |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 322 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 323 | self.logger.error("\n\tERROR: REDFISH is not available for %s." % self.hostname) |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 324 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 325 | if protocol == 'IPMI': |
| 326 | if protocol in working_protocol_list: |
| 327 | self.protocol_ipmi(target_type, k) |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 328 | else: |
Peter D Phan | d1fccd3 | 2021-07-21 06:45:54 -0500 | [diff] [blame] | 329 | self.logger.error("\n\tERROR: IPMI is not available for %s." % self.hostname) |
George Keishing | 04d2910 | 2021-07-16 02:05:57 -0500 | [diff] [blame] | 330 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 331 | if protocol == 'SHELL': |
| 332 | if protocol in working_protocol_list: |
| 333 | self.protocol_shell_script(target_type, k) |
George Keishing | 04d2910 | 2021-07-16 02:05:57 -0500 | [diff] [blame] | 334 | else: |
| 335 | self.logger.error("\n\tERROR: can't execute SHELL script") |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 336 | |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 337 | # Close network connection after collecting all files |
Peter D Phan | 7610bc4 | 2021-07-06 06:31:05 -0500 | [diff] [blame] | 338 | self.elapsed_time = time.strftime("%H:%M:%S", time.gmtime(time.time() - self.start_time)) |
Peter D Phan | bff617a | 2021-07-22 08:41:35 -0500 | [diff] [blame] | 339 | if self.ssh_remoteclient: |
| 340 | self.ssh_remoteclient.ssh_remoteclient_disconnect() |
| 341 | if self.telnet_remoteclient: |
| 342 | self.telnet_remoteclient.tn_remoteclient_disconnect() |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 343 | |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 344 | def protocol_ssh(self, |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 345 | target_type, |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 346 | sub_type): |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 347 | r""" |
| 348 | Perform actions using SSH and SCP protocols. |
| 349 | |
| 350 | Description of argument(s): |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 351 | target_type OS Type of remote host. |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 352 | sub_type Group type of commands. |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 353 | """ |
| 354 | |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 355 | if sub_type == 'DUMP_LOGS': |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 356 | self.group_copy(self.ffdc_actions[target_type][sub_type]) |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 357 | else: |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 358 | self.collect_and_copy_ffdc(self.ffdc_actions[target_type][sub_type]) |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 359 | |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 360 | def protocol_telnet(self, |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 361 | target_type, |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 362 | sub_type): |
| 363 | r""" |
| 364 | Perform actions using telnet protocol. |
| 365 | Description of argument(s): |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 366 | target_type OS Type of remote host. |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 367 | """ |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 368 | self.logger.info("\n\t[Run] Executing commands on %s using %s" % (self.hostname, 'TELNET')) |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 369 | telnet_files_saved = [] |
| 370 | progress_counter = 0 |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 371 | list_of_commands = self.ffdc_actions[target_type][sub_type]['COMMANDS'] |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 372 | for index, each_cmd in enumerate(list_of_commands, start=0): |
| 373 | command_txt, command_timeout = self.unpack_command(each_cmd) |
| 374 | result = self.telnet_remoteclient.execute_command(command_txt, command_timeout) |
| 375 | if result: |
| 376 | try: |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 377 | targ_file = self.ffdc_actions[target_type][sub_type]['FILES'][index] |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 378 | except IndexError: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 379 | targ_file = command_txt |
| 380 | self.logger.warning( |
| 381 | "\n\t[WARN] Missing filename to store data from telnet %s." % each_cmd) |
| 382 | self.logger.warning("\t[WARN] Data will be stored in %s." % targ_file) |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 383 | targ_file_with_path = (self.ffdc_dir_path |
| 384 | + self.ffdc_prefix |
| 385 | + targ_file) |
| 386 | # Creates a new file |
| 387 | with open(targ_file_with_path, 'wb') as fp: |
| 388 | fp.write(result) |
| 389 | fp.close |
| 390 | telnet_files_saved.append(targ_file) |
| 391 | progress_counter += 1 |
| 392 | self.print_progress(progress_counter) |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 393 | self.logger.info("\n\t[Run] Commands execution completed.\t\t [OK]") |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 394 | for file in telnet_files_saved: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 395 | self.logger.info("\n\t\tSuccessfully save file " + file + ".") |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 396 | |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 397 | def protocol_redfish(self, |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 398 | target_type, |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 399 | sub_type): |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 400 | r""" |
| 401 | Perform actions using Redfish protocol. |
| 402 | |
| 403 | Description of argument(s): |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 404 | target_type OS Type of remote host. |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 405 | sub_type Group type of commands. |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 406 | """ |
| 407 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 408 | self.logger.info("\n\t[Run] Executing commands to %s using %s" % (self.hostname, 'REDFISH')) |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 409 | redfish_files_saved = [] |
| 410 | progress_counter = 0 |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 411 | list_of_URL = self.ffdc_actions[target_type][sub_type]['URL'] |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 412 | for index, each_url in enumerate(list_of_URL, start=0): |
| 413 | redfish_parm = '-u ' + self.username + ' -p ' + self.password + ' -r ' \ |
| 414 | + self.hostname + ' -S Always raw GET ' + each_url |
| 415 | |
| 416 | result = self.run_redfishtool(redfish_parm) |
| 417 | if result: |
| 418 | try: |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 419 | targ_file = self.get_file_list(self.ffdc_actions[target_type][sub_type])[index] |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 420 | except IndexError: |
| 421 | targ_file = each_url.split('/')[-1] |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 422 | self.logger.warning( |
| 423 | "\n\t[WARN] Missing filename to store data from redfish URL %s." % each_url) |
| 424 | self.logger.warning("\t[WARN] Data will be stored in %s." % targ_file) |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 425 | |
| 426 | targ_file_with_path = (self.ffdc_dir_path |
| 427 | + self.ffdc_prefix |
| 428 | + targ_file) |
| 429 | |
| 430 | # Creates a new file |
| 431 | with open(targ_file_with_path, 'w') as fp: |
| 432 | fp.write(result) |
| 433 | fp.close |
| 434 | redfish_files_saved.append(targ_file) |
| 435 | |
| 436 | progress_counter += 1 |
| 437 | self.print_progress(progress_counter) |
| 438 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 439 | self.logger.info("\n\t[Run] Commands execution completed.\t\t [OK]") |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 440 | |
| 441 | for file in redfish_files_saved: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 442 | self.logger.info("\n\t\tSuccessfully save file " + file + ".") |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 443 | |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 444 | def protocol_ipmi(self, |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 445 | target_type, |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 446 | sub_type): |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 447 | r""" |
| 448 | Perform actions using ipmitool over LAN protocol. |
| 449 | |
| 450 | Description of argument(s): |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 451 | target_type OS Type of remote host. |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 452 | sub_type Group type of commands. |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 453 | """ |
| 454 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 455 | self.logger.info("\n\t[Run] Executing commands to %s using %s" % (self.hostname, 'IPMI')) |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 456 | ipmi_files_saved = [] |
| 457 | progress_counter = 0 |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 458 | list_of_cmd = self.get_command_list(self.ffdc_actions[target_type][sub_type]) |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 459 | for index, each_cmd in enumerate(list_of_cmd, start=0): |
George Keishing | 484f824 | 2021-07-27 01:42:02 -0500 | [diff] [blame^] | 460 | result = self.run_ipmitool(each_cmd) |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 461 | if result: |
| 462 | try: |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 463 | targ_file = self.get_file_list(self.ffdc_actions[target_type][sub_type])[index] |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 464 | except IndexError: |
George Keishing | 6ea92b0 | 2021-07-01 11:20:50 -0500 | [diff] [blame] | 465 | targ_file = each_cmd.split('/')[-1] |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 466 | self.logger.warning("\n\t[WARN] Missing filename to store data from IPMI %s." % each_cmd) |
| 467 | self.logger.warning("\t[WARN] Data will be stored in %s." % targ_file) |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 468 | |
| 469 | targ_file_with_path = (self.ffdc_dir_path |
| 470 | + self.ffdc_prefix |
| 471 | + targ_file) |
| 472 | |
| 473 | # Creates a new file |
| 474 | with open(targ_file_with_path, 'w') as fp: |
| 475 | fp.write(result) |
| 476 | fp.close |
| 477 | ipmi_files_saved.append(targ_file) |
| 478 | |
| 479 | progress_counter += 1 |
| 480 | self.print_progress(progress_counter) |
| 481 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 482 | self.logger.info("\n\t[Run] Commands execution completed.\t\t [OK]") |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 483 | |
| 484 | for file in ipmi_files_saved: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 485 | self.logger.info("\n\t\tSuccessfully save file " + file + ".") |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 486 | |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 487 | def collect_and_copy_ffdc(self, |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 488 | ffdc_actions_for_target_type, |
Peter D Phan | 2b8052d | 2021-06-22 10:55:41 -0500 | [diff] [blame] | 489 | form_filename=False): |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 490 | r""" |
| 491 | Send commands in ffdc_config file to targeted system. |
| 492 | |
| 493 | Description of argument(s): |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 494 | ffdc_actions_for_target_type commands and files for the selected remote host type. |
Peter D Phan | 2b8052d | 2021-06-22 10:55:41 -0500 | [diff] [blame] | 495 | form_filename if true, pre-pend self.target_type to filename |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 496 | """ |
| 497 | |
Peter D Phan | 2b6cb3a | 2021-07-19 06:55:42 -0500 | [diff] [blame] | 498 | # Executing commands, if any |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 499 | self.ssh_execute_ffdc_commands(ffdc_actions_for_target_type, |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 500 | form_filename) |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 501 | |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 502 | # Copying files |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 503 | if self.ssh_remoteclient.scpclient: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 504 | self.logger.info("\n\n\tCopying FFDC files from remote system %s.\n" % self.hostname) |
Peter D Phan | 2b8052d | 2021-06-22 10:55:41 -0500 | [diff] [blame] | 505 | |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 506 | # Retrieving files from target system |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 507 | list_of_files = self.get_file_list(ffdc_actions_for_target_type) |
Peter D Phan | 2b8052d | 2021-06-22 10:55:41 -0500 | [diff] [blame] | 508 | self.scp_ffdc(self.ffdc_dir_path, self.ffdc_prefix, form_filename, list_of_files) |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 509 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 510 | self.logger.info("\n\n\tSkip copying FFDC files from remote system %s.\n" % self.hostname) |
Peter D Phan | 04aca3b | 2021-06-21 10:37:18 -0500 | [diff] [blame] | 511 | |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 512 | def get_command_list(self, |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 513 | ffdc_actions_for_target_type): |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 514 | r""" |
| 515 | Fetch list of commands from configuration file |
| 516 | |
| 517 | Description of argument(s): |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 518 | ffdc_actions_for_target_type commands and files for the selected remote host type. |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 519 | """ |
| 520 | try: |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 521 | list_of_commands = ffdc_actions_for_target_type['COMMANDS'] |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 522 | except KeyError: |
| 523 | list_of_commands = [] |
| 524 | return list_of_commands |
| 525 | |
| 526 | def get_file_list(self, |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 527 | ffdc_actions_for_target_type): |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 528 | r""" |
| 529 | Fetch list of commands from configuration file |
| 530 | |
| 531 | Description of argument(s): |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 532 | ffdc_actions_for_target_type commands and files for the selected remote host type. |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 533 | """ |
| 534 | try: |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 535 | list_of_files = ffdc_actions_for_target_type['FILES'] |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 536 | except KeyError: |
| 537 | list_of_files = [] |
| 538 | return list_of_files |
| 539 | |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 540 | def unpack_command(self, |
| 541 | command): |
| 542 | r""" |
| 543 | Unpack command from config file |
| 544 | |
| 545 | Description of argument(s): |
| 546 | command Command from config file. |
| 547 | """ |
| 548 | if isinstance(command, dict): |
| 549 | command_txt = next(iter(command)) |
| 550 | command_timeout = next(iter(command.values())) |
| 551 | elif isinstance(command, str): |
| 552 | command_txt = command |
| 553 | # Default command timeout 60 seconds |
| 554 | command_timeout = 60 |
| 555 | |
| 556 | return command_txt, command_timeout |
| 557 | |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 558 | def ssh_execute_ffdc_commands(self, |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 559 | ffdc_actions_for_target_type, |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 560 | form_filename=False): |
| 561 | r""" |
| 562 | Send commands in ffdc_config file to targeted system. |
| 563 | |
| 564 | Description of argument(s): |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 565 | ffdc_actions_for_target_type commands and files for the selected remote host type. |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 566 | form_filename if true, pre-pend self.target_type to filename |
| 567 | """ |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 568 | self.logger.info("\n\t[Run] Executing commands on %s using %s" |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 569 | % (self.hostname, ffdc_actions_for_target_type['PROTOCOL'][0])) |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 570 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 571 | list_of_commands = self.get_command_list(ffdc_actions_for_target_type) |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 572 | # If command list is empty, returns |
| 573 | if not list_of_commands: |
| 574 | return |
| 575 | |
| 576 | progress_counter = 0 |
| 577 | for command in list_of_commands: |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 578 | command_txt, command_timeout = self.unpack_command(command) |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 579 | |
| 580 | if form_filename: |
| 581 | command_txt = str(command_txt % self.target_type) |
| 582 | |
Peter D Phan | 2b6cb3a | 2021-07-19 06:55:42 -0500 | [diff] [blame] | 583 | cmd_exit_code, err, response = \ |
| 584 | self.ssh_remoteclient.execute_command(command_txt, command_timeout) |
| 585 | |
| 586 | if cmd_exit_code: |
| 587 | self.logger.warning( |
| 588 | "\n\t\t[WARN] %s exits with code %s." % (command_txt, str(cmd_exit_code))) |
| 589 | self.logger.warning("\t\t[WARN] %s " % err) |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 590 | |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 591 | progress_counter += 1 |
| 592 | self.print_progress(progress_counter) |
| 593 | |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 594 | self.logger.info("\n\t[Run] Commands execution completed.\t\t [OK]") |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 595 | |
Peter D Phan | 56429a6 | 2021-06-23 08:38:29 -0500 | [diff] [blame] | 596 | def group_copy(self, |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 597 | ffdc_actions_for_target_type): |
Peter D Phan | 56429a6 | 2021-06-23 08:38:29 -0500 | [diff] [blame] | 598 | r""" |
| 599 | scp group of files (wild card) from remote host. |
| 600 | |
| 601 | Description of argument(s): |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 602 | fdc_actions_for_target_type commands and files for the selected remote host type. |
Peter D Phan | 56429a6 | 2021-06-23 08:38:29 -0500 | [diff] [blame] | 603 | """ |
Peter D Phan | 3beb02e | 2021-07-06 13:25:17 -0500 | [diff] [blame] | 604 | |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 605 | if self.ssh_remoteclient.scpclient: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 606 | self.logger.info("\n\tCopying DUMP files from remote system %s.\n" % self.hostname) |
Peter D Phan | 56429a6 | 2021-06-23 08:38:29 -0500 | [diff] [blame] | 607 | |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 608 | list_of_commands = self.get_command_list(ffdc_actions_for_target_type) |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 609 | # If command list is empty, returns |
| 610 | if not list_of_commands: |
| 611 | return |
Peter D Phan | 56429a6 | 2021-06-23 08:38:29 -0500 | [diff] [blame] | 612 | |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 613 | for command in list_of_commands: |
| 614 | try: |
| 615 | filename = command.split(' ')[2] |
| 616 | except IndexError: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 617 | self.logger.info("\t\tInvalid command %s for DUMP_LOGS block." % command) |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 618 | continue |
| 619 | |
Peter D Phan | 2b6cb3a | 2021-07-19 06:55:42 -0500 | [diff] [blame] | 620 | cmd_exit_code, err, response = \ |
| 621 | self.ssh_remoteclient.execute_command(command) |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 622 | |
Peter D Phan | 2b6cb3a | 2021-07-19 06:55:42 -0500 | [diff] [blame] | 623 | # If file does not exist, code take no action. |
| 624 | # cmd_exit_code is ignored for this scenario. |
Peter D Phan | 56429a6 | 2021-06-23 08:38:29 -0500 | [diff] [blame] | 625 | if response: |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 626 | scp_result = self.ssh_remoteclient.scp_file_from_remote(filename, self.ffdc_dir_path) |
Peter D Phan | 56429a6 | 2021-06-23 08:38:29 -0500 | [diff] [blame] | 627 | if scp_result: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 628 | self.logger.info("\t\tSuccessfully copied from " + self.hostname + ':' + filename) |
Peter D Phan | 56429a6 | 2021-06-23 08:38:29 -0500 | [diff] [blame] | 629 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 630 | self.logger.info("\t\tThere is no " + filename) |
Peter D Phan | 56429a6 | 2021-06-23 08:38:29 -0500 | [diff] [blame] | 631 | |
| 632 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 633 | self.logger.info("\n\n\tSkip copying files from remote system %s.\n" % self.hostname) |
Peter D Phan | 56429a6 | 2021-06-23 08:38:29 -0500 | [diff] [blame] | 634 | |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 635 | def scp_ffdc(self, |
| 636 | targ_dir_path, |
Peter D Phan | 2b8052d | 2021-06-22 10:55:41 -0500 | [diff] [blame] | 637 | targ_file_prefix, |
| 638 | form_filename, |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 639 | file_list=None, |
| 640 | quiet=None): |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 641 | r""" |
| 642 | SCP all files in file_dict to the indicated directory on the local system. |
| 643 | |
| 644 | Description of argument(s): |
| 645 | targ_dir_path The path of the directory to receive the files. |
| 646 | targ_file_prefix Prefix which will be pre-pended to each |
| 647 | target file's name. |
| 648 | file_dict A dictionary of files to scp from targeted system to this system |
| 649 | |
| 650 | """ |
| 651 | |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 652 | progress_counter = 0 |
| 653 | for filename in file_list: |
Peter D Phan | 2b8052d | 2021-06-22 10:55:41 -0500 | [diff] [blame] | 654 | if form_filename: |
| 655 | filename = str(filename % self.target_type) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 656 | source_file_path = filename |
| 657 | targ_file_path = targ_dir_path + targ_file_prefix + filename.split('/')[-1] |
| 658 | |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 659 | # If source file name contains wild card, copy filename as is. |
| 660 | if '*' in source_file_path: |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 661 | scp_result = self.ssh_remoteclient.scp_file_from_remote(source_file_path, self.ffdc_dir_path) |
Peter D Phan | babf296 | 2021-07-07 11:24:40 -0500 | [diff] [blame] | 662 | else: |
Peter D Phan | 5963d63 | 2021-07-12 09:58:55 -0500 | [diff] [blame] | 663 | scp_result = self.ssh_remoteclient.scp_file_from_remote(source_file_path, targ_file_path) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 664 | |
| 665 | if not quiet: |
| 666 | if scp_result: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 667 | self.logger.info( |
| 668 | "\t\tSuccessfully copied from " + self.hostname + ':' + source_file_path + ".\n") |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 669 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 670 | self.logger.info( |
| 671 | "\t\tFail to copy from " + self.hostname + ':' + source_file_path + ".\n") |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 672 | else: |
| 673 | progress_counter += 1 |
| 674 | self.print_progress(progress_counter) |
| 675 | |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 676 | def set_ffdc_defaults(self): |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 677 | r""" |
| 678 | Set a default value for self.ffdc_dir_path and self.ffdc_prefix. |
| 679 | Collected ffdc file will be stored in dir /self.location/hostname_timestr/. |
| 680 | Individual ffdc file will have timestr_filename. |
| 681 | |
| 682 | Description of class variables: |
| 683 | self.ffdc_dir_path The dir path where collected ffdc data files should be put. |
| 684 | |
| 685 | self.ffdc_prefix The prefix to be given to each ffdc file name. |
| 686 | |
| 687 | """ |
| 688 | |
| 689 | timestr = time.strftime("%Y%m%d-%H%M%S") |
| 690 | self.ffdc_dir_path = self.location + "/" + self.hostname + "_" + timestr + "/" |
| 691 | self.ffdc_prefix = timestr + "_" |
| 692 | self.validate_local_store(self.ffdc_dir_path) |
| 693 | |
| 694 | def validate_local_store(self, dir_path): |
| 695 | r""" |
| 696 | Ensure path exists to store FFDC files locally. |
| 697 | |
| 698 | Description of variable: |
| 699 | dir_path The dir path where collected ffdc data files will be stored. |
| 700 | |
| 701 | """ |
| 702 | |
| 703 | if not os.path.exists(dir_path): |
| 704 | try: |
George Keishing | 7b3a513 | 2021-07-13 09:24:02 -0500 | [diff] [blame] | 705 | os.makedirs(dir_path, 0o755) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 706 | except (IOError, OSError) as e: |
| 707 | # PermissionError |
| 708 | if e.errno == EPERM or e.errno == EACCES: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 709 | self.logger.error( |
George Keishing | 7bf5509 | 2021-07-22 12:33:34 -0500 | [diff] [blame] | 710 | '\tERROR: os.makedirs %s failed with PermissionError.\n' % dir_path) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 711 | else: |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 712 | self.logger.error( |
George Keishing | 7bf5509 | 2021-07-22 12:33:34 -0500 | [diff] [blame] | 713 | '\tERROR: os.makedirs %s failed with %s.\n' % (dir_path, e.strerror)) |
Peter D Phan | 72ce6b8 | 2021-06-03 06:18:26 -0500 | [diff] [blame] | 714 | sys.exit(-1) |
| 715 | |
| 716 | def print_progress(self, progress): |
| 717 | r""" |
| 718 | Print activity progress + |
| 719 | |
| 720 | Description of variable: |
| 721 | progress Progress counter. |
| 722 | |
| 723 | """ |
| 724 | |
| 725 | sys.stdout.write("\r\t" + "+" * progress) |
| 726 | sys.stdout.flush() |
| 727 | time.sleep(.1) |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 728 | |
| 729 | def verify_redfish(self): |
| 730 | r""" |
| 731 | Verify remote host has redfish service active |
| 732 | |
| 733 | """ |
| 734 | redfish_parm = '-u ' + self.username + ' -p ' + self.password + ' -r ' \ |
| 735 | + self.hostname + ' -S Always raw GET /redfish/v1/' |
| 736 | return(self.run_redfishtool(redfish_parm, True)) |
| 737 | |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 738 | def verify_ipmi(self): |
| 739 | r""" |
| 740 | Verify remote host has IPMI LAN service active |
| 741 | |
| 742 | """ |
George Keishing | 484f824 | 2021-07-27 01:42:02 -0500 | [diff] [blame^] | 743 | if self.target_type == 'OPENBMC': |
| 744 | ipmi_parm = 'ipmitool -I lanplus -C 17 -U ' + self.username + ' -P ' \ |
| 745 | + self.password + ' -H ' + self.hostname + ' power status' |
| 746 | else: |
| 747 | ipmi_parm = 'ipmitool -I lanplus -P ' \ |
| 748 | + self.password + ' -H ' + self.hostname + ' power status' |
| 749 | |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 750 | return(self.run_ipmitool(ipmi_parm, True)) |
| 751 | |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 752 | def run_redfishtool(self, |
| 753 | parms_string, |
| 754 | quiet=False): |
| 755 | r""" |
| 756 | Run CLI redfishtool |
| 757 | |
| 758 | Description of variable: |
| 759 | parms_string redfishtool subcommand and options. |
| 760 | quiet do not print redfishtool error message if True |
| 761 | """ |
| 762 | |
| 763 | result = subprocess.run(['redfishtool ' + parms_string], |
| 764 | stdout=subprocess.PIPE, |
| 765 | stderr=subprocess.PIPE, |
| 766 | shell=True, |
| 767 | universal_newlines=True) |
| 768 | |
| 769 | if result.stderr and not quiet: |
George Keishing | 7bf5509 | 2021-07-22 12:33:34 -0500 | [diff] [blame] | 770 | self.logger.error('\n\tERROR with redfishtool ' + parms_string) |
| 771 | self.logger.error('\n\t%s' % result.stderr.split('\n')) |
Peter D Phan | 0c66977 | 2021-06-24 13:52:42 -0500 | [diff] [blame] | 772 | |
| 773 | return result.stdout |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 774 | |
| 775 | def run_ipmitool(self, |
| 776 | parms_string, |
| 777 | quiet=False): |
| 778 | r""" |
| 779 | Run CLI IPMI tool. |
| 780 | |
| 781 | Description of variable: |
| 782 | parms_string ipmitool subcommand and options. |
| 783 | quiet do not print redfishtool error message if True |
| 784 | """ |
| 785 | |
George Keishing | 484f824 | 2021-07-27 01:42:02 -0500 | [diff] [blame^] | 786 | result = subprocess.run([parms_string], |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 787 | stdout=subprocess.PIPE, |
| 788 | stderr=subprocess.PIPE, |
| 789 | shell=True, |
| 790 | universal_newlines=True) |
| 791 | |
| 792 | if result.stderr and not quiet: |
George Keishing | 484f824 | 2021-07-27 01:42:02 -0500 | [diff] [blame^] | 793 | self.logger.error('\n\t\tERROR with %s ' % parms_string) |
Peter D Phan | e86d9a5 | 2021-07-15 10:42:25 -0500 | [diff] [blame] | 794 | self.logger.error('\t\t' + result.stderr) |
George Keishing | eafba18 | 2021-06-29 13:44:58 -0500 | [diff] [blame] | 795 | |
| 796 | return result.stdout |
George Keishing | 04d2910 | 2021-07-16 02:05:57 -0500 | [diff] [blame] | 797 | |
| 798 | def run_shell_script(self, |
| 799 | parms_string, |
| 800 | quiet=False): |
| 801 | r""" |
| 802 | Run CLI shell script tool. |
| 803 | |
| 804 | Description of variable: |
| 805 | parms_string script command options. |
| 806 | quiet do not print redfishtool error message if True |
| 807 | """ |
| 808 | |
| 809 | result = subprocess.run([parms_string], |
| 810 | stdout=subprocess.PIPE, |
| 811 | stderr=subprocess.PIPE, |
| 812 | shell=True, |
| 813 | universal_newlines=True) |
| 814 | |
| 815 | if result.stderr and not quiet: |
| 816 | self.logger.error('\n\t\tERROR executing %s' % parms_string) |
| 817 | self.logger.error('\t\t' + result.stderr) |
| 818 | |
| 819 | return result.stdout |
| 820 | |
| 821 | def protocol_shell_script(self, |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 822 | target_type, |
George Keishing | 04d2910 | 2021-07-16 02:05:57 -0500 | [diff] [blame] | 823 | sub_type): |
| 824 | r""" |
| 825 | Perform SHELL script execution locally. |
| 826 | |
| 827 | Description of argument(s): |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 828 | target_type OS Type of remote host. |
George Keishing | 04d2910 | 2021-07-16 02:05:57 -0500 | [diff] [blame] | 829 | sub_type Group type of commands. |
| 830 | """ |
| 831 | |
| 832 | self.logger.info("\n\t[Run] Executing commands to %s using %s" % (self.hostname, 'SHELL')) |
| 833 | shell_files_saved = [] |
| 834 | progress_counter = 0 |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 835 | list_of_cmd = self.get_command_list(self.ffdc_actions[target_type][sub_type]) |
George Keishing | 04d2910 | 2021-07-16 02:05:57 -0500 | [diff] [blame] | 836 | for index, each_cmd in enumerate(list_of_cmd, start=0): |
| 837 | |
| 838 | result = self.run_shell_script(each_cmd) |
| 839 | if result: |
| 840 | try: |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 841 | targ_file = self.get_file_list(self.ffdc_actions[target_type][sub_type])[index] |
George Keishing | 04d2910 | 2021-07-16 02:05:57 -0500 | [diff] [blame] | 842 | except IndexError: |
| 843 | targ_file = each_cmd.split('/')[-1] |
| 844 | self.logger.warning("\n\t[WARN] Missing filename to store data %s." % each_cmd) |
| 845 | self.logger.warning("\t[WARN] Data will be stored in %s." % targ_file) |
| 846 | |
| 847 | targ_file_with_path = (self.ffdc_dir_path |
| 848 | + self.ffdc_prefix |
| 849 | + targ_file) |
| 850 | |
| 851 | # Creates a new file |
| 852 | with open(targ_file_with_path, 'w') as fp: |
| 853 | fp.write(result) |
| 854 | fp.close |
| 855 | shell_files_saved.append(targ_file) |
| 856 | |
| 857 | progress_counter += 1 |
| 858 | self.print_progress(progress_counter) |
| 859 | |
| 860 | self.logger.info("\n\t[Run] Commands execution completed.\t\t [OK]") |
| 861 | |
| 862 | for file in shell_files_saved: |
| 863 | self.logger.info("\n\t\tSuccessfully save file " + file + ".") |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 864 | |
| 865 | def verify_protocol(self, protocol_list): |
| 866 | r""" |
| 867 | Perform protocol working check. |
| 868 | |
| 869 | Description of argument(s): |
| 870 | protocol_list List of protocol. |
| 871 | """ |
| 872 | |
| 873 | tmp_list = [] |
| 874 | if self.target_is_pingable(): |
| 875 | tmp_list.append("SHELL") |
| 876 | |
| 877 | for protocol in protocol_list: |
| 878 | if self.remote_protocol != 'ALL': |
| 879 | if self.remote_protocol != protocol: |
| 880 | continue |
| 881 | |
| 882 | # Only check SSH/SCP once for both protocols |
| 883 | if protocol == 'SSH' or protocol == 'SCP' and protocol not in tmp_list: |
| 884 | if self.ssh_to_target_system(): |
George Keishing | aa63870 | 2021-07-26 11:48:28 -0500 | [diff] [blame] | 885 | # Add only what user asked. |
| 886 | if self.remote_protocol != 'ALL': |
| 887 | tmp_list.append(self.remote_protocol) |
| 888 | else: |
| 889 | tmp_list.append('SSH') |
| 890 | tmp_list.append('SCP') |
George Keishing | f5a5750 | 2021-07-22 16:43:47 -0500 | [diff] [blame] | 891 | |
| 892 | if protocol == 'TELNET': |
| 893 | if self.telnet_to_target_system(): |
| 894 | tmp_list.append(protocol) |
| 895 | |
| 896 | if protocol == 'REDFISH': |
| 897 | if self.verify_redfish(): |
| 898 | tmp_list.append(protocol) |
| 899 | self.logger.info("\n\t[Check] %s Redfish Service.\t\t [OK]" % self.hostname) |
| 900 | else: |
| 901 | self.logger.info("\n\t[Check] %s Redfish Service.\t\t [NOT AVAILABLE]" % self.hostname) |
| 902 | |
| 903 | if protocol == 'IPMI': |
| 904 | if self.verify_ipmi(): |
| 905 | tmp_list.append(protocol) |
| 906 | self.logger.info("\n\t[Check] %s IPMI LAN Service.\t\t [OK]" % self.hostname) |
| 907 | else: |
| 908 | self.logger.info("\n\t[Check] %s IPMI LAN Service.\t\t [NOT AVAILABLE]" % self.hostname) |
| 909 | |
| 910 | return tmp_list |