knife-ucs 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -17,7 +17,7 @@ Depending on your system's configuration, you may need to run this command with
17
17
 
18
18
  # Configuration #
19
19
 
20
- In order to communicate with Cisco UCS XMO API you will have to tell Knife the username, password and the IP address of the UCS Manager. The easiest way to accomplish this is to create some entries in your `knife.rb` file:
20
+ In order to communicate with Cisco UCS XML API you will have to tell Knife the username, password and the IP address of the UCS Manager. The easiest way to accomplish this is to create some entries in your `knife.rb` file:
21
21
 
22
22
  knife[:ucsm_username] = "Your UCSM username"
23
23
  knife[:ucsm_password] = "Your UCSM password"
@@ -35,26 +35,7 @@ If your knife.rb file will be checked into a SCM system (ie readable by others)
35
35
 
36
36
  This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a `--help` flag
37
37
 
38
- Examples:
39
-
40
- knife openstack ucs blades list
41
- -----------------------------
42
-
43
- List blade information:
44
-
45
- -> knife ucs blades list
46
- ID Model Serial CPUs Memory[MB] Adaptors EtnernetIfs FCifs Availability Power
47
- 1/6 N20-B6620-1 582 1 4096 1 2 0 available off
48
- 1/2 N20-B6620-1 579 1 4096 1 2 2 available off
49
- 1/7 N20-B6620-1 583 1 4096 1 2 2 available off
50
- 1/8 N20-B6730-1 585 1 8192 1 0 0 unavailable off
51
- 1/1 N20-B6620-1 577 2 8192 1 3 0 unavailable on
52
- 1/5 N20-B6620-1 581 1 4096 1 2 2 available off
53
- 1/3 B230-BASE-M2 578 1 16384 1 2 0 available off
54
- 1/4 N20-B6620-1 580 1 4096 1 2 2 available off
55
- ->
56
-
57
-
38
+ Example usage can be found here -> https://github.com/murraju/knife-ucs/wiki
58
39
 
59
40
  # License #
60
41
 
@@ -63,7 +63,7 @@ class Chef
63
63
  end
64
64
  end
65
65
 
66
- #Intialize Inventory and Provisioner objects
66
+ #Intialize objects
67
67
  def inventory
68
68
  ucs_inventory = UCSInventory.new
69
69
  @inventory ||= begin
@@ -38,7 +38,7 @@ class Chef
38
38
  :short => "-O ORG",
39
39
  :long => "--org ORG",
40
40
  :description => "The sub organization",
41
- :proc => Proc.new { |f| Chef::Config[:knife][:orgs] = f }
41
+ :proc => Proc.new { |f| Chef::Config[:knife][:org] = f }
42
42
 
43
43
 
44
44
  def run
