Don't thrash out the content of remote commands stderr

parent 2fbd9bb3
......@@ -112,8 +112,9 @@ def advanced_info_of_resource(resource, needed_attributes, storwize_connection,
elif resource == 'lsenclosurepsu':
stdin, stdout, stderr = storwize_connection.exec_command('svcinfo {0} -psu {1} {2}'.format(resource, id_of_resource[1], id_of_resource[0]))
if len(stderr.read()) > 0:
storwize_logger.info("Error Occurs in advanced info of enclosure - {0}".format(stderr.read()))
stderr_content = stderr.read().rstrip('\n')
if len(stderr_content) > 0:
storwize_logger.info("Error Occurs in advanced info of enclosure - {0}".format(stderr_content))
storwize_logout(storwize_connection)
sys.exit("1100")
else:
......@@ -177,8 +178,9 @@ def discovering_resources(storwize_user, storwize_password, storwize_ip, storwiz
for resource in list_resources:
stdin, stdout, stderr = storwize_connection.exec_command('svcinfo {0} -delim :'.format(resource))
if len(stderr.read()) > 0: # Если случились ошибки, запиши их в лог и выйди из скрипта (If errors occur, than write them to log and correctyl end of ssh-session)
storwize_logger.info("Error Occurs in SSH Command - {0}".format(stderr.read()))
stderr_content = stderr.read().rstrip('\n')
if len(stderr_content) > 0: # Если случились ошибки, запиши их в лог и выйди из скрипта (If errors occur, than write them to log and correctyl end of ssh-session)
storwize_logger.info("Error Occurs in SSH Command - {0}".format(stderr_content))
storwize_logout(storwize_connection)
sys.exit("1100")
else:
......@@ -249,8 +251,9 @@ def get_status_resources(storwize_user, storwize_password, storwize_ip, storwize
for resource in list_resources:
stdin, stdout, stderr = storwize_connection.exec_command('svcinfo {0} -delim :'.format(resource))
if len(stderr.read()) > 0: # Если случились ошибки, запиши их в лог и выйди из скрипта (If errors occur, then write them to log-file and correctyly end of ssh-session)
storwize_logger.error("Error Occurs in SSH Command - {0}".format(stderr.read()))
stderr_content = stderr.read().rstrip('\n')
if len(stderr_content) > 0: # Если случились ошибки, запиши их в лог и выйди из скрипта (If errors occur, then write them to log-file and correctyly end of ssh-session)
storwize_logger.error("Error Occurs in SSH Command - {0}".format(stderr_content))
storwize_logout(storwize_connection)
sys.exit("1100")
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment