mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Additional tests in various areas
This commit is contained in:
parent
9bba325915
commit
ce59b31c8d
File diff suppressed because it is too large
Load Diff
@ -92,6 +92,7 @@ class Services:
|
|||||||
"network": {
|
"network": {
|
||||||
"name": "Test Network",
|
"name": "Test Network",
|
||||||
"displaytext": "Test Network",
|
"displaytext": "Test Network",
|
||||||
|
"vlan": 2370,
|
||||||
},
|
},
|
||||||
"lbrule": {
|
"lbrule": {
|
||||||
"name": "SSH",
|
"name": "SSH",
|
||||||
@ -137,7 +138,7 @@ class Services:
|
|||||||
"publicport": 22,
|
"publicport": 22,
|
||||||
"protocol": 'TCP',
|
"protocol": 'TCP',
|
||||||
},
|
},
|
||||||
"ostypeid": '01853327-513e-4508-9628-f1f55db1946f',
|
"ostypeid": 'bc66ada0-99e7-483b-befc-8fb0c2129b70',
|
||||||
# Cent OS 5.3 (64 bit)
|
# Cent OS 5.3 (64 bit)
|
||||||
"sleep": 60,
|
"sleep": 60,
|
||||||
"timeout": 10,
|
"timeout": 10,
|
||||||
@ -1811,3 +1812,131 @@ class TestNetworkUpgrade(cloudstackTestCase):
|
|||||||
changecidr=True
|
changecidr=True
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skip("Skipped since shared network requires StartIp/endIp/gateway/netmask")
|
||||||
|
class TestSharedNetworkWithoutIp(cloudstackTestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.api_client = super(
|
||||||
|
TestSharedNetworkWithoutIp,
|
||||||
|
cls
|
||||||
|
).getClsTestClient().getApiClient()
|
||||||
|
cls.services = Services().services
|
||||||
|
# Get Zone, Domain and templates
|
||||||
|
cls.domain = get_domain(cls.api_client, cls.services)
|
||||||
|
cls.zone = get_zone(cls.api_client, cls.services)
|
||||||
|
cls.template = get_template(
|
||||||
|
cls.api_client,
|
||||||
|
cls.zone.id,
|
||||||
|
cls.services["ostypeid"]
|
||||||
|
)
|
||||||
|
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||||
|
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||||
|
|
||||||
|
cls.service_offering = ServiceOffering.create(
|
||||||
|
cls.api_client,
|
||||||
|
cls.services["service_offering"]
|
||||||
|
)
|
||||||
|
|
||||||
|
cls._cleanup = [
|
||||||
|
cls.service_offering,
|
||||||
|
]
|
||||||
|
return
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
try:
|
||||||
|
#Cleanup resources used
|
||||||
|
cleanup_resources(cls.api_client, cls._cleanup)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
|
return
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.apiclient = self.testClient.getApiClient()
|
||||||
|
self.dbclient = self.testClient.getDbConnection()
|
||||||
|
self.account = Account.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["account"],
|
||||||
|
admin=True,
|
||||||
|
domainid=self.domain.id
|
||||||
|
)
|
||||||
|
self.cleanup = []
|
||||||
|
return
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
try:
|
||||||
|
self.account.delete(self.apiclient)
|
||||||
|
interval = list_configurations(
|
||||||
|
self.apiclient,
|
||||||
|
name='account.cleanup.interval'
|
||||||
|
)
|
||||||
|
# Sleep to ensure that all resources are deleted
|
||||||
|
time.sleep(int(interval[0].value) * 2)
|
||||||
|
#Clean up, terminate the created network offerings
|
||||||
|
cleanup_resources(self.apiclient, self.cleanup)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
|
return
|
||||||
|
|
||||||
|
@attr(tags=["advanced", "advancedns", "simulator", "network", "api"])
|
||||||
|
def test_deployVmSharedNetworkWithoutIpRange(self):
|
||||||
|
"""Test deployVM in shared network without startIp/endIp
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Steps for validation
|
||||||
|
# 1. create a shared network using shared network offering but do not
|
||||||
|
# specify startIp/endIp arguments
|
||||||
|
# 2. create an account
|
||||||
|
# 3. deploy a VM in this account using the above network
|
||||||
|
# Validate the following
|
||||||
|
# 1. listNetworks should return the created network
|
||||||
|
# 2. listAccounts to return the created account
|
||||||
|
# 3. VM deployment should succeed and NIC is in networks address space
|
||||||
|
# 4. delete the account
|
||||||
|
|
||||||
|
self.debug(
|
||||||
|
"Fetching default shared network offering from nw offerings")
|
||||||
|
network_offerings = NetworkOffering.list(
|
||||||
|
self.apiclient,
|
||||||
|
listall=True,
|
||||||
|
guestiptype="Shared",
|
||||||
|
name="DefaultSharedNetworkOffering",
|
||||||
|
displaytext="Offering for Shared networks"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
isinstance(network_offerings, list),
|
||||||
|
True,
|
||||||
|
"Nw offerings should have atleast a shared nw offering"
|
||||||
|
)
|
||||||
|
shared_nw_off = network_offerings[0]
|
||||||
|
self.debug("Shared netwrk offering: %s" % shared_nw_off.name)
|
||||||
|
|
||||||
|
self.debug("Creating a network from shared network offering")
|
||||||
|
self.network = Network.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["network"],
|
||||||
|
accountid=self.account.account.name,
|
||||||
|
domainid=self.account.account.domainid,
|
||||||
|
networkofferingid=shared_nw_off.id,
|
||||||
|
zoneid=self.zone.id
|
||||||
|
)
|
||||||
|
self.debug("Created network with ID: %s" % self.network.id)
|
||||||
|
|
||||||
|
self.debug("Deploying VM in account: %s" % self.account.account.name)
|
||||||
|
try:
|
||||||
|
# Spawn an instance in that network
|
||||||
|
VirtualMachine.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["virtual_machine"],
|
||||||
|
accountid=self.account.account.name,
|
||||||
|
domainid=self.account.account.domainid,
|
||||||
|
serviceofferingid=self.service_offering.id,
|
||||||
|
networkids=[str(self.network.id)]
|
||||||
|
)
|
||||||
|
self.debug("Deployed VM in network: %s" % self.network.id)
|
||||||
|
except Exception as e:
|
||||||
|
self.fail("Deply Vm in shared network failed! - %s" % e)
|
||||||
|
return
|
||||||
|
|||||||
@ -62,8 +62,8 @@ class Services:
|
|||||||
"name": "Tiny Instance",
|
"name": "Tiny Instance",
|
||||||
"displaytext": "Tiny Instance",
|
"displaytext": "Tiny Instance",
|
||||||
"cpunumber": 1,
|
"cpunumber": 1,
|
||||||
"cpuspeed": 100, # in MHz
|
"cpuspeed": 100, # in MHz
|
||||||
"memory": 64, # In MBs
|
"memory": 64, # In MBs
|
||||||
},
|
},
|
||||||
"disk_offering": {
|
"disk_offering": {
|
||||||
"displaytext": "Tiny Disk Offering",
|
"displaytext": "Tiny Disk Offering",
|
||||||
@ -89,7 +89,30 @@ class Services:
|
|||||||
"ostypeid": '01853327-513e-4508-9628-f1f55db1946f',
|
"ostypeid": '01853327-513e-4508-9628-f1f55db1946f',
|
||||||
"templatefilter": 'self',
|
"templatefilter": 'self',
|
||||||
},
|
},
|
||||||
"ostypeid": '01853327-513e-4508-9628-f1f55db1946f',
|
"network_offering": {
|
||||||
|
"name": 'Network offering-VR services',
|
||||||
|
"displaytext": 'Network offering-VR services',
|
||||||
|
"guestiptype": 'Isolated',
|
||||||
|
"supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
|
||||||
|
"traffictype": 'GUEST',
|
||||||
|
"availability": 'Optional',
|
||||||
|
"serviceProviderList": {
|
||||||
|
"Dhcp": 'VirtualRouter',
|
||||||
|
"Dns": 'VirtualRouter',
|
||||||
|
"SourceNat": 'VirtualRouter',
|
||||||
|
"PortForwarding": 'VirtualRouter',
|
||||||
|
"Vpn": 'VirtualRouter',
|
||||||
|
"Firewall": 'VirtualRouter',
|
||||||
|
"Lb": 'VirtualRouter',
|
||||||
|
"UserData": 'VirtualRouter',
|
||||||
|
"StaticNat": 'VirtualRouter',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"network": {
|
||||||
|
"name": "Test Network",
|
||||||
|
"displaytext": "Test Network",
|
||||||
|
},
|
||||||
|
"ostypeid": 'bc66ada0-99e7-483b-befc-8fb0c2129b70',
|
||||||
# Cent OS 5.3 (64 bit)
|
# Cent OS 5.3 (64 bit)
|
||||||
"sleep": 60,
|
"sleep": 60,
|
||||||
"timeout": 10,
|
"timeout": 10,
|
||||||
@ -156,7 +179,7 @@ class TestProjectLimits(cloudstackTestCase):
|
|||||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
|
@attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
|
||||||
def test_01_project_limits(self):
|
def test_01_project_limits(self):
|
||||||
""" Test project limits
|
""" Test project limits
|
||||||
"""
|
"""
|
||||||
@ -303,7 +326,7 @@ class TestProjectLimits(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
|
@attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
|
||||||
@unittest.skip("No provision for updating resource limits from account through API")
|
@unittest.skip("No provision for updating resource limits from account through API")
|
||||||
def test_02_project_limits_normal_user(self):
|
def test_02_project_limits_normal_user(self):
|
||||||
""" Test project limits
|
""" Test project limits
|
||||||
@ -527,7 +550,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
|
@attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
|
||||||
def test_03_vm_per_project(self):
|
def test_03_vm_per_project(self):
|
||||||
"""Test VM limit per project
|
"""Test VM limit per project
|
||||||
"""
|
"""
|
||||||
@ -543,7 +566,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
0, # Instance
|
0, # Instance
|
||||||
max=2,
|
max=2,
|
||||||
projectid=self.project.id
|
projectid=self.project.id
|
||||||
)
|
)
|
||||||
@ -589,7 +612,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "eip", "advancedns", "simulator"])
|
@attr(tags=["advanced", "eip", "advancedns", "simulator"])
|
||||||
def test_04_publicip_per_project(self):
|
def test_04_publicip_per_project(self):
|
||||||
"""Test Public IP limit per project
|
"""Test Public IP limit per project
|
||||||
"""
|
"""
|
||||||
@ -607,7 +630,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
1, # Public Ip
|
1, # Public Ip
|
||||||
max=2,
|
max=2,
|
||||||
projectid=self.project.id
|
projectid=self.project.id
|
||||||
)
|
)
|
||||||
@ -674,7 +697,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
|
@attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
|
||||||
def test_05_snapshots_per_project(self):
|
def test_05_snapshots_per_project(self):
|
||||||
"""Test Snapshot limit per project
|
"""Test Snapshot limit per project
|
||||||
"""
|
"""
|
||||||
@ -691,7 +714,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
3, # Snapshot
|
3, # Snapshot
|
||||||
max=1,
|
max=1,
|
||||||
projectid=self.project.id
|
projectid=self.project.id
|
||||||
)
|
)
|
||||||
@ -751,7 +774,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
|
@attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
|
||||||
def test_06_volumes_per_project(self):
|
def test_06_volumes_per_project(self):
|
||||||
"""Test Volumes limit per project
|
"""Test Volumes limit per project
|
||||||
"""
|
"""
|
||||||
@ -768,7 +791,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
2, # Volume
|
2, # Volume
|
||||||
max=2,
|
max=2,
|
||||||
projectid=self.project.id
|
projectid=self.project.id
|
||||||
)
|
)
|
||||||
@ -800,7 +823,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "basic", "sg", "eip", "advancedns"])
|
@attr(tags=["advanced", "basic", "sg", "eip", "advancedns"])
|
||||||
def test_07_templates_per_project(self):
|
def test_07_templates_per_project(self):
|
||||||
"""Test Templates limit per project
|
"""Test Templates limit per project
|
||||||
"""
|
"""
|
||||||
@ -813,7 +836,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
# Reset the volume limits
|
# Reset the volume limits
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
2, # Volume
|
2, # Volume
|
||||||
max=5,
|
max=5,
|
||||||
projectid=self.project.id
|
projectid=self.project.id
|
||||||
)
|
)
|
||||||
@ -823,7 +846,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
4, # Template
|
4, # Template
|
||||||
max=1,
|
max=1,
|
||||||
projectid=self.project.id
|
projectid=self.project.id
|
||||||
)
|
)
|
||||||
@ -884,3 +907,141 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||||||
projectid=self.project.id
|
projectid=self.project.id
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TestMaxProjectNetworks(cloudstackTestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.api_client = super(
|
||||||
|
TestMaxProjectNetworks,
|
||||||
|
cls
|
||||||
|
).getClsTestClient().getApiClient()
|
||||||
|
cls.services = Services().services
|
||||||
|
# Get Zone, Domain and templates
|
||||||
|
cls.domain = get_domain(cls.api_client, cls.services)
|
||||||
|
cls.zone = get_zone(cls.api_client, cls.services)
|
||||||
|
cls.template = get_template(
|
||||||
|
cls.api_client,
|
||||||
|
cls.zone.id,
|
||||||
|
cls.services["ostypeid"]
|
||||||
|
)
|
||||||
|
cls.service_offering = ServiceOffering.create(
|
||||||
|
cls.api_client,
|
||||||
|
cls.services["service_offering"]
|
||||||
|
)
|
||||||
|
cls.network_offering = NetworkOffering.create(
|
||||||
|
cls.api_client,
|
||||||
|
cls.services["network_offering"],
|
||||||
|
conservemode=True
|
||||||
|
)
|
||||||
|
# Enable Network offering
|
||||||
|
cls.network_offering.update(cls.api_client, state='Enabled')
|
||||||
|
|
||||||
|
cls._cleanup = [
|
||||||
|
cls.service_offering,
|
||||||
|
cls.network_offering
|
||||||
|
]
|
||||||
|
return
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
try:
|
||||||
|
#Cleanup resources used
|
||||||
|
cleanup_resources(cls.api_client, cls._cleanup)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
|
return
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.apiclient = self.testClient.getApiClient()
|
||||||
|
self.dbclient = self.testClient.getDbConnection()
|
||||||
|
self.account = Account.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["account"],
|
||||||
|
admin=True,
|
||||||
|
domainid=self.domain.id
|
||||||
|
)
|
||||||
|
self.cleanup = []
|
||||||
|
return
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
try:
|
||||||
|
#Clean up, terminate the created network offerings
|
||||||
|
cleanup_resources(self.apiclient, self.cleanup)
|
||||||
|
self.account.delete(self.apiclient)
|
||||||
|
interval = list_configurations(
|
||||||
|
self.apiclient,
|
||||||
|
name='account.cleanup.interval'
|
||||||
|
)
|
||||||
|
# Sleep to ensure that all resources are deleted
|
||||||
|
time.sleep(int(interval[0].value) * 2)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
|
return
|
||||||
|
|
||||||
|
@attr(tags=["advanced", "advancedns", "simulator",
|
||||||
|
"api", "basic", "eip", "sg"])
|
||||||
|
def test_maxAccountNetworks(self):
|
||||||
|
"""Test Limit number of guest account specific networks
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Steps for validation
|
||||||
|
# 1. Fetch max.account.networks from configurations
|
||||||
|
# 2. Create an account. Create account more that max.accout.network
|
||||||
|
# 3. Create network should fail
|
||||||
|
|
||||||
|
self.debug("Creating project with '%s' as admin" %
|
||||||
|
self.account.account.name)
|
||||||
|
# Create project as a domain admin
|
||||||
|
project = Project.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["project"],
|
||||||
|
account=self.account.account.name,
|
||||||
|
domainid=self.account.account.domainid
|
||||||
|
)
|
||||||
|
# Cleanup created project at end of test
|
||||||
|
self.cleanup.append(project)
|
||||||
|
self.debug("Created project with domain admin with ID: %s" %
|
||||||
|
project.id)
|
||||||
|
|
||||||
|
config = Configurations.list(
|
||||||
|
self.apiclient,
|
||||||
|
name='max.project.networks',
|
||||||
|
listall=True
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
isinstance(config, list),
|
||||||
|
True,
|
||||||
|
"List configurations hsould have max.project.networks"
|
||||||
|
)
|
||||||
|
|
||||||
|
config_value = int(config[0].value)
|
||||||
|
self.debug("max.project.networks: %s" % config_value)
|
||||||
|
|
||||||
|
for ctr in range(config_value):
|
||||||
|
# Creating network using the network offering created
|
||||||
|
self.debug("Creating network with network offering: %s" %
|
||||||
|
self.network_offering.id)
|
||||||
|
network = Network.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["network"],
|
||||||
|
projectid=project.id,
|
||||||
|
networkofferingid=self.network_offering.id,
|
||||||
|
zoneid=self.zone.id
|
||||||
|
)
|
||||||
|
self.debug("Created network with ID: %s" % network.id)
|
||||||
|
self.debug(
|
||||||
|
"Creating network in account already having networks : %s" %
|
||||||
|
config_value)
|
||||||
|
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
Network.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["network"],
|
||||||
|
projectid=project.id,
|
||||||
|
networkofferingid=self.network_offering.id,
|
||||||
|
zoneid=self.zone.id
|
||||||
|
)
|
||||||
|
self.debug('Create network failed (as expected)')
|
||||||
|
return
|
||||||
|
|||||||
@ -49,8 +49,10 @@ class Services:
|
|||||||
"name": "Tiny Instance",
|
"name": "Tiny Instance",
|
||||||
"displaytext": "Tiny Instance",
|
"displaytext": "Tiny Instance",
|
||||||
"cpunumber": 1,
|
"cpunumber": 1,
|
||||||
"cpuspeed": 100, # in MHz
|
"cpuspeed": 100,
|
||||||
"memory": 64, # In MBs
|
# in MHz
|
||||||
|
"memory": 64,
|
||||||
|
# In MBs
|
||||||
},
|
},
|
||||||
"disk_offering": {
|
"disk_offering": {
|
||||||
"displaytext": "Small",
|
"displaytext": "Small",
|
||||||
@ -76,7 +78,30 @@ class Services:
|
|||||||
"ostypeid": '01853327-513e-4508-9628-f1f55db1946f',
|
"ostypeid": '01853327-513e-4508-9628-f1f55db1946f',
|
||||||
"templatefilter": 'self',
|
"templatefilter": 'self',
|
||||||
},
|
},
|
||||||
"ostypeid": '01853327-513e-4508-9628-f1f55db1946f',
|
"network_offering": {
|
||||||
|
"name": 'Network offering',
|
||||||
|
"displaytext": 'Network offering',
|
||||||
|
"guestiptype": 'Isolated',
|
||||||
|
"supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
|
||||||
|
"traffictype": 'GUEST',
|
||||||
|
"availability": 'Optional',
|
||||||
|
"serviceProviderList": {
|
||||||
|
"Dhcp": 'VirtualRouter',
|
||||||
|
"Dns": 'VirtualRouter',
|
||||||
|
"SourceNat": 'VirtualRouter',
|
||||||
|
"PortForwarding": 'VirtualRouter',
|
||||||
|
"Vpn": 'VirtualRouter',
|
||||||
|
"Firewall": 'VirtualRouter',
|
||||||
|
"Lb": 'VirtualRouter',
|
||||||
|
"UserData": 'VirtualRouter',
|
||||||
|
"StaticNat": 'VirtualRouter',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"network": {
|
||||||
|
"name": "test network",
|
||||||
|
"displaytext": "test network"
|
||||||
|
},
|
||||||
|
"ostypeid": 'bc66ada0-99e7-483b-befc-8fb0c2129b70',
|
||||||
# Cent OS 5.3 (64 bit)
|
# Cent OS 5.3 (64 bit)
|
||||||
"sleep": 60,
|
"sleep": 60,
|
||||||
"timeout": 10,
|
"timeout": 10,
|
||||||
@ -153,7 +178,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
|
|||||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "advancedns", "simulator"])
|
@attr(tags=["advanced", "advancedns", "simulator"])
|
||||||
def test_01_vm_per_account(self):
|
def test_01_vm_per_account(self):
|
||||||
"""Test VM limit per account
|
"""Test VM limit per account
|
||||||
"""
|
"""
|
||||||
@ -170,7 +195,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
0, # Instance
|
0, # Instance
|
||||||
account=self.account_1.account.name,
|
account=self.account_1.account.name,
|
||||||
domainid=self.account_1.account.domainid,
|
domainid=self.account_1.account.domainid,
|
||||||
max=1
|
max=1
|
||||||
@ -246,7 +271,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "advancedns", "simulator"])
|
@attr(tags=["advanced", "advancedns", "simulator"])
|
||||||
def test_02_publicip_per_account(self):
|
def test_02_publicip_per_account(self):
|
||||||
"""Test Public IP limit per account
|
"""Test Public IP limit per account
|
||||||
"""
|
"""
|
||||||
@ -266,7 +291,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
1, # Public Ip
|
1, # Public Ip
|
||||||
account=self.account_1.account.name,
|
account=self.account_1.account.name,
|
||||||
domainid=self.account_1.account.domainid,
|
domainid=self.account_1.account.domainid,
|
||||||
max=2
|
max=2
|
||||||
@ -389,8 +414,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(speed = "slow")
|
@attr(speed="slow")
|
||||||
@attr(tags = ["advanced", "advancedns", "simulator"])
|
@attr(tags=["advanced", "advancedns", "simulator"])
|
||||||
def test_03_snapshots_per_account(self):
|
def test_03_snapshots_per_account(self):
|
||||||
"""Test Snapshot limit per account
|
"""Test Snapshot limit per account
|
||||||
"""
|
"""
|
||||||
@ -410,7 +435,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
3, # Snapshot
|
3, # Snapshot
|
||||||
account=self.account_1.account.name,
|
account=self.account_1.account.name,
|
||||||
domainid=self.account_1.account.domainid,
|
domainid=self.account_1.account.domainid,
|
||||||
max=1
|
max=1
|
||||||
@ -546,7 +571,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "advancedns", "simulator"])
|
@attr(tags=["advanced", "advancedns", "simulator"])
|
||||||
def test_04_volumes_per_account(self):
|
def test_04_volumes_per_account(self):
|
||||||
"""Test Volumes limit per account
|
"""Test Volumes limit per account
|
||||||
"""
|
"""
|
||||||
@ -566,7 +591,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
2, # Volume
|
2, # Volume
|
||||||
account=self.account_1.account.name,
|
account=self.account_1.account.name,
|
||||||
domainid=self.account_1.account.domainid,
|
domainid=self.account_1.account.domainid,
|
||||||
max=2
|
max=2
|
||||||
@ -688,7 +713,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "advancedns"])
|
@attr(tags=["advanced", "advancedns"])
|
||||||
def test_05_templates_per_account(self):
|
def test_05_templates_per_account(self):
|
||||||
"""Test Templates limit per account
|
"""Test Templates limit per account
|
||||||
"""
|
"""
|
||||||
@ -706,7 +731,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
4, # Template
|
4, # Template
|
||||||
account=self.account_1.account.name,
|
account=self.account_1.account.name,
|
||||||
domainid=self.account_1.account.domainid,
|
domainid=self.account_1.account.domainid,
|
||||||
max=1
|
max=1
|
||||||
@ -918,7 +943,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "advancedns", "simulator"])
|
@attr(tags=["advanced", "advancedns", "simulator"])
|
||||||
def test_01_vm_per_domain(self):
|
def test_01_vm_per_domain(self):
|
||||||
"""Test VM limit per domain
|
"""Test VM limit per domain
|
||||||
"""
|
"""
|
||||||
@ -935,7 +960,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
0, # Instance
|
0, # Instance
|
||||||
domainid=self.account.account.domainid,
|
domainid=self.account.account.domainid,
|
||||||
max=2
|
max=2
|
||||||
)
|
)
|
||||||
@ -984,7 +1009,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "advancedns", "simulator"])
|
@attr(tags=["advanced", "advancedns", "simulator"])
|
||||||
def test_01_publicip_per_domain(self):
|
def test_01_publicip_per_domain(self):
|
||||||
"""Test Public IP limit per domain
|
"""Test Public IP limit per domain
|
||||||
"""
|
"""
|
||||||
@ -1003,7 +1028,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
1, # Public Ip
|
1, # Public Ip
|
||||||
domainid=self.account.account.domainid,
|
domainid=self.account.account.domainid,
|
||||||
max=2
|
max=2
|
||||||
)
|
)
|
||||||
@ -1054,8 +1079,8 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(speed = "slow")
|
@attr(speed="slow")
|
||||||
@attr(tags = ["advanced", "advancedns", "simulator"])
|
@attr(tags=["advanced", "advancedns", "simulator"])
|
||||||
def test_03_snapshots_per_domain(self):
|
def test_03_snapshots_per_domain(self):
|
||||||
"""Test Snapshot limit per domain
|
"""Test Snapshot limit per domain
|
||||||
"""
|
"""
|
||||||
@ -1075,7 +1100,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
3, # Snapshot
|
3, # Snapshot
|
||||||
domainid=self.account.account.domainid,
|
domainid=self.account.account.domainid,
|
||||||
max=1
|
max=1
|
||||||
)
|
)
|
||||||
@ -1138,7 +1163,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "advancedns", "simulator"])
|
@attr(tags=["advanced", "advancedns", "simulator"])
|
||||||
def test_04_volumes_per_domain(self):
|
def test_04_volumes_per_domain(self):
|
||||||
"""Test Volumes limit per domain
|
"""Test Volumes limit per domain
|
||||||
"""
|
"""
|
||||||
@ -1157,7 +1182,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
2, # Volume
|
2, # Volume
|
||||||
domainid=self.account.account.domainid,
|
domainid=self.account.account.domainid,
|
||||||
max=2
|
max=2
|
||||||
)
|
)
|
||||||
@ -1191,7 +1216,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "advancedns"])
|
@attr(tags=["advanced", "advancedns"])
|
||||||
def test_05_templates_per_domain(self):
|
def test_05_templates_per_domain(self):
|
||||||
"""Test Templates limit per domain
|
"""Test Templates limit per domain
|
||||||
"""
|
"""
|
||||||
@ -1207,7 +1232,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
2, # Volume
|
2, # Volume
|
||||||
domainid=self.account.account.domainid,
|
domainid=self.account.account.domainid,
|
||||||
max=5
|
max=5
|
||||||
)
|
)
|
||||||
@ -1218,7 +1243,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
# Set usage_vm=1 for Account 1
|
# Set usage_vm=1 for Account 1
|
||||||
update_resource_limit(
|
update_resource_limit(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
4, # Template
|
4, # Template
|
||||||
domainid=self.account.account.domainid,
|
domainid=self.account.account.domainid,
|
||||||
max=2
|
max=2
|
||||||
)
|
)
|
||||||
@ -1300,3 +1325,129 @@ class TestResourceLimitsDomain(cloudstackTestCase):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TestMaxAccountNetworks(cloudstackTestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.api_client = super(
|
||||||
|
TestMaxAccountNetworks,
|
||||||
|
cls
|
||||||
|
).getClsTestClient().getApiClient()
|
||||||
|
cls.services = Services().services
|
||||||
|
# Get Zone, Domain and templates
|
||||||
|
cls.domain = get_domain(cls.api_client, cls.services)
|
||||||
|
cls.zone = get_zone(cls.api_client, cls.services)
|
||||||
|
cls.template = get_template(
|
||||||
|
cls.api_client,
|
||||||
|
cls.zone.id,
|
||||||
|
cls.services["ostypeid"]
|
||||||
|
)
|
||||||
|
|
||||||
|
cls.service_offering = ServiceOffering.create(
|
||||||
|
cls.api_client,
|
||||||
|
cls.services["service_offering"]
|
||||||
|
)
|
||||||
|
cls.network_offering = NetworkOffering.create(
|
||||||
|
cls.api_client,
|
||||||
|
cls.services["network_offering"],
|
||||||
|
conservemode=True
|
||||||
|
)
|
||||||
|
# Enable Network offering
|
||||||
|
cls.network_offering.update(cls.api_client, state='Enabled')
|
||||||
|
|
||||||
|
cls._cleanup = [
|
||||||
|
cls.service_offering,
|
||||||
|
cls.network_offering
|
||||||
|
]
|
||||||
|
return
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
try:
|
||||||
|
#Cleanup resources used
|
||||||
|
cleanup_resources(cls.api_client, cls._cleanup)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
|
return
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.apiclient = self.testClient.getApiClient()
|
||||||
|
self.dbclient = self.testClient.getDbConnection()
|
||||||
|
self.account = Account.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["account"],
|
||||||
|
admin=True,
|
||||||
|
domainid=self.domain.id
|
||||||
|
)
|
||||||
|
self.cleanup = []
|
||||||
|
return
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
try:
|
||||||
|
self.account.delete(self.apiclient)
|
||||||
|
interval = list_configurations(
|
||||||
|
self.apiclient,
|
||||||
|
name='account.cleanup.interval'
|
||||||
|
)
|
||||||
|
# Sleep to ensure that all resources are deleted
|
||||||
|
time.sleep(int(interval[0].value) * 2)
|
||||||
|
#Clean up, terminate the created network offerings
|
||||||
|
cleanup_resources(self.apiclient, self.cleanup)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
|
return
|
||||||
|
|
||||||
|
@attr(tags=["advanced", "advancedns", "simulator",
|
||||||
|
"api", "basic", "eip", "sg"])
|
||||||
|
def test_maxAccountNetworks(self):
|
||||||
|
"""Test Limit number of guest account specific networks
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Steps for validation
|
||||||
|
# 1. Fetch max.account.networks from configurations
|
||||||
|
# 2. Create an account. Create account more that max.accout.network
|
||||||
|
# 3. Create network should fail
|
||||||
|
|
||||||
|
config = Configurations.list(
|
||||||
|
self.apiclient,
|
||||||
|
name='max.account.networks',
|
||||||
|
listall=True
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
isinstance(config, list),
|
||||||
|
True,
|
||||||
|
"List configurations should have max.account.networks"
|
||||||
|
)
|
||||||
|
|
||||||
|
config_value = int(config[0].value)
|
||||||
|
self.debug("max.account.networks: %s" % config_value)
|
||||||
|
|
||||||
|
for ctr in range(config_value):
|
||||||
|
# Creating network using the network offering created
|
||||||
|
self.debug("Creating network with network offering: %s" %
|
||||||
|
self.network_offering.id)
|
||||||
|
network = Network.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["network"],
|
||||||
|
accountid=self.account.account.name,
|
||||||
|
domainid=self.account.account.domainid,
|
||||||
|
networkofferingid=self.network_offering.id,
|
||||||
|
zoneid=self.zone.id
|
||||||
|
)
|
||||||
|
self.debug("Created network with ID: %s" % network.id)
|
||||||
|
self.debug(
|
||||||
|
"Creating network in account already having networks : %s" %
|
||||||
|
config_value)
|
||||||
|
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
Network.create(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["network"],
|
||||||
|
accountid=self.account.account.name,
|
||||||
|
domainid=self.account.account.domainid,
|
||||||
|
networkofferingid=self.network_offering.id,
|
||||||
|
zoneid=self.zone.id
|
||||||
|
)
|
||||||
|
self.debug('Create network failed (as expected)')
|
||||||
|
return
|
||||||
|
|||||||
@ -79,10 +79,14 @@ class Services:
|
|||||||
"name": "testISO",
|
"name": "testISO",
|
||||||
"url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso",
|
"url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso",
|
||||||
# Source URL where ISO is located
|
# Source URL where ISO is located
|
||||||
"ostypeid": '01853327-513e-4508-9628-f1f55db1946f',
|
"ostypeid": 'bc66ada0-99e7-483b-befc-8fb0c2129b70',
|
||||||
},
|
},
|
||||||
|
"custom_volume": {
|
||||||
|
"customdisksize": 2,
|
||||||
|
"diskname": "Custom disk",
|
||||||
|
},
|
||||||
"sleep": 50,
|
"sleep": 50,
|
||||||
"ostypeid": '01853327-513e-4508-9628-f1f55db1946f',
|
"ostypeid": 'bc66ada0-99e7-483b-befc-8fb0c2129b70',
|
||||||
"mode": 'advanced',
|
"mode": 'advanced',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1027,3 +1031,139 @@ class TestVolumes(cloudstackTestCase):
|
|||||||
"Check if volume exists in ListVolumes"
|
"Check if volume exists in ListVolumes"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class TestDeployVmWithCustomDisk(cloudstackTestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.api_client = super(
|
||||||
|
TestDeployVmWithCustomDisk,
|
||||||
|
cls
|
||||||
|
).getClsTestClient().getApiClient()
|
||||||
|
cls.services = Services().services
|
||||||
|
|
||||||
|
# Get Zone, Domain and templates
|
||||||
|
cls.domain = get_domain(cls.api_client, cls.services)
|
||||||
|
cls.zone = get_zone(cls.api_client, cls.services)
|
||||||
|
cls.disk_offering = DiskOffering.create(
|
||||||
|
cls.api_client,
|
||||||
|
cls.services["disk_offering"],
|
||||||
|
custom=True
|
||||||
|
)
|
||||||
|
template = get_template(
|
||||||
|
cls.api_client,
|
||||||
|
cls.zone.id,
|
||||||
|
cls.services["ostypeid"]
|
||||||
|
)
|
||||||
|
cls.services["zoneid"] = cls.zone.id
|
||||||
|
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||||
|
cls.services["virtual_machine"]["template"] = template.id
|
||||||
|
|
||||||
|
# Create VMs, NAT Rules etc
|
||||||
|
cls.account = Account.create(
|
||||||
|
cls.api_client,
|
||||||
|
cls.services["account"],
|
||||||
|
domainid=cls.domain.id
|
||||||
|
)
|
||||||
|
|
||||||
|
cls.services["account"] = cls.account.account.name
|
||||||
|
cls.service_offering = ServiceOffering.create(
|
||||||
|
cls.api_client,
|
||||||
|
cls.services["service_offering"]
|
||||||
|
)
|
||||||
|
cls._cleanup = [
|
||||||
|
cls.service_offering,
|
||||||
|
cls.disk_offering,
|
||||||
|
cls.account
|
||||||
|
]
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
|
||||||
|
self.apiclient = self.testClient.getApiClient()
|
||||||
|
self.dbclient = self.testClient.getDbConnection()
|
||||||
|
self.cleanup = []
|
||||||
|
|
||||||
|
@attr(tags=["advanced", "configuration", "advancedns", "simulator",
|
||||||
|
"api", "basic", "eip", "sg"])
|
||||||
|
def test_deployVmWithCustomDisk(self):
|
||||||
|
"""Test custom disk sizes beyond range
|
||||||
|
"""
|
||||||
|
# Steps for validation
|
||||||
|
# 1. listConfigurations - custom.diskoffering.size.min
|
||||||
|
# and custom.diskoffering.size.max
|
||||||
|
# 2. deployVm with custom disk offering size < min
|
||||||
|
# 3. deployVm with custom disk offering min< size < max
|
||||||
|
# 4. deployVm with custom disk offering size > max
|
||||||
|
# Validate the following
|
||||||
|
# 2. and 4. of deploy VM should fail.
|
||||||
|
# Only case 3. should succeed.
|
||||||
|
# cleanup all created data disks from the account
|
||||||
|
|
||||||
|
config = Configurations.list(
|
||||||
|
self.apiclient,
|
||||||
|
name="custom.diskoffering.size.min"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
isinstance(config, list),
|
||||||
|
True,
|
||||||
|
"custom.diskoffering.size.min should be present in global config"
|
||||||
|
)
|
||||||
|
# minimum size of custom disk (in GBs)
|
||||||
|
min_size = int(config[0].value)
|
||||||
|
self.debug("custom.diskoffering.size.min: %s" % min_size)
|
||||||
|
|
||||||
|
config = Configurations.list(
|
||||||
|
self.apiclient,
|
||||||
|
name="custom.diskoffering.size.max"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
isinstance(config, list),
|
||||||
|
True,
|
||||||
|
"custom.diskoffering.size.min should be present in global config"
|
||||||
|
)
|
||||||
|
# maximum size of custom disk (in GBs)
|
||||||
|
max_size = int(config[0].value)
|
||||||
|
self.debug("custom.diskoffering.size.max: %s" % max_size)
|
||||||
|
|
||||||
|
self.debug("Creating a volume with size less than min cust disk size")
|
||||||
|
self.services["custom_volume"]["customdisksize"] = (min_size - 1)
|
||||||
|
self.services["custom_volume"]["zoneid"] = self.zone.id
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
Volume.create_custom_disk(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["custom_volume"],
|
||||||
|
account=self.account.account.name,
|
||||||
|
domainid=self.account.account.domainid,
|
||||||
|
diskofferingid=self.disk_offering.id
|
||||||
|
)
|
||||||
|
self.debug("Create volume failed!")
|
||||||
|
|
||||||
|
self.debug("Creating a volume with size more than max cust disk size")
|
||||||
|
self.services["custom_volume"]["customdisksize"] = (max_size + 1)
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
Volume.create_custom_disk(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["custom_volume"],
|
||||||
|
account=self.account.account.name,
|
||||||
|
domainid=self.account.account.domainid,
|
||||||
|
diskofferingid=self.disk_offering.id
|
||||||
|
)
|
||||||
|
self.debug("Create volume failed!")
|
||||||
|
|
||||||
|
self.debug("Creating a volume with size more than min cust disk " +
|
||||||
|
"but less than max cust disk size"
|
||||||
|
)
|
||||||
|
self.services["custom_volume"]["customdisksize"] = (min_size + 1)
|
||||||
|
try:
|
||||||
|
Volume.create_custom_disk(
|
||||||
|
self.apiclient,
|
||||||
|
self.services["custom_volume"],
|
||||||
|
account=self.account.account.name,
|
||||||
|
domainid=self.account.account.domainid,
|
||||||
|
diskofferingid=self.disk_offering.id
|
||||||
|
)
|
||||||
|
self.debug("Create volume of cust disk size succeeded")
|
||||||
|
except Exception as e:
|
||||||
|
self.fail("Create volume failed with exception: %s" % e)
|
||||||
|
return
|
||||||
|
|||||||
@ -158,6 +158,45 @@ class User:
|
|||||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||||
return(apiclient.listUsers(cmd))
|
return(apiclient.listUsers(cmd))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def registerUserKeys(cls, apiclient, userid):
|
||||||
|
cmd = registerUserKeys.registerUserKeysCmd()
|
||||||
|
cmd.id = userid
|
||||||
|
return apiclient.registerUserKeys(cmd)
|
||||||
|
|
||||||
|
def update(self, apiclient, **kwargs):
|
||||||
|
"""Updates the user details"""
|
||||||
|
|
||||||
|
cmd = updateUser.updateUserCmd()
|
||||||
|
cmd.id = self.id
|
||||||
|
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||||
|
return (apiclient.updateUser(cmd))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def update(cls, apiclient, id, **kwargs):
|
||||||
|
"""Updates the user details (class method)"""
|
||||||
|
|
||||||
|
cmd = updateUser.updateUserCmd()
|
||||||
|
cmd.id = id
|
||||||
|
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||||
|
return (apiclient.updateUser(cmd))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def login(cls, apiclient, username, password, domain=None, domainid=None):
|
||||||
|
"""Logins to the CloudStack"""
|
||||||
|
|
||||||
|
cmd = login.loginCmd()
|
||||||
|
cmd.username = username
|
||||||
|
# MD5 hashcoded password
|
||||||
|
mdf = hashlib.md5()
|
||||||
|
mdf.update(password)
|
||||||
|
cmd.password = mdf.hexdigest()
|
||||||
|
if domain:
|
||||||
|
cmd.domain = domain
|
||||||
|
if domainid:
|
||||||
|
cmd.domainid = domainid
|
||||||
|
return apiclient.login(cmd)
|
||||||
|
|
||||||
|
|
||||||
class VirtualMachine:
|
class VirtualMachine:
|
||||||
"""Manage virtual machine lifecycle"""
|
"""Manage virtual machine lifecycle"""
|
||||||
@ -174,7 +213,8 @@ class VirtualMachine:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, apiclient, services, templateid=None, accountid=None,
|
def create(cls, apiclient, services, templateid=None, accountid=None,
|
||||||
domainid=None, networkids=None, serviceofferingid=None,
|
domainid=None, networkids=None, serviceofferingid=None,
|
||||||
securitygroupids=None, projectid=None, mode='basic'):
|
securitygroupids=None, projectid=None, startvm=None,
|
||||||
|
diskofferingid=None, hostid=None, mode='basic'):
|
||||||
"""Create the instance"""
|
"""Create the instance"""
|
||||||
|
|
||||||
cmd = deployVirtualMachine.deployVirtualMachineCmd()
|
cmd = deployVirtualMachine.deployVirtualMachineCmd()
|
||||||
@ -219,6 +259,12 @@ class VirtualMachine:
|
|||||||
if projectid:
|
if projectid:
|
||||||
cmd.projectid = projectid
|
cmd.projectid = projectid
|
||||||
|
|
||||||
|
if startvm is not None:
|
||||||
|
cmd.startvm = startvm
|
||||||
|
|
||||||
|
if hostid:
|
||||||
|
cmd.hostid = hostid
|
||||||
|
|
||||||
virtual_machine = apiclient.deployVirtualMachine(cmd)
|
virtual_machine = apiclient.deployVirtualMachine(cmd)
|
||||||
|
|
||||||
# VM should be in Running state after deploy
|
# VM should be in Running state after deploy
|
||||||
@ -392,12 +438,17 @@ class Volume:
|
|||||||
return Volume(apiclient.createVolume(cmd).__dict__)
|
return Volume(apiclient.createVolume(cmd).__dict__)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_custom_disk(cls, apiclient, services,
|
def create_custom_disk(cls, apiclient, services, account=None,
|
||||||
account=None, domainid=None):
|
domainid=None, diskofferingid=None):
|
||||||
"""Create Volume from Custom disk offering"""
|
"""Create Volume from Custom disk offering"""
|
||||||
cmd = createVolume.createVolumeCmd()
|
cmd = createVolume.createVolumeCmd()
|
||||||
cmd.name = services["diskname"]
|
cmd.name = services["diskname"]
|
||||||
cmd.diskofferingid = services["customdiskofferingid"]
|
|
||||||
|
if diskofferingid:
|
||||||
|
cmd.diskofferingid = diskofferingid
|
||||||
|
elif "customdiskofferingid" in services:
|
||||||
|
cmd.diskofferingid = services["customdiskofferingid"]
|
||||||
|
|
||||||
cmd.size = services["customdisksize"]
|
cmd.size = services["customdisksize"]
|
||||||
cmd.zoneid = services["zoneid"]
|
cmd.zoneid = services["zoneid"]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user