@@ -0,0 +1,186 @@
1
+ # Author:: Murali Raju (<murali.raju@appliv.com>)
2
+ # Copyright:: Copyright (c) 2012 Murali Raju.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'chef/knife/ucs_base'
19
+
20
+ class Chef
21
+ class Knife
22
+ class UcsPoolCreate < Knife
23
+
24
+ include Knife::UCSBase
25
+
26
+ deps do
27
+ require 'readline'
28
+ require 'chef/json_compat'
29
+ require 'chef/knife/bootstrap'
30
+ Chef::Knife::Bootstrap.load_deps
31
+ end
32
+
33
+ banner "knife ucs pool create (options)"
34
+
35
+ attr_accessor :initial_sleep_delay
36
+
37
+ option :pool,
38
+ :short => "-P POOL",
39
+ :long => "--pool POOLTYPE",
40
+ :description => "UCS pool types <mac,uuid,wwpn,wwnn,managementip>",
41
+ :proc => Proc.new { |f| Chef::Config[:knife][:pool] = f }
42
+
43
+ option :name,
44
+ :short => "-N NAME",
45
+ :long => "--pool-name POOLNAME",
46
+ :description => "The pool name",
47
+ :proc => Proc.new { |f| Chef::Config[:knife][:name] = f }
48
+
49
+ option :start,
50
+ :short => "-S START",
51
+ :long => "--pool-start STARTRANGE",
52
+ :description => "Start of a pool range <IP, WWPN, WWNN, MAC>",
53
+ :proc => Proc.new { |f| Chef::Config[:knife][:start] = f }
54
+
55
+ option :end,
56
+ :short => "-E END",
57
+ :long => "--pool-end ENDRANGE",
58
+ :description => "End of a pool range <IP, WWPN, WWNN, MAC>",
59
+ :proc => Proc.new { |f| Chef::Config[:knife][:end] = f }
60
+
61
+
62
+ option :mask,
63
+ :short => "-M MASK",
64
+ :long => "--subnet-mask SUBNETMASK",
65
+ :description => "The subnet mask for an IP range",
66
+ :proc => Proc.new { |f| Chef::Config[:knife][:mask] = f }
67
+
68
+ option :gateway,
69
+ :short => "-G GATEWAY",
70
+ :long => "--gateway IPGATEWAY",
71
+ :description => "The IP Gateway address of a subnet",
72
+ :proc => Proc.new { |f| Chef::Config[:knife][:gateway] = f }
73
+
74
+ option :org,
75
+ :short => "-O ORG",
76
+ :long => "--org ORG",
77
+ :description => "The organization",
78
+ :proc => Proc.new { |f| Chef::Config[:knife][:org] = f }
79
+
80
+ def run
81
+ $stdout.sync = true
82
+
83
+ pool_type = "#{Chef::Config[:knife][:pool]}"
84
+ case pool_type
85
+ when 'managementip'
86
+ json = { :start_ip => Chef::Config[:knife][:start], :end_ip => Chef::Config[:knife][:end],
87
+ :subnet_mask => Chef::Config[:knife][:mask], :gateway => Chef::Config[:knife][:gateway] }.to_json
88
+
89
+ xml_response = provisioner.create_management_ip_pool(json)
90
+ xml_doc = Nokogiri::XML(xml_response)
91
+
92
+ xml_doc.xpath("configConfMos/outConfigs/pair/ippoolBlock").each do |ippool|
93
+ puts ''
94
+ puts "Management IP Block from: #{ui.color("#{ippool.attributes['from']}", :magenta)} to: #{ui.color("#{ippool.attributes['to']}", :magenta)}" +
95
+ " status: #{ui.color("#{ippool.attributes['status']}", :green)}"
96
+ end
97
+
98
+ #Ugly...refactor later to parse error with better exception handling. Nokogiri xpath search for elements might be an option
99
+ xml_doc.xpath("configConfMos").each do |ippool|
100
+ puts "#{ippool.attributes['errorCode']} #{ui.color("#{ippool.attributes['errorDescr']}", :red)}"
101
+ end
102
+
103
+ when 'mac'
104
+ json = { :mac_pool_name => Chef::Config[:knife][:name], :mac_pool_start => Chef::Config[:knife][:start],
105
+ :mac_pool_end => Chef::Config[:knife][:end], :org => Chef::Config[:knife][:org] }.to_json
106
+
107
+ xml_response = provisioner.create_mac_pool(json)
108
+ xml_doc = Nokogiri::XML(xml_response)
109
+
110
+ xml_doc.xpath("configConfMos/outConfigs/pair/macpoolPool").each do |macpool|
111
+ puts ''
112
+ puts "MAC address pool : #{ui.color("#{macpool.attributes['name']}", :magenta)}" +
113
+ " status: #{ui.color("#{macpool.attributes['status']}", :green)}"
114
+ end
115
+
116
+ #Ugly...refactor later to parse error with better exception handling. Nokogiri xpath search for elements might be an option
117
+ xml_doc.xpath("configConfMos").each do |macpool|
118
+ puts "#{macpool.attributes['errorCode']} #{ui.color("#{macpool.attributes['errorDescr']}", :red)}"
119
+ end
120
+
121
+ when 'wwnn'
122
+ json = { :wwnn_name => Chef::Config[:knife][:name], :wwnn_from => Chef::Config[:knife][:start],
123
+ :wwnn_to => Chef::Config[:knife][:end], :org => Chef::Config[:knife][:org] }.to_json
124
+
125
+ xml_response = provisioner.create_wwnn_pool(json)
126
+ xml_doc = Nokogiri::XML(xml_response)
127
+
128
+ xml_doc.xpath("configConfMos/outConfigs/pair/fcpoolInitiators").each do |wwnn|
129
+ puts ''
130
+ puts "WWNN pool : #{ui.color("#{wwnn.attributes['name']}", :magenta)}" +
131
+ " status: #{ui.color("#{wwnn.attributes['status']}", :green)}"
132
+ end
133
+
134
+ #Ugly...refactor later to parse error with better exception handling. Nokogiri xpath search for elements might be an option
135
+ xml_doc.xpath("configConfMos").each do |wwnn|
136
+ puts "#{wwnn.attributes['errorCode']} #{ui.color("#{wwnn.attributes['errorDescr']}", :red)}"
137
+ end
138
+
139
+
140
+ when 'wwpn'
141
+ json = { :wwpn_name => Chef::Config[:knife][:name], :wwpn_from => Chef::Config[:knife][:start],
142
+ :wwpn_to => Chef::Config[:knife][:end], :org => Chef::Config[:knife][:org] }.to_json
143
+
144
+ xml_response = provisioner.create_wwpn_pool(json)
145
+ xml_doc = Nokogiri::XML(xml_response)
146
+
147
+ xml_doc.xpath("configConfMos/outConfigs/pair/fcpoolInitiators").each do |wwpn|
148
+ puts ''
149
+ puts "WWPN pool : #{ui.color("#{wwpn.attributes['name']}", :magenta)}" +
150
+ " status: #{ui.color("#{wwpn.attributes['status']}", :green)}"
151
+ end
152
+
153
+ #Ugly...refactor later to parse error with better exception handling. Nokogiri xpath search for elements might be an option
154
+ xml_doc.xpath("configConfMos").each do |wwpn|
155
+ puts "#{wwpn.attributes['errorCode']} #{ui.color("#{wwpn.attributes['errorDescr']}", :red)}"
156
+ end
157
+
158
+ when 'uuid'
159
+ json = { :uuid_pool_name => Chef::Config[:knife][:name], :uuid_from => Chef::Config[:knife][:start],
160
+ :uuid_to => Chef::Config[:knife][:end], :org => Chef::Config[:knife][:org] }.to_json
161
+
162
+ xml_response = provisioner.create_uuid_pool(json)
163
+ xml_doc = Nokogiri::XML(xml_response)
164
+
165
+ xml_doc.xpath("configConfMos/outConfigs/pair/uuidpoolPool").each do |uuid|
166
+ puts ''
167
+ puts "UUID pool : #{ui.color("#{uuid.attributes['name']}", :magenta)}" +
168
+ " status: #{ui.color("#{uuid.attributes['status']}", :green)}"
169
+ end
170
+
171
+ #Ugly...refactor later to parse error with better exception handling. Nokogiri xpath search for elements might be an option
172
+ xml_doc.xpath("configConfMos").each do |uuid|
173
+ puts "#{uuid.attributes['errorCode']} #{ui.color("#{uuid.attributes['errorDescr']}", :red)}"
174
+ end
175
+
176
+
177
+ else
178
+ puts "Incorrect options. Please make sure you are using one of the following: mac,uuid,wwpn,wwnn,managementip"
179
+ end
180
+
181
+ end
182
+
183
+ end
184
+ end
185
+ end
186
+
@@ -0,0 +1,37 @@
1
+ # Author:: Murali Raju (<murali.raju@appliv.com>)
2
+ # Copyright:: Copyright (c) 2012 Murali Raju.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'chef/knife/ucs_base'
19
+
20
+ class Chef
21
+ class Knife
22
+ class UcsPoolDelete < Knife
23
+
24
+ include Knife::UCSBase
25
+
26
+ banner "knife ucs pool delete (options)"
27
+
28
+ def run
29
+
30
+
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+
@@ -23,7 +23,7 @@ class Chef
23
23
 
24
24
  include Knife::UCSBase
25
25
 
26
- banner "knife ucs serviceprofile delete SERVICEPROFILE [SERVICEPROFILE] (options)"
26
+ banner "knife ucs serviceprofile delete (options)"
27
27
 
28
28
  def run
29
29
 
@@ -0,0 +1,140 @@
1
+ # Author:: Murali Raju (<murali.raju@appliv.com>)
2
+ # Copyright:: Copyright (c) 2012 Murali Raju.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'chef/knife/ucs_base'
19
+
20
+ class Chef
21
+ class Knife
22
+ class UcsSet < Knife
23
+
24
+ include Knife::UCSBase
25
+
26
+ deps do
27
+ require 'readline'
28
+ require 'chef/json_compat'
29
+ require 'chef/knife/bootstrap'
30
+ Chef::Knife::Bootstrap.load_deps
31
+ end
32
+
33
+ banner "knife ucs set (options)"
34
+
35
+ attr_accessor :initial_sleep_delay
36
+
37
+ option :config,
38
+ :long => "--config-item CONFIGIETM",
39
+ :description => "The item to configure which includes ntp, timezone, power, chassis-discovery",
40
+ :proc => Proc.new { |f| Chef::Config[:knife][:config] = f }
41
+
42
+ option :power,
43
+ :long => "--power-policy POLICY",
44
+ :description => "The power policy to use",
45
+ :proc => Proc.new { |f| Chef::Config[:knife][:policy] = f }
46
+
47
+ option :discovery,
48
+ :long => "--chassis-discovery POLICY",
49
+ :description => "The chassis discovery policy",
50
+ :proc => Proc.new { |f| Chef::Config[:knife][:discovery] = f }
51
+
52
+ option :ntp,
53
+ :long => "--ntp-server NTPSERVER",
54
+ :description => "The ntp server to use",
55
+ :proc => Proc.new { |f| Chef::Config[:knife][:ntp] = f }
56
+
57
+ option :timezone,
58
+ :long => "--time-zone TIMEZONE",
59
+ :description => "The timezone for this UCS Domain",
60
+ :proc => Proc.new { |f| Chef::Config[:knife][:timezone] = f }
61
+
62
+
63
+ def run
64
+ $stdout.sync = true
65
+
66
+ config_item = "#{Chef::Config[:knife][:config]}"
67
+ case config_item
68
+ when 'ntp'
69
+ json = { :ntp_server => Chef::Config[:knife][:ntp] }.to_json
70
+
71
+ xml_response = provisioner.set_ntp(json)
72
+ xml_doc = Nokogiri::XML(xml_response)
73
+
74
+ xml_doc.xpath("configConfMos/outConfigs/pair/commNtpProvider").each do |ntp|
75
+ puts ''
76
+ puts "NTP Server: #{ui.color("#{ntp.attributes['name']}", :magenta)} status: #{ui.color("#{ntp.attributes['status']}", :green)}"
77
+ end
78
+
79
+ #Ugly...refactor later to parse error with better exception handling. Nokogiri xpath search for elements might be an option
80
+ xml_doc.xpath("configConfMos").each do |ntp|
81
+ puts "#{ntp.attributes['errorCode']} #{ui.color("#{ntp.attributes['errorDescr']}", :red)}"
82
+ end
83
+
84
+ when 'power'
85
+ json = { :power_policy => Chef::Config[:knife][:policy] }.to_json
86
+
87
+ xml_response = provisioner.set_power_policy(json)
88
+ xml_doc = Nokogiri::XML(xml_response)
89
+
90
+ xml_doc.xpath("configConfMos/outConfigs/pair/computePsuPolicy").each do |power|
91
+ puts ''
92
+ puts "Power Policy: #{ui.color("#{power.attributes['name']}", :magenta)} status: #{ui.color("#{power.attributes['status']}", :green)}"
93
+ end
94
+
95
+ #Ugly...refactor later to parse error with better exception handling. Nokogiri xpath search for elements might be an option
96
+ xml_doc.xpath("configConfMos").each do |power|
97
+ puts "#{power.attributes['errorCode']} #{ui.color("#{power.attributes['errorDescr']}", :red)}"
98
+ end
99
+
100
+ when 'chassis-discovery'
101
+ json = { :chassis_discovery_policy => Chef::Config[:knife][:discovery] }.to_json
102
+
103
+ xml_response = provisioner.set_chassis_discovery_policy(json)
104
+ xml_doc = Nokogiri::XML(xml_response)
105
+
106
+ xml_doc.xpath("configConfMos/outConfigs/pair/computeChassisDiscPolicy").each do |chassis|
107
+ puts ''
108
+ puts "Chassis Discovery Policy: #{ui.color("#{chassis.attributes['action']}", :magenta)} status: #{ui.color("#{chassis.attributes['status']}", :green)}"
109
+ end
110
+
111
+ #Ugly...refactor later to parse error with better exception handling. Nokogiri xpath search for elements might be an option
112
+ xml_doc.xpath("configConfMos").each do |chassis|
113
+ puts "#{chassis.attributes['errorCode']} #{ui.color("#{chassis.attributes['errorDescr']}", :red)}"
114
+ end
115
+
116
+ when 'timezone'
117
+ json = { :time_zone => Chef::Config[:knife][:timezone] }.to_json
118
+
119
+ xml_response = provisioner.set_time_zone(json)
120
+ xml_doc = Nokogiri::XML(xml_response)
121
+
122
+ xml_doc.xpath("configConfMos/outConfigs/pair/commDateTime").each do |timezone|
123
+ puts ''
124
+ puts "Timezone: #{ui.color("#{timezone.attributes['timezone']}", :magenta)} status: #{ui.color("#{timezone.attributes['status']}", :green)}"
125
+ end
126
+
127
+ #Ugly...refactor later to parse error with better exception handling. Nokogiri xpath search for elements might be an option
128
+ xml_doc.xpath("configConfMos").each do |timezone|
129
+ puts "#{timezone.attributes['errorCode']} #{ui.color("#{timezone.attributes['errorDescr']}", :red)}"
130
+ end
131
+ else
132
+ puts ''
133
+ puts "Incorrect options. Please make sure you are using one of the following: ntp,timezone,power,chassis-discovery"
134
+ puts ''
135
+ end
136
+
137
+ end
138
+ end
139
+ end
140
+ end
@@ -39,10 +39,10 @@ class Chef
39
39
  :description => "The VLAN ID",
40
40
  :proc => Proc.new { |f| Chef::Config[:knife][:vlanid] = f }
41
41
 
42
- option :vlanname,
43
- :long => "--vlanname VLANNAME",
44
- :description => "The VLAN NAME",
45
- :proc => Proc.new { |f| Chef::Config[:knife][:vlanname] = f }
42
+ option :vlanname,
43
+ :long => "--vlanname VLANNAME",
44
+ :description => "The VLAN NAME",
45
+ :proc => Proc.new { |f| Chef::Config[:knife][:vlanname] = f }
46
46
 
47
47
  def run
48
48
  $stdout.sync = true
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Ucs
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-ucs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-25 00:00:00.000000000 Z
12
+ date: 2012-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70353196021020 !ruby/object:Gem::Requirement
16
+ requirement: &70249525442200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.5.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70353196021020
24
+ version_requirements: *70249525442200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rest-client
27
- requirement: &70353196018380 !ruby/object:Gem::Requirement
27
+ requirement: &70249525441480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.6.7
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70353196018380
35
+ version_requirements: *70249525441480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ucslib
38
- requirement: &70353196016100 !ruby/object:Gem::Requirement
38
+ requirement: &70249525440780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.0.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70353196016100
46
+ version_requirements: *70249525440780
47
47
  description: Cisco UCS Support for Chef's Knife Command
48
48
  email:
49
49
  - murraju@appliv.com
@@ -65,10 +65,13 @@ files:
65
65
  - lib/chef/knife/ucs_org_create.rb
66
66
  - lib/chef/knife/ucs_org_delete.rb
67
67
  - lib/chef/knife/ucs_orgs_list.rb
68
+ - lib/chef/knife/ucs_pool_create.rb
69
+ - lib/chef/knife/ucs_pool_delete.rb
68
70
  - lib/chef/knife/ucs_runningfirmware_list.rb
69
71
  - lib/chef/knife/ucs_serviceprofile_create.rb
70
72
  - lib/chef/knife/ucs_serviceprofile_delete.rb
71
73
  - lib/chef/knife/ucs_serviceprofiles_list.rb
74
+ - lib/chef/knife/ucs_set.rb
72
75
  - lib/chef/knife/ucs_vlan_create.rb
73
76
  - lib/chef/knife/ucs_vlan_delete.rb
74
77
  - lib/chef/knife/ucs_vlans_list.rb