@@ -30,3 +30,60 @@ def verify_if_created?(agent, resource_type, resource_name)
3030 end
3131 end
3232end
33+
34+
35+ # Clean the box after each test, make sure the newly created logical volumes, volume groups,
36+ # and physical volumes are removed at the end of each test to make the server ready for the
37+ # next test case.
38+ #
39+ # ==== Attributes
40+ #
41+ # * +pv+ - physical volume, can be one volume or an array of multiple volumes
42+ # * +vg+ - volume group, can be one group or an array of multiple volume groups
43+ # * +lv+ - logical volume, can be one volume or an array of multiple volumes
44+ #
45+ # ==== Returns
46+ #
47+ # +nil+
48+ #
49+ # ==== Raises
50+ # +nil+
51+ # ==== Examples
52+ #
53+ # remove_all(agent, '/dev/sdb', 'VolumeGroup_1234', 'LogicalVolume_fa13')
54+ def remove_all ( agent , pv = nil , vg = nil , lv = nil )
55+ step 'remove logical volume if any:'
56+ if lv
57+ if lv . kind_of? ( Array )
58+ lv . each do |logical_volume |
59+ on ( agent , "umount /dev/#{ vg } /#{ logical_volume } " , :acceptable_exit_codes => [ 0 , 1 ] )
60+ on ( agent , "lvremove /dev/#{ vg } /#{ logical_volume } --force" )
61+ end
62+ else
63+ on ( agent , "umount /dev/#{ vg } /#{ lv } " , :acceptable_exit_codes => [ 0 , 1 ] )
64+ on ( agent , "lvremove /dev/#{ vg } /#{ lv } --force" )
65+ end
66+ end
67+
68+ step 'remove volume group if any:'
69+ if vg
70+ if vg . kind_of? ( Array )
71+ vg . each do |volume_group |
72+ on ( agent , "vgremove /dev/#{ volume_group } " )
73+ end
74+ else
75+ on ( agent , "vgremove /dev/#{ vg } " )
76+ end
77+ end
78+
79+ step 'remove logical volume if any:'
80+ if pv
81+ if pv . kind_of? ( Array )
82+ pv . each do |physical_volume |
83+ on ( agent , "pvremove #{ physical_volume } " )
84+ end
85+ else
86+ on ( agent , "pvremove #{ pv } " )
87+ end
88+ end
89+ end
0 commit comments