knife-ucs 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -3
- data/configs/hosfw.json +18 -0
- data/knife-ucs.gemspec +5 -4
- data/lib/chef/knife/ucs_base.rb +12 -0
- data/lib/chef/knife/ucs_blades_list.rb +2 -0
- data/lib/chef/knife/ucs_cpus_list.rb +2 -0
- data/lib/chef/knife/ucs_org_create.rb +5 -3
- data/lib/chef/knife/ucs_org_delete.rb +3 -1
- data/lib/chef/knife/ucs_orgs_list.rb +2 -0
- data/lib/chef/knife/ucs_policy_create.rb +108 -0
- data/lib/chef/knife/ucs_policy_delete.rb +57 -0
- data/lib/chef/knife/ucs_policy_update.rb +107 -0
- data/lib/chef/knife/ucs_pool_create.rb +21 -27
- data/lib/chef/knife/ucs_pool_delete.rb +3 -1
- data/lib/chef/knife/ucs_pool_list.rb +189 -0
- data/lib/chef/knife/ucs_runningfirmware_list.rb +2 -0
- data/lib/chef/knife/ucs_serviceprofile_create.rb +3 -0
- data/lib/chef/knife/ucs_serviceprofile_delete.rb +3 -1
- data/lib/chef/knife/ucs_serviceprofiles_list.rb +2 -0
- data/lib/chef/knife/ucs_set.rb +75 -12
- data/lib/chef/knife/ucs_template_create.rb +174 -0
- data/lib/chef/knife/ucs_template_delete.rb +59 -0
- data/lib/chef/knife/ucs_vlan_create.rb +8 -6
- data/lib/chef/knife/ucs_vlan_delete.rb +5 -4
- data/lib/chef/knife/ucs_vlans_list.rb +2 -0
- data/lib/chef/knife/ucs_vsans_list.rb +2 -0
- data/lib/knife-ucs/version.rb +1 -1
- metadata +51 -11
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
Knife UCS (
|
1
|
+
Knife UCS (beta)
|
2
2
|
===============
|
3
3
|
|
4
|
-
This is a Chef Knife plugin for Cisco UCS
|
4
|
+
This is a Chef Knife plugin for Cisco UCS. This plugin gives knife the ability to provision, list, and manage Cisco UCS. It leverages UCSlib (http://github.com/murraju/ucslib).
|
5
5
|
|
6
6
|
# Installation #
|
7
7
|
|
@@ -41,7 +41,10 @@ Example usage can be found here -> https://github.com/murraju/knife-ucs/wiki
|
|
41
41
|
|
42
42
|
Author:: Murali Raju <murali.raju@appliv.com>
|
43
43
|
|
44
|
-
|
44
|
+
Author:: Velankani Engineering Team <eng@velankani.net>
|
45
|
+
|
46
|
+
Copyright:: Copyright (c) 2011 Murali Raju <murali.raju@appliv.com>
|
47
|
+
Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc.
|
45
48
|
|
46
49
|
License:: Apache License, Version 2.0
|
47
50
|
|
data/configs/hosfw.json
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"hostfw":{
|
3
|
+
"host_firmware_pkg_name" : "EngHostFW",
|
4
|
+
"hardware_model" : "N20-AC0002",
|
5
|
+
"hardware_type" : "adaptor",
|
6
|
+
"hardware_vendor" : "Cisco Systems Inc",
|
7
|
+
"firmware_version" : "2.0(2q)",
|
8
|
+
"org" : "Eng"
|
9
|
+
},
|
10
|
+
"hostfw":{
|
11
|
+
"host_firmware_pkg_name" : "EngHostFW",
|
12
|
+
"hardware_model" : "N20-AC0002",
|
13
|
+
"hardware_type" : "adaptor",
|
14
|
+
"hardware_vendor" : "Cisco Systems Inc",
|
15
|
+
"firmware_version" : "2.0(2q)",
|
16
|
+
"org" : "Eng"
|
17
|
+
}
|
18
|
+
}
|
data/knife-ucs.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.has_rdoc = true
|
10
10
|
s.extra_rdoc_files = ["README.md", "LICENSE" ]
|
11
|
-
s.authors = ["Murali Raju"]
|
12
|
-
s.email = ["murraju@appliv.com"]
|
13
|
-
s.homepage = "https://github.com/
|
11
|
+
s.authors = ["Murali Raju", "Velankani Engineering"]
|
12
|
+
s.email = ["murraju@appliv.com", "eng@velankani.net"]
|
13
|
+
s.homepage = "https://github.com/velankanisys/knife-ucs"
|
14
14
|
s.summary = %q{Cisco UCS Support for Chef's Knife Command}
|
15
15
|
s.description = s.summary
|
16
16
|
|
@@ -21,5 +21,6 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_dependency "nokogiri", "~> 1.5.2"
|
23
23
|
s.add_dependency "rest-client", "~> 1.6.7"
|
24
|
-
s.add_dependency "ucslib", "~> 0.
|
24
|
+
s.add_dependency "ucslib", "~> 0.1.6"
|
25
|
+
s.add_dependency "chef", "~>10.16.2"
|
25
26
|
end
|
data/lib/chef/knife/ucs_base.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# Author:: Velankani Engineering <eng@velankani.net>
|
2
3
|
# Copyright:: Copyright (c) 2012 Murali Raju.
|
4
|
+
# Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc
|
3
5
|
# License:: Apache License, Version 2.0
|
4
6
|
#
|
5
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -54,6 +56,9 @@ class Chef
|
|
54
56
|
|
55
57
|
def connection
|
56
58
|
ucs_session = UCSToken.new
|
59
|
+
Chef::Log.debug("username: #{Chef::Config[:knife][:ucsm_username]}")
|
60
|
+
Chef::Log.debug("password: #{Chef::Config[:knife][:ucsm_password]}")
|
61
|
+
Chef::Log.debug("host: #{Chef::Config[:knife][:ucsm_host]}")
|
57
62
|
@connection ||= begin
|
58
63
|
connection = ucs_session.get_token({
|
59
64
|
:username => Chef::Config[:knife][:ucsm_username],
|
@@ -76,6 +81,13 @@ class Chef
|
|
76
81
|
provisioner = UCSProvision.new(connection)
|
77
82
|
end
|
78
83
|
end
|
84
|
+
|
85
|
+
def manager
|
86
|
+
ucs_manager = UCSManage.new(connection)
|
87
|
+
@manager ||= begin
|
88
|
+
manager = ucs_manager.discover_state
|
89
|
+
end
|
90
|
+
end
|
79
91
|
|
80
92
|
def destroyer
|
81
93
|
@destroyer ||= begin
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# Author:: Velankani Engineering <eng@velankani.net>
|
2
3
|
# Copyright:: Copyright (c) 2012 Murali Raju.
|
4
|
+
# Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc
|
3
5
|
# License:: Apache License, Version 2.0
|
4
6
|
#
|
5
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# Author:: Velankani Engineering <eng@velankani.net>
|
2
3
|
# Copyright:: Copyright (c) 2012 Murali Raju.
|
4
|
+
# Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc
|
3
5
|
# License:: Apache License, Version 2.0
|
4
6
|
#
|
5
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# Author:: Velankani Engineering <eng@velankani.net>
|
2
3
|
# Copyright:: Copyright (c) 2012 Murali Raju.
|
4
|
+
# Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc
|
3
5
|
# License:: Apache License, Version 2.0
|
4
6
|
#
|
5
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -44,15 +46,15 @@ class Chef
|
|
44
46
|
def run
|
45
47
|
$stdout.sync = true
|
46
48
|
|
47
|
-
xml_response = provisioner.
|
49
|
+
xml_response = provisioner.set_org({:org => Chef::Config[:knife][:org]}.to_json)
|
48
50
|
xml_doc = Nokogiri::XML(xml_response)
|
49
51
|
|
50
52
|
xml_doc.xpath("configConfMos/outConfigs/pair/orgOrg").each do |org|
|
51
53
|
puts ''
|
52
|
-
puts "Org: #{ui.color("#{org.attributes['name']}", :
|
54
|
+
puts "Org: #{ui.color("#{org.attributes['name']}", :blue)} status: #{ui.color("#{org.attributes['status']}", :green)}"
|
53
55
|
end
|
54
56
|
|
55
|
-
|
57
|
+
|
56
58
|
xml_doc.xpath("configConfMos").each do |org|
|
57
59
|
puts "#{org.attributes['errorCode']} #{ui.color("#{org.attributes['errorDescr']}", :red)}"
|
58
60
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# Author:: Velankani Engineering <eng@velankani.net>
|
2
3
|
# Copyright:: Copyright (c) 2012 Murali Raju.
|
4
|
+
# Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc
|
3
5
|
# License:: Apache License, Version 2.0
|
4
6
|
#
|
5
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -49,7 +51,7 @@ class Chef
|
|
49
51
|
|
50
52
|
xml_doc.xpath("configConfMos/outConfigs/pair/orgOrg").each do |org|
|
51
53
|
puts ''
|
52
|
-
puts "Org: #{ui.color("#{org.attributes['name']}", :
|
54
|
+
puts "Org: #{ui.color("#{org.attributes['name']}", :blue)} status: #{ui.color("#{org.attributes['status']}", :red)}"
|
53
55
|
end
|
54
56
|
|
55
57
|
#Ugly...refactor later to parse error with better exception handling. Nokogiri xpath search for elements might be an option
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# Author:: Velankani Engineering <eng@velankani.net>
|
2
3
|
# Copyright:: Copyright (c) 2012 Murali Raju.
|
4
|
+
# Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc
|
3
5
|
# License:: Apache License, Version 2.0
|
4
6
|
#
|
5
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# Author:: Velankani Engineering <eng@velankani.net>
|
3
|
+
# Copyright:: Copyright (c) 2012 Murali Raju.
|
4
|
+
# Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef/knife/ucs_base'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Knife
|
24
|
+
class UcsPolicyCreate < Knife
|
25
|
+
|
26
|
+
include Knife::UCSBase
|
27
|
+
|
28
|
+
deps do
|
29
|
+
require 'readline'
|
30
|
+
require 'chef/json_compat'
|
31
|
+
require 'chef/knife/bootstrap'
|
32
|
+
Chef::Knife::Bootstrap.load_deps
|
33
|
+
end
|
34
|
+
|
35
|
+
banner "knife ucs policy create (options)"
|
36
|
+
|
37
|
+
attr_accessor :initial_sleep_delay
|
38
|
+
|
39
|
+
option :policy,
|
40
|
+
:long => "--policy-type POLICY",
|
41
|
+
:description => "The policy type <boot,host-firmware,mgmt-firmware>",
|
42
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:policy] = f }
|
43
|
+
|
44
|
+
option :org,
|
45
|
+
:long => "--org ORG",
|
46
|
+
:description => "The organization to use",
|
47
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:org] = f }
|
48
|
+
|
49
|
+
option :name,
|
50
|
+
:long => "--policy-name POLICYNAME",
|
51
|
+
:description => "The policy name to use",
|
52
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:name] = f }
|
53
|
+
|
54
|
+
option :hardwaremodel,
|
55
|
+
:long => "--hardware-model MODEL",
|
56
|
+
:description => "The hardware model used with firmware policies",
|
57
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:hardwaremodel] = f }
|
58
|
+
|
59
|
+
option :hardwaretype,
|
60
|
+
:long => "--hardware-type TYPE",
|
61
|
+
:description => "The hardware type used with firmware policies",
|
62
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:hardwaretype] = f }
|
63
|
+
|
64
|
+
option :hardwarevendor,
|
65
|
+
:long => "--hardware-vendor VENDOR",
|
66
|
+
:description => "The hardware vendor used with firmware policies",
|
67
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:hardwarevendor] = f }
|
68
|
+
|
69
|
+
option :firmwareversion,
|
70
|
+
:long => "--firmware-version VERSION",
|
71
|
+
:description => "The firmware version used with firmware policies",
|
72
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:firmwareversion] = f }
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
def run
|
77
|
+
$stdout.sync = true
|
78
|
+
|
79
|
+
policy = "#{Chef::Config[:knife][:policy]}".downcase
|
80
|
+
case policy
|
81
|
+
when 'host-firmware'
|
82
|
+
|
83
|
+
json = { :host_firmware_pkg_name => Chef::Config[:knife][:name], :hardware_model => Chef::Config[:knife][:hardwaremodel].to_s,
|
84
|
+
:hardware_type => Chef::Config[:knife][:hardwaretype].to_s, :hardware_vendor => Chef::Config[:knife][:hardwarevendor].to_s,
|
85
|
+
:firmware_version => Chef::Config[:knife][:firmwareversion].to_s, :org => Chef::Config[:knife][:org] }.to_json
|
86
|
+
|
87
|
+
xml_response = provisioner.set_host_firmware_package(json)
|
88
|
+
xml_doc = Nokogiri::XML(xml_response)
|
89
|
+
|
90
|
+
xml_doc.xpath("configConfMos/outConfigs/pair/firmwareComputeHostPack").each do |hostfw|
|
91
|
+
puts ''
|
92
|
+
puts "Host Firmware Pack: #{ui.color("#{hostfw.attributes['name']}", :blue)}" +
|
93
|
+
" status: #{ui.color("#{hostfw.attributes['status']}", :green)}"
|
94
|
+
end
|
95
|
+
|
96
|
+
xml_doc.xpath("configConfMos").each do |hostfw|
|
97
|
+
puts "#{hostfw.attributes['errorCode']} #{ui.color("#{hostfw.attributes['errorDescr']}", :red)}"
|
98
|
+
end
|
99
|
+
|
100
|
+
else
|
101
|
+
puts "Incorrect options. Please make sure you are using one of the following: host-firmware, mgmt-firmware"
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# Author:: Velankani Engineering <eng@velankani.net>
|
3
|
+
# Copyright:: Copyright (c) 2012 Murali Raju.
|
4
|
+
# Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef/knife/ucs_base'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Knife
|
24
|
+
class UcsPolicyDelete < Knife
|
25
|
+
|
26
|
+
include Knife::UCSBase
|
27
|
+
|
28
|
+
deps do
|
29
|
+
require 'readline'
|
30
|
+
require 'chef/json_compat'
|
31
|
+
require 'chef/knife/bootstrap'
|
32
|
+
Chef::Knife::Bootstrap.load_deps
|
33
|
+
end
|
34
|
+
|
35
|
+
banner "knife ucs policy delete (options)"
|
36
|
+
|
37
|
+
attr_accessor :initial_sleep_delay
|
38
|
+
|
39
|
+
option :policy,
|
40
|
+
:long => "--policy-type POLICY",
|
41
|
+
:description => "The policy type <boot,hostfirmware,managementfirmware>",
|
42
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:policy] = f }
|
43
|
+
|
44
|
+
option :name,
|
45
|
+
:long => "--policy-name POLICYNAME",
|
46
|
+
:description => "The policy name",
|
47
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:name] = f }
|
48
|
+
|
49
|
+
def run
|
50
|
+
$stdout.sync = true
|
51
|
+
|
52
|
+
#TBD
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# Author:: Velankani Engineering <eng@velankani.net>
|
3
|
+
# Copyright:: Copyright (c) 2012 Murali Raju.
|
4
|
+
# Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
require 'chef/knife/ucs_base'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
class UcsPolicyUpdate < Knife
|
24
|
+
|
25
|
+
include Knife::UCSBase
|
26
|
+
|
27
|
+
deps do
|
28
|
+
require 'readline'
|
29
|
+
require 'chef/json_compat'
|
30
|
+
require 'chef/knife/bootstrap'
|
31
|
+
Chef::Knife::Bootstrap.load_deps
|
32
|
+
end
|
33
|
+
|
34
|
+
banner "knife ucs policy update (options)"
|
35
|
+
|
36
|
+
attr_accessor :initial_sleep_delay
|
37
|
+
|
38
|
+
option :policy,
|
39
|
+
:long => "--policy-type POLICY",
|
40
|
+
:description => "The policy type <boot,host-firmware,mgmt-firmware>",
|
41
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:policy] = f }
|
42
|
+
|
43
|
+
option :org,
|
44
|
+
:long => "--org ORG",
|
45
|
+
:description => "The organization to use",
|
46
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:org] = f }
|
47
|
+
|
48
|
+
option :name,
|
49
|
+
:long => "--policy-name POLICYNAME",
|
50
|
+
:description => "The policy name to use",
|
51
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:name] = f }
|
52
|
+
|
53
|
+
option :hardwaremodel,
|
54
|
+
:long => "--hardware-model MODEL",
|
55
|
+
:description => "The hardware model used with firmware policies",
|
56
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:hardwaremodel] = f }
|
57
|
+
|
58
|
+
option :hardwaretype,
|
59
|
+
:long => "--hardware-type TYPE",
|
60
|
+
:description => "The hardware type used with firmware policies",
|
61
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:hardwaretype] = f }
|
62
|
+
|
63
|
+
option :hardwarevendor,
|
64
|
+
:long => "--hardware-vendor VENDOR",
|
65
|
+
:description => "The hardware vendor used with firmware policies",
|
66
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:hardwarevendor] = f }
|
67
|
+
|
68
|
+
option :firmwareversion,
|
69
|
+
:long => "--firmware-version VERSION",
|
70
|
+
:description => "The firmware version used with firmware policies",
|
71
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:firmwareversion] = f }
|
72
|
+
|
73
|
+
|
74
|
+
def run
|
75
|
+
$stdout.sync = true
|
76
|
+
|
77
|
+
policy = "#{Chef::Config[:knife][:policy]}".downcase
|
78
|
+
case policy
|
79
|
+
when 'host-firmware'
|
80
|
+
|
81
|
+
json = { :host_firmware_pkg_name => Chef::Config[:knife][:name], :hardware_model => Chef::Config[:knife][:hardwaremodel].to_s,
|
82
|
+
:hardware_type => Chef::Config[:knife][:hardwaretype].to_s, :hardware_vendor => Chef::Config[:knife][:hardwarevendor].to_s,
|
83
|
+
:firmware_version => Chef::Config[:knife][:firmwareversion].to_s, :org => Chef::Config[:knife][:org] }.to_json
|
84
|
+
|
85
|
+
|
86
|
+
xml_response = updater.update_host_firmware_package(json)
|
87
|
+
xml_doc = Nokogiri::XML(xml_response)
|
88
|
+
|
89
|
+
xml_doc.xpath("configConfMos/outConfigs/pair/firmwareComputeHostPack").each do |hostfw|
|
90
|
+
puts ''
|
91
|
+
puts "Host Firmware Pack: #{ui.color("#{hostfw.attributes['name']}", :blue)}" +
|
92
|
+
" status: #{ui.color("#{hostfw.attributes['status']}", :green)}"
|
93
|
+
end
|
94
|
+
|
95
|
+
xml_doc.xpath("configConfMos").each do |hostfw|
|
96
|
+
puts "#{hostfw.attributes['errorCode']} #{ui.color("#{hostfw.attributes['errorDescr']}", :red)}"
|
97
|
+
end
|
98
|
+
|
99
|
+
else
|
100
|
+
puts "Incorrect options. Please make sure you are using one of the following: host-firmware, mgmt-firmware"
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# Author:: Velankani Engineering <eng@velankani.net>
|
2
3
|
# Copyright:: Copyright (c) 2012 Murali Raju.
|
4
|
+
# Copyright:: Copyright (c) 2012 Velankani Information Systems, Inc
|
3
5
|
# License:: Apache License, Version 2.0
|
4
6
|
#
|
5
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -14,7 +16,6 @@
|
|
14
16
|
# See the License for the specific language governing permissions and
|
15
17
|
# limitations under the License.
|
16
18
|
#
|
17
|
-
|
18
19
|
require 'chef/knife/ucs_base'
|
19
20
|
|
20
21
|
class Chef
|
@@ -34,45 +35,38 @@ class Chef
|
|
34
35
|
|
35
36
|
attr_accessor :initial_sleep_delay
|
36
37
|
|
37
|
-
option :
|
38
|
-
:
|
39
|
-
:long => "--pool POOLTYPE",
|
38
|
+
option :pooltype,
|
39
|
+
:long => "--pool-type POOLTYPE",
|
40
40
|
:description => "UCS pool types <mac,uuid,wwpn,wwnn,managementip>",
|
41
|
-
:proc => Proc.new { |f| Chef::Config[:knife][:
|
41
|
+
:proc => Proc.new { |f| Chef::Config[:knife][:pooltype] = f }
|
42
42
|
|
43
43
|
option :name,
|
44
|
-
:short => "-N NAME",
|
45
44
|
:long => "--pool-name POOLNAME",
|
46
45
|
:description => "The pool name",
|
47
46
|
:proc => Proc.new { |f| Chef::Config[:knife][:name] = f }
|
48
47
|
|
49
48
|
option :start,
|
50
|
-
:short => "-S START",
|
51
49
|
:long => "--pool-start STARTRANGE",
|
52
50
|
:description => "Start of a pool range <IP, WWPN, WWNN, MAC>",
|
53
51
|
:proc => Proc.new { |f| Chef::Config[:knife][:start] = f }
|
54
52
|
|
55
53
|
option :end,
|
56
|
-
:short => "-E END",
|
57
54
|
:long => "--pool-end ENDRANGE",
|
58
55
|
:description => "End of a pool range <IP, WWPN, WWNN, MAC>",
|
59
56
|
:proc => Proc.new { |f| Chef::Config[:knife][:end] = f }
|
60
57
|
|
61
58
|
|
62
59
|
option :mask,
|
63
|
-
:short => "-M MASK",
|
64
60
|
:long => "--subnet-mask SUBNETMASK",
|
65
61
|
:description => "The subnet mask for an IP range",
|
66
62
|
:proc => Proc.new { |f| Chef::Config[:knife][:mask] = f }
|
67
63
|
|
68
64
|
option :gateway,
|
69
|
-
:short => "-G GATEWAY",
|
70
65
|
:long => "--gateway IPGATEWAY",
|
71
66
|
:description => "The IP Gateway address of a subnet",
|
72
67
|
:proc => Proc.new { |f| Chef::Config[:knife][:gateway] = f }
|
73
68
|
|
74
69
|
option :org,
|
75
|
-
:short => "-O ORG",
|
76
70
|
:long => "--org ORG",
|
77
71
|
:description => "The organization",
|
78
72
|
:proc => Proc.new { |f| Chef::Config[:knife][:org] = f }
|
@@ -80,22 +74,22 @@ class Chef
|
|
80
74
|
def run
|
81
75
|
$stdout.sync = true
|
82
76
|
|
83
|
-
pool_type = "#{Chef::Config[:knife][:
|
77
|
+
pool_type = "#{Chef::Config[:knife][:pooltype]}".downcase
|
84
78
|
case pool_type
|
85
79
|
when 'managementip'
|
86
80
|
json = { :start_ip => Chef::Config[:knife][:start], :end_ip => Chef::Config[:knife][:end],
|
87
81
|
:subnet_mask => Chef::Config[:knife][:mask], :gateway => Chef::Config[:knife][:gateway] }.to_json
|
88
82
|
|
89
|
-
xml_response = provisioner.
|
83
|
+
xml_response = provisioner.set_management_ip_pool(json)
|
90
84
|
xml_doc = Nokogiri::XML(xml_response)
|
91
85
|
|
92
86
|
xml_doc.xpath("configConfMos/outConfigs/pair/ippoolBlock").each do |ippool|
|
93
87
|
puts ''
|
94
|
-
puts "Management IP Block from: #{ui.color("#{ippool.attributes['from']}", :
|
88
|
+
puts "Management IP Block from: #{ui.color("#{ippool.attributes['from']}", :blue)} to: #{ui.color("#{ippool.attributes['to']}", :blue)}" +
|
95
89
|
" status: #{ui.color("#{ippool.attributes['status']}", :green)}"
|
96
90
|
end
|
97
91
|
|
98
|
-
|
92
|
+
|
99
93
|
xml_doc.xpath("configConfMos").each do |ippool|
|
100
94
|
puts "#{ippool.attributes['errorCode']} #{ui.color("#{ippool.attributes['errorDescr']}", :red)}"
|
101
95
|
end
|
@@ -104,16 +98,16 @@ class Chef
|
|
104
98
|
json = { :mac_pool_name => Chef::Config[:knife][:name], :mac_pool_start => Chef::Config[:knife][:start],
|
105
99
|
:mac_pool_end => Chef::Config[:knife][:end], :org => Chef::Config[:knife][:org] }.to_json
|
106
100
|
|
107
|
-
xml_response = provisioner.
|
101
|
+
xml_response = provisioner.set_mac_pool(json)
|
108
102
|
xml_doc = Nokogiri::XML(xml_response)
|
109
103
|
|
110
104
|
xml_doc.xpath("configConfMos/outConfigs/pair/macpoolPool").each do |macpool|
|
111
105
|
puts ''
|
112
|
-
puts "MAC address pool : #{ui.color("#{macpool.attributes['name']}", :
|
106
|
+
puts "MAC address pool : #{ui.color("#{macpool.attributes['name']}", :blue)}" +
|
113
107
|
" status: #{ui.color("#{macpool.attributes['status']}", :green)}"
|
114
108
|
end
|
115
109
|
|
116
|
-
|
110
|
+
|
117
111
|
xml_doc.xpath("configConfMos").each do |macpool|
|
118
112
|
puts "#{macpool.attributes['errorCode']} #{ui.color("#{macpool.attributes['errorDescr']}", :red)}"
|
119
113
|
end
|
@@ -122,16 +116,16 @@ class Chef
|
|
122
116
|
json = { :wwnn_name => Chef::Config[:knife][:name], :wwnn_from => Chef::Config[:knife][:start],
|
123
117
|
:wwnn_to => Chef::Config[:knife][:end], :org => Chef::Config[:knife][:org] }.to_json
|
124
118
|
|
125
|
-
xml_response = provisioner.
|
119
|
+
xml_response = provisioner.set_wwnn_pool(json)
|
126
120
|
xml_doc = Nokogiri::XML(xml_response)
|
127
121
|
|
128
122
|
xml_doc.xpath("configConfMos/outConfigs/pair/fcpoolInitiators").each do |wwnn|
|
129
123
|
puts ''
|
130
|
-
puts "WWNN pool : #{ui.color("#{wwnn.attributes['name']}", :
|
124
|
+
puts "WWNN pool : #{ui.color("#{wwnn.attributes['name']}", :blue)}" +
|
131
125
|
" status: #{ui.color("#{wwnn.attributes['status']}", :green)}"
|
132
126
|
end
|
133
127
|
|
134
|
-
|
128
|
+
|
135
129
|
xml_doc.xpath("configConfMos").each do |wwnn|
|
136
130
|
puts "#{wwnn.attributes['errorCode']} #{ui.color("#{wwnn.attributes['errorDescr']}", :red)}"
|
137
131
|
end
|
@@ -141,16 +135,16 @@ class Chef
|
|
141
135
|
json = { :wwpn_name => Chef::Config[:knife][:name], :wwpn_from => Chef::Config[:knife][:start],
|
142
136
|
:wwpn_to => Chef::Config[:knife][:end], :org => Chef::Config[:knife][:org] }.to_json
|
143
137
|
|
144
|
-
xml_response = provisioner.
|
138
|
+
xml_response = provisioner.set_wwpn_pool(json)
|
145
139
|
xml_doc = Nokogiri::XML(xml_response)
|
146
140
|
|
147
141
|
xml_doc.xpath("configConfMos/outConfigs/pair/fcpoolInitiators").each do |wwpn|
|
148
142
|
puts ''
|
149
|
-
puts "WWPN pool : #{ui.color("#{wwpn.attributes['name']}", :
|
143
|
+
puts "WWPN pool : #{ui.color("#{wwpn.attributes['name']}", :blue)}" +
|
150
144
|
" status: #{ui.color("#{wwpn.attributes['status']}", :green)}"
|
151
145
|
end
|
152
146
|
|
153
|
-
|
147
|
+
|
154
148
|
xml_doc.xpath("configConfMos").each do |wwpn|
|
155
149
|
puts "#{wwpn.attributes['errorCode']} #{ui.color("#{wwpn.attributes['errorDescr']}", :red)}"
|
156
150
|
end
|
@@ -159,16 +153,16 @@ class Chef
|
|
159
153
|
json = { :uuid_pool_name => Chef::Config[:knife][:name], :uuid_from => Chef::Config[:knife][:start],
|
160
154
|
:uuid_to => Chef::Config[:knife][:end], :org => Chef::Config[:knife][:org] }.to_json
|
161
155
|
|
162
|
-
xml_response = provisioner.
|
156
|
+
xml_response = provisioner.set_uuid_pool(json)
|
163
157
|
xml_doc = Nokogiri::XML(xml_response)
|
164
158
|
|
165
159
|
xml_doc.xpath("configConfMos/outConfigs/pair/uuidpoolPool").each do |uuid|
|
166
160
|
puts ''
|
167
|
-
puts "UUID pool : #{ui.color("#{uuid.attributes['name']}", :
|
161
|
+
puts "UUID pool : #{ui.color("#{uuid.attributes['name']}", :blue)}" +
|
168
162
|
" status: #{ui.color("#{uuid.attributes['status']}", :green)}"
|
169
163
|
end
|
170
164
|
|
171
|
-
|
165
|
+
|
172
166
|
xml_doc.xpath("configConfMos").each do |uuid|
|
173
167
|
puts "#{uuid.attributes['errorCode']} #{ui.color("#{uuid.attributes['errorDescr']}", :red)}"
|
174
168
|
end
|