diff --git a/tools/marvin/marvin/factory/data/network.py b/tools/marvin/marvin/factory/data/network.py index ad6101c013e..962d24f7029 100644 --- a/tools/marvin/marvin/factory/data/network.py +++ b/tools/marvin/marvin/factory/data/network.py @@ -30,6 +30,7 @@ class GuestIsolatedNetworkFactory(NetworkFactory): DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory, apiclient=factory.SelfAttribute('..apiclient'), name=factory.Sequence(lambda n: 'GuestIsolatedNetworkOffering-%s' % random_gen()), + enable__apiclient=factory.SelfAttribute('..apiclient') ) networkofferingid = factory.LazyAttribute(lambda no: no.networkoffering.id if no.networkoffering else no.networkoffering) zoneid = None diff --git a/tools/marvin/marvin/factory/data/networkoffering.py b/tools/marvin/marvin/factory/data/networkoffering.py index 829aee0488c..96f77cf3b42 100644 --- a/tools/marvin/marvin/factory/data/networkoffering.py +++ b/tools/marvin/marvin/factory/data/networkoffering.py @@ -44,11 +44,11 @@ class DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory(NetworkOfferingF } ) # enable the offering post generation - factory.PostGenerationMethodCall('update', - factory.SelfAttribute('..apiclient'), - id=factory.SelfAttribute('..id'), - state='Enabled') - + @factory.post_generation + def enable(self, create, extracted, **kwargs): + if not create: + return + self.update(apiclient=kwargs['apiclient'], id=self.id, state='Enabled') class DefaultSharedNetworkOfferingWithSGServiceFactory(NetworkOfferingFactory): @@ -79,10 +79,12 @@ class DefaultSharedNetworkOfferingWithSGServiceFactory(NetworkOfferingFactory): ) # enable the offering post generation - factory.PostGenerationMethodCall('update', - factory.SelfAttribute('..apiclient'), - id=factory.SelfAttribute('..id'), - state='Enabled') + @factory.post_generation + def enable(self, create, extracted, **kwargs): + if not create: + return + self.update(apiclient=kwargs['apiclient'], id=self.id, state='Enabled') + class DefaultSharedNetworkOfferingFactory(NetworkOfferingFactory): @@ -109,7 +111,8 @@ class DefaultSharedNetworkOfferingFactory(NetworkOfferingFactory): ) # enable the offering post generation - factory.PostGenerationMethodCall('update', - factory.SelfAttribute('..apiclient'), - id=factory.SelfAttribute('..id'), - state='Enabled') + @factory.post_generation + def enable(self, create, extracted, **kwargs): + if not create: + return + self.update(apiclient=kwargs['apiclient'], id=self.id, state='Enabled') diff --git a/tools/marvin/marvin/test/test_factories.py b/tools/marvin/marvin/test/test_factories.py index bf6f22836ac..2dd5069b670 100644 --- a/tools/marvin/marvin/test/test_factories.py +++ b/tools/marvin/marvin/test/test_factories.py @@ -201,17 +201,17 @@ class NetworkFactoryTest(unittest.TestCase): logging=logging.getLogger('factory.cloudstack')).getApiClient() def tearDown(self): - pass + self.accnt.delete() @attr(tags='network') def test_isolatedGuestNetwork(self): """Test to create a network within a guest account @return: """ - accnt = UserAccountFactory(apiclient=self.apiClient) + self.accnt = UserAccountFactory(apiclient=self.apiClient) zones = Zone.list(apiclient=self.apiClient) network = GuestIsolatedNetworkFactory( apiclient=self.apiClient, - zoneid=zones[0].id, + zoneid=zones[0].id ) - self.debug("network created with id, name" %(network.id, network.name)) \ No newline at end of file + logging.getLogger('factory.cloudstack').debug("network created with id %s, name %s" %(network.id, network.name)) \ No newline at end of file