marvin_refactor: network data factory network can create isolated guest and shared guest networks. the network object will inturn use the default networkofferings which are auto-enabeld by their postgenerators
Signed-off-by: Prasanna Santhanam <t...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ffb7820a Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ffb7820a Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ffb7820a Branch: refs/heads/marvin-refactor Commit: ffb7820a869a117506c89554563ae59fd41a7348 Parents: b19faea Author: Prasanna Santhanam <t...@apache.org> Authored: Sat Sep 7 11:02:18 2013 +0530 Committer: Prasanna Santhanam <t...@apache.org> Committed: Wed Oct 2 20:27:28 2013 +0530 ---------------------------------------------------------------------- tools/marvin/marvin/factory/data/network.py | 48 ++++++++++++++++++++ .../marvin/factory/data/networkoffering.py | 44 +++++++++++++++++- 2 files changed, 91 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffb7820a/tools/marvin/marvin/factory/data/network.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/factory/data/network.py b/tools/marvin/marvin/factory/data/network.py new file mode 100644 index 0000000..ad6101c --- /dev/null +++ b/tools/marvin/marvin/factory/data/network.py @@ -0,0 +1,48 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import factory +from marvin.legacy.utils import random_gen +from marvin.factory.network import NetworkFactory +from marvin.factory.data.networkoffering import DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory +from marvin.factory.data.networkoffering import DefaultSharedNetworkOfferingFactory + +class GuestIsolatedNetworkFactory(NetworkFactory): + + displaytext = factory.Sequence(lambda n: 'GuestIsolatedNetwork-%s' % random_gen()) + name = factory.Sequence(lambda n: 'GuestIsolatedNetwork-%s' % random_gen()) + networkoffering =\ + factory.SubFactory( + DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory, + apiclient=factory.SelfAttribute('..apiclient'), + name=factory.Sequence(lambda n: 'GuestIsolatedNetworkOffering-%s' % random_gen()), + ) + networkofferingid = factory.LazyAttribute(lambda no: no.networkoffering.id if no.networkoffering else no.networkoffering) + zoneid = None + +class SharedNetworkFactory(NetworkFactory): + + displaytext = factory.Sequence(lambda n: 'SharedNetwork-%s' % random_gen()) + name = factory.Sequence(lambda n: 'SharedNetwork-%d' % random_gen()) + networkoffering = \ + factory.SubFactory( + DefaultSharedNetworkOfferingFactory, + apiclient=factory.SelfAttribute('..apiclient'), + name=factory.Sequence(lambda n: 'SharedNetworkOffering-%s' % random_gen()) + ) + networkofferingid = factory.LazyAttribute(lambda no: no.networkoffering.id if not no.networkoffering else no.networkoffering) + zoneid = None \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ffb7820a/tools/marvin/marvin/factory/data/networkoffering.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/factory/data/networkoffering.py b/tools/marvin/marvin/factory/data/networkoffering.py index 4e54c4b..829aee0 100644 --- a/tools/marvin/marvin/factory/data/networkoffering.py +++ b/tools/marvin/marvin/factory/data/networkoffering.py @@ -17,7 +17,7 @@ import factory from marvin.factory.networkoffering import NetworkOfferingFactory -from marvin.utils import random_gen +from marvin.legacy.utils import random_gen class DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory(NetworkOfferingFactory): @@ -43,6 +43,12 @@ class DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory(NetworkOfferingF 'provider': 'VirtualRouter' } ) + # enable the offering post generation + factory.PostGenerationMethodCall('update', + factory.SelfAttribute('..apiclient'), + id=factory.SelfAttribute('..id'), + state='Enabled') + class DefaultSharedNetworkOfferingWithSGServiceFactory(NetworkOfferingFactory): @@ -71,3 +77,39 @@ class DefaultSharedNetworkOfferingWithSGServiceFactory(NetworkOfferingFactory): 'provider': provider } ) + + # enable the offering post generation + factory.PostGenerationMethodCall('update', + factory.SelfAttribute('..apiclient'), + id=factory.SelfAttribute('..id'), + state='Enabled') + + +class DefaultSharedNetworkOfferingFactory(NetworkOfferingFactory): + + displaytext = factory.Sequence(lambda n : "DefaultSharedNetworkOfferingFactory-%d" % n) + name = factory.Sequence(lambda n : "DefaultSharedNetworkOfferingFactory-%d" % n) + availability = "Optional" + supportedservices = "Dns,Dhcp,UserData" + guestiptype = "Shared" + traffictype = "GUEST" + + specifyVlan = True + specifyIpRanges = True + isPersistent = False + conserveMode = True + + serviceProviderList = [] + for service in map(lambda l: l.strip(' '), supportedservices.split(',')): + serviceProviderList.append( + { + 'service': service, + 'provider': 'VirtualRouter' + } + ) + + # enable the offering post generation + factory.PostGenerationMethodCall('update', + factory.SelfAttribute('..apiclient'), + id=factory.SelfAttribute('..id'), + state='Enabled')