make typeerrors give more accurate and clearer errors
This commit is contained in:
parent
830db7f051
commit
37f9aa76be
|
@ -3,11 +3,11 @@ import logging
|
||||||
def listServers(serverName):
|
def listServers(serverName):
|
||||||
# Input validation
|
# Input validation
|
||||||
if not type(serverName) is list:
|
if not type(serverName) is list:
|
||||||
raise TypeError("ssh_runcmd: command must be a list, '" + str(serverName) + "' is not.")
|
raise TypeError("listServers: serverName must be a list, '" + str(serverName) + "' is not.")
|
||||||
# Check if the first item in the list is the header. If this is true (data started at right place), most likely the other data is fine as well.
|
# Check if the first item in the list is the header. If this is true (data started at right place), most likely the other data is fine as well.
|
||||||
if not serverName[0] == 'Bay Server Name Serial Number Status Power UID Partner\r':
|
if not serverName[0] == 'Bay Server Name Serial Number Status Power UID Partner\r':
|
||||||
logging.critical(serverName)
|
logging.critical(serverName)
|
||||||
raise ValueError('Unexpected data recieved while listing servers.')
|
raise ValueError('listServers: Unexpected data recieved.')
|
||||||
|
|
||||||
serverNamePos = [] # Init list
|
serverNamePos = [] # Init list
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@ import logging
|
||||||
def relativeUsage(encPowerUsageAC, baysInUseCount, servers):
|
def relativeUsage(encPowerUsageAC, baysInUseCount, servers):
|
||||||
# Input validation
|
# Input validation
|
||||||
if not type(encPowerUsageAC) is int:
|
if not type(encPowerUsageAC) is int:
|
||||||
raise TypeError("ssh_runcmd: command must be an integer, '" + str(encPowerUsageAC) + "' is not.")
|
raise TypeError("relativeUsage: command must be an integer, '" + str(encPowerUsageAC) + "' is not.")
|
||||||
if not type(baysInUseCount) is int:
|
if not type(baysInUseCount) is int:
|
||||||
raise TypeError("ssh_runcmd: command must be an integer, '" + str(baysInUseCount) + "' is not.")
|
raise TypeError("relativeUsage: command must be an integer, '" + str(baysInUseCount) + "' is not.")
|
||||||
if not type(servers) is list:
|
if not type(servers) is list:
|
||||||
raise TypeError("ssh_runcmd: command must be a list, '" + str(servers) + "' is not.")
|
raise TypeError("relativeUsage: command must be a list, '" + str(servers) + "' is not.")
|
||||||
|
|
||||||
# Add up the total DC usage of blades.
|
# Add up the total DC usage of blades.
|
||||||
absoluteBladesUsage = 0
|
absoluteBladesUsage = 0
|
||||||
|
|
Loading…
Reference in New Issue