knife-ipmi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # Knife IPMI
2
+
3
+ This plugin provides basic IPMI controls through knife. It requires that your nodes have populated IPMI information such as that provided by the ohai-ipmi plugin.
4
+
5
+ ## Requirements
6
+ `ruby-ipmitool`
7
+ `ohai-ipmi` - In order to populate IPMI data on the Chef::Node
8
+
9
+ ## What can it do?
10
+
11
+ The plugin currently provides power controls 'on', 'off', 'status', 'reset', 'soft' which equate directly to their IPMI namesakes.
12
+
13
+ knife ipmi power on NODE
14
+ knife ipmi power off NODE
15
+ knife ipmi power status NODE
16
+ knife ipmi power reset NODE
17
+ knife ipmi power soft NODE
@@ -0,0 +1,12 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.authors = ["Paul Thomas"]
3
+ gem.email = ["gems@paulthomas.eu"]
4
+ gem.description = %q{Interact with ruby-ipmitool using knife}
5
+ gem.summary = %q{Interact with ruby-ipmitool using knife}
6
+ gem.homepage = "http://github.com/Afterglow/knife-ipmi"
7
+
8
+ gem.files = `git ls-files`.split($\)
9
+ gem.name = "knife-ipmi"
10
+ gem.require_paths = ["lib"]
11
+ gem.version = "0.0.1"
12
+ end
@@ -0,0 +1,49 @@
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
+ require 'chef/search/query'
21
+ require 'ruby-ipmitool'
22
+
23
+ class Chef
24
+ class Knife
25
+ module IpmiBase
26
+ def ipmi
27
+ unless name_args.size == 1
28
+ puts "You need to specify a node to act on"
29
+ show_usage
30
+ exit 1
31
+ end
32
+ unless defined? config[:ipmi_user]
33
+ puts "Please set your IPMI username in knife.rb"
34
+ exit 1
35
+ end
36
+ unless defined? config[:ipmi_user]
37
+ puts "Please set your IPMI password in knife.rb"
38
+ exit 1
39
+ end
40
+
41
+ node = Chef::Node.load(name_args[0])
42
+ unless node.has_key? 'ipmi'
43
+ puts "Node had no IPMI details (is it running ohai-ipmi plugin?)"
44
+ end
45
+ @conn = Ipmitool.new(:host => node.ipmi.address, :user => Chef::Config[:knife][:ipmi_user], :password => Chef::Config[:knife][:ipmi_pass])
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,33 @@
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/ipmi_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class IpmiPowerOff < Knife
24
+ include Knife::IpmiBase
25
+
26
+ banner "knife ipmi power off NODE"
27
+
28
+ def run
29
+ puts ipmi.power("off")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
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/ipmi_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class IpmiPowerOn < Knife
24
+ include Knife::IpmiBase
25
+
26
+ banner "knife ipmi power on NODE"
27
+
28
+ def run
29
+ puts ipmi.power("on")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
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/ipmi_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class IpmiPowerReset < Knife
24
+ include Knife::IpmiBase
25
+
26
+ banner "knife ipmi power reset NODE"
27
+
28
+ def run
29
+ puts ipmi.power("reset")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
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/ipmi_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class IpmiPowerSoft < Knife
24
+ include Knife::IpmiBase
25
+
26
+ banner "knife ipmi power soft NODE"
27
+
28
+ def run
29
+ puts ipmi.power("soft")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
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/ipmi_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class IpmiPowerStatus < Knife
24
+ include Knife::IpmiBase
25
+
26
+ banner "knife ipmi power status NODE"
27
+
28
+ def run
29
+ puts ipmi.power("status")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ module Knife
2
+ module Ipmi
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knife-ipmi
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-05 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Interact with ruby-ipmitool using knife
15
+ email:
16
+ - gems@paulthomas.eu
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - README.md
23
+ - knife-ipmi.gemspec
24
+ - lib/chef/knife/ipmi_base.rb
25
+ - lib/chef/knife/ipmi_power_off.rb
26
+ - lib/chef/knife/ipmi_power_on.rb
27
+ - lib/chef/knife/ipmi_power_reset.rb
28
+ - lib/chef/knife/ipmi_power_soft.rb
29
+ - lib/chef/knife/ipmi_power_status.rb
30
+ - lib/knife-ipmi/version.rb
31
+ homepage: http://github.com/Afterglow/knife-ipmi
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.24
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Interact with ruby-ipmitool using knife
55
+ test_files: []