mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
affinitygroup bvt: changes to the bvt for affinity groups
Added tags for the test, base.py extensions for list, craete, delete and fixes to the test Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
parent
7201eb9ee4
commit
9de7a68e92
@ -52,12 +52,12 @@ class Services:
|
||||
# In MBs
|
||||
},
|
||||
"ostype": 'CentOS 5.3 (64-bit)',
|
||||
"mode": 'advanced',
|
||||
"virtual_machine" : {
|
||||
"affinity": {
|
||||
"name": "webvms",
|
||||
"type": "host anti-affinity",
|
||||
}
|
||||
},
|
||||
"hypervisor" : "XenServer",
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,19 +98,22 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase):
|
||||
cls.services["service_offering"]
|
||||
)
|
||||
|
||||
cls.ag = AffinityGroup.create(cls.api_client, cls.services["virtual_machine"]["affinity"], domainid=cls.domain.id)
|
||||
cls.ag = AffinityGroup.create(cls.api_client, cls.services["virtual_machine"]["affinity"],
|
||||
account=cls.services["account"], domainid=cls.domain.id)
|
||||
|
||||
cls._cleanup = [
|
||||
cls.service_offering,
|
||||
cls.disk_offering,
|
||||
cls.account,
|
||||
]
|
||||
return
|
||||
|
||||
@attr(tags=["simulator", "basic", "advanced"])
|
||||
@attr(tags=["simulator", "basic", "advanced", "multihost"])
|
||||
def test_DeployVmAntiAffinityGroup(self):
|
||||
"""
|
||||
Deploys a couple of VMs in the same affinity group and verifies they are not on the same host
|
||||
test DeployVM in anti-affinity groups
|
||||
|
||||
deploy VM1 and VM2 in the same host-anti-affinity groups
|
||||
Verify that the vms are deployed on separate hosts
|
||||
"""
|
||||
#deploy VM1 in affinity group created in setUp
|
||||
vm1 = VirtualMachine.create(
|
||||
@ -120,8 +123,7 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase):
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
affinitygroupnames=self.ag.name,
|
||||
mode=self.services["mode"]
|
||||
affinitygroupnames=[self.ag.name]
|
||||
)
|
||||
|
||||
list_vm1 = list_virtual_machines(
|
||||
@ -154,12 +156,11 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase):
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
affinitygroupnames=self.ag.name,
|
||||
mode=self.services["mode"]
|
||||
affinitygroupnames=[self.ag.name]
|
||||
)
|
||||
list_vm2 = list_virtual_machines(
|
||||
self.api_client,
|
||||
id=self.vm1.id
|
||||
id=vm2.id
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(list_vm2, list),
|
||||
|
||||
@ -90,10 +90,7 @@ class Account:
|
||||
cmd.firstname = services["firstname"]
|
||||
cmd.lastname = services["lastname"]
|
||||
|
||||
# Password Encoding
|
||||
mdf = hashlib.md5()
|
||||
mdf.update(services["password"])
|
||||
cmd.password = mdf.hexdigest()
|
||||
cmd.password = services["password"]
|
||||
cmd.username = "-".join([services["username"], random_gen()])
|
||||
|
||||
if domainid:
|
||||
@ -223,7 +220,7 @@ class VirtualMachine:
|
||||
def create(cls, apiclient, services, templateid=None, accountid=None,
|
||||
domainid=None, zoneid=None, networkids=None, serviceofferingid=None,
|
||||
securitygroupids=None, projectid=None, startvm=None,
|
||||
diskofferingid=None, affinitygroupname=None, hostid=None, mode='basic'):
|
||||
diskofferingid=None, affinitygroupnames=None, hostid=None, mode='basic'):
|
||||
"""Create the instance"""
|
||||
|
||||
cmd = deployVirtualMachine.deployVirtualMachineCmd()
|
||||
@ -270,6 +267,8 @@ class VirtualMachine:
|
||||
|
||||
if "affinitygroupnames" in services:
|
||||
cmd.affinitygroupnames = services["affinitygroupnames"]
|
||||
elif affinitygroupnames:
|
||||
cmd.affinitygroupnames = affinitygroupnames
|
||||
|
||||
if projectid:
|
||||
cmd.projectid = projectid
|
||||
@ -2441,13 +2440,19 @@ class AffinityGroup:
|
||||
agCmd.type = services['type']
|
||||
agCmd.account = services['account'] if 'account' in services else account
|
||||
agCmd.domainid = services['domainid'] if 'domainid' in services else domainid
|
||||
return AffinityGroup(apiclient.createAffinityGroup(agCmd).__dict__)
|
||||
|
||||
def update(self):
|
||||
def update(self, apiclient):
|
||||
pass
|
||||
|
||||
def delete(self):
|
||||
pass
|
||||
def delete(self, apiclient):
|
||||
cmd = deleteAffinityGroup.deleteAffinityGroupCmd()
|
||||
cmd.id = self.id
|
||||
return apiclient.deleteVPC(cmd)
|
||||
|
||||
|
||||
@classmethod
|
||||
def list(cls):
|
||||
pass
|
||||
def list(cls, apiclient, **kwargs):
|
||||
cmd = listAffinityGroups.listAffinityGroupsCmd()
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.listVPCs(cmd))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user