22#
33# ==== Attributes
44#
5- # * +resource_type+ - resorce type, i.e 'physical_volume', 'volume_group', 'logical_volume', or 'filesystem'
5+ # * +resource_type+ - resorce type, i.e 'physical_volume', 'volume_group', 'logical_volume', 'filesystem',
6+ # * 'aix_physical_volume', 'aix_volume_group', or 'aix_logical_volume'.
67# * +resource_name+ - The name of resource type, i.e '/dev/sdb' for physical volume, vg_1234 for volume group
78# * +vg+ - volume group name associated with logical volume (if any)
89# * +properties+ - a matching string or regular expression in logical volume properties
@@ -26,13 +27,29 @@ def verify_if_created?(agent, resource_type, resource_name, vg=nil, properties=n
2627 assert_match ( /#{ resource_name } / , result . stdout , 'Unexpected error was detected' )
2728 end
2829 when 'logical_volume'
29- fail_test "Error: missing volume group that the logical volume is associated with" unless vg
30+ raise ArgumentError , 'Missing volume group that the logical volume is associated with' unless vg
3031 on ( agent , "lvdisplay /dev/#{ vg } /#{ resource_name } " ) do |result |
3132 assert_match ( /#{ resource_name } / , result . stdout , 'Unexpected error was detected' )
3233 if properties
3334 assert_match ( /#{ properties } / , result . stdout , 'Unexpected error was detected' )
3435 end
3536 end
37+ when 'aix_physical_volume'
38+ on ( agent , "lspv #{ resource_name } " ) do |result |
39+ assert_match ( /Physical volume #{ resource_name } is not assigned to/ , result . stdout , 'Unexpected error was detected' )
40+ end
41+ when 'aix_volume_group'
42+ on ( agent , "lsvg" ) do |result |
43+ assert_match ( /#{ resource_name } / , result . stdout , 'Unexpected error was detected' )
44+ end
45+ when 'aix_logical_volume'
46+ raise ArgumentError , 'Missing volume group that the logical volume is associated with' unless vg
47+ on ( agent , "lslv #{ resource_name } " ) do |result |
48+ assert_match ( /#{ resource_name } / , result . stdout , 'Unexpected error was detected' )
49+ if properties
50+ assert_match ( /#{ properties } / , result . stdout , 'Unexpected error was detected' )
51+ end
52+ end
3653 end
3754end
3855
@@ -68,6 +85,7 @@ def is_correct_format?(agent, volume_group, logical_volume, format_type)
6885# * +pv+ - physical volume, can be one volume or an array of multiple volumes
6986# * +vg+ - volume group, can be one group or an array of multiple volume groups
7087# * +lv+ - logical volume, can be one volume or an array of multiple volumes
88+ # * +aix+ - if the agent is an AIX server.
7189#
7290# ==== Returns
7391#
@@ -78,41 +96,47 @@ def is_correct_format?(agent, volume_group, logical_volume, format_type)
7896# ==== Examples
7997#
8098# remove_all(agent, '/dev/sdb', 'VolumeGroup_1234', 'LogicalVolume_fa13')
81- def remove_all ( agent , pv = nil , vg = nil , lv = nil )
82- step 'remove logical volume if any:'
83- if lv
84- if lv . kind_of? ( Array )
85- lv . each do |logical_volume |
86- on ( agent , "umount /dev/#{ vg } /#{ logical_volume } " , :acceptable_exit_codes => [ 0 , 1 ] )
87- on ( agent , "lvremove /dev/#{ vg } /#{ logical_volume } --force" )
99+ def remove_all ( agent , pv = nil , vg = nil , lv = nil , aix = false )
100+ if aix
101+ step 'remove aix volume group, physical/logical volume '
102+ on ( agent , "reducevg -d -f #{ vg } #{ pv } " )
103+ on ( agent , "rm -rf /dev/#{ vg } /dev/#{ lv } " )
104+ else
105+ step 'remove logical volume if any:'
106+ if lv
107+ if lv . kind_of? ( Array )
108+ lv . each do |logical_volume |
109+ on ( agent , "umount /dev/#{ vg } /#{ logical_volume } " , :acceptable_exit_codes => [ 0 , 1 ] )
110+ on ( agent , "lvremove /dev/#{ vg } /#{ logical_volume } --force" )
111+ end
112+ else
113+ #note: in some test cases, for example, the test case 'create_vg_property_logical_volume'
114+ # the logical volume must be unmount before being able to delete it
115+ on ( agent , "umount /dev/#{ vg } /#{ lv } " , :acceptable_exit_codes => [ 0 , 1 ] )
116+ on ( agent , "lvremove /dev/#{ vg } /#{ lv } --force" )
88117 end
89- else
90- #note: in some test cases, for example, the test case 'create_vg_property_logical_volume'
91- # the logical volume must be unmount before being able to delete it
92- on ( agent , "umount /dev/#{ vg } /#{ lv } " , :acceptable_exit_codes => [ 0 , 1 ] )
93- on ( agent , "lvremove /dev/#{ vg } /#{ lv } --force" )
94118 end
95- end
96119
97- step 'remove volume group if any:'
98- if vg
99- if vg . kind_of? ( Array )
100- vg . each do |volume_group |
101- on ( agent , "vgremove /dev/#{ volume_group } " )
120+ step 'remove volume group if any:'
121+ if vg
122+ if vg . kind_of? ( Array )
123+ vg . each do |volume_group |
124+ on ( agent , "vgremove /dev/#{ volume_group } " )
125+ end
126+ else
127+ on ( agent , "vgremove /dev/#{ vg } " )
102128 end
103- else
104- on ( agent , "vgremove /dev/#{ vg } " )
105129 end
106- end
107130
108- step 'remove logical volume if any:'
109- if pv
110- if pv . kind_of? ( Array )
111- pv . each do |physical_volume |
112- on ( agent , "pvremove #{ physical_volume } " )
131+ step 'remove logical volume if any:'
132+ if pv
133+ if pv . kind_of? ( Array )
134+ pv . each do |physical_volume |
135+ on ( agent , "pvremove #{ physical_volume } " )
136+ end
137+ else
138+ on ( agent , "pvremove #{ pv } " )
113139 end
114- else
115- on ( agent , "pvremove #{ pv } " )
116140 end
117141 end
118142end
0 commit comments