knife-hardware 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in knife-hardware.gemspec
4
+ gemspec
@@ -0,0 +1,17 @@
1
+ #
2
+ # Author:: Paul Thomas (<paul@paulthomas.eu>)
3
+ # Copyright:: Copyright (c) 2012 Paul Thomas
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
@@ -0,0 +1,30 @@
1
+ # Knife::Hardware
2
+
3
+ This gem is only really useful if you happen to track persistent hardware information in a data bag called hardware and link it to nodes by UUID. IF you don't do this then this plugin is useless to you.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'knife-hardware'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install knife-hardware
18
+
19
+ ## Usage
20
+
21
+ knife hardware show NODE
22
+ knife hardware edit NODE
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'knife-hardware/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "knife-hardware"
8
+ gem.version = Knife::Hardware::VERSION
9
+ gem.authors = ["Paul Thomas"]
10
+ gem.email = ["paul@paulthomas.eu"]
11
+ gem.description = %q{Automatically link the hardware data bag items to their node}
12
+ gem.summary = %q{Links items in the hardware data bag to a node using the UUID as a key}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency "chef"
21
+ end
@@ -0,0 +1,47 @@
1
+ #
2
+ # Author:: Paul Thomas (<paul@paulthomas.eu>)
3
+ # Copyright:: Copyright (c) 2012 Paul Thomas
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife'
20
+
21
+ class Chef
22
+ class Knife
23
+ module HardwareBase
24
+ def getUuid
25
+ unless name_args.size == 1
26
+ puts "You need to specify a node"
27
+ show_usage
28
+ exit 1
29
+ end
30
+
31
+ node = Chef::Node.load(name_args[0])
32
+ unless node.has_key? 'uuid'
33
+ puts "Node has no UUID, cannot link to a hardware data bag item"
34
+ show_usage
35
+ exit 1
36
+ end
37
+ if node.uuid.nil?
38
+ puts "UUID was nil so I can't lookup the data bag"
39
+ show_usage
40
+ exit 1
41
+ end
42
+ puts "Working on #{node.uuid}"
43
+ return node.uuid
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,38 @@
1
+ #
2
+ # Author:: Paul Thomas (<paul@paulthomas.eu>)
3
+ # Copyright:: Copyright (c) 2012 Paul Thomas
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife/hardware_base'
20
+ require 'chef/knife/data_bag_edit'
21
+
22
+ class Chef
23
+ class Knife
24
+ class HardwareEdit < Knife
25
+ include Knife::HardwareBase
26
+ banner "knife hardware edit NODE"
27
+
28
+ def run
29
+ uuid = getUuid()
30
+ dbedit = Chef::Knife::DataBagEdit.new
31
+ puts "Showing data bag item hardware #{uuid}"
32
+ dbedit.config[:editor] = ENV['EDITOR']
33
+ dbedit.name_args = ['hardware', uuid]
34
+ dbedit.run
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,37 @@
1
+ #
2
+ # Author:: Paul Thomas (<paul@paulthomas.eu>)
3
+ # Copyright:: Copyright (c) 2012 Paul Thomas
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife/hardware_base'
20
+ require 'chef/knife/data_bag_show'
21
+
22
+ class Chef
23
+ class Knife
24
+ class HardwareShow < Knife
25
+ include Knife::HardwareBase
26
+ banner "knife hardware show NODE"
27
+
28
+ def run
29
+ uuid = getUuid()
30
+ dbshow = Chef::Knife::DataBagShow.new
31
+ puts "Showing data bag item hardware #{uuid}"
32
+ dbshow.name_args = ['hardware', uuid]
33
+ dbshow.run
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ module Knife
2
+ module Hardware
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knife-hardware
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Paul Thomas
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: chef
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Automatically link the hardware data bag items to their node
31
+ email:
32
+ - paul@paulthomas.eu
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - knife-hardware.gemspec
43
+ - lib/chef/knife/hardware_base.rb
44
+ - lib/chef/knife/hardware_edit.rb
45
+ - lib/chef/knife/hardware_show.rb
46
+ - lib/knife-hardware/version.rb
47
+ homepage: ''
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 1.8.24
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Links items in the hardware data bag to a node using the UUID as a key
71
+ test_files: []