chef-ruby-lvm 0.3.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e7275c5fa9d67b4e1d363b5b5d881e8360bf3f5d
4
- data.tar.gz: 2ccee9355be13c3718be47859b79bc2ce438e04b
2
+ SHA256:
3
+ metadata.gz: 387e82dccd992f5aa8417b707db59bbf1d4f1c83f623c65a571ad1dbcab83826
4
+ data.tar.gz: d3b216108125e8cb2db811484fb981f76989709937c2e49c0f4a55dcc70a24e1
5
5
  SHA512:
6
- metadata.gz: 207a4ffda7f53258a316f573c82f51ffb9c910d0db68505e6e3e68321fa5442b5cf61d39d5c4f81b610818cbfa3a1dfcb3ccd6036e4813d48711822fb7dcbee0
7
- data.tar.gz: 36a88227100fdd3f78c5d723f6f36163baaf136e66fc168f20057cf26e1546347e6d9decfe7639300491ce80f1d574a10f7bb4fcebfee4d717583c12d4547794
6
+ metadata.gz: cfe0a7841855c5f023390a84f40e919834051e646f2c7fc73e8a99b011e38646f2b8655064acac2e5785214070a7326b2d0ba545dd03624fc6a0c77a9d356601
7
+ data.tar.gz: c4f6d11d71e226a0008f63a9eb39c258fd869dc17181160493401133699b7759ef4f89fccf64df046746a44c78c99918ed87e77033a46f2bc79364ac1ba4c7e6
@@ -0,0 +1 @@
1
+ @sous-chefs/maintainers
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: � Bug Report
3
+ about: If something isn't working as expected �.
4
+ labels: "Status: Untriaged"
5
+ ---
6
+
7
+ # Version:
8
+
9
+ [Version of the project installed]
10
+
11
+ # Environment:
12
+
13
+ [Details about the environment such as the Operating System, cookbook details, etc...]
14
+
15
+ # Scenario:
16
+
17
+ [What you are trying to achieve and you can't?]
18
+
19
+ # Steps to Reproduce:
20
+
21
+ [If you are filing an issue what are the things we need to do in order to repro your problem?]
22
+
23
+ # Expected Result:
24
+
25
+ [What are you expecting to happen as the consequence of above reproduction steps?]
26
+
27
+ # Actual Result:
28
+
29
+ [What actually happens after the reproduction steps?]
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: Design Proposal
3
+ about: I have a significant change I would like to propose and discuss before starting
4
+ labels: "Status: Untriaged"
5
+ ---
6
+
7
+ ### When a Change Needs a Design Proposal
8
+
9
+ A design proposal should be opened any time a change meets one of the following qualifications:
10
+
11
+ - Significantly changes the user experience of a project in a way that impacts users.
12
+ - Significantly changes the underlying architecture of the project in a way that impacts other developers.
13
+ - Changes the development or testing process of the project such as a change of CI systems or test frameworks.
14
+
15
+ ### Why We Use This Process
16
+
17
+ - Allows all interested parties (including any community member) to discuss large impact changes to a project.
18
+ - Serves as a durable paper trail for discussions regarding project architecture.
19
+ - Forces design discussions to occur before PRs are created.
20
+ - Reduces PR refactoring and rejected PRs.
21
+
22
+ ---
23
+
24
+ <!--- Proposal description and rationale. -->
25
+
26
+ ## Motivation
27
+
28
+ <!---
29
+ As a <<user_profile>>,
30
+ I want to <<functionality>>,
31
+ so that <<benefit>>.
32
+ -->
33
+
34
+ ## Specification
35
+
36
+ <!--- A detailed description of the planned implementation. -->
37
+
38
+ ## Downstream Impact
39
+
40
+ <!--- Which other tools will be impacted by this work? -->
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: 🚀 Enhancement Request
3
+ about: I have a suggestion (and may want to implement it 🙂)!
4
+ labels: "Status: Untriaged"
5
+ ---
6
+
7
+ ### Describe the Enhancement:
8
+ <!--- What you are trying to achieve that you can't? -->
9
+
10
+ ### Describe the Need:
11
+ <!--- What kind of user do you believe would utilize this enhancement, and how many users might want this functionality -->
12
+
13
+ ### Current Alternative
14
+ <!--- Is there a current alternative that you can utilize to workaround the lack of this enhancement -->
15
+
16
+ ### Can We Help You Implement This?:
17
+ <!--- The best way to ensure your enhancement is built is to help implement the enhancement yourself. If you're interested in helping out we'd love to give you a hand to make this possible. Let us know if there's something you need. -->
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: 🤗 Support Question
3
+ about: If you have a question 💬, please check out our Slack!
4
+ ---
5
+
6
+ We use GitHub issues to track bugs and feature requests. If you need help please post to our Mailing List or join the Chef Community Slack.
7
+
8
+ * Chef Community Slack at http://community-slack.chef.io/.
9
+ * Chef Mailing List https://discourse.chef.io/
10
+
11
+
12
+ Support issues opened here will be closed and redirected to Slack or Discourse.
@@ -0,0 +1,15 @@
1
+ ### Description
2
+
3
+ [Please describe what this change achieves]
4
+
5
+ ### Issues Resolved
6
+
7
+ [List any existing issues this PR resolves, or any Discourse or
8
+ StackOverflow discussions that are relevant]
9
+
10
+ ### Check List
11
+
12
+ - [ ] New functionality includes tests
13
+ - [ ] All tests pass
14
+ - [ ] All commits have been signed-off for the Developer Certificate of Origin. See <https://github.com/chef/chef/blob/master/CONTRIBUTING.md#developer-certification-of-origin-dco>
15
+ - [ ] PR title is a worthy inclusion in the CHANGELOG
@@ -0,0 +1,9 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "06:00"
8
+ timezone: America/Los_Angeles
9
+ open-pull-requests-limit: 10
data/CHANGELOG.md CHANGED
@@ -1,34 +1,46 @@
1
- # 0.3.0 (2016-06-21)
1
+ # Change log
2
+
3
+ ## 0.4.2
4
+
5
+ - Fix undefined variable error in `LVM::External::Module`
6
+
7
+ ## 0.4.1 (2022-04-25)
8
+
9
+ - Use new minor version of chef-ruby-lvm-attrib
10
+ - Chefstyle fixes
11
+ - Optimize requires with require_relative & use __dir__ not __FILE__
12
+
13
+ ## 0.4.0 (2018-07-23)
14
+
15
+ - Added additional_arguments option that allows passing options to commands
16
+
17
+ ## 0.3.0 (2017-06-21)
2
18
 
3
19
  - Depend on di-ruby-lvm-attrib ~0.2 to bring in the last few years of releases
4
20
 
5
- # 0.2.2 (2016-12-12)
21
+ ## 0.2.2 (2016-12-13)
6
22
 
7
23
  - Fork di-ruby-lvm as chef-ruby-lvm in order to unblock the Chef lvm cookbook support for the latest Linux distros
8
24
  - Convert the readme to markdown and reword portions
9
25
  - Resolve all chefstyle warnings
10
26
  - Added a Gemfile/Rakefile for chefstyle linting
11
27
 
12
- # 0.2.1 (2015-12-04)
28
+ ## 0.2.1 (2015-12-04)
13
29
 
14
30
  - Fix failures calling the calling physical_volumes list method
15
31
 
16
- # 0.2.0 (2015-12-01)
32
+ ## 0.2.0 (2015-12-01)
17
33
 
18
34
  - Minor code refactoring
19
35
  - Improve runtime with multiple VGs
20
36
  - Use just a gemspec instead of hoe
21
37
  - Require a newer di-ruby-lvm-attrib gem
22
38
 
23
- ....
24
-
25
- # 0.1.1 (2008-07-21)
26
-
27
- - 1 major enhancement
39
+ ## 0.1.1 (2008-07-21)
28
40
 
29
- - A complete rewrite! We won't bother attempting to wrap complex lvm operations, but instead provide LVM.raw() command. The wrapper now focuses purely on translating lvm lv/vg/pv data into the most useful ruby objects possible. The arguments passed to the underlying binaries have been broken out into a ruby-lvm-attributes package.
41
+ - A complete rewrite! We won't bother attempting to wrap complex lvm operations, but instead provide LVM.raw() command. The wrapper now focuses purely on translating lvm lv/vg/pv data into the most useful ruby objects possible. The arguments passed to the underlying binaries have been broken out into a ruby-lvm-attributes package.
30
42
 
31
- # 0.0.1 (2008-05-28)
43
+ ## 0.0.1 (2008-05-28)
32
44
 
33
45
  - 1 major enhancement
34
46
 
@@ -0,0 +1 @@
1
+ Please refer to the Chef Community Code of Conduct at https://www.chef.io/code-of-conduct/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,3 @@
1
+ # Contributing
2
+
3
+ Please refer to <https://github.com/chef/chef/blob/main/CONTRIBUTING.md>
data/Gemfile CHANGED
@@ -4,4 +4,5 @@ gemspec
4
4
 
5
5
  group :development do
6
6
  gem "chefstyle"
7
+ gem "rake"
7
8
  end
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # chef-ruby-lvm
2
2
 
3
- This is a fork of the chef-ruby-lvm gem found at <https://github.com/gregsymons/chef-ruby-lvm>. The primary difference from upstream is that it depends on chef-ruby-lvm-attrib instead of chef-ruby-lvm-attrib. This adds support for lvm version 2.02.66(2) and later.
3
+ [![Gem Version](https://badge.fury.io/rb/chef-ruby-lvm.svg)](https://badge.fury.io/rb/chef-ruby-lvm)
4
4
 
5
- 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.
5
+ This is a fork of the chef-ruby-lvm gem found at <https://github.com/gregsymons/di-ruby-lvm>. The primary difference from upstream is that it depends on chef-ruby-lvm-attrib instead of di-ruby-lvm-attrib. It was in turn forked from ruby-lvm. This adds support for lvm version 2.02.66(2) and later.
6
+
7
+ This is a wrapper for the LVM2 administration utility, lvm. Its primary function is 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.
6
8
 
7
9
  Due to a lack of LVM2 api this is a best effort attempt at ruby integration but subject to complete replacement in the future.
8
10
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- task :default => :style
3
+ task default: :style
4
4
 
5
5
  require "chefstyle"
6
6
  require "rubocop/rake_task"
@@ -1,11 +1,6 @@
1
- $:.unshift(File.expand_path("../lib/", __FILE__))
1
+ $:.unshift(File.expand_path("lib", __dir__))
2
2
  require "lvm/version"
3
3
 
4
- deps = {
5
- "open4" => ["~> 0.9", ">= 0.9.6"],
6
- "chef-ruby-lvm-attrib" => ["~> 0.2"],
7
- }
8
-
9
4
  Gem::Specification.new do |gem|
10
5
  gem.authors = ["Tim Smith", "Greg Symons", "Matthew Kent"]
11
6
  gem.email = ["tsmith@chef.io", "mkent@magoazul.com", "gsymons@gsconsulting.biz"]
@@ -19,7 +14,6 @@ Gem::Specification.new do |gem|
19
14
  gem.require_paths = ["lib"]
20
15
  gem.version = LVM::VERSION
21
16
 
22
- deps.each do |dep, constraints|
23
- gem.add_runtime_dependency dep, *constraints
24
- end
17
+ gem.add_runtime_dependency "chef-ruby-lvm-attrib", "~> 0.3"
18
+ gem.add_runtime_dependency "open4", "~> 0.9", ">= 0.9.6"
25
19
  end
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # Demonstration of passing additional arguments to the LVM object
4
+
5
+ $: << __dir__ + "/../lib"
6
+
7
+ require "lvm"
8
+
9
+ # List out volume groups with the --ignoreskippedcluster argument appended to the base argument list
10
+ lvm = LVM::LVM.new(command: "/usr/bin/sudo /sbin/lvm", additional_arguments: "--ignoreskippedcluster")
11
+
12
+ volume_groups = lvm.volume_groups
13
+ puts volume_groups.map(&:name)
@@ -3,14 +3,14 @@
3
3
  # Demonstration of the creation of an lvm snapshot, using sudo, and reading its
4
4
  # attributes.
5
5
 
6
- $: << File.dirname(__FILE__) + "/../lib"
6
+ $: << __dir__ + "/../lib"
7
7
 
8
8
  require "lvm"
9
9
 
10
10
  vol = "sys.vg/tmp.lv"
11
11
  snap = "demo_snap"
12
12
 
13
- lvm = LVM::LVM.new(:command => "/usr/bin/sudo /sbin/lvm")
13
+ lvm = LVM::LVM.new(command: "/usr/bin/sudo /sbin/lvm")
14
14
 
15
15
  if lvm.logical_volumes[snap]
16
16
  puts "#{snap} exists! Remove it"
@@ -20,9 +20,9 @@ end
20
20
  lvm.raw("lvcreate --snapshot --size 10M --name #{snap} #{vol}")
21
21
  lv = lvm.logical_volumes[snap]
22
22
 
23
- out = <<msg
23
+ out = <<MSG
24
24
  snapshot of #{vol}, #{snap}, created
25
25
  - uuid: #{lv.uuid}
26
26
  - major,minor: #{lv.kernel_major},#{lv.kernel_minor}
27
- msg
27
+ MSG
28
28
  puts out
@@ -2,11 +2,11 @@
2
2
 
3
3
  # Demonstration of the exception handling with raw commands.
4
4
 
5
- $: << File.dirname(__FILE__) + "/../lib"
5
+ $: << __dir__ + "/../lib"
6
6
 
7
7
  require "lvm"
8
8
 
9
- lvm = LVM::LVM.new(:command => "/usr/bin/sudo /sbin/lvm")
9
+ lvm = LVM::LVM.new(command: "/usr/bin/sudo /sbin/lvm")
10
10
 
11
11
  begin
12
12
  lvm.raw("--blah blah")
@@ -3,11 +3,11 @@
3
3
  # A more advanced demonstration displaying a complete overview of the current
4
4
  # lvm configuration.
5
5
 
6
- $: << File.dirname(__FILE__) + "/../lib"
6
+ $: << __dir__ + "/../lib"
7
7
 
8
8
  require "lvm"
9
9
 
10
- LVM::LVM.new({ :command => "/usr/bin/sudo /sbin/lvm" }) do |lvm|
10
+ LVM::LVM.new({ command: "/usr/bin/sudo /sbin/lvm" }) do |lvm|
11
11
  puts "lvm version: #{lvm.version}\n"
12
12
 
13
13
  puts "\nlogical view"
data/lib/lvm/external.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "rubygems"
1
+ require "rubygems" unless defined?(Gem)
2
2
  require "open4"
3
3
 
4
4
  module LVM
@@ -9,7 +9,7 @@ module LVM
9
9
  output = []
10
10
  error = nil
11
11
  stat = Open4.popen4(cmd) do |pid, stdin, stdout, stderr|
12
- while line = stdout.gets
12
+ while (line = stdout.gets)
13
13
  output << line
14
14
  end
15
15
  error = stderr.read.strip
@@ -25,9 +25,9 @@ module LVM
25
25
  end
26
26
 
27
27
  if block_given?
28
- return output.each { |l| yield l }
28
+ output.each { |l| yield l }
29
29
  else
30
- return output.join
30
+ output.join
31
31
  end
32
32
  end
33
33
  module_function :cmd
@@ -1,4 +1,4 @@
1
- require "ostruct"
1
+ require "ostruct" unless defined?(OpenStruct)
2
2
 
3
3
  module LVM
4
4
  class LogicalVolume < OpenStruct
@@ -1,4 +1,4 @@
1
- require "ostruct"
1
+ require "ostruct" unless defined?(OpenStruct)
2
2
 
3
3
  module LVM
4
4
  class LogicalVolumeSegment < OpenStruct; end
@@ -1,6 +1,6 @@
1
- require "lvm/volumes"
2
- require "lvm/wrapper/lvs"
3
- require "lvm/wrapper/lvsseg"
1
+ require_relative "volumes"
2
+ require_relative "wrapper/lvs"
3
+ require_relative "wrapper/lvsseg"
4
4
 
5
5
  module LVM
6
6
  class LogicalVolumes
@@ -28,7 +28,7 @@ module LVM
28
28
  end
29
29
 
30
30
  def list
31
- self.each {}
31
+ each {}
32
32
  end
33
33
  end
34
34
  end
@@ -1,4 +1,4 @@
1
- require "ostruct"
1
+ require "ostruct" unless defined?(OpenStruct)
2
2
 
3
3
  module LVM
4
4
  class PhysicalVolume < OpenStruct; end
@@ -1,4 +1,4 @@
1
- require "ostruct"
1
+ require "ostruct" unless defined?(OpenStruct)
2
2
 
3
3
  module LVM
4
4
  class PhysicalVolumeSegment < OpenStruct; end
@@ -1,6 +1,6 @@
1
- require "lvm/volumes"
2
- require "lvm/wrapper/pvs"
3
- require "lvm/wrapper/pvsseg"
1
+ require_relative "volumes"
2
+ require_relative "wrapper/pvs"
3
+ require_relative "wrapper/pvsseg"
4
4
 
5
5
  module LVM
6
6
  class PhysicalVolumes
@@ -28,7 +28,7 @@ module LVM
28
28
  end
29
29
 
30
30
  def list
31
- self.each {}
31
+ each {}
32
32
  end
33
33
  end
34
34
  end
data/lib/lvm/userland.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "ostruct"
1
+ require "ostruct" unless defined?(OpenStruct)
2
2
 
3
3
  module LVM
4
4
  class UserLand < OpenStruct; end
data/lib/lvm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LVM
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.2".freeze
3
3
  end
@@ -1,4 +1,4 @@
1
- require "ostruct"
1
+ require "ostruct" unless defined?(OpenStruct)
2
2
 
3
3
  module LVM
4
4
  class VolumeGroup < OpenStruct; end
@@ -1,7 +1,7 @@
1
- require "lvm/volumes"
2
- require "lvm/logical_volumes"
3
- require "lvm/physical_volumes"
4
- require "lvm/wrapper/vgs"
1
+ require_relative "volumes"
2
+ require_relative "logical_volumes"
3
+ require_relative "physical_volumes"
4
+ require_relative "wrapper/vgs"
5
5
 
6
6
  module LVM
7
7
  class VolumeGroups
@@ -33,7 +33,7 @@ module LVM
33
33
  end
34
34
 
35
35
  def list
36
- self.each {}
36
+ each {}
37
37
  end
38
38
  end
39
39
  end
data/lib/lvm/volumes.rb CHANGED
@@ -2,13 +2,13 @@ module LVM
2
2
  module Volumes
3
3
  def [](name)
4
4
  each { |o| return o if o.name == name }
5
- return nil
5
+ nil
6
6
  end
7
7
 
8
8
  def to_s
9
9
  x = []
10
10
  each { |o| x << o.name }
11
- return x.join(" ")
11
+ x.join(" ")
12
12
  end
13
13
  end
14
14
  end
@@ -2,9 +2,9 @@ module LVM
2
2
  module Wrapper
3
3
  module Reporting
4
4
  module Constants
5
- SEPERATOR = "^"
6
- BASE_ARGUMENTS = "--verbose --separator=#{SEPERATOR} --noheadings --nosuffix --units=b --unbuffered --options %s"
7
- EMPTY = "-"
5
+ SEPERATOR = "^".freeze
6
+ BASE_ARGUMENTS = "--verbose --separator=#{SEPERATOR} --noheadings --nosuffix --units=b --unbuffered --options %s".freeze
7
+ EMPTY = "-".freeze
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
- require "lvm/wrapper"
2
- require "lvm/logical_volume"
1
+ require_relative "../wrapper"
2
+ require_relative "../logical_volume"
3
3
 
4
4
  module LVM
5
5
  module Wrapper
@@ -11,11 +11,11 @@ module LVM
11
11
 
12
12
  def initialize(options)
13
13
  @attributes = Attributes.load(options[:version], ATTRIBUTES_FILE)
14
- @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND)}"
14
+ @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND, options[:additional_arguments])}"
15
15
  end
16
16
 
17
- BASE_COMMAND = "lvs #{Reporting::BASE_ARGUMENTS}"
18
- ATTRIBUTES_FILE = "lvs.yaml"
17
+ BASE_COMMAND = "lvs #{Reporting::BASE_ARGUMENTS}".freeze
18
+ ATTRIBUTES_FILE = "lvs.yaml".freeze
19
19
 
20
20
  # lv_attr attribute handling constants
21
21
  # roughly by order referenced in lib/report/report.c:292 (_lvstatus_disp)
@@ -34,13 +34,13 @@ module LVM
34
34
  "S" => :invalid_snapshot,
35
35
  # custom, empty is a standard volume
36
36
  "-" => :normal,
37
- }
37
+ }.freeze
38
38
  PERMISSIONS = {
39
39
  "w" => :writeable,
40
40
  "r" => :readonly,
41
41
  # custom, from reading source
42
42
  "-" => :locked_by_pvmove,
43
- }
43
+ }.freeze
44
44
  ALLOCATION_POLICY = {
45
45
  "c" => :contiguous,
46
46
  "l" => :cling,
@@ -52,11 +52,11 @@ module LVM
52
52
  "N" => :normal_locked,
53
53
  "A" => :anywhere_locked,
54
54
  "I" => :inherited_locked,
55
- }
55
+ }.freeze
56
56
  FIXED_MINOR = {
57
57
  # code says its a boolean
58
58
  "m" => true,
59
- }
59
+ }.freeze
60
60
  STATE = {
61
61
  "s" => :suspended,
62
62
  "a" => :active,
@@ -64,25 +64,25 @@ module LVM
64
64
  "d" => :inactive_without_table,
65
65
  "S" => :suspended_snapshot,
66
66
  "I" => :invalid_snapshot,
67
- }
67
+ }.freeze
68
68
  DEVICE_OPEN = {
69
69
  # code says its a boolean
70
70
  "o" => true,
71
- }
71
+ }.freeze
72
72
 
73
73
  def list
74
74
  output = External.cmd(@command)
75
75
  data = parse(output)
76
76
  if block_given?
77
- return data.each { |obj| yield obj }
77
+ data.each { |obj| yield obj }
78
78
  else
79
- return data
79
+ data
80
80
  end
81
81
  end
82
82
 
83
83
  private
84
84
 
85
- def parse_lv_attr(lv_attr) #:nodoc:
85
+ def parse_lv_attr(lv_attr) # :nodoc:
86
86
  translated = {}
87
87
  # translate them into nice symbols and a couple booleans
88
88
  translated[:volume_type] = VOLUME_TYPE[lv_attr[0].chr]
@@ -92,11 +92,11 @@ module LVM
92
92
  translated[:state] = STATE[lv_attr[4].chr]
93
93
  translated[:device_open] = DEVICE_OPEN[lv_attr[5].chr] ? true : false
94
94
 
95
- return translated
95
+ translated
96
96
  end
97
97
 
98
- # Parses the output of self.command
99
- def parse(output) #:nodoc:
98
+ # Parses the output of self.command
99
+ def parse(output) # :nodoc:
100
100
  volumes = []
101
101
 
102
102
  output.split("\n").each do |line|
@@ -119,7 +119,7 @@ module LVM
119
119
  end
120
120
  end
121
121
 
122
- return volumes
122
+ volumes
123
123
  end # parse
124
124
  end # class LVS
125
125
  end # module Wrapper
@@ -1,5 +1,5 @@
1
- require "lvm/wrapper"
2
- require "lvm/logical_volume_segment"
1
+ require_relative "../wrapper"
2
+ require_relative "../logical_volume_segment"
3
3
 
4
4
  module LVM
5
5
  module Wrapper
@@ -12,25 +12,25 @@ module LVM
12
12
 
13
13
  def initialize(options)
14
14
  @attributes = Attributes.load(options[:version], ATTRIBUTES_FILE)
15
- @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND)}"
15
+ @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND, options[:additional_arguments])}"
16
16
  end
17
17
 
18
- BASE_COMMAND = "lvs #{Reporting::BASE_ARGUMENTS}"
19
- ATTRIBUTES_FILE = "lvsseg.yaml"
18
+ BASE_COMMAND = "lvs #{Reporting::BASE_ARGUMENTS}".freeze
19
+ ATTRIBUTES_FILE = "lvsseg.yaml".freeze
20
20
 
21
21
  def list
22
22
  output = External.cmd(@command)
23
23
  data = parse(output)
24
24
  if block_given?
25
- return data.each { |obj| yield obj }
25
+ data.each { |obj| yield obj }
26
26
  else
27
- return data
27
+ data
28
28
  end
29
29
  end
30
30
 
31
31
  private
32
32
 
33
- # Parses the output of self.command
33
+ # Parses the output of self.command
34
34
  def parse(output)
35
35
  volumes = []
36
36
 
@@ -49,7 +49,7 @@ module LVM
49
49
  end
50
50
  end
51
51
 
52
- return volumes
52
+ volumes
53
53
  end # parse
54
54
  end # class LVSSEG
55
55
  end # module Wrapper
@@ -1,5 +1,5 @@
1
- require "lvm/wrapper"
2
- require "lvm/physical_volume"
1
+ require_relative "../wrapper"
2
+ require_relative "../physical_volume"
3
3
 
4
4
  module LVM
5
5
  module Wrapper
@@ -11,11 +11,11 @@ module LVM
11
11
 
12
12
  def initialize(options)
13
13
  @attributes = Attributes.load(options[:version], ATTRIBUTES_FILE)
14
- @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND)}"
14
+ @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND, options[:additional_arguments])}"
15
15
  end
16
16
 
17
- BASE_COMMAND = "pvs #{Reporting::BASE_ARGUMENTS}"
18
- ATTRIBUTES_FILE = "pvs.yaml"
17
+ BASE_COMMAND = "pvs #{Reporting::BASE_ARGUMENTS}".freeze
18
+ ATTRIBUTES_FILE = "pvs.yaml".freeze
19
19
 
