diff --git a/setup/dev/advanced.cfg b/setup/dev/advanced.cfg index 216314ff6bc..610adf31291 100644 --- a/setup/dev/advanced.cfg +++ b/setup/dev/advanced.cfg @@ -44,14 +44,10 @@ { "broadcastdomainrange": "ZONE", "name": "VpcVirtualRouter" - }, - { - "broadcastdomainrange": "ZONE", - "name": "InternalLbVm" } ], "isolationmethods": [ - "VLAN" + "VLAN" ] } ], @@ -90,12 +86,8 @@ "clustertype": "CloudManaged", "primaryStorages": [ { - "url": "nfs://10.147.28.6:/export/home/sandbox/primary0", + "url": "nfs://10.147.28.6:/export/home/sandbox/primary", "name": "PS0" - }, - { - "url": "nfs://10.147.28.6:/export/home/sandbox/primary1", - "name": "PS1" } ] }, diff --git a/setup/dev/basic.cfg b/setup/dev/basic.cfg index e91c87aba81..4fdf16dc58d 100644 --- a/setup/dev/basic.cfg +++ b/setup/dev/basic.cfg @@ -44,7 +44,7 @@ } ], "isolationmethods": [ - "L3" + "L3" ] } ], diff --git a/tools/marvin/marvin/integration/lib/factory/ClusterFactory.py b/tools/marvin/marvin/integration/lib/factory/ClusterFactory.py index eaf7daa5fa5..e8e2e223542 100644 --- a/tools/marvin/marvin/integration/lib/factory/ClusterFactory.py +++ b/tools/marvin/marvin/integration/lib/factory/ClusterFactory.py @@ -1,6 +1,9 @@ import factory from marvin.integration.lib.base import Cluster -class ClusterFactory(factory.Factory): +from marvin.integration.lib.factory.CloudStackBaseFactory import CloudStackBaseFactory +from marvin.integration.lib.utils import random_gen + +class ClusterFactory(CloudStackBaseFactory): FACTORY_FOR = Cluster @@ -10,16 +13,12 @@ class ClusterFactory(factory.Factory): podid = None zoneid = None +class XenClusterFactory(ClusterFactory): + clustername = factory.Sequence(lambda n: "xencluster" + random_gen()) + clustertype = "XenServer" + hypervisor = "XenServer" - FACTORY_FOR = Cluster - - - - FACTORY_FOR = Cluster - - id = None - - - FACTORY_FOR = Cluster - - id = None +class KvmClusterFactory(ClusterFactory): + clustername = factory.Sequence(lambda n: "kvmcluster" + random_gen()) + clustertype = "KVM" + hypervisor = "KVM" diff --git a/tools/marvin/marvin/integration/lib/factory/DomainFactory.py b/tools/marvin/marvin/integration/lib/factory/DomainFactory.py index 1c511709538..337f9f2153e 100644 --- a/tools/marvin/marvin/integration/lib/factory/DomainFactory.py +++ b/tools/marvin/marvin/integration/lib/factory/DomainFactory.py @@ -21,4 +21,4 @@ class DomainFactory(factory.Factory): FACTORY_FOR = Domain - name = "Domain" + factory.Sequence(lambda n : random_gen()) + name = factory.Sequence(lambda n : "Domain" + random_gen()) diff --git a/tools/marvin/marvin/integration/lib/factory/UserFactory.py b/tools/marvin/marvin/integration/lib/factory/UserFactory.py index eb2cafbe89b..9f0cc77d03d 100644 --- a/tools/marvin/marvin/integration/lib/factory/UserFactory.py +++ b/tools/marvin/marvin/integration/lib/factory/UserFactory.py @@ -16,14 +16,19 @@ # under the License. import factory from marvin.integration.lib.base import User +from marvin.integration.lib.factory import CloudStackBaseFactory +from marvin.integration.lib.factory.AccountFactory import AccountFactory -class UserFactory(factory.Factory): +class UserFactory(CloudStackBaseFactory): - FACTORY_FOR = User + FACTORY_FOR = User.User - account = None - email = None - firstname = None - lastname = None - password = None - username = None + account = factory.SubFactory(AccountFactory) + email = account.email + firstname = account.firstname + lastname = account.lastname + password = account.password + username = account.username + +class AdminUserFactory(UserFactory): + account = factory.SubFactory(AccountFactory, accounttype=1) diff --git a/tools/marvin/marvin/integration/lib/factory/VpnUserFactory.py b/tools/marvin/marvin/integration/lib/factory/VpnUserFactory.py index 8a7121e5e0f..8647ea90419 100644 --- a/tools/marvin/marvin/integration/lib/factory/VpnUserFactory.py +++ b/tools/marvin/marvin/integration/lib/factory/VpnUserFactory.py @@ -1,8 +1,24 @@ +# 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.integration.lib.base import VpnUser class VpnUserFactory(factory.Factory): - FACTORY_FOR = VpnUser + FACTORY_FOR = VpnUser.VpnUser - password = None - username = None + password = "password" + username = "vpnuser" diff --git a/tools/marvin/marvin/integration/lib/factory/ZoneFactory.py b/tools/marvin/marvin/integration/lib/factory/ZoneFactory.py index c1aa0f05a9f..31c5264820f 100644 --- a/tools/marvin/marvin/integration/lib/factory/ZoneFactory.py +++ b/tools/marvin/marvin/integration/lib/factory/ZoneFactory.py @@ -16,11 +16,22 @@ # under the License. import factory from marvin.integration.lib.base import Zone -class ZoneFactory(factory.Factory): +from marvin.integration.lib.factory.CloudStackBaseFactory import CloudStackBaseFactory +from marvin.integration.lib.utils import random_gen + +class ZoneFactory(CloudStackBaseFactory): FACTORY_FOR = Zone - dns1 = None - internaldns1 = None + dns1 = "8.8.8.8" + internaldns1 = "8.8.8.8" name = None networktype = None + +class AdvancedZoneFactory(ZoneFactory): + name = factory.Sequence(lambda n: "advzone" + random_gen()) + networktype = "Advanced" + +class BasicZoneFactory(ZoneFactory): + name = factory.Sequence(lambda n: "basiczone" + random_gen()) + networktype = "Basic" diff --git a/tools/marvin/marvin/integration/lib/factory/test/testFactories.py b/tools/marvin/marvin/integration/lib/factory/test/testFactories.py index 7e682c21d6b..c7a0a2c4075 100644 --- a/tools/marvin/marvin/integration/lib/factory/test/testFactories.py +++ b/tools/marvin/marvin/integration/lib/factory/test/testFactories.py @@ -35,6 +35,9 @@ from marvin.integration.lib.factory.TemplateFactory import * from marvin.integration.lib.factory.VirtualMachineFactory import * from marvin.integration.lib.base.VirtualMachine import VirtualMachine +from marvin.integration.lib.factory.UserFactory import * +from marvin.integration.lib.base.User import User + class AccountFactoryTest(unittest.TestCase): def setUp(self): self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() @@ -116,4 +119,20 @@ class VirtualMachineFactoryTest(unittest.TestCase): template = get_template(apiclient=self.apiClient, zoneid = zones[0].id, ostype=tf.ostype) vmf = VirtualMachineFactory(serviceofferingid = sf.id, templateid = template.id, zoneid = zones[0].id) - vm = VirtualMachine.create(apiclient=self.apiClient, VirtualMachineFactory=vmf) \ No newline at end of file + vm = VirtualMachine.create(apiclient=self.apiClient, VirtualMachineFactory=vmf) + +class UserFactorySubFactoryTest(unittest.TestCase): + def setUp(self): + self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + + def tearDown(self): + pass + + def test_userSubFactory(self): + uf = UserFactory() + account = AccountFactory.create(apiclient=self.apiClient, AccountFactory=uf.account) + self.assertTrue(account is not None, msg="no account was created") + users = User.list(apiclient=self.apiClient, account=account.name) + self.assertTrue(users is not None, msg="no users were found in the account") + self.assertTrue(len(users) > 0, msg="user list is empty") + self.assertEqual(users[0].username, uf.username, msg="usernames are not same") diff --git a/tools/marvin/marvin/jsonHelper.py b/tools/marvin/marvin/jsonHelper.py index ae40b8dabf0..a075095f06b 100644 --- a/tools/marvin/marvin/jsonHelper.py +++ b/tools/marvin/marvin/jsonHelper.py @@ -16,7 +16,7 @@ # under the License. import cloudstackException -import json +import simplejson as json import inspect from cloudstackAPI import * @@ -117,12 +117,12 @@ def finalizeResultObj(result, responseName, responsecls): if not isinstance(value, jsonLoader): return result - findObj = False - for k, v in value.__dict__.iteritems(): - if k in responsecls.__dict__: - findObj = True + mirrorObj = True + for k,v in value.__dict__.iteritems(): + if k not in responsecls.__dict__: + mirrorObj = False break - if findObj: + if mirrorObj: return value else: return result @@ -274,8 +274,8 @@ due to missing parameter jobid" zone = getResultObj(result, res) print zone.id - result = '{ "attachvolumeresponse" : {"jobid":24} }' - res = attachVolume.attachVolumeResponse() + result = '{ "queryasyncjobresultresponse" : {"accountid":"4a8c3cd0-a696-11e2-b7a5-1aab0c3b0463","userid":"4a8c671e-a696-11e2-b7a5-1aab0c3b0463","cmd":"org.apache.cloudstack.api.command.admin.network.CreatePhysicalNetworkCmd","jobstatus":1,"jobprocstatus":0,"jobresultcode":0,"jobresulttype":"object","jobresult":{"physicalnetwork":{"id":"e0bc9017-9ba8-4551-a6f9-6b3b2ac1d59c","name":"Sandbox-pnet","broadcastdomainrange":"ZONE","zoneid":"88e796cd-953a-44b9-9445-a7c3ee205cc2","state":"Disabled"}},"created":"2013-04-16T18:37:01+0530","jobid":"8fc09350-f42a-4e04-9427-3d1b68f73dd0"} }' + res = createPhysicalNetwork.createPhysicalNetworkResponse() res = getResultObj(result, res) print res diff --git a/tools/marvin/marvin/sandbox/advanced/advanced_env.py b/tools/marvin/marvin/sandbox/advanced/advanced_env.py index 1728e61fb19..4a2fbfbda0f 100644 --- a/tools/marvin/marvin/sandbox/advanced/advanced_env.py +++ b/tools/marvin/marvin/sandbox/advanced/advanced_env.py @@ -50,9 +50,6 @@ def describeResources(config): vpcprovider = provider() vpcprovider.name = 'VpcVirtualRouter' - - lbprovider = provider() - lbprovider.name = 'InternalLbVm' pn = physical_network() pn.name = "Sandbox-pnet" @@ -63,16 +60,14 @@ def describeResources(config): traffictype("Public", {"simulator":"cloud-simulator-public"})] pn.isolationmethods = ["VLAN"] pn.providers.append(vpcprovider) - pn.providers.append(lbprovider) pn2 = physical_network() pn2.name = "Sandbox-pnet2" pn2.vlan = config.get('cloudstack', 'pnet2.vlan') pn2.tags = ["cloud-simulator-guest"] pn2.traffictypes = [traffictype('Guest', {'simulator': 'cloud-simulator-guest'})] - pn2.isolationmethods = ["VLAN"] + pn.isolationmethods = ["VLAN"] pn2.providers.append(vpcprovider) - pn2.providers.append(lbprovider) z.physical_networks.append(pn) z.physical_networks.append(pn2) diff --git a/tools/marvin/marvin/sandbox/demo/simulator/simulator_setup.py b/tools/marvin/marvin/sandbox/demo/simulator/simulator_setup.py index d45d48243bd..65294f2b349 100644 --- a/tools/marvin/marvin/sandbox/demo/simulator/simulator_setup.py +++ b/tools/marvin/marvin/sandbox/demo/simulator/simulator_setup.py @@ -52,6 +52,7 @@ def describeResources(config): pn.isolationmethods = ["VLAN"] pn.providers.append(vpcprovider) pn.vlan = config.get('cloudstack', 'zone.vlan') + pn.isolationmethods = ['VLAN'] z.physical_networks.append(pn)