Class: UCSUpdate
- Inherits:
-
Object
- Object
- UCSUpdate
- Defined in:
- lib/ucslib/update.rb
Overview
- Author
-
Murali Raju (<[email protected]>)
- Copyright
-
Copyright © 2012 Murali Raju.
- License
-
Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Instance Method Summary collapse
-
#initialize(tokenjson) ⇒ UCSUpdate
constructor
A new instance of UCSUpdate.
- #update_boot_policy_on_service_profile_template(json) ⇒ Object
- #update_host_firmware_package(json) ⇒ Object
Constructor Details
#initialize(tokenjson) ⇒ UCSUpdate
Returns a new instance of UCSUpdate.
20 21 22 23 24 25 26 |
# File 'lib/ucslib/update.rb', line 20 def initialize(tokenjson) @cookie = "#{JSON.parse(tokenjson)['cookie']}" ip = "#{JSON.parse(tokenjson)['ip']}" @url = "https://#{ip}/nuova" end |
Instance Method Details
#update_boot_policy_on_service_profile_template(json) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ucslib/update.rb', line 66 def update_boot_policy_on_service_profile_template(json) service_profile_template_name = JSON.parse(json)['service_profile_template_name'] org = JSON.parse(json)['org'] service_profile_template_mgmt_ip_pool = JSON.parse(json)['service_profile_template_mgmt_ip_pool'] service_profile_template_boot_policy = JSON.parse(json)['service_profile_template_boot_policy'] service_profile_template_host_fw_policy = JSON.parse(json)['service_profile_template_host_fw_policy'] service_profile_template_uuid_pool = JSON.parse(json)['service_profile_template_uuid_pool'] xml_builder = Nokogiri::XML::Builder.new do |xml| xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){ xml.inConfigs{ xml.pair('key' => "org-root/org-#{org}/ls-#{service_profile_template_name}"){ xml.lsServer('agentPolicyName' => '', 'biosProfileName' => '', 'bootPolicyName' => "#{service_profile_template_boot_policy}", 'descr' => '', 'dn' => "org-root/org-#{org}/ls-#{service_profile_template_name}", 'dynamicConPolicyName' => '', 'extIPPoolName' => "#{service_profile_template_mgmt_ip_pool}", 'extIPState' => 'none', 'hostFwPolicyName' => "#{service_profile_template_host_fw_policy}", 'identPoolName' => "#{service_profile_template_uuid_pool}", 'localDiskPolicyName' => 'default', 'maintPolicyName' => 'default', 'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => '', 'policyOwner' => 'local', 'powerPolicyName' => 'default', 'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => '', 'statsPolicyName' => 'default', 'status' => 'created,modified', 'usrLbl' => '', 'uuid' => '0', 'vconProfileName' => '') } } } end #Create Template xml update_boot_policy_on_service_profile_template_xml = xml_builder.to_xml.to_s #Post Update Boot Policy on Service Profile Template begin RestClient.post(@url, update_boot_policy_on_service_profile_template_xml, :content_type => 'text/xml').body rescue Exception => e raise "Error #{e}" end end |
#update_host_firmware_package(json) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ucslib/update.rb', line 28 def update_host_firmware_package(json) host_firmware_pkg_name = JSON.parse(json)['host_firmware_pkg_name'] hardware_model = JSON.parse(json)['hardware_model'].to_s hardware_type = JSON.parse(json)['hardware_type'] hardware_vendor = JSON.parse(json)['hardware_vendor'].to_s firmware_version = JSON.parse(json)['firmware_version'].to_s org = JSON.parse(json)['org'] xml_builder = Nokogiri::XML::Builder.new do |xml| xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){ xml.inConfigs{ xml.pair('key' => "org-root/org-#{org}/fw-host-pack-#{host_firmware_pkg_name}"){ xml.firmwareComputeHostPack('descr' => '', 'dn' => "org-root/org-#{org}/fw-host-pack-#{host_firmware_pkg_name}", 'ignoreCompCheck' => 'yes', 'mode' => 'staged', 'stageSize' => '0', 'updateTrigger' => 'immediate'){ xml.firmwarePackItem('hwModel' => "#{hardware_model}", 'hwVendor' => "#{hardware_vendor}", 'rn' => "pack-image-#{hardware_vendor}|#{hardware_model}|#{hardware_type}", 'type' => "#{hardware_type}", 'version' => "#{firmware_version}") } } } } end #Create XML update_host_firmware_packageXML = xml_builder.to_xml.to_s #Post begin RestClient.post(@url, update_host_firmware_packageXML, :content_type => 'text/xml').body rescue Exception => e raise "Error #{e}" end end |