def test_print_if_failure(self): items = [ fake.FakeUnityObject(_id='sv_2', _code=1, name="Lun 1"), fake.FakeUnityObject(_id='sv_3', _code=1, name="Lun 2") ] status_code = [(1, 'sv_1'), (1, 'sv_3')] r = utils.print_if_failure(status_code, items) self.assertEqual(1, r)
def check(self): all_status = ok, warning, critical, unknown = utils.get_all_status( self.disks) code = utils.max_if_not_empty(ok + warning + critical + unknown, key=lambda i: i[0]) code = code[0] status_mark = utils.get_status_mark("DISK", code) first_line = "Total Disks #{}, Failed Disks: {}, Hot spares: {}, " \ "Unbounded: {}".format( len(ok + warning + critical + unknown), [c[1] for c in critical], self.get_hot_spares(), self.get_unbounded_disks()) # Status line print(status_mark + first_line + " | ") # Failed details utils.print_if_failure(all_status[code], self.disks) return code
def check(self): all_status = ok, warning, critical, unknown = utils.get_all_status( self.sas_ports) code = utils.max_if_not_empty(ok + warning + critical + unknown, key=lambda i: i[0]) code = code[0] status_mark = utils.get_status_mark("SAS_PORT", code) first_line = "Total SAS ports #{}, Failed ports(ID): {}".format( len(ok + warning + critical + unknown), [c[1] for c in critical]) # Status line print(status_mark + first_line + " | ") # Failed details utils.print_if_failure(all_status[code], self.sas_ports) # Performance detail for port in self.sas_ports: print("{}: Link status={}, Current Speed={}".format( port.name, self.get_link_status(port), utils.format_enum(port.current_speed))) return code
def check(self): all_status = ok, warning, critical, unknown = utils.get_all_status( self.pools) code = utils.max_if_not_empty(ok + warning + critical + unknown, key=lambda i: i[0]) code = code[0] status_mark = utils.get_status_mark("POOL", code) first_line = "Total POOLs #{}, Failed POOLs: {}".format( len(ok + warning + critical + unknown), ', '.join( [utils.get_by_id(c[1], self.pools).name for c in critical])) # Status line print(status_mark + first_line + " | ") # Failed details utils.print_if_failure(all_status[code], self.pools) # Performance detail for p in self.pools: print("{}: Total Cap={} GiB, " "Available Cap={} GiB({:.2f}%) ".format( p.name, utils.byte_to_GiB(p.size_total), utils.byte_to_GiB(p.size_free), (p.size_free / p.size_total) * 100)) return code
def check(self): all_status = ok, warning, critical, unknown = utils.get_all_status( self.dae) code = utils.max_if_not_empty(ok + warning + critical + unknown, key=lambda i: i[0]) code = code[0] status_mark = utils.get_status_mark("DAE", code) first_line = "Total DAEs #{}, Failed DAE(ID): {}".format( len(ok + warning + critical + unknown), [c[1] for c in critical]) # Status line print(status_mark + first_line + " | ") # Failed details utils.print_if_failure(all_status[code], self.dae) # Performance detail for d in self.dae: print("{}: Power(curr/avg/max_if_not_empty)={}/{}/{} watts, " "Temperature(curr/avg/max_if_not_empty)={}/{}/{} degrees , " "Speed(curr/max)={}/{} GB".format( d.name, d.current_power, d.avg_power, d.max_power, d.current_temperature, d.avg_temperature, d.max_temperature, utils.byte_to_GB(d.current_speed), utils.byte_to_GB(d.max_speed))) return code
def check(self): all_status = ok, warning, critical, unknown = utils.get_all_status( self.ethernet_ports) code = utils.max_if_not_empty(ok + warning + critical + unknown, key=lambda i: i[0]) code = code[0] status_mark = utils.get_status_mark("ETHERNET_PORT", code) first_line = "Total ethernet ports #{}, Failed ports(ID): {}".format( len(ok + warning + critical + unknown), ', '.join([ utils.get_by_id(c[1], self.ethernet_ports).name for c in critical ])) # Status line print(status_mark + first_line + " | ") # Failed details utils.print_if_failure(all_status[code], self.ethernet_ports) # Performance detail for port in self.ethernet_ports: print("{}: Link status={}, Requested Speed={}, " "Current Speed={}".format( port.name, "UP" if port.is_link_up else "DOWN", utils.format_enum(port.requested_speed), utils.format_enum(port.speed))) return code