lab-manager 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/lab_machines.sh +28 -0
- data/lib/lab_manager.rb +28 -19
- metadata +4 -3
data/bin/lab_machines.sh
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# ##########################################################################################
|
3
|
+
# lab_machines.rb
|
4
|
+
#
|
5
|
+
# bin/lab_machines.rb "ORG" "WORKSPACE" "CONFIGURATION"
|
6
|
+
# bin/lab_machines.rb "ORG" "WORKSPACE" "CONFIGURATION" "excludeMachine1" "excludeMachine2"
|
7
|
+
# ##########################################################################################
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
$:.unshift "#{File.dirname(__FILE__)}/../lib"
|
11
|
+
require "lab_manager"
|
12
|
+
|
13
|
+
if (ARGV.size < 3)
|
14
|
+
puts "usage: #{File.basename __FILE__} <organization> <workspace> <configuration> [<machine to exclude> ...]"
|
15
|
+
Process.exit(1)
|
16
|
+
end
|
17
|
+
|
18
|
+
organization = ARGV[0]
|
19
|
+
workspace = ARGV[1]
|
20
|
+
configuration = ARGV[2]
|
21
|
+
excludeMachines = ARGV[3..-1]
|
22
|
+
|
23
|
+
lab = LabManager.new(organization)
|
24
|
+
lab.workspace = workspace
|
25
|
+
machines = lab.machines(configuration, :exclude => excludeMachines)
|
26
|
+
|
27
|
+
Machine.to_csv(machines)
|
28
|
+
|
data/lib/lab_manager.rb
CHANGED
@@ -19,15 +19,12 @@ require 'lab_manager/httpclient_patch'
|
|
19
19
|
#
|
20
20
|
class LabManager
|
21
21
|
|
22
|
-
@@DEBUG =
|
22
|
+
@@DEBUG = false
|
23
23
|
|
24
24
|
def self.DEBUG=(value)
|
25
25
|
@@DEBUG = value
|
26
26
|
end
|
27
27
|
|
28
|
-
@@configPath = File.expand_path("~/.lab_manager")
|
29
|
-
@@url = nil
|
30
|
-
|
31
28
|
def self.configPath
|
32
29
|
@@configPath
|
33
30
|
end
|
@@ -41,20 +38,31 @@ class LabManager
|
|
41
38
|
def self.url=(value)
|
42
39
|
@@url = value
|
43
40
|
end
|
41
|
+
def self.username
|
42
|
+
@@username
|
43
|
+
end
|
44
|
+
def self.password
|
45
|
+
@@password
|
46
|
+
end
|
44
47
|
|
45
48
|
def self.reset
|
49
|
+
@@configPath = File.expand_path("~/.lab_manager")
|
50
|
+
|
46
51
|
@@url = nil
|
52
|
+
@@username = nil
|
53
|
+
@@password = nil
|
47
54
|
end
|
55
|
+
reset
|
48
56
|
|
49
57
|
attr_accessor :workspace
|
50
58
|
|
51
|
-
def initialize(organization, username, password, url = nil)
|
52
|
-
|
59
|
+
def initialize(organization, username = nil, password = nil, url = nil)
|
60
|
+
load_config(url, username, password)
|
53
61
|
raise "Missing url" if @@url.nil?
|
62
|
+
raise "Missing username" if @@username.nil?
|
63
|
+
raise "Missing password" if @@password.nil?
|
54
64
|
|
55
65
|
@organization = organization
|
56
|
-
@username = username
|
57
|
-
@password = password
|
58
66
|
end
|
59
67
|
|
60
68
|
#<GetConfigurationByName xmlns="http://vmware.com/labmanager">
|
@@ -135,25 +143,26 @@ class LabManager
|
|
135
143
|
def proxy
|
136
144
|
factory = SOAP::WSDLDriverFactory.new("#{@@url}?WSDL")
|
137
145
|
proxy = factory.create_rpc_driver
|
138
|
-
proxy.wiredump_dev = STDOUT if DEBUG
|
146
|
+
proxy.wiredump_dev = STDOUT if @@DEBUG
|
139
147
|
proxy.generate_explicit_type = false # No datatype with request
|
140
|
-
proxy.headerhandler << LabManagerHeader.new(@organization, @workspace,
|
148
|
+
proxy.headerhandler << LabManagerHeader.new(@organization, @workspace, @@username, @@password)
|
141
149
|
|
142
150
|
#proxy.streamhandler.client.ssl_config.verify_mode = false
|
143
151
|
|
144
152
|
proxy
|
145
153
|
end
|
146
154
|
|
147
|
-
def load_config(url)
|
148
|
-
if
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
url = config["url"]
|
154
|
-
end
|
155
|
+
def load_config(url, username, password)
|
156
|
+
if File.exists? @@configPath
|
157
|
+
config = YAML::load_file(@@configPath)
|
158
|
+
@@url = config["url"]
|
159
|
+
@@username = config["username"]
|
160
|
+
@@password = config["password"]
|
155
161
|
end
|
156
|
-
|
162
|
+
|
163
|
+
@@url = url if !url.nil?
|
164
|
+
@@username = username if !username.nil?
|
165
|
+
@@password = password if !password.nil?
|
157
166
|
end
|
158
167
|
end
|
159
168
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab-manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 7
|
10
|
+
version: 1.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ed Sumerfield
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/lab_manager/httpclient_patch.rb
|
59
59
|
- lib/lab_manager/machine.rb
|
60
60
|
- lib/lab_manager.rb
|
61
|
+
- bin/lab_machines.sh
|
61
62
|
has_rdoc: true
|
62
63
|
homepage:
|
63
64
|
licenses: []
|