20
20
  # pv_attr attribute handling constants
21
21
  # roughly by order referenced in lib/report/report.c:360 (_pvstatus_disp)
@@ -23,34 +23,34 @@ module LVM
23
23
  ALLOCATABLE = {
24
24
  # code says its a boolean
25
25
  "a" => true,
26
- }
26
+ }.freeze
27
27
  EXPORTED = {
28
28
  # code says its a boolean
29
29
  "x" => true,
30
- }
30
+ }.freeze
31
31
 
32
32
  def list
33
33
  output = External.cmd(@command)
34
34
  data = parse(output)
35
35
  if block_given?
36
- return data.each { |obj| yield obj }
36
+ data.each { |obj| yield obj }
37
37
  else
38
- return data
38
+ data
39
39
  end
40
40
  end
41
41
 
42
42
  private
43
43
 
44
- def parse_pv_attr(pv_attr) #:nodoc:
44
+ def parse_pv_attr(pv_attr) # :nodoc:
45
45
  translated = {}
46
- # translate them into nice symbols and a couple booleans
46
+ # translate them into nice symbols and a couple booleans
47
47
  translated[:allocatable] = ALLOCATABLE[pv_attr[0].chr] ? true : false
48
48
  translated[:exported] = EXPORTED[pv_attr[1].chr] ? true : false
49
49
 
50
- return translated
50
+ translated
51
51
  end
52
52
 
53
- # Parses the output of self.command
53
+ # Parses the output of self.command
54
54
  def parse(output)
55
55
  volumes = []
56
56
 
@@ -74,7 +74,7 @@ module LVM
74
74
  end
75
75
  end
76
76
 
77
- return volumes
77
+ volumes
78
78
  end # parse
79
79
  end # class PVS
80
80
  end # module Wrapper
@@ -1,5 +1,5 @@
1
- require "lvm/wrapper"
2
- require "lvm/physical_volume_segment"
1
+ require_relative "../wrapper"
2
+ require_relative "../physical_volume_segment"
3
3
 
4
4
  module LVM
5
5
  module Wrapper
@@ -12,25 +12,25 @@ module LVM
12
12
 
13
13
  def initialize(options)
14
14
  @attributes = Attributes.load(options[:version], ATTRIBUTES_FILE)
15
- @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND)}"
15
+ @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND, options[:additional_arguments])}"
16
16
  end
17
17
 
18
- BASE_COMMAND = "pvs #{Reporting::BASE_ARGUMENTS}"
19
- ATTRIBUTES_FILE = "pvsseg.yaml"
18
+ BASE_COMMAND = "pvs #{Reporting::BASE_ARGUMENTS}".freeze
19
+ ATTRIBUTES_FILE = "pvsseg.yaml".freeze
20
20
 
21
21
  def list
22
22
  output = External.cmd(@command)
23
23
  data = parse(output)
24
24
  if block_given?
25
- return data.each { |obj| yield obj }
25
+ data.each { |obj| yield obj }
26
26
  else
27
- return data
27
+ data
28
28
  end
29
29
  end
30
30
 
31
31
  private
32
32
 
33
- # Parses the output of self.command
33
+ # Parses the output of self.command
34
34
  def parse(output)
35
35
  volumes = []
36
36
 
@@ -49,7 +49,7 @@ module LVM
49
49
  end
50
50
  end
51
51
 
52
- return volumes
52
+ volumes
53
53
  end # parse
54
54
  end # class PVSSEG
55
55
  end # module Wrapper
@@ -1,5 +1,5 @@
1
- require "lvm/wrapper"
2
- require "lvm/volume_group"
1
+ require_relative "../wrapper"
2
+ require_relative "../volume_group"
3
3
 
4
4
  module LVM
5
5
  module Wrapper
@@ -11,11 +11,11 @@ module LVM
11
11
 
12
12
  def initialize(options)
13
13
  @attributes = Attributes.load(options[:version], ATTRIBUTES_FILE)
14
- @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND)}"
14
+ @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND, options[:additional_arguments])}"
15
15
  end
16
16
 
17
- BASE_COMMAND = "vgs #{Reporting::BASE_ARGUMENTS}"
18
- ATTRIBUTES_FILE = "vgs.yaml"
17
+ BASE_COMMAND = "vgs #{Reporting::BASE_ARGUMENTS}".freeze
18
+ ATTRIBUTES_FILE = "vgs.yaml".freeze
19
19
 
20
20
  # vg_attr attribute handling constants
21
21
  # roughly by order referenced in lib/report/report.c:360 (_vgstatus_disp)
@@ -23,19 +23,19 @@ module LVM
23
23
  PERMISSIONS = {
24
24
  "w" => :writeable,
25
25
  "r" => :readonly,
26
- }
26
+ }.freeze
27
27
  RESIZEABLE = {
28
28
  # code says its a boolean
29
29
  "z" => true,
30
- }
30
+ }.freeze
31
31
  EXPORTED = {
32
32
  # code says its a boolean
33
33
  "x" => true,
34
- }
34
+ }.freeze
35
35
  PARTIAL = {
36
36
  # code says its a boolean
37
37
  "p" => true,
38
- }
38
+ }.freeze
39
39
  ALLOCATION_POLICY = {
40
40
  "c" => :contiguous,
41
41
  "l" => :cling,
@@ -47,25 +47,25 @@ module LVM
47
47
  "N" => :normal_locked,
48
48
  "A" => :anywhere_locked,
49
49
  "I" => :inherited_locked,
50
- }
50
+ }.freeze
51
51
  CLUSTERED = {
52
52
  # code says its a boolean
53
53
  "c" => true,
54
- }
54
+ }.freeze
55
55
 
56
56
  def list
57
57
  output = External.cmd(@command)
58
58
  data = parse(output)
59
59
  if block_given?
60
- return data.each { |obj| yield obj }
60
+ data.each { |obj| yield obj }
61
61
  else
62
- return data
62
+ data
63
63
  end
64
64
  end
65
65
 
66
66
  private
67
67
 
68
- def parse_vg_attr(vg_attr) #:nodoc:
68
+ def parse_vg_attr(vg_attr) # :nodoc:
69
69
  translated = {}
70
70
  # translate them into nice symbols and a couple booleans
71
71
  translated[:permissions] = PERMISSIONS[vg_attr[0].chr]
@@ -75,11 +75,11 @@ module LVM
75
75
  translated[:allocation_policy] = ALLOCATION_POLICY[vg_attr[4].chr]
76
76
  translated[:clustered] = CLUSTERED[vg_attr[5].chr] ? true : false
77
77
 
78
- return translated
78
+ translated
79
79
  end
80
80
 
81
- # Parses the output of self.command
82
- def parse(output) #:nodoc:
81
+ # Parses the output of self.command
82
+ def parse(output) # :nodoc:
83
83
  volumes = []
84
84
 
85
85
  output.split("\n").each do |line|
@@ -102,7 +102,7 @@ module LVM
102
102
  end
103
103
  end
104
104
 
105
- return volumes
105
+ volumes
106
106
  end # parse
107
107
  end # class VGS
108
108
  end # module Wrapper
data/lib/lvm/wrapper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "lvm/attributes"
2
- require "lvm/external"
3
- require "lvm/wrapper/constants"
2
+ require_relative "external"
3
+ require_relative "wrapper/constants"
4
4
 
5
5
  module LVM
6
6
  module Wrapper
@@ -9,7 +9,7 @@ module LVM
9
9
 
10
10
  # Breakdown return values into attribute => value hash suitable for
11
11
  # OpenStruct
12
- def process_line(expected_attributes, line) #:nodoc:
12
+ def process_line(expected_attributes, line) # :nodoc:
13
13
  line.strip!
14
14
  values = line.split(SEPERATOR)
15
15
  # nil is easier
@@ -26,6 +26,7 @@ module LVM
26
26
  # use hints for type conversion
27
27
  case attribute[:type_hint]
28
28
  when "String"
29
+ value = value.to_s
29
30
  when "Integer"
30
31
  value = value.to_i
31
32
  when "Float"
@@ -34,17 +35,20 @@ module LVM
34
35
  attributes[name] = value
35
36
  end
36
37
 
37
- return attributes
38
+ attributes
38
39
  end
39
40
  module_function :process_line
40
41
 
41
- def build_command(expected_attributes, base)
42
+ def build_command(expected_attributes, base, additional_arguments = [])
42
43
  opts = []
43
44
  expected_attributes.each do |a|
44
45
  opts << a[:column]
45
46
  end
46
47
 
47
- return base % opts.join(",")
48
+ additional_arguments = [] if additional_arguments.nil?
49
+ additional_arguments = [additional_arguments] if additional_arguments.is_a?(String)
50
+
51
+ base % opts.join(",") + "#{additional_arguments.empty? ? "" : " "}#{additional_arguments.join(" ")}"
48
52
  end
49
53
  module_function :build_command
50
54
  end # module Reporting
data/lib/lvm.rb CHANGED
@@ -1,9 +1,9 @@
1
- require "lvm/external"
2
- require "lvm/userland"
3
- require "lvm/logical_volumes"
4
- require "lvm/volume_groups"
5
- require "lvm/physical_volumes"
6
- require "lvm/version"
1
+ require_relative "lvm/external"
2
+ require_relative "lvm/userland"
3
+ require_relative "lvm/logical_volumes"
4
+ require_relative "lvm/volume_groups"
5
+ require_relative "lvm/physical_volumes"
6
+ require_relative "lvm/version"
7
7
 
8
8
  module LVM
9
9
  class LVM
@@ -11,20 +11,22 @@ module LVM
11
11
  attr_reader :logical_volumes
12
12
  attr_reader :volume_groups
13
13
  attr_reader :physical_volumes
14
+ attr_reader :additional_arguments
14
15
 
15
- VALID_OPTIONS = [
16
- :command,
17
- :version,
18
- :debug,
19
- ]
16
+ VALID_OPTIONS = %i{
17
+ command
18
+ version
19
+ debug
20
+ additional_arguments
21
+ }.freeze
20
22
 
21
- DEFAULT_COMMAND = "/sbin/lvm"
23
+ DEFAULT_COMMAND = "/sbin/lvm".freeze
22
24
 
23
25
  def initialize(options = {})
24
26
  # handy, thanks net-ssh!
25
27
  invalid_options = options.keys - VALID_OPTIONS
26
28
  if invalid_options.any?
27
- raise ArgumentError, "invalid option(s): #{invalid_options.join(', ')}"
29
+ raise ArgumentError, "invalid option(s): #{invalid_options.join(", ")}"
28
30
  end
29
31
 
30
32
  @command = options[:command] || DEFAULT_COMMAND
@@ -40,7 +42,7 @@ module LVM
40
42
  if block_given?
41
43
  yield self
42
44
  else
43
- return self
45
+ self
44
46
  end
45
47
  end
46
48
 
@@ -50,14 +52,14 @@ module LVM
50
52
  output << line
51
53
  end
52
54
  if block_given?
53
- return output.each { |l| yield l }
55
+ output.each { |l| yield l }
54
56
  else
55
- return output.join
57
+ output.join
56
58
  end
57
59
  end
58
60
 
59
61
  def version
60
- %r{^(.*?)(-| )}.match(userland.lvm_version)[1]
62
+ /^(.*?)(-| )/.match(userland.lvm_version)[1]
61
63
  end
62
64
 
63
65
  # helper methods
@@ -65,16 +67,16 @@ module LVM
65
67
  userland = UserLand.new
66
68
  raw("version") do |line|
67
69
  case line
68
- when %r{^\s+LVM version:\s+([0-9].*)$}
70
+ when /^\s+LVM version:\s+([0-9].*)$/
69
71
  userland.lvm_version = $1
70
- when %r{^\s+Library version:\s+([0-9].*)$}
72
+ when /^\s+Library version:\s+([0-9].*)$/
71
73
  userland.library_version = $1
72
- when %r{^\s+Driver version:\s+([0-9].*)$}
74
+ when /^\s+Driver version:\s+([0-9].*)$/
73
75
  userland.driver_version = $1
74
76
  end
75
77
  end
76
78
 
77
- return userland
79
+ userland
78
80
  end
79
81
  end
80
82
  end
metadata CHANGED
@@ -1,51 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-ruby-lvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Smith
8
8
  - Greg Symons
9
9
  - Matthew Kent
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-06-21 00:00:00.000000000 Z
13
+ date: 2022-05-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: open4
16
+ name: chef-ruby-lvm-attrib
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '0.9'
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: 0.9.6
21
+ version: '0.3'
25
22
  type: :runtime
26
23
  prerelease: false
27
24
  version_requirements: !ruby/object:Gem::Requirement
28
25
  requirements:
29
26
  - - "~>"
30
27
  - !ruby/object:Gem::Version
31
- version: '0.9'
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 0.9.6
28
+ version: '0.3'
35
29
  - !ruby/object:Gem::Dependency
36
- name: chef-ruby-lvm-attrib
30
+ name: open4
37
31
  requirement: !ruby/object:Gem::Requirement
38
32
  requirements:
39
33
  - - "~>"
40
34
  - !ruby/object:Gem::Version
41
- version: '0.2'
35
+ version: '0.9'
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 0.9.6
42
39
  type: :runtime
43
40
  prerelease: false
44
41
  version_requirements: !ruby/object:Gem::Requirement
45
42
  requirements:
46
43
  - - "~>"
47
44
  - !ruby/object:Gem::Version
48
- version: '0.2'
45
+ version: '0.9'
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 0.9.6
49
49
  description: A wrapper for the LVM2 administration utility, lvm.
50
50
  email:
51
51
  - tsmith@chef.io
@@ -55,12 +55,22 @@ executables: []
55
55
  extensions: []
56
56
  extra_rdoc_files: []
57
57
  files:
58
+ - ".github/CODEOWNERS"
59
+ - ".github/ISSUE_TEMPLATE/BUG_TEMPLATE.md"
60
+ - ".github/ISSUE_TEMPLATE/DESIGN_PROPOSAL.md"
61
+ - ".github/ISSUE_TEMPLATE/ENHANCEMENT_REQUEST_TEMPLATE.md"
62
+ - ".github/ISSUE_TEMPLATE/SUPPORT_QUESTION.md"
63
+ - ".github/PULL_REQUEST_TEMPLATE.md"
64
+ - ".github/dependabot.yml"
58
65
  - ".gitignore"
59
66
  - CHANGELOG.md
67
+ - CODE_OF_CONDUCT.md
68
+ - CONTRIBUTING.md
60
69
  - Gemfile
61
70
  - README.md
62
71
  - Rakefile
63
72
  - chef-ruby-lvm.gemspec
73
+ - examples/additional_arguments.rb
64
74
  - examples/create_snapshot.rb
65
75
  - examples/error_handling.rb
66
76
  - examples/show_lvm_config.rb
@@ -89,7 +99,7 @@ homepage: https://github.com/chef/chef-ruby-lvm
89
99
  licenses:
90
100
  - MIT
91
101
  metadata: {}
92
- post_install_message:
102
+ post_install_message:
93
103
  rdoc_options: []
94
104
  require_paths:
95
105
  - lib
@@ -104,9 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
114
  - !ruby/object:Gem::Version
105
115
  version: '0'
106
116
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.6.12
109
- signing_key:
117
+ rubygems_version: 3.3.7
118
+ signing_key:
110
119
  specification_version: 4
111
120
  summary: A wrapper for the LVM2 administration utility, lvm.
112
121
  test_files: