chef-ruby-lvm 0.4.0 → 0.4.3

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
2
  SHA256:
3
- metadata.gz: 1c6e301ce4adb07645a893d2252dbf09afa4a48e0c499009fd05f6b2986af4a6
4
- data.tar.gz: d583993d1b468e641e309cdb3588df42aa2180b7201d1d92f9f061baa28e9169
3
+ metadata.gz: ad3c076640b333f12d077631f973569347733b5260cbe1a48abb31a9b6985b9e
4
+ data.tar.gz: 0e7d3eff156cdf9586a0cd2142f995e07086484dea4b809c6d2f154c0967ad7b
5
5
  SHA512:
6
- metadata.gz: 5143a086558cbc283dbb1a191bfd06550c9b4993e2430918537d6b4651101563526f9d0bbb89949a19f547df49d229e77aca8c47540b5fe764404dce247c5252
7
- data.tar.gz: bc4dcb8a345d1de6dd4b86eac506118d418663ba75ebb1769199130e70fce32f821248b3d211ceeffbddabc78f51982fabff6d8e3e2e50a75ff6fc51cdd17bee
6
+ metadata.gz: 5c71a54a7f072489dc7d9618483dc819ebb04b058ac7697380b10270f6e0bcac7fc6a6382bf7a00dc5532122356ad977bcf99cca71adf96098676c78a426648a
7
+ data.tar.gz: d909f5d2d9c07d307c0c6fca2c07497145a27fc0ebd412b2489f82b0f4e1d95f421753e03af41cc20cd40219cc379c47bdbc96d16879ce69c983090d5a34a297
@@ -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,38 +1,50 @@
1
- # 0.4.0 (2018-07-23)
1
+ # Change log
2
+
3
+ ## 0.4.3
4
+
5
+ - Update open4 requirement
6
+
7
+ ## 0.4.2
8
+
9
+ - Fix undefined variable error in `LVM::External::Module`
10
+
11
+ ## 0.4.1 (2022-04-25)
12
+
13
+ - Use new minor version of chef-ruby-lvm-attrib
14
+ - Chefstyle fixes
15
+ - Optimize requires with require_relative & use __dir__ not __FILE__
16
+
17
+ ## 0.4.0 (2018-07-23)
2
18
 
3
19
  - Added additional_arguments option that allows passing options to commands
4
20
 
5
- # 0.3.0 (2016-06-21)
21
+ ## 0.3.0 (2017-06-21)
6
22
 
7
23
  - Depend on di-ruby-lvm-attrib ~0.2 to bring in the last few years of releases
8
24
 
9
- # 0.2.2 (2016-12-12)
25
+ ## 0.2.2 (2016-12-13)
10
26
 
11
27
  - Fork di-ruby-lvm as chef-ruby-lvm in order to unblock the Chef lvm cookbook support for the latest Linux distros
12
28
  - Convert the readme to markdown and reword portions
13
29
  - Resolve all chefstyle warnings
14
30
  - Added a Gemfile/Rakefile for chefstyle linting
15
31
 
16
- # 0.2.1 (2015-12-04)
32
+ ## 0.2.1 (2015-12-04)
17
33
 
18
34
  - Fix failures calling the calling physical_volumes list method
19
35
 
20
- # 0.2.0 (2015-12-01)
36
+ ## 0.2.0 (2015-12-01)
21
37
 
22
38
  - Minor code refactoring
23
39
  - Improve runtime with multiple VGs
24
40
  - Use just a gemspec instead of hoe
25
41
  - Require a newer di-ruby-lvm-attrib gem
26
42
 
27
- ....
28
-
29
- # 0.1.1 (2008-07-21)
30
-
31
- - 1 major enhancement
43
+ ## 0.1.1 (2008-07-21)
32
44
 
33
- - 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.
45
+ - 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.
34
46
 
35
- # 0.0.1 (2008-05-28)
47
+ ## 0.0.1 (2008-05-28)
36
48
 
37
49
  - 1 major enhancement
38
50
 
@@ -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.6", "< 2.0"
25
19
  end
@@ -2,12 +2,12 @@
2
2
 
3
3
  # Demonstration of passing additional arguments to the LVM object
4
4
 
5
- $: << File.dirname(__FILE__) + "/../lib"
5
+ $: << __dir__ + "/../lib"
6
6
 
7
7
  require "lvm"
8
8
 
9
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")
10
+ lvm = LVM::LVM.new(command: "/usr/bin/sudo /sbin/lvm", additional_arguments: "--ignoreskippedcluster")
11
11
 
12
12
  volume_groups = lvm.volume_groups
13
- puts volume_groups.map { |vg| vg.name }
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.4.0"
2
+ VERSION = "0.4.3".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
@@ -14,8 +14,8 @@ module LVM
14
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
@@ -15,22 +15,22 @@ module LVM
15
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
@@ -14,8 +14,8 @@ module LVM
14
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
@@ -15,22 +15,22 @@ module LVM
15
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
@@ -14,8 +14,8 @@ module LVM
14
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,7 +35,7 @@ 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
 
@@ -47,7 +48,7 @@ module LVM
47
48
  additional_arguments = [] if additional_arguments.nil?
48
49
  additional_arguments = [additional_arguments] if additional_arguments.is_a?(String)
49
50
 
50
- return base % opts.join(",") + "#{additional_arguments.empty? ? '' : ' '}#{additional_arguments.join(' ')}"
51
+ base % opts.join(",") + "#{additional_arguments.empty? ? "" : " "}#{additional_arguments.join(" ")}"
51
52
  end
52
53
  module_function :build_command
53
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
@@ -13,20 +13,20 @@ module LVM
13
13
  attr_reader :physical_volumes
14
14
  attr_reader :additional_arguments
15
15
 
16
- VALID_OPTIONS = [
17
- :command,
18
- :version,
19
- :debug,
20
- :additional_arguments,
21
- ]
16
+ VALID_OPTIONS = %i{
17
+ command
18
+ version
19
+ debug
20
+ additional_arguments
21
+ }.freeze
22
22
 
23
- DEFAULT_COMMAND = "/sbin/lvm"
23
+ DEFAULT_COMMAND = "/sbin/lvm".freeze
24
24
 
25
25
  def initialize(options = {})
26
26
  # handy, thanks net-ssh!
27
27
  invalid_options = options.keys - VALID_OPTIONS
28
28
  if invalid_options.any?
29
- raise ArgumentError, "invalid option(s): #{invalid_options.join(', ')}"
29
+ raise ArgumentError, "invalid option(s): #{invalid_options.join(", ")}"
30
30
  end
31
31
 
32
32
  @command = options[:command] || DEFAULT_COMMAND
@@ -42,7 +42,7 @@ module LVM
42
42
  if block_given?
43
43
  yield self
44
44
  else
45
- return self
45
+ self
46
46
  end
47
47
  end
48
48
 
@@ -52,14 +52,14 @@ module LVM
52
52
  output << line
53
53
  end
54
54
  if block_given?
55
- return output.each { |l| yield l }
55
+ output.each { |l| yield l }
56
56
  else
57
- return output.join
57
+ output.join
58
58
  end
59
59
  end
60
60
 
61
61
  def version
62
- %r{^(.*?)(-| )}.match(userland.lvm_version)[1]
62
+ /^(.*?)(-| )/.match(userland.lvm_version)[1]
63
63
  end
64
64
 
65
65
  # helper methods
@@ -67,16 +67,16 @@ module LVM
67
67
  userland = UserLand.new
68
68
  raw("version") do |line|
69
69
  case line
70
- when %r{^\s+LVM version:\s+([0-9].*)$}
70
+ when /^\s+LVM version:\s+([0-9].*)$/
71
71
  userland.lvm_version = $1
72
- when %r{^\s+Library version:\s+([0-9].*)$}
72
+ when /^\s+Library version:\s+([0-9].*)$/
73
73
  userland.library_version = $1
74
- when %r{^\s+Driver version:\s+([0-9].*)$}
74
+ when /^\s+Driver version:\s+([0-9].*)$/
75
75
  userland.driver_version = $1
76
76
  end
77
77
  end
78
78
 
79
- return userland
79
+ userland
80
80
  end
81
81
  end
82
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.4.0
4
+ version: 0.4.3
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: 2018-07-24 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
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 0.9.6
36
+ - - "<"
40
37
  - !ruby/object:Gem::Version
41
- version: '0.2'
38
+ version: '2.0'
42
39
  type: :runtime
43
40
  prerelease: false
44
41
  version_requirements: !ruby/object:Gem::Requirement
45
42
  requirements:
46
- - - "~>"
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.6
46
+ - - "<"
47
47
  - !ruby/object:Gem::Version
48
- version: '0.2'
48
+ version: '2.0'
49
49
  description: A wrapper for the LVM2 administration utility, lvm.
50
50
  email:
51
51
  - tsmith@chef.io
@@ -55,8 +55,17 @@ 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
@@ -90,7 +99,7 @@ homepage: https://github.com/chef/chef-ruby-lvm
90
99
  licenses:
91
100
  - MIT
92
101
  metadata: {}
93
- post_install_message:
102
+ post_install_message:
94
103
  rdoc_options: []
95
104
  require_paths:
96
105
  - lib
@@ -105,9 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
114
  - !ruby/object:Gem::Version
106
115
  version: '0'
107
116
  requirements: []
108
- rubyforge_project:
109
- rubygems_version: 2.7.5
110
- signing_key:
117
+ rubygems_version: 3.3.7
118
+ signing_key:
111
119
  specification_version: 4
112
120
  summary: A wrapper for the LVM2 administration utility, lvm.
113
121
  test_files: