labmanager 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +3 -0
- data/lib/labmanager/constants.rb +37 -0
- data/lib/labmanager/labmanager_service.rb +267 -0
- data/test/12test_labmanager_proxy.rb +67 -0
- data/test/test_configuration.rb +63 -0
- data/test/test_framework.rb +34 -0
- data/test/test_helper.rb +350 -0
- data/test/test_machines.rb +64 -0
- data/test/test_networks.rb +39 -0
- data/test/test_templates.rb +53 -0
- metadata +101 -0
data/README
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Constants
|
2
|
+
|
3
|
+
MACHINE_ACTION_POWERON =1;
|
4
|
+
MACHINE_ACTION_POWEROFF =2;
|
5
|
+
MACHINE_ACTION_SUSPEND =3;
|
6
|
+
MACHINE_ACTION_RESUME =4;
|
7
|
+
MACHINE_ACTION_RESET =5;
|
8
|
+
MACHINE_ACTION_SNAPSHOT =6;
|
9
|
+
MACHINE_ACTION_REVERT =7;
|
10
|
+
MACHINE_ACTION_SHUTDOWN =8;
|
11
|
+
MACHINE_ACTION_CONSOLIDATE =9;
|
12
|
+
MACHINE_ACTION_EJECTCD =10;
|
13
|
+
MACHINE_ACTION_EJECTFLOPPY =11;
|
14
|
+
MACHINE_ACTION_DEPLOY =12;
|
15
|
+
MACHINE_ACTION_UNDEPLOY =13;
|
16
|
+
MACHINE_ACTION_FORCEUNDEPLOY =14;
|
17
|
+
|
18
|
+
MACHINE_STATUS_OFF =1;
|
19
|
+
MACHINE_STATUS_ON =2;
|
20
|
+
MACHINE_STATUS_SUSPENDED =3;
|
21
|
+
MACHINE_STATUS_STUCK =4;
|
22
|
+
MACHINE_STATUS_INVALID =128;
|
23
|
+
|
24
|
+
|
25
|
+
CONFIGURATION_ACTION_POWERON=1;
|
26
|
+
CONFIGURATION_ACTION_POWEROFF=2;
|
27
|
+
CONFIGURATION_ACTION_SUSPEND=3;
|
28
|
+
CONFIGURATION_ACTION_RESUME=4;
|
29
|
+
CONFIGURATION_ACTION_RESET=5;
|
30
|
+
CONFIGURATION_ACTION_SNAPSHOT=6;
|
31
|
+
CONFIGURATION_ACTION_REVERT=7;
|
32
|
+
CONFIGURATION_ACTION_SHUTDOWN=8;
|
33
|
+
|
34
|
+
|
35
|
+
FENCE_MODE_UNFENCED = 1;
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,267 @@
|
|
1
|
+
require "handsoap"
|
2
|
+
require "labmanager/constants"
|
3
|
+
|
4
|
+
class LabmanagerService < Handsoap::Service
|
5
|
+
|
6
|
+
include Constants
|
7
|
+
|
8
|
+
@@workspace =''
|
9
|
+
@@username =''
|
10
|
+
@@password =''
|
11
|
+
@@pragmatic=false
|
12
|
+
|
13
|
+
|
14
|
+
def self.configure(config)
|
15
|
+
@@wsdl = config[:wsdl]
|
16
|
+
|
17
|
+
@@username = config[:username]
|
18
|
+
@@password = config[:password]
|
19
|
+
@@workspace = config[:workspace]
|
20
|
+
@@pragmatic = config[:pragmatic]
|
21
|
+
|
22
|
+
endpoint :uri => @@wsdl, :version => 2
|
23
|
+
end
|
24
|
+
|
25
|
+
# Register namespaces for request
|
26
|
+
def on_create_document(doc)
|
27
|
+
|
28
|
+
|
29
|
+
doc.alias 'labmanager', 'http://vmware.com/labmanager'
|
30
|
+
|
31
|
+
header = doc.find("Header")
|
32
|
+
header.add "labmanager:AuthenticationHeader" do |s|
|
33
|
+
s.set_attr "env:mustUnderstand", "1"
|
34
|
+
|
35
|
+
s.add "labmanager:workspacename", @@workspace
|
36
|
+
s.add "labmanager:username", @@username
|
37
|
+
s.add "labmanager:password", @@password
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def on_response_document(doc)
|
46
|
+
doc.add_namespace 'labmanager', 'http://vmware.com/labmanager'
|
47
|
+
end
|
48
|
+
|
49
|
+
def createConfiguration(args = {})
|
50
|
+
puts "create Document"
|
51
|
+
|
52
|
+
begin
|
53
|
+
|
54
|
+
response = invoke('labmanager:ConfigurationCreateEx') do |message|
|
55
|
+
message.add('labmanager:name',args[:name])
|
56
|
+
message.add('labmanager:desc',args[:description])
|
57
|
+
end
|
58
|
+
|
59
|
+
puts "create Document 2"
|
60
|
+
|
61
|
+
(response/"//labmanager:ConfigurationCreateExResponse/labmanager:ConfigurationCreateExResult").to_i
|
62
|
+
|
63
|
+
rescue Handsoap::Fault => error
|
64
|
+
if @@pragmatic then
|
65
|
+
config = getConfigurationByName(args[:name])
|
66
|
+
config[:id]
|
67
|
+
else
|
68
|
+
raise error
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def deleteConfiguration(id)
|
76
|
+
|
77
|
+
response = invoke('labmanager:ConfigurationDelete') do |message|
|
78
|
+
message.add('labmanager:configurationId',id)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
def getConfigurationByName(name)
|
84
|
+
response = invoke('labmanager:GetConfigurationByName') do |message|
|
85
|
+
message.add('labmanager:name',name)
|
86
|
+
end
|
87
|
+
|
88
|
+
hashes = (response/"//labmanager:GetConfigurationByNameResponse/labmanager:GetConfigurationByNameResult/labmanager:Configuration").map do |configuration|
|
89
|
+
{
|
90
|
+
:id => (configuration/"labmanager:id").to_s,
|
91
|
+
:name => (configuration/"labmanager:name").to_s,
|
92
|
+
:description => (configuration/"labmanager:description").to_s
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
return hashes[0]
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
def getConfigurations
|
101
|
+
response = invoke('labmanager:GetCurrentWorkspace')
|
102
|
+
|
103
|
+
hashes = (response/"//labmanager:GetCurrentWorkspaceResponse/labmanager:GetCurrentWorkspaceResult/labmanager:Configurations/labmanager:Configuration").map do |configuration|
|
104
|
+
{
|
105
|
+
:id => (configuration/"labmanager:id").to_s,
|
106
|
+
:name => (configuration/"labmanager:name").to_s,
|
107
|
+
:description => (configuration/"labmanager:description").to_s
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
def listTemplates()
|
114
|
+
response = invoke('labmanager:ListTemplates')
|
115
|
+
|
116
|
+
hashes = (response/"//labmanager:ListTemplatesResponse/labmanager:ListTemplatesResult/labmanager:Template").map do |template|
|
117
|
+
{
|
118
|
+
:id => (template/"labmanager:id").to_s,
|
119
|
+
:name => (template/"labmanager:name").to_s,
|
120
|
+
:description => (template/"labmanager:description").to_s
|
121
|
+
}
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
def getTemplate(id)
|
127
|
+
response = invoke('labmanager:GetTemplate') do |message|
|
128
|
+
message.add('labmanager:id',id)
|
129
|
+
end
|
130
|
+
|
131
|
+
template =
|
132
|
+
{
|
133
|
+
:id => (response/"//labmanager:GetTemplateResponse/labmanager:GetTemplateResult/labmanager:id").to_s,
|
134
|
+
:name => (response/"//labmanager:GetTemplateResponse/labmanager:GetTemplateResult/labmanager:name").to_s,
|
135
|
+
:description => (response/"//labmanager:GetTemplateResponse/labmanager:GetTemplateResult/labmanager:description").to_s
|
136
|
+
}
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
def getTemplateByName(name)
|
141
|
+
response = invoke('labmanager:GetTemplateByName') do |message|
|
142
|
+
message.add('labmanager:name',name)
|
143
|
+
end
|
144
|
+
|
145
|
+
hashes = (response/"//labmanager:GetTemplateByNameResponse/labmanager:GetTemplateByNameResult/labmanager:Template").map do |template|
|
146
|
+
{
|
147
|
+
:id => (template/"labmanager:id").to_s,
|
148
|
+
:name => (template/"labmanager:name").to_s,
|
149
|
+
:description => (template/"labmanager:description").to_s
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
153
|
+
return hashes[0]
|
154
|
+
end
|
155
|
+
|
156
|
+
def getNetworkByName(name)
|
157
|
+
response = invoke('labmanager:GetNetworkTemplateByName') do |message|
|
158
|
+
message.add('labmanager:name',name)
|
159
|
+
end
|
160
|
+
|
161
|
+
network =
|
162
|
+
{
|
163
|
+
:id => (response/"//labmanager:GetNetworkTemplateByNameResponse/labmanager:GetNetworkTemplateByNameResult/labmanager:NetID").to_s,
|
164
|
+
:name => (response/"//labmanager:GetNetworkTemplateByNameResponse/labmanager:GetNetworkTemplateByNameResult/labmanager:Name").to_s,
|
165
|
+
:description => (response/"//labmanager:GetNetworkTemplateByNameResponse/labmanager:GetNetworkTemplateByNameResult/labmanager:Description").to_s
|
166
|
+
}
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
def listNetworks()
|
171
|
+
response = invoke('labmanager:ListNetworks')
|
172
|
+
|
173
|
+
hashes = (response/"//labmanager:ListNetworksResponse/labmanager:ListNetworksResult/labmanager:Network").map do |network|
|
174
|
+
{
|
175
|
+
:id => (network/"labmanager:NetID").to_s,
|
176
|
+
:name => (network/"labmanager:Name").to_s,
|
177
|
+
:description => (network/"labmanager:Description").to_s
|
178
|
+
}
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def createMachine(config)
|
183
|
+
begin
|
184
|
+
response = invoke('labmanager:ConfigurationAddMachineEx') do |message|
|
185
|
+
message.add('labmanager:id',config[:configuration_id])
|
186
|
+
message.add('labmanager:template_id',config[:template_id])
|
187
|
+
message.add('labmanager:name',config[:name])
|
188
|
+
message.add('labmanager:desc',config[:description])
|
189
|
+
message.add('labmanager:netInfo') do |netinfo|
|
190
|
+
netinfo.add('labmanager:NetInfo') do |network|
|
191
|
+
network.add('labmanager:networkId',config[:network_id])
|
192
|
+
network.add('labmanager:ipAddress',config[:ipaddress])
|
193
|
+
network.add('labmanager:ipAddressingMode',config[:ipaddressingmode])
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
(response/"//labmanager:ConfigurationAddMachineExResponse/labmanager:ConfigurationAddMachineExResult").to_i
|
200
|
+
|
201
|
+
rescue Handsoap::Fault => error
|
202
|
+
if @@pragmatic then
|
203
|
+
machine = getMachineByName(config[:configuration_id],config[:name])
|
204
|
+
machine[:id]
|
205
|
+
else
|
206
|
+
raise error
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def undeployMachine(id)
|
212
|
+
performMachineAction(id,MACHINE_ACTION_UNDEPLOY)
|
213
|
+
end
|
214
|
+
|
215
|
+
def deployMachine(id)
|
216
|
+
performMachineAction(id,MACHINE_ACTION_DEPLOY)
|
217
|
+
end
|
218
|
+
|
219
|
+
def performMachineAction(id,action)
|
220
|
+
begin
|
221
|
+
response = invoke('labmanager:MachinePerformAction') do |message|
|
222
|
+
message.add('labmanager:machineId',id)
|
223
|
+
message.add('labmanager:action',action)
|
224
|
+
end
|
225
|
+
|
226
|
+
rescue Handsoap::Fault => error
|
227
|
+
if !@@pragmatic then
|
228
|
+
raise error
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def deleteMachine(id)
|
234
|
+
begin
|
235
|
+
response = invoke('labmanager:MachineDelete') do |message|
|
236
|
+
message.add('labmanager:vmId',id)
|
237
|
+
end
|
238
|
+
|
239
|
+
rescue Handsoap::Fault => error
|
240
|
+
if !@@pragmatic then
|
241
|
+
raise error
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def getMachine(id)
|
247
|
+
|
248
|
+
end
|
249
|
+
|
250
|
+
def getMachineByName(config_id,name)
|
251
|
+
response = invoke('labmanager:GetMachineByName') do |message|
|
252
|
+
message.add('labmanager:configurationId',config_id)
|
253
|
+
message.add('labmanager:name',name)
|
254
|
+
end
|
255
|
+
|
256
|
+
machine =
|
257
|
+
{
|
258
|
+
:id => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:id").to_s,
|
259
|
+
:name => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:name").to_s,
|
260
|
+
:description => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:description").to_s
|
261
|
+
}
|
262
|
+
|
263
|
+
end
|
264
|
+
|
265
|
+
private
|
266
|
+
|
267
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "labmanager/labmanager_service"
|
3
|
+
|
4
|
+
class TestLabmanagerProxy < Test::Unit::TestCase
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
def test_configuration
|
9
|
+
|
10
|
+
setupProxy
|
11
|
+
|
12
|
+
id1 = LabmanagerService.createConfiguration(:name => 'ajb1', :description => 'ajb1')
|
13
|
+
|
14
|
+
configuration = LabmanagerService.getConfigurationByName("ajb1")
|
15
|
+
|
16
|
+
configurations = LabmanagerService.getConfigurations()
|
17
|
+
|
18
|
+
template = LabmanagerService.getTemplateByName("RedHat.5.WDF.external.V1.0")
|
19
|
+
|
20
|
+
network = LabmanagerService.getNetworkByName("BSS General")
|
21
|
+
|
22
|
+
machine = LabmanagerService.createMachine({:configuration_id =>id1,:template_id=>602,:network_id=>network[:id],:ipaddressingmode=>'STATIC_AUTOMATIC',:name=>"andrew",:description=>"testing"})
|
23
|
+
|
24
|
+
LabmanagerService.deployMachine(machine)
|
25
|
+
|
26
|
+
LabmanagerService.undeployMachine(machine)
|
27
|
+
|
28
|
+
LabmanagerService.deleteMachine(machine)
|
29
|
+
|
30
|
+
LabmanagerService.deleteConfiguration(id1)
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_templates
|
35
|
+
setupProxy
|
36
|
+
|
37
|
+
templates = LabmanagerService.listTemplates()
|
38
|
+
|
39
|
+
template = LabmanagerService.getTemplate(206)
|
40
|
+
|
41
|
+
template = LabmanagerService.getTemplateByName("W2008_64_Monsoon_v1.0")
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def test_networks
|
48
|
+
setupProxy
|
49
|
+
networks = LabmanagerService.listNetworks()
|
50
|
+
|
51
|
+
network = LabmanagerService.getNetworkByName("BSS Corp")
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
private
|
58
|
+
def setupProxy
|
59
|
+
|
60
|
+
config = {:pragmatic=>true,:wsdl =>"https://localhost:8080/LabManager/SOAP/LabManagerInternal.asmx?wsdl",:username=>"apiuser",:password =>"api4testing",:workspace=>"Officelan CPS Dev"}
|
61
|
+
|
62
|
+
proxy = LabmanagerService.configure(config)
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "labmanager/labmanager_service"
|
3
|
+
require "handsoap"
|
4
|
+
require "test_helper"
|
5
|
+
|
6
|
+
class TestCreateconfiguration < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include TestHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
configure
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_createConfiguration
|
16
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_CREATE_CONFIGURATION, :status => 200
|
17
|
+
Handsoap.http_driver = :mock
|
18
|
+
|
19
|
+
driver = Handsoap::Http.drivers[:mock].new
|
20
|
+
result = LabmanagerService.createConfiguration(:name=>'test',:description=>'test')
|
21
|
+
|
22
|
+
assert_equal result,1
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def test_getConfiguration
|
28
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_GET_CONFIGURATION, :status => 200
|
29
|
+
Handsoap.http_driver = :mock
|
30
|
+
|
31
|
+
driver = Handsoap::Http.drivers[:mock].new
|
32
|
+
result = LabmanagerService.getConfigurationByName("test")
|
33
|
+
|
34
|
+
assert_equal result[:id],"1"
|
35
|
+
assert_equal result[:name],"test"
|
36
|
+
assert_equal result[:description],"Some test"
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_getConfigurations
|
41
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_GET_WORKSPACE, :status => 200
|
42
|
+
Handsoap.http_driver = :mock
|
43
|
+
|
44
|
+
driver = Handsoap::Http.drivers[:mock].new
|
45
|
+
result = LabmanagerService.getConfigurations()
|
46
|
+
|
47
|
+
assert_equal result.length,2
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def test_deleteConfiguration
|
53
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_DELETE_CONFIGURATION, :status => 200
|
54
|
+
Handsoap.http_driver = :mock
|
55
|
+
|
56
|
+
driver = Handsoap::Http.drivers[:mock].new
|
57
|
+
result = LabmanagerService.deleteConfiguration(1)
|
58
|
+
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "labmanager/labmanager_service"
|
3
|
+
require "handsoap"
|
4
|
+
require "test_helper"
|
5
|
+
|
6
|
+
class TestFramework < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include TestHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
|
12
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_CREATE_CONFIGURATION, :status => 200
|
13
|
+
Handsoap.http_driver = :mock
|
14
|
+
|
15
|
+
configure
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_framework
|
20
|
+
driver = Handsoap::Http.drivers[:mock].new
|
21
|
+
result = LabmanagerService.createConfiguration(:name=>'test',:description=>'test')
|
22
|
+
|
23
|
+
assert_equal 'http://localhost/LabManager/test', driver.last_request.url
|
24
|
+
assert_equal :post, driver.last_request.http_method
|
25
|
+
|
26
|
+
# Check that at least some elements of the authentication header are included
|
27
|
+
assert_match(/<labmanager:AuthenticationHeader env:mustUnderstand="1" xmlns:labmanager="http:\/\/vmware.com\/labmanager\">/,driver.last_request.body)
|
28
|
+
assert_match(/<labmanager:username>testuser<\/labmanager:username>/,driver.last_request.body)
|
29
|
+
assert_match(/<labmanager:password>testpassword<\/labmanager:password>/,driver.last_request.body)
|
30
|
+
assert_match(/<labmanager:workspacename>testworkspace<\/labmanager:workspacename>/,driver.last_request.body)
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,350 @@
|
|
1
|
+
module TestHelper
|
2
|
+
|
3
|
+
def configure
|
4
|
+
config = {:wsdl =>"http://localhost/LabManager/test",:username=>"testuser",:password =>"testpassword",:workspace=>"testworkspace"}
|
5
|
+
LabmanagerService.configure(config)
|
6
|
+
end
|
7
|
+
|
8
|
+
REQUEST_HEADERS = 'Date: Thur, 14 Apr 2011 11:57:36 GMT
|
9
|
+
Content-Type: text/xml;charset=UTF-8
|
10
|
+
'.gsub(/\n/, "\r\n")
|
11
|
+
|
12
|
+
ENV_CREATE_CONFIGURATION = '<?xml version="1.0" encoding="UTF-8"?>
|
13
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
14
|
+
<soap:Body>
|
15
|
+
<ConfigurationCreateExResponse xmlns="http://vmware.com/labmanager">
|
16
|
+
<ConfigurationCreateExResult>1</ConfigurationCreateExResult>
|
17
|
+
</ConfigurationCreateExResponse>
|
18
|
+
</soap:Body>
|
19
|
+
</soap:Envelope>
|
20
|
+
'
|
21
|
+
|
22
|
+
ENV_GET_CONFIGURATION = '<?xml version="1.0" encoding="UTF-8"?>
|
23
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
24
|
+
<soap:Body>
|
25
|
+
<GetConfigurationByNameResponse xmlns="http://vmware.com/labmanager">
|
26
|
+
<GetConfigurationByNameResult>
|
27
|
+
<Configuration>
|
28
|
+
<id>1</id>
|
29
|
+
<name>test</name>
|
30
|
+
<description>Some test</description>
|
31
|
+
<isPublic>true</isPublic>
|
32
|
+
<isDeployed>false</isDeployed>
|
33
|
+
<fenceMode>0</fenceMode>
|
34
|
+
<type>1</type>
|
35
|
+
<owner>testuser</owner>
|
36
|
+
<dateCreated>2011-04-14T12:31:24.667</dateCreated>
|
37
|
+
<autoDeleteInMilliSeconds>0</autoDeleteInMilliSeconds>
|
38
|
+
<bucketName>Workspace</bucketName>
|
39
|
+
<mustBeFenced>NotSpecified</mustBeFenced>
|
40
|
+
<autoDeleteDateTime>9999-12-31T23:59:59.9999999</autoDeleteDateTime>
|
41
|
+
</Configuration>
|
42
|
+
</GetConfigurationByNameResult>
|
43
|
+
</GetConfigurationByNameResponse>
|
44
|
+
</soap:Body>
|
45
|
+
</soap:Envelope>
|
46
|
+
'
|
47
|
+
|
48
|
+
ENV_GET_WORKSPACE = '<?xml version="1.0" encoding="UTF-8"?>
|
49
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
50
|
+
<soap:Body>
|
51
|
+
<GetCurrentWorkspaceResponse xmlns="http://vmware.com/labmanager">
|
52
|
+
<GetCurrentWorkspaceResult>
|
53
|
+
<Id>1</Id>
|
54
|
+
<Name>workspace</Name>
|
55
|
+
<Description/>
|
56
|
+
<BucketType>3</BucketType>
|
57
|
+
<StoredVMQuota>0</StoredVMQuota>
|
58
|
+
<DeployedVMQuota>0</DeployedVMQuota>
|
59
|
+
<IsEnabled>true</IsEnabled>
|
60
|
+
<ResourcePools>
|
61
|
+
<ResourcePool>
|
62
|
+
<ID>7</ID>
|
63
|
+
<isEnabled>true</isEnabled>
|
64
|
+
<isBlackListed>false</isBlackListed>
|
65
|
+
<rpValRefFullID>resgroup-101</rpValRefFullID>
|
66
|
+
<rpValRefShortID>resgroup-101</rpValRefShortID>
|
67
|
+
<name>workspace</name>
|
68
|
+
<description/>
|
69
|
+
<path>BB/Cluster 1/Path/workspace</path>
|
70
|
+
</ResourcePool>
|
71
|
+
</ResourcePools>
|
72
|
+
<Configurations>
|
73
|
+
<Configuration>
|
74
|
+
<id>1</id>
|
75
|
+
<name>config1</name>
|
76
|
+
<description>Configuration 1</description>
|
77
|
+
<isPublic>true</isPublic>
|
78
|
+
<isDeployed>true</isDeployed>
|
79
|
+
<fenceMode>1</fenceMode>
|
80
|
+
<type>1</type>
|
81
|
+
<owner>D042651</owner>
|
82
|
+
<dateCreated>2011-01-11T09:27:07.077</dateCreated>
|
83
|
+
<autoDeleteInMilliSeconds>0</autoDeleteInMilliSeconds>
|
84
|
+
<bucketName>workspace</bucketName>
|
85
|
+
<mustBeFenced>NotSpecified</mustBeFenced>
|
86
|
+
<autoDeleteDateTime>9999-12-31T23:59:59.9999999</autoDeleteDateTime>
|
87
|
+
</Configuration>
|
88
|
+
<Configuration>
|
89
|
+
<id>2</id>
|
90
|
+
<name>config2</name>
|
91
|
+
<description>Configuration 2</description>
|
92
|
+
<isPublic>true</isPublic>
|
93
|
+
<isDeployed>true</isDeployed>
|
94
|
+
<fenceMode>1</fenceMode>
|
95
|
+
<type>1</type>
|
96
|
+
<owner>apiuser</owner>
|
97
|
+
<dateCreated>2011-01-20T11:39:46.92</dateCreated>
|
98
|
+
<autoDeleteInMilliSeconds>0</autoDeleteInMilliSeconds>
|
99
|
+
<bucketName>workspace</bucketName>
|
100
|
+
<mustBeFenced>NotSpecified</mustBeFenced>
|
101
|
+
<autoDeleteDateTime>9999-12-31T23:59:59.9999999</autoDeleteDateTime>
|
102
|
+
</Configuration>
|
103
|
+
</Configurations>
|
104
|
+
</GetCurrentWorkspaceResult>
|
105
|
+
</GetCurrentWorkspaceResponse>
|
106
|
+
</soap:Body>
|
107
|
+
</soap:Envelope>
|
108
|
+
'
|
109
|
+
|
110
|
+
|
111
|
+
ENV_DELETE_CONFIGURATION = '<?xml version="1.0" encoding="UTF-8"?>
|
112
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
113
|
+
<soap:Body>
|
114
|
+
<ConfigurationDeleteResponse xmlns="http://vmware.com/labmanager"/>
|
115
|
+
</soap:Body>
|
116
|
+
</soap:Envelope>
|
117
|
+
'
|
118
|
+
ENV_LIST_TEMPLATES = '<?xml version="1.0" encoding="UTF-8"?>
|
119
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
120
|
+
<soap:Body>
|
121
|
+
<ListTemplatesResponse xmlns="http://vmware.com/labmanager">
|
122
|
+
<ListTemplatesResult>
|
123
|
+
<Template>
|
124
|
+
<id>1</id>
|
125
|
+
<name>template1</name>
|
126
|
+
<description>Template 1</description>
|
127
|
+
<storage_id>21</storage_id>
|
128
|
+
<virtualization_id>6</virtualization_id>
|
129
|
+
<memory>2048</memory>
|
130
|
+
<mac_address>00:50:54:20:01:f3</mac_address>
|
131
|
+
<isAutoConfigEnabled>false</isAutoConfigEnabled>
|
132
|
+
<isPublic>true</isPublic>
|
133
|
+
<isPublished>true</isPublished>
|
134
|
+
<isBusy>false</isBusy>
|
135
|
+
<isDeployed>false</isDeployed>
|
136
|
+
<status>0</status>
|
137
|
+
<managedServerDeployed/>
|
138
|
+
</Template>
|
139
|
+
<Template>
|
140
|
+
<id>2</id>
|
141
|
+
<name>template2</name>
|
142
|
+
<description>Template 2</description>
|
143
|
+
<storage_id>21</storage_id>
|
144
|
+
<virtualization_id>6</virtualization_id>
|
145
|
+
<memory>2048</memory>
|
146
|
+
<mac_address>01:51:56:20:02:92</mac_address>
|
147
|
+
<isAutoConfigEnabled>false</isAutoConfigEnabled>
|
148
|
+
<isPublic>true</isPublic>
|
149
|
+
<isPublished>true</isPublished>
|
150
|
+
<isBusy>false</isBusy>
|
151
|
+
<isDeployed>false</isDeployed>
|
152
|
+
<status>0</status>
|
153
|
+
<managedServerDeployed/>
|
154
|
+
</Template>
|
155
|
+
</ListTemplatesResult>
|
156
|
+
</ListTemplatesResponse>
|
157
|
+
</soap:Body>
|
158
|
+
</soap:Envelope>
|
159
|
+
'
|
160
|
+
|
161
|
+
ENV_GET_TEMPLATE = '<?xml version="1.0" encoding="UTF-8"?>
|
162
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
163
|
+
<soap:Body>
|
164
|
+
<GetTemplateResponse xmlns="http://vmware.com/labmanager">
|
165
|
+
<GetTemplateResult>
|
166
|
+
<id>1</id>
|
167
|
+
<name>testtemplate</name>
|
168
|
+
<description>Test Template</description>
|
169
|
+
<storage_id>21</storage_id>
|
170
|
+
<virtualization_id>6</virtualization_id>
|
171
|
+
<memory>4096</memory>
|
172
|
+
<mac_address>01:50:56:20:02:c1</mac_address>
|
173
|
+
<isAutoConfigEnabled>false</isAutoConfigEnabled>
|
174
|
+
<isPublic>true</isPublic>
|
175
|
+
<isPublished>false</isPublished>
|
176
|
+
<isBusy>false</isBusy>
|
177
|
+
<isDeployed>false</isDeployed>
|
178
|
+
<status>0</status>
|
179
|
+
<managedServerDeployed/>
|
180
|
+
</GetTemplateResult>
|
181
|
+
</GetTemplateResponse>
|
182
|
+
</soap:Body>
|
183
|
+
</soap:Envelope>
|
184
|
+
'
|
185
|
+
|
186
|
+
ENV_GET_TEMPLATES_BYNAME = '<?xml version="1.0" encoding="UTF-8"?>
|
187
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
188
|
+
<soap:Body>
|
189
|
+
<GetTemplateByNameResponse xmlns="http://vmware.com/labmanager">
|
190
|
+
<GetTemplateByNameResult>
|
191
|
+
<Template>
|
192
|
+
<id>1</id>
|
193
|
+
<name>template1</name>
|
194
|
+
<description>Template 1</description>
|
195
|
+
<storage_id>21</storage_id>
|
196
|
+
<virtualization_id>6</virtualization_id>
|
197
|
+
<memory>2048</memory>
|
198
|
+
<mac_address>00:50:54:20:01:f3</mac_address>
|
199
|
+
<isAutoConfigEnabled>false</isAutoConfigEnabled>
|
200
|
+
<isPublic>true</isPublic>
|
201
|
+
<isPublished>true</isPublished>
|
202
|
+
<isBusy>false</isBusy>
|
203
|
+
<isDeployed>false</isDeployed>
|
204
|
+
<status>0</status>
|
205
|
+
<managedServerDeployed/>
|
206
|
+
</Template>
|
207
|
+
|
208
|
+
</GetTemplateByNameResult>
|
209
|
+
</GetTemplateByNameResponse>
|
210
|
+
</soap:Body>
|
211
|
+
</soap:Envelope>
|
212
|
+
'
|
213
|
+
|
214
|
+
ENV_LIST_NETWORKS = '<?xml version="1.0" encoding="UTF-8"?>
|
215
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
216
|
+
<soap:Body>
|
217
|
+
<ListNetworksResponse xmlns="http://vmware.com/labmanager">
|
218
|
+
<ListNetworksResult>
|
219
|
+
<Network>
|
220
|
+
<DeployFenced>false</DeployFenced>
|
221
|
+
<DeployFencedMode>Nonfenced</DeployFencedMode>
|
222
|
+
<Description/>
|
223
|
+
<Dns1>10.0.0.2</Dns1>
|
224
|
+
<Dns2>10.0.0.3</Dns2>
|
225
|
+
<DnsSuffix>wdf.sap.corp</DnsSuffix>
|
226
|
+
<Gateway>10.0.0.1</Gateway>
|
227
|
+
<IPAddressingMode>AUTOMATIC_OR_MANUAL</IPAddressingMode>
|
228
|
+
<IsAddressingModeLocked>false</IsAddressingModeLocked>
|
229
|
+
<IsDeployFencedLocked>false</IsDeployFencedLocked>
|
230
|
+
<IsNone>false</IsNone>
|
231
|
+
<IsPhysical>true</IsPhysical>
|
232
|
+
<Name>Network 1</Name>
|
233
|
+
<NetID>1</NetID>
|
234
|
+
<Netmask>255.255.255.0</Netmask>
|
235
|
+
<NetType>Template</NetType>
|
236
|
+
<VlanID>1128</VlanID>
|
237
|
+
<NetworkValref>CP TREX-4LM32</NetworkValref>
|
238
|
+
<parentNetId>0</parentNetId>
|
239
|
+
<userId>0</userId>
|
240
|
+
</Network>
|
241
|
+
<Network>
|
242
|
+
<DeployFenced>false</DeployFenced>
|
243
|
+
<DeployFencedMode>Nonfenced</DeployFencedMode>
|
244
|
+
<Description/>
|
245
|
+
<Dns1>10.0.0.2</Dns1>
|
246
|
+
<Dns2>10.0.0.3</Dns2>
|
247
|
+
<DnsSuffix>wdf.sap.corp</DnsSuffix>
|
248
|
+
<Gateway>10.0.0.1</Gateway>
|
249
|
+
<IPAddressingMode>AUTOMATIC_OR_MANUAL</IPAddressingMode>
|
250
|
+
<IsAddressingModeLocked>false</IsAddressingModeLocked>
|
251
|
+
<IsDeployFencedLocked>false</IsDeployFencedLocked>
|
252
|
+
<IsNone>false</IsNone>
|
253
|
+
<IsPhysical>true</IsPhysical>
|
254
|
+
<Name>Network 2</Name>
|
255
|
+
<NetID>1</NetID>
|
256
|
+
<Netmask>255.255.255.0</Netmask>
|
257
|
+
<NetType>Template</NetType>
|
258
|
+
<VlanID>1128</VlanID>
|
259
|
+
<NetworkValref>CP TREX-4LM32</NetworkValref>
|
260
|
+
<parentNetId>0</parentNetId>
|
261
|
+
<userId>0</userId>
|
262
|
+
</Network>
|
263
|
+
|
264
|
+
</ListNetworksResult>
|
265
|
+
</ListNetworksResponse>
|
266
|
+
</soap:Body>
|
267
|
+
</soap:Envelope>
|
268
|
+
'
|
269
|
+
|
270
|
+
ENV_GET_NETWORK = '<?xml version="1.0" encoding="UTF-8"?>
|
271
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
272
|
+
<soap:Body>
|
273
|
+
<GetNetworkTemplateByNameResponse xmlns="http://vmware.com/labmanager">
|
274
|
+
<GetNetworkTemplateByNameResult>
|
275
|
+
<DeployFenced>false</DeployFenced>
|
276
|
+
<DeployFencedMode>Nonfenced</DeployFencedMode>
|
277
|
+
<Description/>
|
278
|
+
<Dns1>10.0.0.2</Dns1>
|
279
|
+
<Dns2>10.0.0.3</Dns2>
|
280
|
+
<DnsSuffix>wdf.sap.corp</DnsSuffix>
|
281
|
+
<Gateway>10.0.0.1</Gateway>
|
282
|
+
<IPAddressingMode>AUTOMATIC_OR_MANUAL</IPAddressingMode>
|
283
|
+
<IsAddressingModeLocked>false</IsAddressingModeLocked>
|
284
|
+
<IsDeployFencedLocked>false</IsDeployFencedLocked>
|
285
|
+
<IsNone>false</IsNone>
|
286
|
+
<IsPhysical>true</IsPhysical>
|
287
|
+
<Name>Network 1</Name>
|
288
|
+
<NetID>1</NetID>
|
289
|
+
<Netmask>255.255.255.0</Netmask>
|
290
|
+
<NetType>Template</NetType>
|
291
|
+
<VlanID>1128</VlanID>
|
292
|
+
<NetworkValref>CP TREX-4LM32</NetworkValref>
|
293
|
+
<parentNetId>0</parentNetId>
|
294
|
+
<userId>0</userId>
|
295
|
+
</GetNetworkTemplateByNameResult>
|
296
|
+
</GetNetworkTemplateByNameResponse>
|
297
|
+
|
298
|
+
</soap:Body>
|
299
|
+
</soap:Envelope>
|
300
|
+
'
|
301
|
+
|
302
|
+
ENV_CREATE_MACHINE = '<?xml version="1.0" encoding="UTF-8"?>
|
303
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
304
|
+
<soap:Body>
|
305
|
+
<ConfigurationAddMachineExResponse xmlns="http://vmware.com/labmanager">
|
306
|
+
<ConfigurationAddMachineExResult>1</ConfigurationAddMachineExResult>
|
307
|
+
</ConfigurationAddMachineExResponse>
|
308
|
+
</soap:Body>
|
309
|
+
</soap:Envelope>
|
310
|
+
'
|
311
|
+
|
312
|
+
ENV_GET_MACHINE = '<?xml version="1.0" encoding="UTF-8"?>
|
313
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
314
|
+
<soap:Body>
|
315
|
+
<GetMachineByNameResponse xmlns="http://vmware.com/labmanager">
|
316
|
+
<GetMachineByNameResult>
|
317
|
+
<id>1</id>
|
318
|
+
<name>machine1</name>
|
319
|
+
<description>Machine 1</description>
|
320
|
+
<internalIP>10.0.0.1</internalIP>
|
321
|
+
<macAddress>00:50:56:20:03:06</macAddress>
|
322
|
+
<memory>2048</memory>
|
323
|
+
<status>0</status>
|
324
|
+
<isDeployed>false</isDeployed>
|
325
|
+
<configID>1</configID>
|
326
|
+
<DatastoreNameResidesOn>test1</DatastoreNameResidesOn>
|
327
|
+
<OwnerFullName>Owner</OwnerFullName>
|
328
|
+
</GetMachineByNameResult>
|
329
|
+
</GetMachineByNameResponse>
|
330
|
+
</soap:Body>
|
331
|
+
</soap:Envelope>
|
332
|
+
'
|
333
|
+
|
334
|
+
ENV_MACHINE_ACTION = '<?xml version="1.0" encoding="UTF-8"?>
|
335
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
336
|
+
<soap:Body>
|
337
|
+
<MachinePerformActionResponse xmlns="http://vmware.com/labmanager"/>
|
338
|
+
</soap:Body>
|
339
|
+
</soap:Envelope>
|
340
|
+
'
|
341
|
+
|
342
|
+
|
343
|
+
ENV_MACHINE_DELETE = '<?xml version="1.0" encoding="UTF-8"?>
|
344
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
345
|
+
<soap:Body>
|
346
|
+
<MachineDeleteResponse xmlns="http://vmware.com/labmanager"/>
|
347
|
+
</soap:Body>
|
348
|
+
</soap:Envelope>
|
349
|
+
'
|
350
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "labmanager/labmanager_service"
|
3
|
+
require "handsoap"
|
4
|
+
require "test_helper"
|
5
|
+
|
6
|
+
class TestMachines < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include TestHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
configure
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_createMachine
|
16
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_CREATE_MACHINE, :status => 200
|
17
|
+
Handsoap.http_driver = :mock
|
18
|
+
|
19
|
+
driver = Handsoap::Http.drivers[:mock].new
|
20
|
+
result = LabmanagerService.createMachine({:configuration_id =>1,:template_id=>1,:name=>"testing",:description=>"testing"})
|
21
|
+
|
22
|
+
assert_equal result,1
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_getMachineByName
|
27
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_GET_MACHINE, :status => 200
|
28
|
+
Handsoap.http_driver = :mock
|
29
|
+
|
30
|
+
driver = Handsoap::Http.drivers[:mock].new
|
31
|
+
result = LabmanagerService.getMachineByName("1","testing")
|
32
|
+
|
33
|
+
assert_equal result[:id],"1"
|
34
|
+
assert_equal result[:name],"machine1"
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_deployMachine
|
38
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_MACHINE_ACTION, :status => 200
|
39
|
+
Handsoap.http_driver = :mock
|
40
|
+
|
41
|
+
driver = Handsoap::Http.drivers[:mock].new
|
42
|
+
result = LabmanagerService.deployMachine(1)
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_undeployMachine
|
47
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_MACHINE_ACTION, :status => 200
|
48
|
+
Handsoap.http_driver = :mock
|
49
|
+
|
50
|
+
driver = Handsoap::Http.drivers[:mock].new
|
51
|
+
result = LabmanagerService.undeployMachine(1)
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_deleteMachine
|
56
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_MACHINE_DELETE, :status => 200
|
57
|
+
Handsoap.http_driver = :mock
|
58
|
+
|
59
|
+
driver = Handsoap::Http.drivers[:mock].new
|
60
|
+
result = LabmanagerService.deleteMachine(1)
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "labmanager/labmanager_service"
|
3
|
+
require "handsoap"
|
4
|
+
require "test_helper"
|
5
|
+
|
6
|
+
class TestNetworks < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include TestHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
configure
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_listNetworks
|
16
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_LIST_NETWORKS, :status => 200
|
17
|
+
Handsoap.http_driver = :mock
|
18
|
+
|
19
|
+
driver = Handsoap::Http.drivers[:mock].new
|
20
|
+
result = LabmanagerService.listNetworks()
|
21
|
+
|
22
|
+
assert_equal result.length,2
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_getNetwork
|
27
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_GET_NETWORK, :status => 200
|
28
|
+
Handsoap.http_driver = :mock
|
29
|
+
|
30
|
+
driver = Handsoap::Http.drivers[:mock].new
|
31
|
+
result = LabmanagerService.getNetworkByName("network1")
|
32
|
+
|
33
|
+
assert_equal result[:id],"1"
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "labmanager/labmanager_service"
|
3
|
+
require "handsoap"
|
4
|
+
require "test_helper"
|
5
|
+
|
6
|
+
class TestTemplates < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include TestHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
configure
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_listTemplates
|
16
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_LIST_TEMPLATES, :status => 200
|
17
|
+
Handsoap.http_driver = :mock
|
18
|
+
|
19
|
+
driver = Handsoap::Http.drivers[:mock].new
|
20
|
+
result = LabmanagerService.listTemplates()
|
21
|
+
|
22
|
+
assert_equal result.length,2
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_getTemplate
|
27
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_GET_TEMPLATE, :status => 200
|
28
|
+
Handsoap.http_driver = :mock
|
29
|
+
|
30
|
+
driver = Handsoap::Http.drivers[:mock].new
|
31
|
+
result = LabmanagerService.getTemplate(1)
|
32
|
+
|
33
|
+
assert_equal result[:id],"1"
|
34
|
+
assert_equal result[:name],"testtemplate"
|
35
|
+
assert_equal result[:description],"Test Template"
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_getTemplateByName
|
40
|
+
Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_GET_TEMPLATES_BYNAME, :status => 200
|
41
|
+
Handsoap.http_driver = :mock
|
42
|
+
|
43
|
+
driver = Handsoap::Http.drivers[:mock].new
|
44
|
+
result = LabmanagerService.getTemplateByName("template1")
|
45
|
+
|
46
|
+
assert_equal result[:id],"1"
|
47
|
+
assert_equal result[:name],"template1"
|
48
|
+
assert_equal result[:description],"Template 1"
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: labmanager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrew Battye
|
9
|
+
autorequire: name
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-18 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: handsoap
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.1.8
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: curb
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.7.15
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: nokogiri
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.4.4
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id003
|
48
|
+
description:
|
49
|
+
email: andrew@battye.com
|
50
|
+
executables: []
|
51
|
+
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files:
|
55
|
+
- README
|
56
|
+
files:
|
57
|
+
- lib/labmanager/constants.rb
|
58
|
+
- lib/labmanager/labmanager_service.rb
|
59
|
+
- test/12test_labmanager_proxy.rb
|
60
|
+
- test/test_configuration.rb
|
61
|
+
- test/test_framework.rb
|
62
|
+
- test/test_helper.rb
|
63
|
+
- test/test_machines.rb
|
64
|
+
- test/test_networks.rb
|
65
|
+
- test/test_templates.rb
|
66
|
+
- README
|
67
|
+
homepage: ""
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: "0"
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.7.2
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: Ruby SOAP proxy for VMware Lab Manager
|
94
|
+
test_files:
|
95
|
+
- test/12test_labmanager_proxy.rb
|
96
|
+
- test/test_configuration.rb
|
97
|
+
- test/test_framework.rb
|
98
|
+
- test/test_helper.rb
|
99
|
+
- test/test_machines.rb
|
100
|
+
- test/test_networks.rb
|
101
|
+
- test/test_templates.rb
|