Exemplo n.º 1
0
def get_storage_drives(slot):
    exp = re.compile(
        r"physicaldrive (?P<location>\S+) \(port (?P<port>[^:]+):box (?P<box>\d+):bay (?P<bay>\d+), (?P<size>[^\)]+)\): (?P<status>\S+)",
        re.I | re.M)
    drives = []
    for match in re.finditer(exp, _get_storage_drives(slot)):
        drives.append({
            "location": match.group("location"),
            "port": match.group("port"),
            "box": int(match.group("box")),
            "bay": int(match.group("bay")),
            "size": util.from_nice_size(match.group("size")),
            "status": match.group("status")
        })
    return drives
Exemplo n.º 2
0
def get_storage_drives_detail(slot):
    exp = re.compile(
        r"physicaldrive (?P<location>\S+)\s+Port: (?P<port>\S+)\s+Box: (?P<box>\d+)\s+Bay: (?P<bay>\d+)\s+Status: (?P<status>\S+).+?Size: (?P<size>\d+ ?\S+).+?Serial Number: (?P<serial>\S+).+?Current Temperature \(C\): (?P<temp>\d+)\s+Maximum Temperature \(C\): (?P<max_temp>\d+)",
        re.I | re.M | re.S)
    drives = []
    for match in re.finditer(exp, _get_storage_drives_detail(slot)):
        drives.append({
            "location": match.group("location"),
            "port": match.group("port"),
            "box": int(match.group("box")),
            "bay": int(match.group("bay")),
            "size": util.from_nice_size(match.group("size")),
            "status": match.group("status"),
            "serial": match.group("serial"),
            "temp": float(match.group("temp")),
            "max_temp": float(match.group("max_temp"))
        })
    return drives
Exemplo n.º 3
0
	def test_pb_iec(self):
		self.assertEqual(util.from_nice_size("9 PB", iec=True), 9 * 1024 * 1024 * 1024 * 1024 * 1024)
Exemplo n.º 4
0
	def test_tb_iec(self):
		self.assertEqual(util.from_nice_size("13 TB", iec=True), 13 * 1024 * 1024 * 1024 * 1024)
Exemplo n.º 5
0
	def test_gb_iec(self):
		self.assertEqual(util.from_nice_size("5 GB", iec=True), 5 * 1024 * 1024 * 1024)
Exemplo n.º 6
0
	def test_mb_iec(self):
		self.assertEqual(util.from_nice_size("7 MB", iec=True), 7 * 1024 * 1024)
Exemplo n.º 7
0
	def test_kb_iec(self):
		self.assertEqual(util.from_nice_size("3 kB", iec=True), 3 * 1024)
Exemplo n.º 8
0
	def test_tb(self):
		self.assertEqual(util.from_nice_size("13 TB"), 13 * 1000 * 1000 * 1000 * 1000)
Exemplo n.º 9
0
	def test_pib(self):
		self.assertEqual(util.from_nice_size("9 PiB"), 9 * 1024 * 1024 * 1024 * 1024 * 1024)
Exemplo n.º 10
0
	def test_tib(self):
		self.assertEqual(util.from_nice_size("13 TiB"), 13 * 1024 * 1024 * 1024 * 1024)
Exemplo n.º 11
0
	def test_gib(self):
		self.assertEqual(util.from_nice_size("5 GiB"), 5 * 1024 * 1024 * 1024)
Exemplo n.º 12
0
	def test_mib(self):
		self.assertEqual(util.from_nice_size("7 MiB"), 7 * 1024 * 1024)
Exemplo n.º 13
0
	def test_kib(self):
		self.assertEqual(util.from_nice_size("3 kiB"), 3 * 1024)
Exemplo n.º 14
0
	def test_eb(self):
		self.assertEqual(util.from_nice_size("72 EB"), 72 * 1000 * 1000 * 1000 * 1000 *1000 * 1000)
Exemplo n.º 15
0
	def test_pb(self):
		self.assertEqual(util.from_nice_size("9 PB"), 9 * 1000 * 1000 * 1000 * 1000 * 1000)
Exemplo n.º 16
0
	def test_eb_iec(self):
		self.assertEqual(util.from_nice_size("72 EB", iec=True), 72 * 1024 * 1024 * 1024 * 1024 *1024 * 1024)
Exemplo n.º 17
0
	def test_mb(self):
		self.assertEqual(util.from_nice_size("7 MB"), 7 * 1000 * 1000)
Exemplo n.º 18
0
	def test_eib(self):
		self.assertEqual(util.from_nice_size("72 EiB"), 72 * 1024 * 1024 * 1024 * 1024 *1024 * 1024)
Exemplo n.º 19
0
	def test_kb(self):
		self.assertEqual(util.from_nice_size("3 kB"), 3 * 1000)
Exemplo n.º 20
0
	def test_gb(self):
		self.assertEqual(util.from_nice_size("5 GB"), 5 * 1000 * 1000 * 1000)