ucslib 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +151 -0
- data/README.rdoc +88 -101
- data/lib/ucslib/Gemfile +4 -0
- data/lib/ucslib/{destroy.rb → service/ucs/destroy.rb} +3 -12
- data/lib/ucslib/{inventory.rb → service/ucs/inventory.rb} +34 -31
- data/lib/ucslib/{manage.rb → service/ucs/manage.rb} +14 -22
- data/lib/ucslib/{parser.rb → service/ucs/parser.rb} +19 -19
- data/lib/ucslib/{provision.rb → service/ucs/provision.rb} +59 -66
- data/lib/ucslib/service/ucs/session.rb +110 -0
- data/lib/ucslib/{stats.rb → service/ucs/stats.rb} +21 -1
- data/lib/ucslib/service/ucs/ucs.rb +70 -0
- data/lib/ucslib/{update.rb → service/ucs/update.rb} +9 -17
- data/lib/ucslib/version.rb +2 -1
- data/lib/ucslib.rb +3 -8
- metadata +26 -71
- data/.gitignore +0 -4
- data/Gemfile +0 -4
- data/html/README_rdoc.html +0 -226
- data/html/UCSInventory.html +0 -533
- data/html/UCSProvision.html +0 -1914
- data/html/UCSToken.html +0 -338
- data/html/Ucslib.html +0 -173
- data/html/created.rid +0 -7
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +0 -273
- data/html/js/darkfish.js +0 -116
- data/html/js/jquery.js +0 -32
- data/html/js/quicksearch.js +0 -114
- data/html/js/thickbox-compressed.js +0 -10
- data/html/lib/ucslib/inventory_rb.html +0 -75
- data/html/lib/ucslib/provision_rb.html +0 -75
- data/html/lib/ucslib/session_rb.html +0 -75
- data/html/lib/ucslib/version_rb.html +0 -75
- data/html/lib/ucslib_rb.html +0 -89
- data/html/rdoc.css +0 -763
- data/lib/ucslib/session.rb +0 -108
- data/ucslib.gemspec +0 -45
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0172126a4b6154c64708a1484a9b2893d11344e6
|
4
|
+
data.tar.gz: 36511401b59e7332222d10a8fb92559438e49ad5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b9d31b08263cbb3e164445c7cf11b624f92d7ac11b799779ad848e765af88837768aaadf55611a46742a72b3e683457a8aba11b54014da97f4729c6b633e1cc0
|
7
|
+
data.tar.gz: e1ec6b08d119ac16266d80a67959af5308e28e23f433c8831e9480520cac479a17a2b0cf3564dcb84829c88dbeb977d3c294ed588aec81da96fcf1f26cad81b1
|
data/README.md
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
## ucslib (beta)
|
2
|
+
|
3
|
+
Ruby Client Library for Cisco UCS Manager that could be used for Infrastructure Automation.
|
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
|
6
|
+
|
7
|
+
In addition there is a knife plugin that use ucslib as well - https://github.com/velankanisys/knife-ucs
|
8
|
+
|
9
|
+
** Version 0.1.8 has been released **
|
10
|
+
|
11
|
+
0.1.8
|
12
|
+
|
13
|
+
Namespace updates (clean up) and support for ruby 2.1.0
|
14
|
+
|
15
|
+
0.1.7
|
16
|
+
Multi-chassis server pool creation
|
17
|
+
|
18
|
+
0.1.6:
|
19
|
+
Set syslog server implemented in provisioner
|
20
|
+
|
21
|
+
0.1.5:
|
22
|
+
Moved update boot policy to Update instead of manage
|
23
|
+
Disabled Parser code for now to allow ucslib to work on Debian Squeeze running Ruby1.9.1
|
24
|
+
|
25
|
+
0.1.4:
|
26
|
+
Bug fixes.
|
27
|
+
|
28
|
+
0.1.3:
|
29
|
+
Host firmware XML change for UCS 2.1.
|
30
|
+
|
31
|
+
0.1.2:
|
32
|
+
Bug fixes.
|
33
|
+
|
34
|
+
0.1.1:
|
35
|
+
|
36
|
+
1. Provision has set_ vs create_ methods. Please update your apps.
|
37
|
+
2. Added Manage functions to associate service profiles to server pools
|
38
|
+
|
39
|
+
## Install
|
40
|
+
|
41
|
+
gem install ucslib
|
42
|
+
|
43
|
+
## Usage (example pry session)
|
44
|
+
|
45
|
+
[1] pry(main)> require 'ucslib'
|
46
|
+
=> true
|
47
|
+
[2] pry(main)> authjson = { :username => 'admin', :password => 'admin', :ip => '172.16.192.175' }.to_json
|
48
|
+
=> "{\"username\":\"admin\",\"password\":\"admin\",\"ip\":\"172.16.192.175\"}"
|
49
|
+
[3] pry(main)> ucs = UCS.new(authjson)
|
50
|
+
Your credentials are username: admin password: admin ip: 172.16.192.175 url https://172.16.192.175/nuova
|
51
|
+
=> #<UCS:0x007fd269d1eb18>
|
52
|
+
[4] pry(main)> token = ucs.get_token(authjson)
|
53
|
+
=> "{\"cookie\":\"1398284131/87cdd12e-7cb4-4e0d-b39d-e39a827e3870\",\"username\":\"admin\",\"password\":\"admin\",\"ip\":\"172.16.192.175\"}"
|
54
|
+
[5] pry(main)> inventory = ucs.discover(token)
|
55
|
+
|
56
|
+
Hit q to quit
|
57
|
+
|
58
|
+
=> #(Document:0x3fd4a6f99e70 {
|
59
|
+
name = "document",
|
60
|
+
children = [
|
61
|
+
#(Element:0x3fd4a6f9954c {
|
62
|
+
name = "configResolveClasses",
|
63
|
+
attributes = [
|
64
|
+
#(Attr:0x3fd4a6f99254 {
|
65
|
+
name = "cookie",
|
66
|
+
value = "1398284407/c298b159-0cee-434a-ae55-c116b8cd19fe"
|
67
|
+
}),
|
68
|
+
#(Attr:0x3fd4a6f99240 { name = "response", value = "yes" })],
|
69
|
+
children = [
|
70
|
+
#(Text " "),
|
71
|
+
#(Element:0x3fd4a6fa1b20 {
|
72
|
+
name = "outConfigs",
|
73
|
+
children = [
|
74
|
+
#(Text " "),
|
75
|
+
#(Element:0x3fd4a6fa10d0 {
|
76
|
+
name = "topSystem",
|
77
|
+
attributes = [
|
78
|
+
#(Attr:0x3fd4a6fa0e3c {
|
79
|
+
name = "address",
|
80
|
+
value = "172.16.192.175"
|
81
|
+
}),
|
82
|
+
#(Attr:0x3fd4a6fa0e28 {
|
83
|
+
name = "currentTime",
|
84
|
+
value = "2014-04-23T20:29:13.906"
|
85
|
+
}),
|
86
|
+
#(Attr:0x3fd4a6fa0e14 { name = "descr", value = "" }),
|
87
|
+
#(Attr:0x3fd4a6fa0e00 { name = "dn", value = "sys" }),
|
88
|
+
#(Attr:0x3fd4a6fa0dec { name = "ipv6Addr", value = "::" }),
|
89
|
+
#(Attr:0x3fd4a6fa0dd8 { name = "mode", value = "cluster" }),
|
90
|
+
#(Attr:0x3fd4a6fa0dc4 {
|
91
|
+
name = "name",
|
92
|
+
value = "UCSPE-172-16-192-175"
|
93
|
+
}),
|
94
|
+
#(Attr:0x3fd4a6fa0db0 { name = "owner", value = "" }),
|
95
|
+
#(Attr:0x3fd4a6fa0d9c { name = "site", value = "" }),
|
96
|
+
#(Attr:0x3fd4a6fa0d88 {
|
97
|
+
name = "systemUpTime",
|
98
|
+
value = "00:06:18:58"
|
99
|
+
[6] pry(main)>ucs.list_blades(inventory)
|
100
|
+
Blade : 1/1 model: N20-B6620-1 with serial: 3324 is powered: on
|
101
|
+
Blade : 1/2 model: N20-B6620-1 with serial: 3325 is powered: on
|
102
|
+
Blade : 1/5 model: UCSB-B200-M3 with serial: 3327 is powered: on
|
103
|
+
Blade : 1/6 model: N20-B6625-1 with serial: 3328 is powered: on
|
104
|
+
Blade : 1/3 model: N20-B6620-2 with serial: 3326 is powered: on
|
105
|
+
Blade : 1/7 model: N20-B6740-2 with serial: 3329 is powered: on
|
106
|
+
=> 0
|
107
|
+
[7] pry(main)>vlan200 = { :vlan_id => '200', :vlan_name => 'OpenStack-Mgmt' }.to_json
|
108
|
+
=> "{\"vlan_id\":\"200\",\"vlan_name\":\"OpenStack-Mgmt\"}"
|
109
|
+
[8] pry(main)> ucs.set_vlan(vlan200)
|
110
|
+
=> " <configConfMos cookie=\"1398291606/fe13664b-b79d-4ac7-9d0f-98cedffd1c5e\" response=\"yes\"> <outConfigs> <pair key=\"fabric/lan/net-OpenStack-Mgmt\"> <fabricVlan childAction=\"deleteNonPresent\" cloud=\"ethlan\" compressionType=\"included\" configIssues=\"\" defaultNet=\"no\" dn=\"fabric/lan/net-OpenStack-Mgmt\" epDn=\"\" fltAggr=\"0\" global=\"0\" id=\"200\" ifRole=\"network\" ifType=\"virtual\" local=\"0\" locale=\"external\" mcastPolicyName=\"\" name=\"OpenStack-Mgmt\" operMcastPolicyName=\"\" operState=\"ok\" peerDn=\"\" policyOwner=\"local\" pubNwDn=\"\" pubNwId=\"1\" pubNwName=\"\" sharing=\"none\" status=\"created\" switchId=\"dual\" transport=\"ether\" type=\"lan\"/> </pair> </outConfigs> </configConfMos>"
|
111
|
+
[9] pry(main)> ucs.delete_vlan(vlan200)
|
112
|
+
=> " <configConfMos cookie=\"1398291606/fe13664b-b79d-4ac7-9d0f-98cedffd1c5e\" response=\"yes\"> <outConfigs> <pair key=\"fabric/lan/net-OpenStack-Mgmt\"> <fabricVlan cloud=\"ethlan\" compressionType=\"included\" configIssues=\"\" defaultNet=\"no\" dn=\"fabric/lan/net-OpenStack-Mgmt\" epDn=\"\" fltAggr=\"0\" global=\"0\" id=\"200\" ifRole=\"network\" ifType=\"virtual\" local=\"0\" locale=\"external\" mcastPolicyName=\"\" name=\"OpenStack-Mgmt\" operMcastPolicyName=\"org-root/mc-policy-default\" operState=\"ok\" peerDn=\"\" policyOwner=\"local\" pubNwDn=\"\" pubNwId=\"1\" pubNwName=\"\" sharing=\"none\" status=\"deleted\" switchId=\"dual\" transport=\"ether\" type=\"lan\"/> </pair> </outConfigs> </configConfMos>"
|
113
|
+
[10] pry(main)>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
Just do "require ucslib" in your apps. Below is an IRB session to highlight some capabilities.
|
118
|
+
|
119
|
+
|
120
|
+
## Features
|
121
|
+
|
122
|
+
1. List inventory of UCS components
|
123
|
+
2. Provision - turn up ports, create port channels, pools, service profiles
|
124
|
+
3. Retrieve stats
|
125
|
+
|
126
|
+
## Issues and Project Management
|
127
|
+
|
128
|
+
Checkout [Pivotal Tracker][1]
|
129
|
+
|
130
|
+
|
131
|
+
## ToDo
|
132
|
+
|
133
|
+
Documentation, Documentation, Documentation!
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
## Contributing to ucslib
|
138
|
+
|
139
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
140
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
141
|
+
* Start a feature/bugfix branch.
|
142
|
+
* Commit and push until you are happy with your contribution.
|
143
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
144
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
145
|
+
|
146
|
+
## Copyright
|
147
|
+
|
148
|
+
Copyright (c) 2012 - 2014 Murali Raju. See LICENSE.txt for further details.
|
149
|
+
|
150
|
+
[1]: https://www.pivotaltracker.com/s/projects/1065870
|
151
|
+
|
data/README.rdoc
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
-
|
1
|
+
== ucslib (beta)
|
2
2
|
|
3
|
-
Ruby Client Library for Cisco UCS Manager that could be used
|
3
|
+
Ruby Client Library for Cisco UCS Manager that could be used for Infrastructure Automation.
|
4
4
|
|
5
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
|
6
6
|
|
7
7
|
In addition there is a knife plugin that use ucslib as well - https://github.com/velankanisys/knife-ucs
|
8
8
|
|
9
|
-
** Version 0.1.
|
9
|
+
** Version 0.1.8 has been released **
|
10
|
+
|
11
|
+
0.1.8
|
12
|
+
|
13
|
+
Namespace updates (clean up) and support for ruby 2.1.0
|
10
14
|
|
11
15
|
0.1.7
|
12
16
|
Multi-chassis server pool creation
|
@@ -18,7 +22,7 @@ Set syslog server implemented in provisioner
|
|
18
22
|
Moved update boot policy to Update instead of manage
|
19
23
|
Disabled Parser code for now to allow ucslib to work on Debian Squeeze running Ruby1.9.1
|
20
24
|
|
21
|
-
0.1.4:
|
25
|
+
0.1.4:
|
22
26
|
Bug fixes.
|
23
27
|
|
24
28
|
0.1.3:
|
@@ -36,104 +40,82 @@ Bug fixes.
|
|
36
40
|
|
37
41
|
gem install ucslib
|
38
42
|
|
39
|
-
== Usage (example
|
43
|
+
== Usage (example pry session)
|
44
|
+
|
45
|
+
[1] pry(main)> require 'ucslib'
|
46
|
+
=> true
|
47
|
+
[2] pry(main)> authjson = { :username => 'admin', :password => 'admin', :ip => '172.16.192.175' }.to_json
|
48
|
+
=> "{\"username\":\"admin\",\"password\":\"admin\",\"ip\":\"172.16.192.175\"}"
|
49
|
+
[3] pry(main)> ucs = UCS.new(authjson)
|
50
|
+
Your credentials are username: admin password: admin ip: 172.16.192.175 url https://172.16.192.175/nuova
|
51
|
+
=> #<UCS:0x007fd269d1eb18>
|
52
|
+
[4] pry(main)> token = ucs.get_token(authjson)
|
53
|
+
=> "{\"cookie\":\"1398284131/87cdd12e-7cb4-4e0d-b39d-e39a827e3870\",\"username\":\"admin\",\"password\":\"admin\",\"ip\":\"172.16.192.175\"}"
|
54
|
+
[5] pry(main)> inventory = ucs.discover(token)
|
55
|
+
|
56
|
+
Hit q to quit
|
57
|
+
|
58
|
+
=> #(Document:0x3fd4a6f99e70 {
|
59
|
+
name = "document",
|
60
|
+
children = [
|
61
|
+
#(Element:0x3fd4a6f9954c {
|
62
|
+
name = "configResolveClasses",
|
63
|
+
attributes = [
|
64
|
+
#(Attr:0x3fd4a6f99254 {
|
65
|
+
name = "cookie",
|
66
|
+
value = "1398284407/c298b159-0cee-434a-ae55-c116b8cd19fe"
|
67
|
+
}),
|
68
|
+
#(Attr:0x3fd4a6f99240 { name = "response", value = "yes" })],
|
69
|
+
children = [
|
70
|
+
#(Text " "),
|
71
|
+
#(Element:0x3fd4a6fa1b20 {
|
72
|
+
name = "outConfigs",
|
73
|
+
children = [
|
74
|
+
#(Text " "),
|
75
|
+
#(Element:0x3fd4a6fa10d0 {
|
76
|
+
name = "topSystem",
|
77
|
+
attributes = [
|
78
|
+
#(Attr:0x3fd4a6fa0e3c {
|
79
|
+
name = "address",
|
80
|
+
value = "172.16.192.175"
|
81
|
+
}),
|
82
|
+
#(Attr:0x3fd4a6fa0e28 {
|
83
|
+
name = "currentTime",
|
84
|
+
value = "2014-04-23T20:29:13.906"
|
85
|
+
}),
|
86
|
+
#(Attr:0x3fd4a6fa0e14 { name = "descr", value = "" }),
|
87
|
+
#(Attr:0x3fd4a6fa0e00 { name = "dn", value = "sys" }),
|
88
|
+
#(Attr:0x3fd4a6fa0dec { name = "ipv6Addr", value = "::" }),
|
89
|
+
#(Attr:0x3fd4a6fa0dd8 { name = "mode", value = "cluster" }),
|
90
|
+
#(Attr:0x3fd4a6fa0dc4 {
|
91
|
+
name = "name",
|
92
|
+
value = "UCSPE-172-16-192-175"
|
93
|
+
}),
|
94
|
+
#(Attr:0x3fd4a6fa0db0 { name = "owner", value = "" }),
|
95
|
+
#(Attr:0x3fd4a6fa0d9c { name = "site", value = "" }),
|
96
|
+
#(Attr:0x3fd4a6fa0d88 {
|
97
|
+
name = "systemUpTime",
|
98
|
+
value = "00:06:18:58"
|
99
|
+
[6] pry(main)>ucs.list_blades(inventory)
|
100
|
+
Blade : 1/1 model: N20-B6620-1 with serial: 3324 is powered: on
|
101
|
+
Blade : 1/2 model: N20-B6620-1 with serial: 3325 is powered: on
|
102
|
+
Blade : 1/5 model: UCSB-B200-M3 with serial: 3327 is powered: on
|
103
|
+
Blade : 1/6 model: N20-B6625-1 with serial: 3328 is powered: on
|
104
|
+
Blade : 1/3 model: N20-B6620-2 with serial: 3326 is powered: on
|
105
|
+
Blade : 1/7 model: N20-B6740-2 with serial: 3329 is powered: on
|
106
|
+
=> 0
|
107
|
+
[7] pry(main)>vlan200 = { :vlan_id => '200', :vlan_name => 'OpenStack-Mgmt' }.to_json
|
108
|
+
=> "{\"vlan_id\":\"200\",\"vlan_name\":\"OpenStack-Mgmt\"}"
|
109
|
+
[8] pry(main)> ucs.set_vlan(vlan200)
|
110
|
+
=> " <configConfMos cookie=\"1398291606/fe13664b-b79d-4ac7-9d0f-98cedffd1c5e\" response=\"yes\"> <outConfigs> <pair key=\"fabric/lan/net-OpenStack-Mgmt\"> <fabricVlan childAction=\"deleteNonPresent\" cloud=\"ethlan\" compressionType=\"included\" configIssues=\"\" defaultNet=\"no\" dn=\"fabric/lan/net-OpenStack-Mgmt\" epDn=\"\" fltAggr=\"0\" global=\"0\" id=\"200\" ifRole=\"network\" ifType=\"virtual\" local=\"0\" locale=\"external\" mcastPolicyName=\"\" name=\"OpenStack-Mgmt\" operMcastPolicyName=\"\" operState=\"ok\" peerDn=\"\" policyOwner=\"local\" pubNwDn=\"\" pubNwId=\"1\" pubNwName=\"\" sharing=\"none\" status=\"created\" switchId=\"dual\" transport=\"ether\" type=\"lan\"/> </pair> </outConfigs> </configConfMos>"
|
111
|
+
[9] pry(main)> ucs.delete_vlan(vlan200)
|
112
|
+
=> " <configConfMos cookie=\"1398291606/fe13664b-b79d-4ac7-9d0f-98cedffd1c5e\" response=\"yes\"> <outConfigs> <pair key=\"fabric/lan/net-OpenStack-Mgmt\"> <fabricVlan cloud=\"ethlan\" compressionType=\"included\" configIssues=\"\" defaultNet=\"no\" dn=\"fabric/lan/net-OpenStack-Mgmt\" epDn=\"\" fltAggr=\"0\" global=\"0\" id=\"200\" ifRole=\"network\" ifType=\"virtual\" local=\"0\" locale=\"external\" mcastPolicyName=\"\" name=\"OpenStack-Mgmt\" operMcastPolicyName=\"org-root/mc-policy-default\" operState=\"ok\" peerDn=\"\" policyOwner=\"local\" pubNwDn=\"\" pubNwId=\"1\" pubNwName=\"\" sharing=\"none\" status=\"deleted\" switchId=\"dual\" transport=\"ether\" type=\"lan\"/> </pair> </outConfigs> </configConfMos>"
|
113
|
+
[10] pry(main)>
|
40
114
|
|
41
115
|
|
42
|
-
Just do "require ucslib" in your apps. Below is an IRB session to highlight some capabilities.
|
43
116
|
|
117
|
+
Just do "require ucslib" in your apps. Below is an IRB session to highlight some capabilities.
|
44
118
|
|
45
|
-
➜ ucslib git:(master) ✗ irb
|
46
|
-
|
47
|
-
1.9.3p194 :001 > require 'ucslib'
|
48
|
-
=> true
|
49
|
-
1.9.3p194 :002 > auth_json = { :username => 'admin', :password => 'admin', :ip => '172.16.75.137' }.to_json
|
50
|
-
=> "{\"username\":\"admin\",\"password\":\"admin\",\"ip\":\"172.16.75.137\"}"
|
51
|
-
1.9.3p194 :003 > ucs_session = UCSToken.new
|
52
|
-
=> #<UCSToken:0x007ff4d92062c0>
|
53
|
-
1.9.3p194 :004 > token_json = ucs_session.get_token(auth_json)
|
54
|
-
=> "{\"cookie\":\"1336941096/ea496248-d200-4a10-8e46-c73b59971864\",\"username\":\"admin\",\"password\":\"admin\",\"ip\":\"172.16.75.137\"}"
|
55
|
-
1.9.3p194 :005 > ucs_inventory = UCSInventory.new
|
56
|
-
=> #<UCSInventory:0x007ff4d92cd8c0>
|
57
|
-
1.9.3p194 :006 > ucs_provision = UCSProvision.new(token_json)
|
58
|
-
=> #<UCSProvision:0x007ff4d92c0378 @cookie="1336941096/ea496248-d200-4a10-8e46-c73b59971864", @url="https://172.16.75.137/nuova">
|
59
|
-
1.9.3p194 :007 > xml_dump = ucs_inventory.discover(token_json)
|
60
|
-
|
61
|
-
1.9.3p194 :008 > ucs_inventory.methods
|
62
|
-
=> [:discover, :list_blades, :list_vsans, :list_vlans, :list_cpus, :list_memory, :list_service_profiles, :list_running_firmware, :to_json, :nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup, :initialize_dup, :initialize_clone, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, :respond_to_missing?, :extend, :display, :method, :public_method, :define_singleton_method, :object_id, :to_enum, :enum_for, :==, :equal?, :!, :!=, :instance_eval, :instance_exec, :__send__, :__id__]
|
63
|
-
1.9.3p194 :009 >
|
64
|
-
|
65
|
-
1.9.3p194 :009 > ucs_inventory.list_blades(xml_dump)
|
66
|
-
Blade : 1/5 model: UCSB-B200-M3 with serial: 1049 is powered: off
|
67
|
-
Blade : 1/6 model: N20-B6625-1 with serial: 1053 is powered: off
|
68
|
-
Blade : 1/1 model: N20-B6620-1 with serial: 1045 is powered: on
|
69
|
-
Blade : 1/7 model: N20-B6740-2 with serial: 1052 is powered: off
|
70
|
-
Blade : 1/2 model: N20-B6620-1 with serial: 1054 is powered: off
|
71
|
-
Blade : 1/4 model: N20-B6620-1 with serial: 1051 is powered: off
|
72
|
-
Blade : 1/3 model: N20-B6620-1 with serial: 1055 is powered: off
|
73
|
-
=> 0
|
74
|
-
1.9.3p194 :010 >
|
75
|
-
|
76
|
-
1.9.3p194 :010 > vlan_json = { :vlan_id => '200', :vlan_name => 'OpenStack-Mgmt' }.to_json
|
77
|
-
=> "{\"vlan_id\":\"200\",\"vlan_name\":\"OpenStack-Mgmt\"}"
|
78
|
-
|
79
|
-
1.9.3p194 :011 > ucs_provision.methods
|
80
|
-
=> [:set_power_policy, :set_chassis_discovery_policy, :set_time_zone, :set_ntp, :create_server_port, :create_network_uplink_port, :create_fc_uplink_port, :create_port_channel, :create_org, :set_local_disk_policy, :create_local_boot_policy, :create_pxe_boot_policy, :create_san_boot_policy, :create_management_ip_pool, :create_vlan, :create_mac_pool, :create_vnic_template, :create_vsan, :create_wwnn_pool, :create_wwpn_pool, :create_vhba_template, :create_uuid_pool, :create_service_profile_template, :create_service_profiles_from_template, :create_service_profiles, :to_json, :nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup, :initialize_dup, :initialize_clone, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, :respond_to_missing?, :extend, :display, :method, :public_method, :define_singleton_method, :object_id, :to_enum, :enum_for, :==, :equal?, :!, :!=, :instance_eval, :instance_exec, :__send__, :__id__]
|
81
|
-
1.9.3p194 :012 >
|
82
|
-
|
83
|
-
1.9.3p194 :012 > ucs_provision.create_vlan(vlan_json)
|
84
|
-
=> " <configConfMos cookie=\"1336941096/ea496248-d200-4a10-8e46-c73b59971864\" response=\"yes\"> <outConfigs> <pair key=\"fabric/lan/net-OpenStack-Mgmt\"> <fabricVlan childAction=\"deleteNonPresent\" defaultNet=\"no\" dn=\"fabric/lan/net-OpenStack-Mgmt\" epDn=\"\" id=\"200\" ifRole=\"network\" ifType=\"virtual\" locale=\"external\" name=\"OpenStack-Mgmt\" operState=\"ok\" peerDn=\"\" pubNwDn=\"\" pubNwId=\"0\" pubNwName=\"\" sharing=\"none\" status=\"created\" switchId=\"dual\" transport=\"ether\" type=\"lan\"/> </pair> </outConfigs> </configConfMos>"
|
85
|
-
1.9.3p194 :013 >
|
86
|
-
|
87
|
-
1.9.3p194 :015 > xml_dump = ucs_inventory.discover(token_json)
|
88
|
-
|
89
|
-
1.9.3p194 :015 > ucs_inventory.list_vlans(xml_dump)
|
90
|
-
VLAN: 1 with name: default
|
91
|
-
VLAN: 1 with name: default
|
92
|
-
VLAN: 5 with name: human-resource
|
93
|
-
VLAN: 1 with name: default
|
94
|
-
VLAN: 3 with name: finance
|
95
|
-
VLAN: 5 with name: human-resource
|
96
|
-
VLAN: 1 with name: default
|
97
|
-
VLAN: 3 with name: finance
|
98
|
-
VLAN: 100 with name: Tenant-1
|
99
|
-
VLAN: 200 with name: OpenStack-Mgmt
|
100
|
-
=> 0
|
101
|
-
1.9.3p194 :016 >
|
102
|
-
|
103
|
-
1.9.3p194 :016 > ucs_stats = UCSStats.new
|
104
|
-
|
105
|
-
1.9.3p194 :017 > statsxml = ucs_stats.fetch(token_json)
|
106
|
-
|
107
|
-
1.9.3p194 :017 > ucs.show_sample(statsml,'fcStats')
|
108
|
-
|
109
|
-
The attributes for fcStats for dn=sys/switch-B/slot-1/switch-fc/port-32/stats are:
|
110
|
-
bytesRx = 125283780333316
|
111
|
-
bytesRxDelta = 142669360
|
112
|
-
bytesRxDeltaAvg = 142706128
|
113
|
-
bytesRxDeltaMax = 146404048
|
114
|
-
bytesRxDeltaMin = 139044968
|
115
|
-
bytesTx = 42023875724480
|
116
|
-
bytesTxDelta = 29946840
|
117
|
-
bytesTxDeltaAvg = 29842170
|
118
|
-
bytesTxDeltaMax = 31907484
|
119
|
-
bytesTxDeltaMin = 27672184
|
120
|
-
intervals = 58982460
|
121
|
-
packetsRx = 67694612103
|
122
|
-
packetsRxDelta = 78357
|
123
|
-
packetsRxDeltaAvg = 78476
|
124
|
-
packetsRxDeltaMax = 80258
|
125
|
-
packetsRxDeltaMin = 76814
|
126
|
-
packetsTx = 22997688197
|
127
|
-
packetsTxDelta = 18346
|
128
|
-
packetsTxDeltaAvg = 18318
|
129
|
-
packetsTxDeltaMax = 19393
|
130
|
-
packetsTxDeltaMin = 17218
|
131
|
-
suspect = no
|
132
|
-
thresholded =
|
133
|
-
timeCollected = 2012-11-16T13:40:32.362
|
134
|
-
update = 65539
|
135
|
-
|
136
|
-
1.9.3p194 :018 > ucs.show_all(statsml,'fcStats') # output omitted
|
137
119
|
|
138
120
|
== Features
|
139
121
|
|
@@ -141,6 +123,11 @@ VLAN: 200 with name: OpenStack-Mgmt
|
|
141
123
|
2. Provision - turn up ports, create port channels, pools, service profiles
|
142
124
|
3. Retrieve stats
|
143
125
|
|
126
|
+
== Issues and Project Management
|
127
|
+
|
128
|
+
Checkout [Pivotal Tracker][1]
|
129
|
+
|
130
|
+
|
144
131
|
== ToDo
|
145
132
|
|
146
133
|
Documentation, Documentation, Documentation!
|
@@ -148,7 +135,7 @@ Documentation, Documentation, Documentation!
|
|
148
135
|
|
149
136
|
|
150
137
|
== Contributing to ucslib
|
151
|
-
|
138
|
+
|
152
139
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
153
140
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
154
141
|
* Start a feature/bugfix branch.
|
@@ -158,7 +145,7 @@ Documentation, Documentation, Documentation!
|
|
158
145
|
|
159
146
|
== Copyright
|
160
147
|
|
161
|
-
Copyright (c) 2012 Murali Raju. See LICENSE.txt for further details.
|
162
|
-
|
148
|
+
Copyright (c) 2012 - 2014 Murali Raju. See LICENSE.txt for further details.
|
163
149
|
|
150
|
+
[1]: https://www.pivotaltracker.com/s/projects/1065870
|
164
151
|
|
data/lib/ucslib/Gemfile
ADDED
@@ -15,16 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
|
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
|
-
|
18
|
+
module Destroy
|
28
19
|
|
29
20
|
def delete_org(json)
|
30
21
|
|
@@ -49,7 +40,7 @@ class UCSDestroy
|
|
49
40
|
rescue Exception => e
|
50
41
|
raise "Error #{e}"
|
51
42
|
end
|
52
|
-
|
43
|
+
|
53
44
|
end
|
54
45
|
|
55
46
|
def delete_vlan(json)
|
@@ -78,6 +69,6 @@ class UCSDestroy
|
|
78
69
|
raise "Error #{e}"
|
79
70
|
end
|
80
71
|
|
81
|
-
end
|
72
|
+
end
|
82
73
|
|
83
74
|
end
|
@@ -16,17 +16,20 @@
|
|
16
16
|
#
|
17
17
|
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
module Inventory
|
20
|
+
|
21
|
+
# Archive code. To be removed later #TODO
|
22
|
+
# def discover(tokenjson)
|
23
|
+
|
24
|
+
# @cookie = "#{JSON.parse(tokenjson)['cookie']}"
|
25
|
+
# ip = "#{JSON.parse(tokenjson)['ip']}"
|
26
|
+
# @url = "https://#{ip}/nuova"
|
27
|
+
|
28
|
+
def discover
|
26
29
|
|
27
30
|
#Start Build the Multi-Class XML
|
28
31
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
29
|
-
xml.configResolveClasses('cookie' => cookie, 'inHierarchical' => 'false') {
|
32
|
+
xml.configResolveClasses('cookie' => @cookie, 'inHierarchical' => 'false') {
|
30
33
|
xml.inIds{
|
31
34
|
xml.classId("value" => "topSystem")
|
32
35
|
xml.classId("value" => "equipmentChassis")
|
@@ -69,46 +72,46 @@ class UCSInventory
|
|
69
72
|
xml.classId("value" => "vmVnicProfCl")
|
70
73
|
xml.classId("value" => "vmVnicProfInst")
|
71
74
|
xml.classId("value" => "vmVsan")
|
72
|
-
}
|
75
|
+
}
|
73
76
|
}
|
74
77
|
end
|
75
78
|
|
76
79
|
#End Build Multi-Class XML
|
77
80
|
|
78
81
|
ucs_multi_class_XML = xml_builder.to_xml.to_s
|
79
|
-
ucs_response_multi_class = RestClient.post(url, ucs_multi_class_XML, :content_type => 'text/xml').body
|
82
|
+
ucs_response_multi_class = RestClient.post(@url, ucs_multi_class_XML, :content_type => 'text/xml').body
|
80
83
|
|
81
84
|
#Uncomment the following to create a dump to review and debug elements
|
82
85
|
# fh = File.new("ucs_response_multiclass.xml", "w")
|
83
|
-
# fh.puts ucs_response_multi_class.inspect
|
86
|
+
# fh.puts ucs_response_multi_class.inspect
|
84
87
|
# fh.close
|
85
|
-
|
88
|
+
|
86
89
|
return Nokogiri::XML(ucs_response_multi_class)
|
87
|
-
|
90
|
+
|
88
91
|
end
|
89
|
-
|
90
|
-
|
92
|
+
|
93
|
+
|
91
94
|
def list_blades(ucs_multi_class_xml)
|
92
|
-
|
95
|
+
|
93
96
|
ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/computeBlade").each do |blade|
|
94
|
-
|
97
|
+
|
95
98
|
puts "Blade : #{blade.attributes["serverId"]} model: #{blade.attributes["model"]}" \
|
96
99
|
" with serial: #{blade.attributes["serial"]} is powered: #{blade.attributes["operPower"]}"
|
97
|
-
|
100
|
+
|
98
101
|
end
|
99
|
-
|
102
|
+
|
100
103
|
end
|
101
|
-
|
104
|
+
|
102
105
|
def list_vsans(ucs_multi_class_xml)
|
103
106
|
|
104
107
|
ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/fabricVsan").each do |fabricvsan|
|
105
|
-
|
108
|
+
|
106
109
|
puts "VSAN: #{fabricvsan.attributes["fcoeVlan"]} with FCoE ID: #{fabricvsan.attributes["id"]}" \
|
107
110
|
" status: #{fabricvsan.attributes["operState"]}"
|
108
111
|
end
|
109
112
|
|
110
113
|
end
|
111
|
-
|
114
|
+
|
112
115
|
def list_vlans(ucs_multi_class_xml)
|
113
116
|
|
114
117
|
ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/fabricVlan").each do |fabricvlan|
|
@@ -116,9 +119,9 @@ class UCSInventory
|
|
116
119
|
puts "VLAN: #{fabricvlan.attributes["id"]} with name: #{fabricvlan.attributes["name"]}"
|
117
120
|
|
118
121
|
end
|
119
|
-
|
122
|
+
|
120
123
|
end
|
121
|
-
|
124
|
+
|
122
125
|
def list_cpus(ucs_multi_class_xml)
|
123
126
|
|
124
127
|
ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/processorUnit").each do |processorunit|
|
@@ -130,7 +133,7 @@ class UCSInventory
|
|
130
133
|
end
|
131
134
|
|
132
135
|
end
|
133
|
-
|
136
|
+
|
134
137
|
def list_memory(ucs_multi_class_xml)
|
135
138
|
|
136
139
|
ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/computeBlade").each do |blade|
|
@@ -138,20 +141,20 @@ class UCSInventory
|
|
138
141
|
puts "Available Memory: #{blade.attributes["availableMemory"]} Total Memory: #{blade.attributes["totalMemory"]} Speed: #{blade.attributes["memorySpeed"]}"
|
139
142
|
|
140
143
|
end
|
141
|
-
|
144
|
+
|
142
145
|
end
|
143
|
-
|
146
|
+
|
144
147
|
def list_service_profiles(ucs_multi_class_xml)
|
145
|
-
|
148
|
+
|
146
149
|
ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/lsServer").each do |serviceprofile|
|
147
150
|
|
148
151
|
puts "Service Profile: #{serviceprofile.attributes["name"]} in #{serviceprofile.attributes["dn"]} with UUID #{serviceprofile.attributes["uuid"]}" \
|
149
152
|
" is: #{serviceprofile.attributes["assocState"]}"
|
150
153
|
|
151
154
|
end
|
152
|
-
|
155
|
+
|
153
156
|
end
|
154
|
-
|
157
|
+
|
155
158
|
def list_running_firmware(ucs_multi_class_xml)
|
156
159
|
|
157
160
|
ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/firmwareRunning").each do |firmware|
|
@@ -162,5 +165,5 @@ class UCSInventory
|
|
162
165
|
end
|
163
166
|
|
164
167
|
end
|
165
|
-
|
168
|
+
|
166
169
|
end
|
@@ -15,19 +15,11 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
|
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
|
18
|
+
module Manage
|
27
19
|
|
28
20
|
|
29
21
|
def discover_state
|
30
|
-
|
22
|
+
|
31
23
|
#Start Build of the Multi-Class XML for interogating state
|
32
24
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
33
25
|
xml.configResolveClasses('cookie' => @cookie, 'inHierarchical' => 'false') {
|
@@ -35,7 +27,7 @@ class UCSManage
|
|
35
27
|
xml.classId("value" => "macpoolPooled")
|
36
28
|
xml.classId("value" => "uuidpoolPooled")
|
37
29
|
xml.classId("value" => "fcpoolInitiator")
|
38
|
-
}
|
30
|
+
}
|
39
31
|
}
|
40
32
|
end
|
41
33
|
|
@@ -46,13 +38,13 @@ class UCSManage
|
|
46
38
|
|
47
39
|
#Uncomment the following to create a dump to review and debug elements
|
48
40
|
# fh = File.new("ucs_response_multiclass_state.xml", "w")
|
49
|
-
# fh.puts ucs_response_multi_class_state.inspect
|
41
|
+
# fh.puts ucs_response_multi_class_state.inspect
|
50
42
|
# fh.close
|
51
|
-
|
52
|
-
Nokogiri::XML(ucs_response_multi_class_state)
|
53
|
-
|
43
|
+
|
44
|
+
Nokogiri::XML(ucs_response_multi_class_state)
|
45
|
+
|
54
46
|
end
|
55
|
-
|
47
|
+
|
56
48
|
|
57
49
|
def associate_service_profile_template_to_server_pool(json)
|
58
50
|
|
@@ -73,8 +65,8 @@ class UCSManage
|
|
73
65
|
'descr' => '', 'dn' => "org-root/org-#{org}/ls-#{service_profile_template_to_bind}",
|
74
66
|
'dynamicConPolicyName' => '', 'extIPState' => 'none', 'hostFwPolicyName' => "#{service_profile_host_fw_policy}",
|
75
67
|
'identPoolName' => "#{service_profile_uuid_pool}", 'localDiskPolicyName' => 'default', 'maintPolicyName' => 'default',
|
76
|
-
'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => "#{service_profile_mgmt_fw_policy}", 'powerPolicyName' => 'default',
|
77
|
-
'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => '',
|
68
|
+
'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => "#{service_profile_mgmt_fw_policy}", 'powerPolicyName' => 'default',
|
69
|
+
'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => '',
|
78
70
|
'statsPolicyName' => 'default', 'status' => 'created,modified', 'usrLbl' => '', 'uuid' => '0', 'vconProfileName' => ''){
|
79
71
|
xml.lsRequirement('name' => "#{service_profile_server_pool}", 'qualifier' => '', 'restrictMigration' => 'no', 'rn' => 'pn-req')
|
80
72
|
}
|
@@ -87,13 +79,13 @@ class UCSManage
|
|
87
79
|
|
88
80
|
associate_service_profile_template_to_server_pool_xml = xml_builder.to_xml.to_s
|
89
81
|
|
90
|
-
#Post
|
82
|
+
#Post
|
91
83
|
begin
|
92
84
|
RestClient.post(@url, associate_service_profile_template_to_server_pool_xml, :content_type => 'text/xml').body
|
93
85
|
rescue Exception => e
|
94
86
|
raise "Error #{e}"
|
95
|
-
end
|
96
|
-
|
87
|
+
end
|
88
|
+
|
97
89
|
end
|
98
|
-
|
90
|
+
|
99
91
|
end
|