ruby-lvm 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +10 -2
  3. data/Manifest.txt +18 -17
  4. data/README.txt +22 -9
  5. data/Rakefile +3 -2
  6. data/Todo.txt +7 -8
  7. data/examples/create_snapshot.rb +20 -8
  8. data/examples/error_handling.rb +8 -2
  9. data/examples/show_lvm_config.rb +40 -0
  10. data/lib/lvm.rb +67 -24
  11. data/lib/lvm/external.rb +25 -30
  12. data/lib/lvm/logical_volume.rb +9 -0
  13. data/lib/lvm/logical_volume_segment.rb +5 -0
  14. data/lib/lvm/logical_volumes.rb +37 -0
  15. data/lib/lvm/physical_volume.rb +5 -0
  16. data/lib/lvm/physical_volume_segment.rb +5 -0
  17. data/lib/lvm/physical_volumes.rb +37 -0
  18. data/lib/lvm/userland.rb +5 -0
  19. data/lib/lvm/volume_group.rb +5 -0
  20. data/lib/lvm/volume_groups.rb +46 -0
  21. data/lib/lvm/volumes.rb +16 -0
  22. data/lib/lvm/wrapper.rb +53 -0
  23. data/lib/lvm/wrapper/constants.rb +11 -0
  24. data/lib/lvm/wrapper/lvs.rb +127 -0
  25. data/lib/lvm/wrapper/lvsseg.rb +59 -0
  26. data/lib/lvm/wrapper/pvs.rb +84 -0
  27. data/lib/lvm/wrapper/pvsseg.rb +57 -0
  28. data/lib/lvm/wrapper/vgs.rb +112 -0
  29. metadata +109 -90
  30. metadata.gz.sig +0 -0
  31. data/examples/show_volumes.rb +0 -26
  32. data/helpers/generate_field_data.rb +0 -117
  33. data/lib/lvm/attrib/lvs.yaml +0 -88
  34. data/lib/lvm/attrib/pvs.yaml +0 -46
  35. data/lib/lvm/attrib/vgs.yaml +0 -55
  36. data/lib/lvm/lv.rb +0 -19
  37. data/lib/lvm/lvmanager.rb +0 -95
  38. data/lib/lvm/lvs.rb +0 -143
  39. data/lib/lvm/lvseg.rb +0 -14
  40. data/lib/lvm/proc.rb +0 -39
  41. data/lib/lvm/pv.rb +0 -15
  42. data/lib/lvm/pvmanager.rb +0 -22
  43. data/lib/lvm/pvs.rb +0 -109
  44. data/lib/lvm/pvseg.rb +0 -14
  45. data/lib/lvm/vg.rb +0 -15
  46. data/lib/lvm/vgmanager.rb +0 -68
  47. data/lib/lvm/vgs.rb +0 -123
