Module: Destroy

Included in:
UCS
Defined in:
lib/ucslib/service/ucs/destroy.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

Instance Method Details

#delete_org(json) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ucslib/service/ucs/destroy.rb', line 20

def delete_org(json)

	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}") {
      xml.orgOrg('dn' => "org-root/org-#{org}", 'status' => 'deleted')
    }
  }
}
end

#Create XML
delete_org_XML= xml_builder.to_xml.to_s

#Post
begin
	RestClient.post(@url, delete_org_XML, :content_type => 'text/xml').body
rescue Exception => e
	raise "Error #{e}"
end

end

#delete_vlan(json) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ucslib/service/ucs/destroy.rb', line 46

def delete_vlan(json)

	vlan_id     = JSON.parse(json)['vlan_id']
	vlan_name   = JSON.parse(json)['vlan_name']

	xml_builder = Nokogiri::XML::Builder.new do |xml|
	  xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
	    xml.inConfigs{
	      xml.pair('key' => "fabric/lan/net-#{vlan_name}"){
	        xml.fabricVlan('dn' => "fabric/lan/net-#{vlan_name}", 'id' => "#{vlan_id}",
	                       'name' => "#{vlan_name}", 'status' => 'deleted')
	      }
	    }
	  }
	end

	#Create XML
	delete_vlan_XML = xml_builder.to_xml.to_s

	#Post
	begin
		RestClient.post(@url, delete_vlan_XML, :content_type => 'text/xml').body
	rescue Exception => e
		raise "Error #{e}"
	end

end