ucslib 0.1.4 → 0.1.5

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.
data/README.rdoc CHANGED
@@ -1,11 +1,27 @@
1
1
  = ucslib (beta)
2
2
 
3
- Ruby Client Library for Cisco UCS Manager that could be used by DevOps toolchains - Puppet or Chef and other custom tools - to provide MaaS (Metal-as-a-Service) for installing and running OpenStack, Hadoop, etc. ucslib accepts JSON as configuration for provisioning.
3
+ Ruby Client Library for Cisco UCS Manager that could be used by DevOps toolchains - Puppet or Chef and other custom tools in order to provide MaaS (Metal-as-a-Service) for installing and running OpenStack, CloudStack or Hadoop, etc on Cisco UCS. ucslib accepts JSON as configuration.
4
4
 
5
+ To see an example of how ucslib is being used, checkout the ucs and ucs-solo Chef Cookbooks created by Velankani Information Systems, Inc here - https://github.com/velankanisys/chef-cookbooks
5
6
 
6
- ** Version 0.1.1 has been released **
7
+ In addition there is a knife plugin that use ucslib as well - https://github.com/velankanisys/knife-ucs
7
8
 
8
- Major changes:
9
+ ** Version 0.1.5 has been released **
10
+
11
+ 0.1.5:
12
+ Moved update boot policy to Update instead of manage
13
+ Disabled Parser code for now to allow ucslib to work on Debian Squeeze running Ruby1.9.1
14
+
15
+ 0.1.4:
16
+ Bug fixes.
17
+
18
+ 0.1.3:
19
+ Host firmware XML change for UCS 2.1.
20
+
21
+ 0.1.2:
22
+ Bug fixes.
23
+
24
+ 0.1.1:
9
25
 
10
26
  1. Provision has set_ vs create_ methods. Please update your apps.
11
27
  2. Added Manage functions to associate service profiles to server pools
@@ -121,12 +137,8 @@ VLAN: 200 with name: OpenStack-Mgmt
121
137
 
122
138
  == ToDo
123
139
 
124
- Besides Documentation, Documentation, Documentation!
140
+ Documentation, Documentation, Documentation!
125
141
 
126
- 1. Firmware Management
127
- 2. Example implementation (workflow) under examples (in progress)
128
- 3. Server Pools (in progress)
129
- 4. Service Profile Association (in progress)
130
142
 
131
143
 
132
144
  == Contributing to ucslib
data/lib/ucslib/manage.rb CHANGED
@@ -27,12 +27,14 @@ class UCSManage
27
27
 
28
28
 
29
29
  def discover_state
30
-
30
+
31
31
  #Start Build of the Multi-Class XML for interogating state
32
32
  xml_builder = Nokogiri::XML::Builder.new do |xml|
33
33
  xml.configResolveClasses('cookie' => @cookie, 'inHierarchical' => 'false') {
34
34
  xml.inIds{
35
35
  xml.classId("value" => "macpoolPooled")
36
+ xml.classId("value" => "uuidpoolPooled")
37
+ xml.classId("value" => "fcpoolInitiator")
36
38
  }
37
39
  }
38
40
  end
@@ -42,13 +44,13 @@ class UCSManage
42
44
  ucs_multi_class_state_xml = xml_builder.to_xml.to_s
43
45
  ucs_response_multi_class_state = RestClient.post(@url, ucs_multi_class_state_xml, :content_type => 'text/xml').body
44
46
 
45
- #Uncomment the following to create a dump to review and debug elements
46
- # fh = File.new("ucs_response_multiclass_state.xml", "w")
47
- # fh.puts ucs_response_multi_class_state.inspect
48
- # fh.close
49
-
50
- Nokogiri::XML(ucs_response_multi_class_state)
51
-
47
+ #Uncomment the following to create a dump to review and debug elements
48
+ # fh = File.new("ucs_response_multiclass_state.xml", "w")
49
+ # fh.puts ucs_response_multi_class_state.inspect
50
+ # fh.close
51
+
52
+ Nokogiri::XML(ucs_response_multi_class_state)
53
+
52
54
  end
53
55
 
54
56
 
@@ -59,8 +61,8 @@ class UCSManage
59
61
  service_profile_mgmt_fw_policy = JSON.parse(json)['service_profile_mgmt_fw_policy']
60
62
  service_profile_uuid_pool = JSON.parse(json)['service_profile_uuid_pool']
61
63
  service_profile_template_to_bind = JSON.parse(json)['service_profile_template_to_bind']
62
- service_profile_server_pool = JSON.parse(json)['service_profile_server_pool']
63
- org = JSON.parse(json)['org']
64
+ service_profile_server_pool = JSON.parse(json)['service_profile_server_pool']
65
+ org = JSON.parse(json)['org']
64
66
 