@@ -0,0 +1,57 @@
1
+ require 'lvm/wrapper'
2
+ require 'lvm/physical_volume_segment'
3
+
4
+ module LVM
5
+ module Wrapper
6
+ # segment output is very different in that its multi line, easier to treat as own command
7
+ class PVSSEG
8
+ include Reporting
9
+
10
+ attr_reader :attributes
11
+ attr_reader :command
12
+
13
+ def initialize(options)
14
+ @attributes = Attributes.load(options[:version], ATTRIBUTES_FILE)
15
+ @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND)}"
16
+ end
17
+
18
+ BASE_COMMAND = "pvs #{Reporting::BASE_ARGUMENTS}"
19
+ ATTRIBUTES_FILE = 'pvsseg.yaml'
20
+
21
+ def list
22
+ output = External.cmd(@command)
23
+ data = parse(output)
24
+ if block_given?
25
+ return data.each { |obj| yield obj }
26
+ else
27
+ return data
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ # Parses the output of self.command
34
+ def parse(output)
35
+ volumes = []
36
+
37
+ output.split("\n").each do |line|
38
+ args = process_line(attributes, line)
39
+
40
+ args[:finish] = args[:start] + args[:size]
41
+
42
+ # finally build our object
43
+ volume = PhysicalVolumeSegment.new(args)
44
+
45
+ if block_given?
46
+ yield volume
47
+ else
48
+ volumes << volume
49
+ end
50
+ end
51
+
52
+ return volumes
53
+ end # parse
54
+
55
+ end # class PVSSEG
56
+ end # module Wrapper
57
+ end # module LVM
@@ -0,0 +1,112 @@
1
+ require 'lvm/wrapper'
2
+ require 'lvm/volume_group'
3
+
4
+ module LVM
5
+ module Wrapper
6
+ class VGS
7
+ include Reporting
8
+
9
+ attr_reader :attributes
10
+ attr_reader :command
11
+
12
+ def initialize(options)
13
+ @attributes = Attributes.load(options[:version], ATTRIBUTES_FILE)
14
+ @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND)}"
15
+ end
16
+
17
+ BASE_COMMAND = "vgs #{Reporting::BASE_ARGUMENTS}"
18
+ ATTRIBUTES_FILE = 'vgs.yaml'
19
+
20
+ # vg_attr attribute handling constants
21
+ # roughly by order referenced in lib/report/report.c:360 (_vgstatus_disp)
22
+ #
23
+ PERMISSIONS = {
24
+ 'w' => :writeable,
25
+ 'r' => :readonly,
26
+ }
27
+ RESIZEABLE = {
28
+ # code says its a boolean
29
+ 'z' => true
30
+ }
31
+ EXPORTED = {
32
+ # code says its a boolean
33
+ 'x' => true
34
+ }
35
+ PARTIAL = {
36
+ # code says its a boolean
37
+ 'p' => true
38
+ }
39
+ ALLOCATION_POLICY = {
40
+ 'c' => :contiguous,
41
+ 'l' => :cling,
42
+ 'n' => :normal,
43
+ 'a' => :anywhere,
44
+ 'i' => :inherited,
45
+ 'C' => :contiguous_locked,
46
+ 'L' => :cling_locked,
47
+ 'N' => :normal_locked,
48
+ 'A' => :anywhere_locked,
49
+ 'I' => :inherited_locked
50
+ }
51
+ CLUSTERED = {
52
+ # code says its a boolean
53
+ 'c' => true
54
+ }
55
+
56
+ def list
57
+ output = External.cmd(@command)
58
+ data = parse(output)
59
+ if block_given?
60
+ return data.each { |obj| yield obj }
61
+ else
62
+ return data
63
+ end
64
+ end
65
+
66
+ private
67
+
68
+ def parse_vg_attr(vg_attr) #:nodoc:
69
+ translated = {}
70
+ # translate them into nice symbols and a couple booleans
71
+ translated[:permissions] = PERMISSIONS[vg_attr[0].chr]
72
+ translated[:resizeable] = RESIZEABLE[vg_attr[1].chr] ? true : false
73
+ translated[:exported] = EXPORTED[vg_attr[2].chr] ? true : false
74
+ translated[:partial] = PARTIAL[vg_attr[3].chr] ? true : false
75
+ translated[:allocation_policy] = ALLOCATION_POLICY[vg_attr[4].chr]
76
+ translated[:clustered] = CLUSTERED[vg_attr[5].chr] ? true : false
77
+
78
+ return translated
79
+ end
80
+
81
+ # Parses the output of self.command
82
+ def parse(output) #:nodoc:
83
+ volumes = []
84
+
85
+ output.split("\n").each do |line|
86
+ args = process_line(attributes, line)
87
+
88
+ # now we force some types to ints since we've requested them as bytes
89
+ # without a suffix
90
+ args[:size] = args[:size].to_i
91
+
92
+ # we resolve the attributes line to nicer symbols
93
+ args.merge!(parse_vg_attr(args[:attr]))
94
+
95
+ # finally build our object
96
+ volume = VolumeGroup.new(args)
97
+
98
+ if block_given?
99
+ yield volume
100
+ else
101
+ volumes << volume
102
+ end
103
+ end
104
+
105
+ return volumes
106
+ end # parse
107
+
108
+ end # class VGS
109
+ end # module Wrapper
110
+ end # module LVM
111
+
112
+
metadata CHANGED
@@ -1,116 +1,135 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
3
- specification_version: 1
4
2
  name: ruby-lvm
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2008-05-30 00:00:00 -07:00
8
- summary: This is a wrapper for the LVM2 administration utility, lvm
9
- require_paths:
10
- - lib
11
- email:
12
- - matt@bravenet.com
13
- homepage: http://ruby-lvm.rubyforge.org
14
- rubyforge_project: ruby-lvm
15
- description: This is a wrapper for the LVM2 administration utility, lvm. Its primary function it to convert physical volumes, logical volumes and volume groups into easy to use ruby objects. It also provides a simple wrapper for typical create/delete/etc operations. Unfortunately due to it's lack of a proper api this is as good as it gets for ruby integration for the forseeable future. See this thread http://www.redhat.com/archives/libvir-list/2007-March/msg00192.html for a similar discussion.
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Kent
16
8
  autorequire:
17
- default_executable:
18
9
  bindir: bin
19
- has_rdoc: true
20
- required_ruby_version: !ruby/object:Gem::Version::Requirement
21
- requirements:
22
- - - ">"
23
- - !ruby/object:Gem::Version
24
- version: 0.0.0
25
- version:
26
- platform: ruby
27
- signing_key:
28
10
  cert_chain:
29
11
  - |
30
12
  -----BEGIN CERTIFICATE-----
31
- MIIDMDCCAh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N4UFxsb/I4MGYvbnrEVc6Ev1ztgK5Kci8oYcINjUhCls
28
+ EOmi6kiwQNdHUW0XLqwGanEip196lyE5IHRylQ5UiwYI0T4hDSc9f0SE+dzENdFw
29
+ doMOs6odERAAmX+M7PQ4i3Zvs+Jv9SazZBcl8+sohZL3I5A1fkNQXts1hV6TObce
30
+ T6VhSPds
49
31
  -----END CERTIFICATE-----
50
32
 
51
- post_install_message:
52
- authors:
53
- - Matthew Kent
54
- files:
55
- - History.txt
56
- - Manifest.txt
57
- - README.txt
58
- - Rakefile
59
- - Todo.txt
60
- - examples/create_snapshot.rb
61
- - examples/error_handling.rb
62
- - examples/show_volumes.rb
63
- - helpers/generate_field_data.rb
64
- - lib/lvm.rb
65
- - lib/lvm/attrib/lvs.yaml
66
- - lib/lvm/attrib/pvs.yaml
67
- - lib/lvm/attrib/vgs.yaml
68
- - lib/lvm/external.rb
69
- - lib/lvm/lv.rb
70
- - lib/lvm/lvmanager.rb
71
- - lib/lvm/lvs.rb
72
- - lib/lvm/lvseg.rb
73
- - lib/lvm/proc.rb
74
- - lib/lvm/pv.rb
75
- - lib/lvm/pvmanager.rb
76
- - lib/lvm/pvs.rb
77
- - lib/lvm/pvseg.rb
78
- - lib/lvm/vg.rb
79
- - lib/lvm/vgmanager.rb
80
- - lib/lvm/vgs.rb
81
- - test/test_lvm.rb
82
- test_files:
83
- - test/test_lvm.rb
84
- rdoc_options:
85
- - --main
86
- - README.txt
87
- extra_rdoc_files:
88
- - History.txt
89
- - Manifest.txt
90
- - README.txt
91
- - Todo.txt
92
- executables: []
93
-
94
- extensions: []
95
-
96
- requirements: []
97
-
33
+ date: 2008-07-31 00:00:00 -07:00
34
+ default_executable:
98
35
  dependencies:
99
36
  - !ruby/object:Gem::Dependency
100
37
  name: open4
38
+ type: :runtime
101
39
  version_requirement:
102
- version_requirements: !ruby/object:Gem::Version::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
103
41
  requirements:
104
42
  - - ">="
105
43
  - !ruby/object:Gem::Version
106
44
  version: 0.9.6
107
45
  version:
46
+ - !ruby/object:Gem::Dependency
47
+ name: ruby-lvm-attrib
48
+ type: :runtime
49
+ version_requirement:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.1
55
+ version:
108
56
  - !ruby/object:Gem::Dependency
109
57
  name: hoe
58
+ type: :development
110
59
  version_requirement:
111
- version_requirements: !ruby/object:Gem::Version::Requirement
60
+ version_requirements: !ruby/object:Gem::Requirement
112
61
  requirements:
113
62
  - - ">="
114
63
  - !ruby/object:Gem::Version
