mirror of https://github.com/apache/cloudstack.git
marvin_refactor: adding isolation methods l3/vlan/gre
also some defaults for factories: cluster, domain, user, vpn, zone Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
parent
47807e8452
commit
c1fd1eb0f6
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
}
|
||||
],
|
||||
"isolationmethods": [
|
||||
"L3"
|
||||
"L3"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
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")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue