28
28
NATRule ,
29
29
Template )
30
30
from marvin .lib .common import get_test_template , get_zone , list_virtual_machines
31
- from marvin .lib .utils import ( validateList , cleanup_resources )
31
+ from marvin .lib .utils import validateList
32
32
from nose .plugins .attrib import attr
33
33
from marvin .codes import PASS ,FAIL
34
34
import base64
@@ -87,6 +87,7 @@ def setUp(self):
87
87
# Get Zone, Domain and Default Built-in template
88
88
self .domain = get_domain (self .apiclient )
89
89
self .zone = get_zone (self .apiclient , self .testClient .getZoneForTests ())
90
+ self .hypervisor = self .testClient .getHypervisorInfo ()
90
91
91
92
#create a user account
92
93
self .account = Account .create (
@@ -96,7 +97,7 @@ def setUp(self):
96
97
)
97
98
98
99
self .testdata ["mode" ] = self .zone .networktype
99
- self .template = get_template (self .apiclient , self .zone .id , self .testdata [ "ostype" ] )
100
+ self .template = get_test_template (self .apiclient , self .zone .id , self .hypervisor )
100
101
101
102
#create a service offering
102
103
small_service_offering = self .testdata ["service_offerings" ]["small" ]
@@ -115,25 +116,21 @@ def setUp(self):
115
116
self .testdata ["network" ],
116
117
networkofferingid = self .no_isolate .id ,
117
118
zoneid = self .zone .id ,
118
- accountid = "admin" ,
119
- domainid = 1
119
+ accountid = self . account . name ,
120
+ domainid = self . account . domainid
120
121
)
121
122
122
123
#build cleanup list
123
124
self .cleanup = [
125
+ self .account ,
126
+ self .no_isolate ,
124
127
self .service_offering ,
125
128
self .isolated_network ,
126
- self .no_isolate ,
127
- self .account ,
128
129
]
129
130
130
131
131
132
def tearDown (self ):
132
- try :
133
- cleanup_resources (self .apiclient , self .cleanup )
134
- except Exception as e :
135
- self .debug ("Warning! Exception in tearDown: %s" % e )
136
-
133
+ super (TestRegisteredUserdata , self ).tearDown ()
137
134
138
135
@attr (tags = ['advanced' , 'simulator' , 'basic' , 'sg' ], required_hardware = False )
139
136
def test_CRUD_operations_userdata (self ):
@@ -192,22 +189,21 @@ def test_deploy_vm_with_registered_userdata(self):
192
189
self .apiclient ,
193
190
self .services ["virtual_machine" ],
194
191
zoneid = self .zone .id ,
195
- accountid = "admin" ,
196
- domainid = 1 ,
192
+ accountid = self . account . name ,
193
+ domainid = self . account . domainid ,
197
194
serviceofferingid = self .service_offering .id ,
198
195
templateid = self .template .id ,
199
196
networkids = [self .isolated_network .id ],
200
197
userdataid = self .userdata2 .userdata .id
201
198
)
202
199
self .cleanup .append (self .virtual_machine )
203
- self .cleanup .append (self .userdata2 )
204
200
205
201
networkid = self .virtual_machine .nic [0 ].networkid
206
202
src_nat_list = PublicIPAddress .list (
207
203
self .apiclient ,
208
204
associatednetworkid = networkid ,
209
- account = "admin" ,
210
- domainid = 1 ,
205
+ account = self . account . name ,
206
+ domainid = self . account . domainid ,
211
207
listall = True ,
212
208
issourcenat = True ,
213
209
)
@@ -320,23 +316,22 @@ def test_deploy_vm_with_registered_userdata_with_params(self):
320
316
self .apiclient ,
321
317
self .services ["virtual_machine" ],
322
318
zoneid = self .zone .id ,
323
- accountid = "admin" ,
324
- domainid = 1 ,
319
+ accountid = self . account . name ,
320
+ domainid = self . account . domainid ,
325
321
serviceofferingid = self .service_offering .id ,
326
322
templateid = self .template .id ,
327
323
networkids = [self .isolated_network .id ],
328
324
userdataid = self .userdata2 .userdata .id ,
329
325
userdatadetails = [{"key1" : "value1" }]
330
326
)
331
327
self .cleanup .append (self .virtual_machine )
332
- self .cleanup .append (self .userdata2 )
333
328
334
329
networkid = self .virtual_machine .nic [0 ].networkid
335
330
src_nat_list = PublicIPAddress .list (
336
331
self .apiclient ,
337
332
associatednetworkid = networkid ,
338
- account = "admin" ,
339
- domainid = 1 ,
333
+ account = self . account . name ,
334
+ domainid = self . account . domainid ,
340
335
listall = True ,
341
336
issourcenat = True ,
342
337
)
@@ -493,15 +488,14 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_allow(self):
493
488
self .apiclient ,
494
489
self .services ["virtual_machine" ],
495
490
zoneid = self .zone .id ,
496
- accountid = "admin" ,
497
- domainid = 1 ,
491
+ accountid = self . account . name ,
492
+ domainid = self . account . domainid ,
498
493
serviceofferingid = self .service_offering .id ,
499
494
templateid = self .template .id ,
500
495
networkids = [self .isolated_network .id ],
501
496
userdataid = self .apiUserdata .userdata .id
502
497
)
503
498
self .cleanup .append (self .virtual_machine )
504
- self .cleanup .append (self .apiUserdata )
505
499
506
500
self .template = Template .linkUserDataToTemplate (
507
501
self .apiclient ,
@@ -512,8 +506,8 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_allow(self):
512
506
src_nat_list = PublicIPAddress .list (
513
507
self .apiclient ,
514
508
associatednetworkid = networkid ,
515
- account = "admin" ,
516
- domainid = 1 ,
509
+ account = self . account . name ,
510
+ domainid = self . account . domainid ,
517
511
listall = True ,
518
512
issourcenat = True ,
519
513
)
@@ -623,16 +617,14 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_append(self):
623
617
self .apiclient ,
624
618
self .services ["virtual_machine" ],
625
619
zoneid = self .zone .id ,
626
- accountid = "admin" ,
627
- domainid = 1 ,
620
+ accountid = self . account . name ,
621
+ domainid = self . account . domainid ,
628
622
serviceofferingid = self .service_offering .id ,
629
623
templateid = self .template .id ,
630
624
networkids = [self .isolated_network .id ],
631
625
userdataid = self .apiUserdata .userdata .id
632
626
)
633
627
self .cleanup .append (self .virtual_machine )
634
- self .cleanup .append (self .apiUserdata )
635
- self .cleanup .append (self .templateUserdata )
636
628
637
629
self .template = Template .linkUserDataToTemplate (
638
630
self .apiclient ,
@@ -643,8 +635,8 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_append(self):
643
635
src_nat_list = PublicIPAddress .list (
644
636
self .apiclient ,
645
637
associatednetworkid = networkid ,
646
- account = "admin" ,
647
- domainid = 1 ,
638
+ account = self . account . name ,
639
+ domainid = self . account . domainid ,
648
640
listall = True ,
649
641
issourcenat = True ,
650
642
)
@@ -770,8 +762,8 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_deny(self):
770
762
self .apiclient ,
771
763
self .services ["virtual_machine" ],
772
764
zoneid = self .zone .id ,
773
- accountid = "admin" ,
774
- domainid = 1 ,
765
+ accountid = self . account . name ,
766
+ domainid = self . account . domainid ,
775
767
serviceofferingid = self .service_offering .id ,
776
768
templateid = self .template .id ,
777
769
networkids = [self .isolated_network .id ],
@@ -781,9 +773,6 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_deny(self):
781
773
self .debug ("Deploy VM with userdata passed during deployment failed as expected because template userdata override policy is deny. Exception here is : %s" %
782
774
e .exception )
783
775
784
- self .cleanup .append (self .apiUserdata )
785
- self .cleanup .append (self .templateUserdata )
786
-
787
776
self .template = Template .linkUserDataToTemplate (
788
777
self .apiclient ,
789
778
templateid = self .template .id
@@ -809,7 +798,6 @@ def test_user_userdata_crud(self):
809
798
account = self .account .name ,
810
799
domainid = self .account .domainid
811
800
)
812
- self .cleanup .append (self .userdata )
813
801
814
802
list_userdata = UserData .list (self .apiclient , id = self .userdata .userdata .id , listall = True )
815
803
self .assertNotEqual (
@@ -853,4 +841,3 @@ def test_user_userdata_crud(self):
853
841
self .userapiclient ,
854
842
id = self .userdata .userdata .id
855
843
)
856
- self .cleanup .remove (self .userdata )
0 commit comments