115
- version: 1.5.3
64
+ version: 1.7.0
116
65
  version:
66
+ description: This is a wrapper for the LVM2 administration utility, lvm. Its primary function it to convert physical volumes, logical volumes and volume groups into easy to use ruby objects. It also provides a simple wrapper for typical create/delete/etc operations. Due to a lack of LVM2 api this is a best effort attempt at ruby integration but subject to complete replacement in the future.
67
+ email:
68
+ - mkent@magoazul.com
69
+ executables: []
70
+
71
+ extensions: []
72
+
73
+ extra_rdoc_files:
74
+ - History.txt
75
+ - Manifest.txt
76
+ - README.txt
77
+ - Todo.txt
78
+ files:
79
+ - History.txt
80
+ - Manifest.txt
81
+ - README.txt
82
+ - Rakefile
83
+ - Todo.txt
84
+ - examples/create_snapshot.rb
85
+ - examples/error_handling.rb
86
+ - examples/show_lvm_config.rb
87
+ - lib/lvm.rb
88
+ - lib/lvm/external.rb
89
+ - lib/lvm/logical_volume.rb
90
+ - lib/lvm/logical_volume_segment.rb
91
+ - lib/lvm/logical_volumes.rb
92
+ - lib/lvm/physical_volume.rb
93
+ - lib/lvm/physical_volume_segment.rb
94
+ - lib/lvm/physical_volumes.rb
95
+ - lib/lvm/userland.rb
96
+ - lib/lvm/volume_group.rb
97
+ - lib/lvm/volume_groups.rb
98
+ - lib/lvm/volumes.rb
99
+ - lib/lvm/wrapper.rb
100
+ - lib/lvm/wrapper/constants.rb
101
+ - lib/lvm/wrapper/lvs.rb
102
+ - lib/lvm/wrapper/lvsseg.rb
103
+ - lib/lvm/wrapper/pvs.rb
104
+ - lib/lvm/wrapper/pvsseg.rb
105
+ - lib/lvm/wrapper/vgs.rb
106
+ - test/test_lvm.rb
107
+ has_rdoc: true
108
+ homepage: http://ruby-lvm.rubyforge.org
109
+ post_install_message:
110
+ rdoc_options:
111
+ - --main
112
+ - README.txt
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: "0"
120
+ version:
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: "0"
126
+ version:
127
+ requirements: []
128
+
129
+ rubyforge_project: ruby-lvm
130
+ rubygems_version: 1.2.0
131
+ signing_key:
132
+ specification_version: 2
133
+ summary: This is a wrapper for the LVM2 administration utility, lvm
134
+ test_files:
135
+ - test/test_lvm.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,26 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- $: << File.dirname(__FILE__) + "/../lib"
4
-
5
- require 'lvm'
6
- require 'lvm/lvmanager'
7
- require 'lvm/pvmanager'
8
- require 'lvm/vgmanager'
9
-
10
- lvm = LVMWrapper::LVM.new(:command => "/usr/bin/sudo /sbin/lvm")
11
- lv = LVMWrapper::LogicalVolumeManager.new(lvm)
12
- vg = LVMWrapper::VolumeGroupManager.new(lvm)
13
- pv = LVMWrapper::PhysicalVolumeManager.new(lvm)
14
-
15
- pv.list.each do |p|
16
- puts "- pv #{p.name}"
17
- end
18
-
19
- puts ""
20
-
21
- vg.list.each do |v|
22
- puts "- vg #{v.name}"
23
- lv.list(v.name).each do |l|
24
- puts "-- lv #{l.name}"
25
- end
26
- end
@@ -1,117 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # collect all lvm reporting columns and format to our liking for inclusion in
4
- # the library
5
- #
6
- # ruby generate_field_data.rb ~/iscsi_work/LVM2.2.02.36
7
-
8
- require 'yaml'
9
-
10
- LVM_COLUMNS = "/lib/report/columns.h"
11
-
12
- CONVERSION_MAP = {
13
- # Only types we can really trust
14
- "uint32" => "Integer",
15
- "int32" => "Integer",
16
- # These were determined by reading the code, they invoke _(u)int32_disp right away
17
- "pvmdas" => "Integer",
18
- "vgmdas" => "Integer",
19
- "lvcount" => "Integer",
20
- "lvsegcount" => "Integer",
21
- "segstartpe" => "Integer",
22
- # listed to return STR?
23
- "lvkmaj" => "Integer",
24
- "lvkmin" => "Integer",
25
- "snpercent" => "Float",
26
- "copypercent" => "Float",
27
- # size32/64, these do unit formatting unless overridden on command line. We
28
- # typically want them in bytes so we can convert them to Integers safely
29
- "size32" => "Integer",
30
- "size64" => "Integer",
31
- # These types return size32/size64 as well
32
- "lvkreadahead" => "Integer",
33
- "pvsize" => "Integer",
34
- "devsize" => "Integer",
35
- "pvfree" => "Integer",
36
- "pvused" => "Integer",
37
- "pvmdafree" => "Integer",
38
- "vgsize" => "Integer",
39
- "vgfree" => "Integer",
40
- "vgmda_free" => "Integer",
41
- "chunksize" => "Integer",
42
- "segstart" => "Integer",
43
- "segsize" => "Integer",
44
- "vgmdafree" => "Integer",
45
- # Weird one, can be "auto" or size32
46
- "lvreadahead" => "String"
47
- }
48
-
49
- lvm_source = ARGV[0]
50
-
51
- lvs = []
52
- vgs = []
53
- pvs = []
54
- File.readlines(lvm_source + LVM_COLUMNS).each do |line|
55
- chunked = line.split(", ")
56
-
57
- app = chunked[0]
58
- general_type = chunked[2]
59
- specific_type = chunked[6]
60
- field = chunked[7]
61
- # description = chunked[8]
62
-
63
- attribute = field
64
- attribute_type = nil
65
-
66
- if app.nil? || general_type.nil? || specific_type.nil? || field.nil?
67
- next
68
- end
69
-
70
- attribute.gsub!('"', '')
71
-
72
- if general_type == "NUM"
73
- attribute_type = CONVERSION_MAP[specific_type]
74
- if attribute_type.nil?
75
- puts "oops, missing hanlding of attribute '#{attribute}' which says its going to return a '#{specific_type}'"
76
- exit 1
77
- end
78
- else
79
- attribute_type = "String"
80
- end
81
- #XXX man page says we can skip the lv_ prefixes! and seg_!
82
- if app == "FIELD(LVS" || app == "FIELD(SEGS"
83
- lvs << { :option => attribute, :type_hint => attribute_type, :method => attribute.sub(%r{^lv_}, '') }
84
- elsif app == "FIELD(PVS" || app == "FIELD(PVSEGS"
85
- pvs << { :option => attribute, :type_hint => attribute_type, :method => attribute.sub(%r{^pv_}, '') }
86
- elsif app == "FIELD(VGS"
87
- vgs << { :option => attribute, :type_hint => attribute_type, :method => attribute.sub(%r{^vg_}, '') }
88
- end
89
- end
90
-
91
- lvs.sort! {|x,y| x[:option] <=> y[:option]}
92
- pvs.sort! {|x,y| x[:option] <=> y[:option]}
93
- vgs.sort! {|x,y| x[:option] <=> y[:option]}
94
-
95
- File.open("lvs.yaml", "w") do |f|
96
- f.write "# these are column to object attribute mappings \n"
97
- f.write "# generated by #{$0} based on \n"
98
- f.write "# #{lvm_source}/lib/report/columns.h\n"
99
- f.write(lvs.to_yaml)
100
- end
101
- puts "Wrote data to lvs.yaml"
102
-
103
- File.open("pvs.yaml", "w") do |f|
104
- f.write "# these are column to object attribute mappings \n"
105
- f.write "# generated by #{$0} based on \n"
106
- f.write "# #{lvm_source}/lib/report/columns.h\n"
107
- f.write(pvs.to_yaml)
108
- end
109
- puts "Wrote data to pvs.yaml"
110
-
111
- File.open("vgs.yaml", "w") do |f|
112
- f.write "# these are column to object attribute mappings \n"
113
- f.write "# generated by #{$0} based on \n"
114
- f.write "# #{lvm_source}/lib/report/columns.h\n"
115
- f.write(vgs.to_yaml)
116
- end
117
- puts "Wrote data to vgs.yaml"