forked from cockpit-project/cockpit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-storage-used
executable file
·78 lines (63 loc) · 2.71 KB
/
check-storage-used
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This file is part of Cockpit.
#
# Copyright (C) 2015 Red Hat, Inc.
#
# Cockpit is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Cockpit is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
from testlib import *
from storagelib import *
class TestStorage(StorageCase):
def testUsed(self):
m = self.machine
b = self.browser
self.login_and_go("/storage")
b.wait_in_text("#drives", "VirtIO")
m.add_disk("50M", serial="DISK1")
b.wait_in_text("#drives", "DISK1")
m.execute("parted -s /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_DISK1 mktable msdos")
m.execute("parted -s /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_DISK1 mkpart primary ext2 1M 25")
m.execute("udevadm settle")
m.execute("echo einszweidrei | cryptsetup luksFormat /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_DISK1-part1")
m.execute("echo einszweidrei | cryptsetup luksOpen /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_DISK1-part1 dm-test")
m.execute("udevadm settle")
m.execute("mke2fs -q -L TEST /dev/mapper/dm-test")
m.execute("mount /dev/mapper/dm-test /mnt")
# Now all of /dev/mapper/dm-test, /dev/sda1, and /dev/sda should be 'in use'.
b.click('tr:contains("DISK1")')
b.wait_visible("#storage-detail")
b.wait_in_text("#content", "/mnt")
self.content_action(2, "Format")
self.dialog_wait_open()
self.dialog_wait_alert("is mounted on /mnt")
self.dialog_cancel()
self.dialog_wait_close()
self.content_action(1, "Delete")
self.dialog_wait_open()
self.dialog_wait_alert("is mounted on /mnt")
self.dialog_cancel()
self.dialog_wait_close()
b.click('[data-action="format_disk"]')
self.dialog_wait_open()
self.dialog_wait_alert("is mounted on /mnt")
self.dialog_cancel()
self.dialog_wait_close()
# Unmount and format the disk.
m.execute("umount /mnt")
b.wait_in_text("#content", "not mounted")
b.click('[data-action="format_disk"]')
self.dialog({})
b.wait_in_text("#content", "50 MB Free Space")
if __name__ == '__main__':
test_main()