ucslib 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ucslib/destroyer.rb +84 -0
- data/lib/ucslib/inventory.rb +1 -1
- data/lib/ucslib/provision.rb +21 -20
- data/lib/ucslib/version.rb +1 -1
- data/lib/ucslib.rb +1 -0
- metadata +9 -8
@@ -0,0 +1,84 @@
|
|
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
|
+
class UCSDestroy
|
19
|
+
|
20
|
+
def initialize(tokenjson)
|
21
|
+
|
22
|
+
@cookie = "#{JSON.parse(tokenjson)['cookie']}"
|
23
|
+
ip = "#{JSON.parse(tokenjson)['ip']}"
|
24
|
+
@url = "https://#{ip}/nuova"
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def delete_org(json)
|
30
|
+
|
31
|
+
org = JSON.parse(json)['org']
|
32
|
+
|
33
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
34
|
+
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false') {
|
35
|
+
xml.inConfigs{
|
36
|
+
xml.pair('key' => "org-root/org-#{org}") {
|
37
|
+
xml.orgOrg('dn' => "org-root/org-#{org}", 'status' => 'deleted')
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
#Create XML
|
44
|
+
delete_org_XML= xml_builder.to_xml.to_s
|
45
|
+
|
46
|
+
#Post
|
47
|
+
|
48
|
+
begin
|
49
|
+
RestClient.post(@url, delete_org_XML, :content_type => 'text/xml').body
|
50
|
+
rescue Exception => e
|
51
|
+
raise "Error #{e}"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def delete_vlan(json)
|
57
|
+
|
58
|
+
vlan_id = JSON.parse(json)['vlan_id']
|
59
|
+
vlan_name = JSON.parse(json)['vlan_name']
|
60
|
+
|
61
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
62
|
+
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
|
63
|
+
xml.inConfigs{
|
64
|
+
xml.pair('key' => "fabric/lan/net-#{vlan_name}"){
|
65
|
+
xml.fabricVlan('dn' => "fabric/lan/net-#{vlan_name}", 'id' => "#{vlan_id}",
|
66
|
+
'name' => "#{vlan_name}", 'status' => 'deleted')
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
#Create XML
|
73
|
+
delete_vlan_XML = xml_builder.to_xml.to_s
|
74
|
+
|
75
|
+
#Post
|
76
|
+
begin
|
77
|
+
RestClient.post(@url, delete_vlan_XML, :content_type => 'text/xml').body
|
78
|
+
rescue Exception => e
|
79
|
+
raise "Error #{e}"
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
data/lib/ucslib/inventory.rb
CHANGED
@@ -77,7 +77,7 @@ class UCSInventory
|
|
77
77
|
|
78
78
|
#Uncomment the following to create a dump to review and debug elements
|
79
79
|
# fh = File.new("ucs_response_multiclass.xml", "w")
|
80
|
-
# fh.puts
|
80
|
+
# fh.puts ucs_response_multi_class.inspect
|
81
81
|
# fh.close
|
82
82
|
|
83
83
|
return Nokogiri::XML(ucs_response_multi_class)
|
data/lib/ucslib/provision.rb
CHANGED
@@ -277,26 +277,27 @@ class UCSProvision
|
|
277
277
|
|
278
278
|
org = JSON.parse(json)['org']
|
279
279
|
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
280
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
281
|
+
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true') {
|
282
|
+
xml.inConfigs{
|
283
|
+
xml.pair('key' => "org-root/org-#{org}") {
|
284
|
+
xml.orgOrg('descr' => "#{org} org", 'dn' => "org-root/org-#{org}", 'name' => "#{org}", 'status' => 'created')
|
285
|
+
}
|
286
|
+
}
|
287
|
+
}
|
288
|
+
end
|
289
|
+
|
290
|
+
#Create XML
|
291
|
+
create_org_XML= xml_builder.to_xml.to_s
|
292
|
+
|
293
|
+
#Post
|
294
|
+
|
295
|
+
begin
|
296
|
+
RestClient.post(@url, create_org_XML, :content_type => 'text/xml').body
|
297
|
+
rescue Exception => e
|
298
|
+
raise "Error #{e}"
|
299
|
+
end
|
300
|
+
|
300
301
|
|
301
302
|
end
|
302
303
|
|
data/lib/ucslib/version.rb
CHANGED
data/lib/ucslib.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.9
|
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-
|
12
|
+
date: 2012-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &70159780134300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70159780134300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rest-client
|
27
|
-
requirement: &
|
27
|
+
requirement: &70159780133380 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70159780133380
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70159780132460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70159780132460
|
47
47
|
description: Ruby Client Library for Cisco UCS Manager that can be used by DevOps
|
48
48
|
toolchains (Chef/Puppet or others) to provide hardware deployment automation
|
49
49
|
email:
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- html/lib/ucslib_rb.html
|
96
96
|
- html/rdoc.css
|
97
97
|
- lib/ucslib.rb
|
98
|
+
- lib/ucslib/destroyer.rb
|
98
99
|
- lib/ucslib/inventory.rb
|
99
100
|
- lib/ucslib/provision.rb
|
100
101
|
- lib/ucslib/session.rb
|