65
67
 
66
68
  xml_builder = Nokogiri::XML::Builder.new do |xml|
@@ -91,6 +93,7 @@ class UCSManage
91
93
  rescue Exception => e
92
94
  raise "Error #{e}"
93
95
  end
94
-
96
+
95
97
  end
98
+
96
99
  end
data/lib/ucslib/parser.rb CHANGED
@@ -15,22 +15,22 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require 'nokogiri'
19
-
20
- class UCSParser
21
- class Nokogiri::XML::Node
22
- TYPENAMES = {1=>'element',2=>'attribute',3=>'text',4=>'cdata',8=>'comment'}
23
- def to_hash
24
- {kind:TYPENAMES[node_type],name:name}.tap do |h|
25
- h.merge! nshref:namespace.href, nsprefix:namespace.prefix if namespace
26
- h.merge! text:text
27
- h.merge! attr:attribute_nodes.map(&:to_hash) if element?
28
- h.merge! kids:children.map(&:to_hash) if element?
29
- end
30
- end
31
- end
32
- class Nokogiri::XML::Document
33
- def to_hash; root.to_hash; end
34
- end
35
-
36
- end
18
+ # require 'nokogiri'
19
+ #
20
+ # class UCSParser
21
+ # class Nokogiri::XML::Node
22
+ # TYPENAMES = {1=>'element',2=>'attribute',3=>'text',4=>'cdata',8=>'comment'}
23
+ # def to_hash
24
+ # {kind:TYPENAMES[node_type],name:name}.tap do |h|
25
+ # h.merge! nshref:namespace.href, nsprefix:namespace.prefix if namespace
26
+ # h.merge! text:text
27
+ # h.merge! attr:attribute_nodes.map(&:to_hash) if element?
28
+ # h.merge! kids:children.map(&:to_hash) if element?
29
+ # end
30
+ # end
31
+ # end
32
+ # class Nokogiri::XML::Document
33
+ # def to_hash; root.to_hash; end
34
+ # end
35
+ #
36
+ # end
data/lib/ucslib/update.rb CHANGED
@@ -63,5 +63,41 @@ class UCSUpdate
63
63
 
64
64
  end
65
65
 
66
+ def update_boot_policy_on_service_profile_template(json)
67
+
68
+ service_profile_template_name = JSON.parse(json)['service_profile_template_name']
69
+ org = JSON.parse(json)['org']
70
+ service_profile_template_mgmt_ip_pool = JSON.parse(json)['service_profile_template_mgmt_ip_pool']
71
+ service_profile_template_boot_policy = JSON.parse(json)['service_profile_template_boot_policy']
72
+ service_profile_template_host_fw_policy = JSON.parse(json)['service_profile_template_host_fw_policy']
73
+ service_profile_template_uuid_pool = JSON.parse(json)['service_profile_template_uuid_pool']
74
+
75
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
76
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
77
+ xml.inConfigs{
78
+ xml.pair('key' => "org-root/org-#{org}/ls-#{service_profile_template_name}"){
79
+ xml.lsServer('agentPolicyName' => '', 'biosProfileName' => '', 'bootPolicyName' => "#{service_profile_template_boot_policy}",
80
+ 'descr' => '', 'dn' => "org-root/org-#{org}/ls-#{service_profile_template_name}",
81
+ 'dynamicConPolicyName' => '', 'extIPPoolName' => "#{service_profile_template_mgmt_ip_pool}",
82
+ 'extIPState' => 'none', 'hostFwPolicyName' => "#{service_profile_template_host_fw_policy}",
83
+ 'identPoolName' => "#{service_profile_template_uuid_pool}", 'localDiskPolicyName' => 'default', 'maintPolicyName' => 'default',
84
+ 'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => '', 'policyOwner' => 'local',
85
+ 'powerPolicyName' => 'default', 'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => '', 'statsPolicyName' => 'default',
86
+ 'status' => 'created,modified', 'usrLbl' => '', 'uuid' => '0', 'vconProfileName' => '')
87
+ }
88
+ }
89
+ }
90
+ end
91
+ #Create Template xml
92
+ update_boot_policy_on_service_profile_template_xml = xml_builder.to_xml.to_s
93
+
94
+ #Post Update Boot Policy on Service Profile Template
95
+ begin
96
+ RestClient.post(@url, update_boot_policy_on_service_profile_template_xml, :content_type => 'text/xml').body
97
+ rescue Exception => e
98
+ raise "Error #{e}"
99
+ end
100
+
101
+ end
66
102
 
67
103
  end
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module Ucslib
19
- VERSION = "0.1.4"
19
+ VERSION = "0.1.5"
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ucslib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-04 00:00:00.000000000 Z
12
+ date: 2012-12-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri