2828 NATRule ,
2929 Template )
3030from 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
3232from nose .plugins .attrib import attr
3333from marvin .codes import PASS ,FAIL
3434import base64
@@ -87,6 +87,7 @@ def setUp(self):
8787 # Get Zone, Domain and Default Built-in template
8888 self .domain = get_domain (self .apiclient )
8989 self .zone = get_zone (self .apiclient , self .testClient .getZoneForTests ())
90+ self .hypervisor = self .testClient .getHypervisorInfo ()
9091
9192 #create a user account
9293 self .account = Account .create (
@@ -96,7 +97,7 @@ def setUp(self):
9697 )
9798
9899 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 )
100101
101102 #create a service offering
102103 small_service_offering = self .testdata ["service_offerings" ]["small" ]
@@ -115,25 +116,21 @@ def setUp(self):
115116 self .testdata ["network" ],
116117 networkofferingid = self .no_isolate .id ,
117118 zoneid = self .zone .id ,
118- accountid = "admin" ,
119- domainid = 1
119+ accountid = self . account . name ,
120+ domainid = self . account . domainid
120121 )
121122
122123 #build cleanup list
123124 self .cleanup = [
125+ self .account ,
126+ self .no_isolate ,
124127 self .service_offering ,
125128 self .isolated_network ,
126- self .no_isolate ,
127- self .account ,
128129 ]
129130
130131
131132 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 ()
137134
138135 @attr (tags = ['advanced' , 'simulator' , 'basic' , 'sg' ], required_hardware = False )
139136 def test_CRUD_operations_userdata (self ):
@@ -192,22 +189,21 @@ def test_deploy_vm_with_registered_userdata(self):
192189 self .apiclient ,
193190 self .services ["virtual_machine" ],
194191 zoneid = self .zone .id ,
195- accountid = "admin" ,
196- domainid = 1 ,
192+ accountid = self . account . name ,
193+ domainid = self . account . domainid ,
197194 serviceofferingid = self .service_offering .id ,
198195 templateid = self .template .id ,
199196 networkids = [self .isolated_network .id ],
200197 userdataid = self .userdata2 .userdata .id
201198 )
202199 self .cleanup .append (self .virtual_machine )
203- self .cleanup .append (self .userdata2 )
204200
205201 networkid = self .virtual_machine .nic [0 ].networkid
206202 src_nat_list = PublicIPAddress .list (
207203 self .apiclient ,
208204 associatednetworkid = networkid ,
209- account = "admin" ,
210- domainid = 1 ,
205+ account = self . account . name ,
206+ domainid = self . account . domainid ,
211207 listall = True ,
212208 issourcenat = True ,
213209 )
@@ -320,23 +316,22 @@ def test_deploy_vm_with_registered_userdata_with_params(self):
320316 self .apiclient ,
321317 self .services ["virtual_machine" ],
322318 zoneid = self .zone .id ,
323- accountid = "admin" ,
324- domainid = 1 ,
319+ accountid = self . account . name ,
320+ domainid = self . account . domainid ,
325321 serviceofferingid = self .service_offering .id ,
326322 templateid = self .template .id ,
327323 networkids = [self .isolated_network .id ],
328324 userdataid = self .userdata2 .userdata .id ,
329325 userdatadetails = [{"key1" : "value1" }]
330326 )
331327 self .cleanup .append (self .virtual_machine )
332- self .cleanup .append (self .userdata2 )
333328
334329 networkid = self .virtual_machine .nic [0 ].networkid
335330 src_nat_list = PublicIPAddress .list (
336331 self .apiclient ,
337332 associatednetworkid = networkid ,
338- account = "admin" ,
339- domainid = 1 ,
333+ account = self . account . name ,
334+ domainid = self . account . domainid ,
340335 listall = True ,
341336 issourcenat = True ,
342337 )
@@ -493,15 +488,14 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_allow(self):
493488 self .apiclient ,
494489 self .services ["virtual_machine" ],
495490 zoneid = self .zone .id ,
496- accountid = "admin" ,
497- domainid = 1 ,
491+ accountid = self . account . name ,
492+ domainid = self . account . domainid ,
498493 serviceofferingid = self .service_offering .id ,
499494 templateid = self .template .id ,
500495 networkids = [self .isolated_network .id ],
501496 userdataid = self .apiUserdata .userdata .id
502497 )
503498 self .cleanup .append (self .virtual_machine )
504- self .cleanup .append (self .apiUserdata )
505499
506500 self .template = Template .linkUserDataToTemplate (
507501 self .apiclient ,
@@ -512,8 +506,8 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_allow(self):
512506 src_nat_list = PublicIPAddress .list (
513507 self .apiclient ,
514508 associatednetworkid = networkid ,
515- account = "admin" ,
516- domainid = 1 ,
509+ account = self . account . name ,
510+ domainid = self . account . domainid ,
517511 listall = True ,
518512 issourcenat = True ,
519513 )
@@ -623,16 +617,14 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_append(self):
623617 self .apiclient ,
624618 self .services ["virtual_machine" ],
625619 zoneid = self .zone .id ,
626- accountid = "admin" ,
627- domainid = 1 ,
620+ accountid = self . account . name ,
621+ domainid = self . account . domainid ,
628622 serviceofferingid = self .service_offering .id ,
629623 templateid = self .template .id ,
630624 networkids = [self .isolated_network .id ],
631625 userdataid = self .apiUserdata .userdata .id
632626 )
633627 self .cleanup .append (self .virtual_machine )
634- self .cleanup .append (self .apiUserdata )
635- self .cleanup .append (self .templateUserdata )
636628
637629 self .template = Template .linkUserDataToTemplate (
638630 self .apiclient ,
@@ -643,8 +635,8 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_append(self):
643635 src_nat_list = PublicIPAddress .list (
644636 self .apiclient ,
645637 associatednetworkid = networkid ,
646- account = "admin" ,
647- domainid = 1 ,
638+ account = self . account . name ,
639+ domainid = self . account . domainid ,
648640 listall = True ,
649641 issourcenat = True ,
650642 )
@@ -770,8 +762,8 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_deny(self):
770762 self .apiclient ,
771763 self .services ["virtual_machine" ],
772764 zoneid = self .zone .id ,
773- accountid = "admin" ,
774- domainid = 1 ,
765+ accountid = self . account . name ,
766+ domainid = self . account . domainid ,
775767 serviceofferingid = self .service_offering .id ,
776768 templateid = self .template .id ,
777769 networkids = [self .isolated_network .id ],
@@ -781,9 +773,6 @@ def test_deploy_vm_with_registered_userdata_with_override_policy_deny(self):
781773 self .debug ("Deploy VM with userdata passed during deployment failed as expected because template userdata override policy is deny. Exception here is : %s" %
782774 e .exception )
783775
784- self .cleanup .append (self .apiUserdata )
785- self .cleanup .append (self .templateUserdata )
786-
787776 self .template = Template .linkUserDataToTemplate (
788777 self .apiclient ,
789778 templateid = self .template .id
@@ -809,7 +798,6 @@ def test_user_userdata_crud(self):
809798 account = self .account .name ,
810799 domainid = self .account .domainid
811800 )
812- self .cleanup .append (self .userdata )
813801
814802 list_userdata = UserData .list (self .apiclient , id = self .userdata .userdata .id , listall = True )
815803 self .assertNotEqual (
@@ -853,4 +841,3 @@ def test_user_userdata_crud(self):
853841 self .userapiclient ,
854842 id = self .userdata .userdata .id
855843 )
856- self .cleanup .remove (self .userdata )
0 commit comments