knife-hmc 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +103 -0
- data/Rakefile +1 -0
- data/knife-hmc.gemspec +26 -0
- data/lib/chef/knife/hmc_base.rb +131 -0
- data/lib/chef/knife/hmc_disk_add.rb +116 -0
- data/lib/chef/knife/hmc_disk_list.rb +173 -0
- data/lib/chef/knife/hmc_disk_remove.rb +67 -0
- data/lib/chef/knife/hmc_image_list.rb +54 -0
- data/lib/chef/knife/hmc_server_config.rb +111 -0
- data/lib/chef/knife/hmc_server_create.rb +368 -0
- data/lib/chef/knife/hmc_server_delete.rb +102 -0
- data/lib/chef/knife/hmc_server_list.rb +55 -0
- data/lib/chef/knife/hmc_server_state.rb +82 -0
- data/lib/knife-hmc/version.rb +6 -0
- data/vendor/bundle/placeholder +0 -0
- metadata +104 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
#
|
2
|
+
# Authors: Christopher M Wood (<woodc@us.ibm.com>)
|
3
|
+
# John F Hutchinson (<jfhutchi@us.ibm.com>)
|
4
|
+
# © Copyright IBM Corporation 2015.
|
5
|
+
#
|
6
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'chef/knife/hmc_base'
|
10
|
+
|
11
|
+
# Needed by the '--purge' deletion option
|
12
|
+
require 'chef/node'
|
13
|
+
require 'chef/api_client'
|
14
|
+
|
15
|
+
class Chef
|
16
|
+
class Knife
|
17
|
+
class HmcServerDelete < Knife
|
18
|
+
|
19
|
+
include Knife::HmcBase
|
20
|
+
|
21
|
+
banner "knife hmc server delete --frame NAME --lpar NAME --primary_vio NAME --secondary_vio NAME"
|
22
|
+
|
23
|
+
option :purge,
|
24
|
+
:short => "-P",
|
25
|
+
:long => "--purge",
|
26
|
+
:boolean => true,
|
27
|
+
:default => false,
|
28
|
+
:description => "Destroy corresponding node and client on the Chef Server, in addition to destroying the OpenStack node itself. Assumes node and client have the same name as the server (if not, add the '--node-name' option)."
|
29
|
+
|
30
|
+
option :chef_node_name,
|
31
|
+
:short => "-N NAME",
|
32
|
+
:long => "--node_name NAME",
|
33
|
+
:description => "The name of the node and client to delete, if it differs from the server name. Only has meaning when used with the '--purge' option."
|
34
|
+
|
35
|
+
option :frame_name,
|
36
|
+
:short => "-f NAME",
|
37
|
+
:long => "--frame NAME",
|
38
|
+
:description => "Name of the Host in which the LPAR resides."
|
39
|
+
|
40
|
+
option :lpar_name,
|
41
|
+
:short => "-l NAME",
|
42
|
+
:long => "--lpar",
|
43
|
+
:description => "Name of LPAR you wish to delete."
|
44
|
+
|
45
|
+
option :vio1_name,
|
46
|
+
:short => "-p NAME",
|
47
|
+
:long => "--primary_vio NAME",
|
48
|
+
:description => "Name of the primary vio."
|
49
|
+
|
50
|
+
option :vio2_name,
|
51
|
+
:short => "-s NAME",
|
52
|
+
:long => "--secondary_vio NAME",
|
53
|
+
:description => "Name of the secondary vio."
|
54
|
+
|
55
|
+
#Extracted from Chef::Knife.delete_object.
|
56
|
+
#That function requires an extra confirmation before
|
57
|
+
#proceeding, which seems overly cautious of an operation
|
58
|
+
#that will destroy the server that the node represents.
|
59
|
+
def destroy_chef_node(objectClass,name,type)
|
60
|
+
object = objectClass.load(name)
|
61
|
+
object.destroy
|
62
|
+
puts "Deleted #{type} #{name}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def run
|
66
|
+
Chef::Log.debug("Deleting server...")
|
67
|
+
|
68
|
+
validate!([:frame_name,:lpar_name])
|
69
|
+
|
70
|
+
hmc = Hmc.new(get_config(:hmc_host), get_config(:hmc_username) , {:password => get_config(:hmc_password)})
|
71
|
+
hmc.connect
|
72
|
+
lpar_hash = hmc.get_lpar_options(get_config(:frame_name),get_config(:lpar_name))
|
73
|
+
lpar = Lpar.new(lpar_hash)
|
74
|
+
|
75
|
+
if get_config(:vio1_name).nil? and get_config(:vio2_name).nil?
|
76
|
+
lpar.delete()
|
77
|
+
puts "#{get_config(:lpar_name)} destroyed"
|
78
|
+
else
|
79
|
+
validate!([:vio1_name, :vio2_name])
|
80
|
+
vio1 = Vio.new(hmc, get_config(:frame_name), get_config(:vio1_name))
|
81
|
+
vio2 = Vio.new(hmc, get_config(:frame_name), get_config(:vio2_name))
|
82
|
+
lpar.delete([vio1,vio2])
|
83
|
+
puts "#{get_config(:lpar_name)} destroyed"
|
84
|
+
end
|
85
|
+
|
86
|
+
Chef::Log.debug("Server #{lpar.name} has been deleted.")
|
87
|
+
|
88
|
+
#If :purge option was specified, delete the Chef node that
|
89
|
+
#represents the LPAR we just deleted
|
90
|
+
if get_config(:purge)
|
91
|
+
Chef::Log.debug("Removing Chef node for #{lpar.name}")
|
92
|
+
node_name = get_config(:chef_node_name) || lpar.name
|
93
|
+
puts "Removing Chef node for #{lpar.name}"
|
94
|
+
destroy_chef_node(Chef::Node, node_name, "node")
|
95
|
+
destroy_chef_node(Chef::ApiClient, node_name, "client")
|
96
|
+
end
|
97
|
+
|
98
|
+
hmc.disconnect
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#
|
2
|
+
# Authors: Christopher M Wood (<woodc@us.ibm.com>)
|
3
|
+
# John F Hutchinson (<jfhutchi@us.ibm.com>)
|
4
|
+
# © Copyright IBM Corporation 2015.
|
5
|
+
#
|
6
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
7
|
+
#
|
8
|
+
require 'chef/knife/hmc_base'
|
9
|
+
|
10
|
+
class Chef
|
11
|
+
class Knife
|
12
|
+
class HmcServerList < Knife
|
13
|
+
|
14
|
+
include Knife::HmcBase
|
15
|
+
|
16
|
+
banner "knife hmc server list [--frame FRAME]"
|
17
|
+
|
18
|
+
option :frame,
|
19
|
+
:short => "-f FRAME",
|
20
|
+
:long => "--frame FRAME",
|
21
|
+
:description => "The name of the frame (as known by the HMC) to list the LPARs of"
|
22
|
+
|
23
|
+
def run
|
24
|
+
Chef::Log.debug("Listing servers...")
|
25
|
+
|
26
|
+
validate!
|
27
|
+
|
28
|
+
hmc = Hmc.new(get_config(:hmc_host), get_config(:hmc_username) , {:password => get_config(:hmc_password)})
|
29
|
+
hmc.connect
|
30
|
+
|
31
|
+
#If frame was specified, list only the LPARs on that frame
|
32
|
+
if !get_config(:frame).nil?
|
33
|
+
validate!([:frame])
|
34
|
+
puts "LPARs on frame #{get_config(:frame)}:"
|
35
|
+
hmc.list_lpars_on_frame(get_config(:frame)).each do |lpar_name|
|
36
|
+
puts "#{lpar_name}"
|
37
|
+
end
|
38
|
+
else
|
39
|
+
#Otherwise, list all of the LPARs on each frame
|
40
|
+
#managed by this HMC
|
41
|
+
frames = hmc.list_frames
|
42
|
+
frames.each do |frame|
|
43
|
+
puts "LPARs on frame #{frame}:"
|
44
|
+
hmc.list_lpars_on_frame(frame).each do |lpar_name|
|
45
|
+
puts "#{lpar_name}"
|
46
|
+
end
|
47
|
+
puts "\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
hmc.disconnect
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#
|
2
|
+
# Authors: Christopher M Wood (<woodc@us.ibm.com>)
|
3
|
+
# John F Hutchinson (<jfhutchi@us.ibm.com>)
|
4
|
+
# © Copyright IBM Corporation 2015.
|
5
|
+
#
|
6
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
7
|
+
#
|
8
|
+
require 'chef/knife/hmc_base'
|
9
|
+
|
10
|
+
class Chef
|
11
|
+
class Knife
|
12
|
+
class HmcServerState < Knife
|
13
|
+
|
14
|
+
include Knife::HmcBase
|
15
|
+
|
16
|
+
banner "knife hmc server state (options)"
|
17
|
+
|
18
|
+
option :lpar_name,
|
19
|
+
:short => "-l NAME",
|
20
|
+
:long => "--lpar NAME",
|
21
|
+
:description => "Name of the LPAR as seen on the HMC Console."
|
22
|
+
|
23
|
+
option :frame_name,
|
24
|
+
:short => "-f NAME",
|
25
|
+
:long => "--frame NAME",
|
26
|
+
:description => "Name of the Host in which the LPAR resides."
|
27
|
+
|
28
|
+
option :power_on,
|
29
|
+
:short => "-p",
|
30
|
+
:long => "--power_on",
|
31
|
+
:boolean => true,
|
32
|
+
:description => "Turn the LPAR on."
|
33
|
+
|
34
|
+
option :power_off_soft,
|
35
|
+
:short => "-o",
|
36
|
+
:long => "--power_off_soft",
|
37
|
+
:boolean => true,
|
38
|
+
:description => "Operating System level shutdown.."
|
39
|
+
|
40
|
+
option :power_off_quick,
|
41
|
+
:short => "-q",
|
42
|
+
:long => "--power_off_quick",
|
43
|
+
:boolean => true,
|
44
|
+
:description => "Instant power off."
|
45
|
+
|
46
|
+
def run
|
47
|
+
Chef::Log.debug("Changing State...")
|
48
|
+
|
49
|
+
validate!([:frame_name,:lpar_name])
|
50
|
+
|
51
|
+
hmc = Hmc.new(get_config(:hmc_host), get_config(:hmc_username) , {:password => get_config(:hmc_password)})
|
52
|
+
hmc.connect
|
53
|
+
|
54
|
+
#Populate hash to make LPAR object
|
55
|
+
lpar_hash = hmc.get_lpar_options(get_config(:frame_name),get_config(:lpar_name))
|
56
|
+
#Create LPAR object based on hash, and VIO objects
|
57
|
+
lpar = Lpar.new(lpar_hash)
|
58
|
+
|
59
|
+
if validate([:power_on])
|
60
|
+
if lpar.is_running?
|
61
|
+
puts "#{get_config(:lpar_name)} is already running, exiting"
|
62
|
+
return true
|
63
|
+
else
|
64
|
+
lpar.activate
|
65
|
+
puts "Powering on #{get_config(:lpar_name)}."
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
if validate([:power_off_soft])
|
70
|
+
lpar.soft_shutdown
|
71
|
+
puts "Shutting down #{get_config(:lpar_name)}."
|
72
|
+
end
|
73
|
+
|
74
|
+
if validate([:power_off_quick])
|
75
|
+
lpar.hard_shutdown
|
76
|
+
puts "Performing hard power off of #{get_config(:lpar_name)}."
|
77
|
+
end
|
78
|
+
hmc.disconnect
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: knife-hmc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John J. Rofrano,Christopher M. Wood, John F. Hutchinson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rbvppc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Knife plugin for use with IBM Hardware Management Console
|
56
|
+
email:
|
57
|
+
- rofrano@us.ibm.com, woodc@us.ibm.com, jfhutchi@us.ibm.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- CHANGELOG.md
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- knife-hmc.gemspec
|
68
|
+
- lib/chef/knife/hmc_base.rb
|
69
|
+
- lib/chef/knife/hmc_disk_add.rb
|
70
|
+
- lib/chef/knife/hmc_disk_list.rb
|
71
|
+
- lib/chef/knife/hmc_disk_remove.rb
|
72
|
+
- lib/chef/knife/hmc_image_list.rb
|
73
|
+
- lib/chef/knife/hmc_server_config.rb
|
74
|
+
- lib/chef/knife/hmc_server_create.rb
|
75
|
+
- lib/chef/knife/hmc_server_delete.rb
|
76
|
+
- lib/chef/knife/hmc_server_list.rb
|
77
|
+
- lib/chef/knife/hmc_server_state.rb
|
78
|
+
- lib/knife-hmc/version.rb
|
79
|
+
- vendor/bundle/placeholder
|
80
|
+
homepage: http://github.com/pseries/knife-hmc
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 2.1.0
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.2.2
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: IBM Hardware Management Console support for Chef's Knife Command
|
104
|
+
test_files: []
|