You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ta...@apache.org on 2015/01/05 14:12:38 UTC
[01/10] git commit: updated refs/heads/master to 22d6565
Repository: cloudstack
Updated Branches:
refs/heads/master 93429443d -> 22d656543
CLOUDSTACK-8124: Skipping snapshot test cases on hyperv
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7f10e6fe
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7f10e6fe
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7f10e6fe
Branch: refs/heads/master
Commit: 7f10e6fe0b6744dd6d3ce5942baa70dc19a1040a
Parents: 9342944
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Wed Dec 24 14:39:20 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Mon Jan 5 17:02:10 2015 +0530
----------------------------------------------------------------------
test/integration/component/test_blocker_bugs.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f10e6fe/test/integration/component/test_blocker_bugs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_blocker_bugs.py b/test/integration/component/test_blocker_bugs.py
index f9530f0..8ba563f 100644
--- a/test/integration/component/test_blocker_bugs.py
+++ b/test/integration/component/test_blocker_bugs.py
@@ -731,7 +731,7 @@ class TestTemplates(cloudstackTestCase):
cls.testClient = super(TestTemplates, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
-
+ cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
# Get Zone, Domain and templates
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
@@ -857,6 +857,8 @@ class TestTemplates(cloudstackTestCase):
# 4. Check the size of snapshot and template
# Create a snapshot from the ROOTDISK
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
snapshot = Snapshot.create(
self.apiclient,
self.volume.id,
@@ -922,6 +924,8 @@ class TestTemplates(cloudstackTestCase):
# 5. Template should be created succesfully
# Create a snapshot from the ROOTDISK
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
snapshot = Snapshot.create(
self.apiclient,
self.volume.id,
[07/10] git commit: updated refs/heads/master to 22d6565
Posted by ta...@apache.org.
CLOUDSTACK-8132: Fixed issue related to secondary storage count of template
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f938a5e1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f938a5e1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f938a5e1
Branch: refs/heads/master
Commit: f938a5e1c352971aa61e75a60935c735c3d3920c
Parents: 17da2e9
Author: Ashutosh K <as...@clogeny.com>
Authored: Mon Dec 29 03:34:37 2014 -0800
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Mon Jan 5 18:30:16 2015 +0530
----------------------------------------------------------------------
test/integration/component/test_ss_limits.py | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f938a5e1/test/integration/component/test_ss_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ss_limits.py b/test/integration/component/test_ss_limits.py
index 22ab99c..32201d8 100644
--- a/test/integration/component/test_ss_limits.py
+++ b/test/integration/component/test_ss_limits.py
@@ -127,7 +127,7 @@ class TestSecondaryStorageLimits(cloudstackTestCase):
except Exception as e:
return [FAIL, e]
return [PASS, None]
-
+
@data(ROOT_DOMAIN_ADMIN, CHILD_DOMAIN_ADMIN)
@attr(tags = ["advanced"], required_hardware="true")
def test_01_register_template(self, value):
@@ -144,24 +144,28 @@ class TestSecondaryStorageLimits(cloudstackTestCase):
response = self.setupAccount(value)
self.assertEqual(response[0], PASS, response[1])
+ apiclient = self.testClient.getUserApiClient(
+ UserName=self.account.name,
+ DomainName=self.account.domain)
+
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["template_2"]["url"] = builtin_info[0]
self.services["template_2"]["hypervisor"] = builtin_info[1]
self.services["template_2"]["format"] = builtin_info[2]
try:
- template = Template.register(self.apiclient,
+ template = Template.register(apiclient,
self.services["template_2"],
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
hypervisor=self.hypervisor)
- template.download(self.apiclient)
+ template.download(apiclient)
except Exception as e:
self.fail("Failed to register template: %s" % e)
- templates = Template.list(self.apiclient,
+ templates = Template.list(apiclient,
templatefilter=\
self.services["template_2"]["templatefilter"],
id=template.id)
@@ -171,19 +175,19 @@ class TestSecondaryStorageLimits(cloudstackTestCase):
templateSize = (templates[0].size / (1024**3))
expectedCount = templateSize
response = matchResourceCount(
- self.apiclient, expectedCount,
+ apiclient, expectedCount,
RESOURCE_SECONDARY_STORAGE,
accountid=self.account.id)
self.assertEqual(response[0], PASS, response[1])
try:
- template.delete(self.apiclient)
+ template.delete(apiclient)
except Exception as e:
self.fail("Failed to delete template: %s" % e)
expectedCount = 0
response = matchResourceCount(
- self.apiclient, expectedCount,
+ apiclient, expectedCount,
RESOURCE_SECONDARY_STORAGE,
accountid=self.account.id)
self.assertEqual(response[0], PASS, response[1])
[04/10] git commit: updated refs/heads/master to 22d6565
Posted by ta...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/214d63ee/test/integration/component/test_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshots.py b/test/integration/component/test_snapshots.py
index 4bb2dcf..5b8cdc7 100644
--- a/test/integration/component/test_snapshots.py
+++ b/test/integration/component/test_snapshots.py
@@ -16,142 +16,143 @@
# under the License.
""" P1 tests for Snapshots
"""
-#Import Local Modules
-from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import cloudstackTestCase
-
-from marvin.lib.base import (Snapshot,
- Template,
- VirtualMachine,
- Account,
- ServiceOffering,
- DiskOffering,
- Volume)
-
-from marvin.lib.common import (get_domain,
- get_zone,
- get_template,
- list_events,
- list_volumes,
- list_snapshots,
- list_templates,
- list_virtual_machines,
- )
-
-from marvin.lib.utils import (cleanup_resources,
- format_volume_to_ext3,
- random_gen,
- is_snapshot_on_nfs,
- get_hypervisor_type)
-
-from marvin.cloudstackAPI import detachVolume
-import time
+# Import Local Modules
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+
+from marvin.lib.base import (Snapshot,
+ Template,
+ VirtualMachine,
+ Account,
+ ServiceOffering,
+ DiskOffering,
+ Volume)
+
+from marvin.lib.common import (get_domain,
+ get_zone,
+ get_template,
+ list_events,
+ list_volumes,
+ list_snapshots,
+ list_templates,
+ list_virtual_machines,
+ )
+from marvin.lib.utils import (cleanup_resources,
+ format_volume_to_ext3,
+ random_gen,
+ is_snapshot_on_nfs,
+ get_hypervisor_type)
+
+from marvin.cloudstackAPI import detachVolume
+import time
class Services:
+
"""Test Snapshots Services
"""
def __init__(self):
self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 200, # in MHz
+ "account": {
+ "email": "test@test.com",
+ "firstname": "Test",
+ "lastname": "User",
+ "username": "test",
+ # Random characters are appended for unique
+ # username
+ "password": "password",
+ },
+ "service_offering": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 200, # in MHz
"memory": 256, # In MBs
+ },
+ "disk_offering": {
+ "displaytext": "Small Disk",
+ "name": "Small Disk",
+ "disksize": 1
+ },
+ "server_with_disk":
+ {
+ "displayname": "Test VM -With Disk",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+
+ "server_without_disk":
+ {
+ "displayname": "Test VM-No Disk",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ # For NAT rule creation
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "server": {
+ "displayname": "TestVM",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "recurring_snapshot": {
+ "intervaltype": 'HOURLY',
+ # Frequency of snapshots
+ "maxsnaps": 1, # Should be min 2
+ "schedule": 1,
+ "timezone": 'US/Arizona',
+ # Timezone Formats -
+ # http://cloud.mindtouch.us/CloudStack_Documentation/Developer's_Guide%3A_CloudStack
+ },
+ "templates": {
+ "displaytext": 'Template',
+ "name": 'Template',
+ "ostype": "CentOS 5.3 (64-bit)",
+ "templatefilter": 'self',
+ },
+ "volume": {
+ "diskname": "APP Data Volume",
+ "size": 1, # in GBs
+ "xenserver": {"rootdiskdevice": "/dev/xvda",
+ "datadiskdevice_1": '/dev/xvdb',
+ "datadiskdevice_2": '/dev/xvdc', # Data Disk
+ },
+ "kvm": {"rootdiskdevice": "/dev/vda",
+ "datadiskdevice_1": "/dev/vdb",
+ "datadiskdevice_2": "/dev/vdc"
},
- "disk_offering": {
- "displaytext": "Small Disk",
- "name": "Small Disk",
- "disksize": 1
- },
- "server_with_disk":
- {
- "displayname": "Test VM -With Disk",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
-
- "server_without_disk":
- {
- "displayname": "Test VM-No Disk",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- # For NAT rule creation
- "publicport": 22,
- "protocol": 'TCP',
- },
- "server": {
- "displayname": "TestVM",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "recurring_snapshot": {
- "intervaltype": 'HOURLY',
- # Frequency of snapshots
- "maxsnaps": 1, # Should be min 2
- "schedule": 1,
- "timezone": 'US/Arizona',
- # Timezone Formats - http://cloud.mindtouch.us/CloudStack_Documentation/Developer's_Guide%3A_CloudStack
- },
- "templates": {
- "displaytext": 'Template',
- "name": 'Template',
- "ostype": "CentOS 5.3 (64-bit)",
- "templatefilter": 'self',
- },
- "volume": {
- "diskname": "APP Data Volume",
- "size": 1, # in GBs
- "xenserver": {"rootdiskdevice":"/dev/xvda",
- "datadiskdevice_1": '/dev/xvdb',
- "datadiskdevice_2": '/dev/xvdc', # Data Disk
- },
- "kvm": {"rootdiskdevice": "/dev/vda",
- "datadiskdevice_1": "/dev/vdb",
- "datadiskdevice_2": "/dev/vdc"
- },
- "vmware": {"rootdiskdevice": "/dev/hda",
- "datadiskdevice_1": "/dev/hdb",
- "datadiskdevice_2": "/dev/hdc"
- }
- },
- "paths": {
- "mount_dir": "/mnt/tmp",
- "sub_dir": "test",
- "sub_lvl_dir1": "test1",
- "sub_lvl_dir2": "test2",
- "random_data": "random.data",
- },
- "ostype": "CentOS 5.3 (64-bit)",
- # Cent OS 5.3 (64 bit)
- "sleep": 60,
- "timeout": 10,
- }
+ "vmware": {"rootdiskdevice": "/dev/hda",
+ "datadiskdevice_1": "/dev/hdb",
+ "datadiskdevice_2": "/dev/hdc"
+ }
+ },
+ "paths": {
+ "mount_dir": "/mnt/tmp",
+ "sub_dir": "test",
+ "sub_lvl_dir1": "test1",
+ "sub_lvl_dir2": "test2",
+ "random_data": "random.data",
+ },
+ "ostype": "CentOS 5.3 (64-bit)",
+ # Cent OS 5.3 (64 bit)
+ "sleep": 60,
+ "timeout": 10,
+ }
class TestSnapshots(cloudstackTestCase):
@@ -167,17 +168,18 @@ class TestSnapshots(cloudstackTestCase):
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
- cls.api_client,
- cls.services["disk_offering"]
- )
+ cls.api_client,
+ cls.services["disk_offering"]
+ )
cls.template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["domainid"] = cls.domain.id
- cls.services["volume"]["zoneid"] = cls.services["server_with_disk"]["zoneid"] = cls.zone.id
+ cls.services["volume"]["zoneid"] = cls.services[
+ "server_with_disk"]["zoneid"] = cls.zone.id
cls.services["server_with_disk"]["diskoffering"] = cls.disk_offering.id
cls.services["server_without_disk"]["zoneid"] = cls.zone.id
@@ -187,23 +189,23 @@ class TestSnapshots(cloudstackTestCase):
cls.services["diskoffering"] = cls.disk_offering.id
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
# Get Hypervisor Type
cls.hypervisor = (get_hypervisor_type(cls.api_client)).lower()
cls._cleanup = [
- cls.service_offering,
- cls.disk_offering
- ]
+ cls.service_offering,
+ cls.disk_offering
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -216,92 +218,105 @@ class TestSnapshots(cloudstackTestCase):
# Create VMs, NAT Rules etc
self.account = Account.create(
- self.apiclient,
- self.services["account"],
- domainid=self.domain.id
- )
+ self.apiclient,
+ self.services["account"],
+ domainid=self.domain.id
+ )
self.virtual_machine = self.virtual_machine_with_disk = \
- VirtualMachine.create(
- self.api_client,
- self.services["server_with_disk"],
- templateid=self.template.id,
- accountid=self.account.name,
- domainid=self.account.domainid,
- serviceofferingid=self.service_offering.id,
- mode=self.services["mode"]
- )
+ VirtualMachine.create(
+ self.api_client,
+ self.services["server_with_disk"],
+ templateid=self.template.id,
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ serviceofferingid=self.service_offering.id,
+ mode=self.services["mode"]
+ )
self.cleanup = [self.account, ]
return
def tearDown(self):
try:
- #Clean up, terminate the created instance, volumes and snapshots
+ # Clean up, terminate the created instance, volumes and snapshots
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(speed = "slow")
+ @attr(speed="slow")
@attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
def test_02_snapshot_data_disk(self):
"""Test Snapshot Data Disk
"""
volume = list_volumes(
- self.apiclient,
- virtualmachineid=self.virtual_machine_with_disk.id,
- type='DATADISK',
- listall=True
- )
+ self.apiclient,
+ virtualmachineid=self.virtual_machine_with_disk.id,
+ type='DATADISK',
+ listall=True
+ )
self.assertEqual(
- isinstance(volume, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(volume, list),
+ True,
+ "Check list response returns a valid list"
+ )
self.debug("Creating a Snapshot from data volume: %s" % volume[0].id)
snapshot = Snapshot.create(
- self.apiclient,
- volume[0].id,
- account=self.account.name,
- domainid=self.account.domainid
- )
+ self.apiclient,
+ volume[0].id,
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
snapshots = list_snapshots(
- self.apiclient,
- id=snapshot.id
- )
+ self.apiclient,
+ id=snapshot.id
+ )
self.assertEqual(
- isinstance(snapshots, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(snapshots, list),
+ True,
+ "Check list response returns a valid list"
+ )
self.assertNotEqual(
- snapshots,
- None,
- "Check if result exists in list item call"
- )
+ snapshots,
+ None,
+ "Check if result exists in list item call"
+ )
self.assertEqual(
- snapshots[0].id,
- snapshot.id,
- "Check resource id in list resources call"
- )
- self.assertTrue(is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot.id))
+ snapshots[0].id,
+ snapshot.id,
+ "Check resource id in list resources call"
+ )
+ self.assertTrue(
+ is_snapshot_on_nfs(
+ self.apiclient,
+ self.dbclient,
+ self.config,
+ self.zone.id,
+ snapshot.id))
return
- @attr(speed = "slow")
- @attr(tags=["advanced", "advancedns", "basic", "sg"], required_hardware="true")
+ @attr(speed="slow")
+ @attr(
+ tags=[
+ "advanced",
+ "advancedns",
+ "basic",
+ "sg"],
+ required_hardware="true")
def test_01_volume_from_snapshot(self):
"""Test Creating snapshot from volume having spaces in name(KVM)
"""
# Validate the following
- #1. Create a virtual machine and data volume
- #2. Attach data volume to VM
- #3. Login to machine; create temp/test directories on data volume and write some random data
- #4. Snapshot the Volume
- #5. Create another Volume from snapshot
- #6. Mount/Attach volume to another virtual machine
- #7. Compare data, data should match
+ # 1. Create a virtual machine and data volume
+ # 2. Attach data volume to VM
+ # 3. Login to machine; create temp/test directories on data volume
+ # and write some random data
+ # 4. Snapshot the Volume
+ # 5. Create another Volume from snapshot
+ # 6. Mount/Attach volume to another virtual machine
+ # 7. Compare data, data should match
random_data_0 = random_gen(size=100)
random_data_1 = random_gen(size=100)
@@ -316,63 +331,60 @@ class TestSnapshots(cloudstackTestCase):
self.virtual_machine.ipaddress)
volume = Volume.create(
- self.apiclient,
- self.services["volume"],
- zoneid=self.zone.id,
- account=self.account.name,
- domainid=self.account.domainid,
- diskofferingid=self.disk_offering.id
- )
+ self.apiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=self.disk_offering.id
+ )
self.debug("Created volume with ID: %s" % volume.id)
self.virtual_machine.attach_volume(
- self.apiclient,
- volume
- )
+ self.apiclient,
+ volume
+ )
self.debug("Attach volume: %s to VM: %s" %
- (volume.id, self.virtual_machine.id))
-
+ (volume.id, self.virtual_machine.id))
self.debug("Formatting volume: %s to ext3" % volume.id)
- #Format partition using ext3
- # Note that this is the second data disk partition of virtual machine as it was already containing
- # data disk before attaching the new volume, Hence datadiskdevice_2
+ # Format partition using ext3
+ # Note that this is the second data disk partition of virtual machine
+ # as it was already containing data disk before attaching the new
+ # volume, Hence datadiskdevice_2
format_volume_to_ext3(
- ssh_client,
- self.services["volume"][self.hypervisor]["datadiskdevice_2"]
- )
- cmds = [ "fdisk -l",
- "mkdir -p %s" % self.services["paths"]["mount_dir"],
- "mount -t ext3 %s1 %s" % (
- self.services["volume"][self.hypervisor]["datadiskdevice_2"],
- self.services["paths"]["mount_dir"]
- ),
- "mkdir -p %s/%s/{%s,%s} " % (
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir1"],
- self.services["paths"]["sub_lvl_dir2"]
- ),
- "echo %s > %s/%s/%s/%s" % (
- random_data_0,
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir1"],
- self.services["paths"]["random_data"]
- ),
- "echo %s > %s/%s/%s/%s" % (
- random_data_1,
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir2"],
- self.services["paths"]["random_data"]
- ),
- "cat %s/%s/%s/%s" % (
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir1"],
- self.services["paths"]["random_data"]
- )
- ]
+ ssh_client,
+ self.services["volume"][self.hypervisor]["datadiskdevice_2"]
+ )
+ cmds = [
+ "fdisk -l",
+ "mkdir -p %s" %
+ self.services["paths"]["mount_dir"],
+ "mount -t ext3 %s1 %s" %
+ (self.services["volume"][
+ self.hypervisor]["datadiskdevice_2"],
+ self.services["paths"]["mount_dir"]),
+ "mkdir -p %s/%s/{%s,%s} " %
+ (self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir1"],
+ self.services["paths"]["sub_lvl_dir2"]),
+ "echo %s > %s/%s/%s/%s" %
+ (random_data_0,
+ self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir1"],
+ self.services["paths"]["random_data"]),
+ "echo %s > %s/%s/%s/%s" %
+ (random_data_1,
+ self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir2"],
+ self.services["paths"]["random_data"]),
+ "cat %s/%s/%s/%s" %
+ (self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir1"],
+ self.services["paths"]["random_data"])]
for c in cmds:
self.debug("Command: %s" % c)
result = ssh_client.execute(c)
@@ -380,95 +392,95 @@ class TestSnapshots(cloudstackTestCase):
# Unmount the Sec Storage
cmds = [
- "umount %s" % (self.services["paths"]["mount_dir"]),
- ]
+ "umount %s" % (self.services["paths"]["mount_dir"]),
+ ]
for c in cmds:
self.debug("Command: %s" % c)
ssh_client.execute(c)
list_volume_response = Volume.list(
- self.apiclient,
- virtualmachineid=self.virtual_machine.id,
- type='DATADISK',
- id=volume.id
- )
+ self.apiclient,
+ virtualmachineid=self.virtual_machine.id,
+ type='DATADISK',
+ id=volume.id
+ )
self.assertEqual(
- isinstance(list_volume_response, list),
- True,
- "Check list volume response for valid data"
- )
+ isinstance(list_volume_response, list),
+ True,
+ "Check list volume response for valid data"
+ )
volume_response = list_volume_response[0]
- #Create snapshot from attached volume
+ # Create snapshot from attached volume
snapshot = Snapshot.create(
- self.apiclient,
- volume_response.id,
- account=self.account.name,
- domainid=self.account.domainid
- )
+ self.apiclient,
+ volume_response.id,
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
self.debug("Created snapshot: %s" % snapshot.id)
- #Create volume from snapshot
+ # Create volume from snapshot
volume_from_snapshot = Volume.create_from_snapshot(
- self.apiclient,
- snapshot.id,
- self.services["volume"],
- account=self.account.name,
- domainid=self.account.domainid
- )
+ self.apiclient,
+ snapshot.id,
+ self.services["volume"],
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
# Detach the volume from virtual machine
self.virtual_machine.detach_volume(
- self.apiclient,
- volume
- )
+ self.apiclient,
+ volume
+ )
self.debug("Detached volume: %s from VM: %s" %
- (volume.id, self.virtual_machine.id))
+ (volume.id, self.virtual_machine.id))
self.debug("Created Volume: %s from Snapshot: %s" % (
- volume_from_snapshot.id,
- snapshot.id))
+ volume_from_snapshot.id,
+ snapshot.id))
volumes = Volume.list(
- self.apiclient,
- id=volume_from_snapshot.id
- )
+ self.apiclient,
+ id=volume_from_snapshot.id
+ )
self.assertEqual(
- isinstance(volumes, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(volumes, list),
+ True,
+ "Check list response returns a valid list"
+ )
self.assertNotEqual(
- len(volumes),
- None,
- "Check Volume list Length"
- )
+ len(volumes),
+ None,
+ "Check Volume list Length"
+ )
self.assertEqual(
- volumes[0].id,
- volume_from_snapshot.id,
- "Check Volume in the List Volumes"
- )
- #Attaching volume to new VM
+ volumes[0].id,
+ volume_from_snapshot.id,
+ "Check Volume in the List Volumes"
+ )
+ # Attaching volume to new VM
new_virtual_machine = VirtualMachine.create(
- self.apiclient,
- self.services["server_without_disk"],
- templateid=self.template.id,
- accountid=self.account.name,
- domainid=self.account.domainid,
- serviceofferingid=self.service_offering.id,
- mode=self.services["mode"]
- )
+ self.apiclient,
+ self.services["server_without_disk"],
+ templateid=self.template.id,
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ serviceofferingid=self.service_offering.id,
+ mode=self.services["mode"]
+ )
self.debug("Deployed new VM for account: %s" % self.account.name)
- #self.cleanup.append(new_virtual_machine)
+ # self.cleanup.append(new_virtual_machine)
self.debug("Attaching volume: %s to VM: %s" % (
- volume_from_snapshot.id,
- new_virtual_machine.id
- ))
+ volume_from_snapshot.id,
+ new_virtual_machine.id
+ ))
new_virtual_machine.attach_volume(
- self.apiclient,
- volume_from_snapshot
- )
+ self.apiclient,
+ volume_from_snapshot
+ )
# Rebooting is required so that newly attached disks are detected
self.debug("Rebooting : %s" % new_virtual_machine.id)
@@ -476,17 +488,20 @@ class TestSnapshots(cloudstackTestCase):
new_virtual_machine.reboot(self.apiclient)
try:
- #Login to VM to verify test directories and files
+ # Login to VM to verify test directories and files
ssh = new_virtual_machine.get_ssh_client()
- # Mount datadiskdevice_1 because this is the first data disk of the new virtual machine
- cmds = ["fdisk -l",
- "mkdir -p %s" % self.services["paths"]["mount_dir"],
- "mount -t ext3 %s1 %s" % (
- self.services["volume"][self.hypervisor]["datadiskdevice_1"],
- self.services["paths"]["mount_dir"]
- ),
- ]
+ # Mount datadiskdevice_1 because this is the first data disk of the
+ # new virtual machine
+ cmds = [
+ "fdisk -l",
+ "mkdir -p %s" %
+ self.services["paths"]["mount_dir"],
+ "mount -t ext3 %s1 %s" %
+ (self.services["volume"][
+ self.hypervisor]["datadiskdevice_1"],
+ self.services["paths"]["mount_dir"]),
+ ]
for c in cmds:
self.debug("Command: %s" % c)
@@ -494,107 +509,119 @@ class TestSnapshots(cloudstackTestCase):
self.debug(result)
returned_data_0 = ssh.execute(
- "cat %s/%s/%s/%s" % (
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir1"],
- self.services["paths"]["random_data"]
- ))
+ "cat %s/%s/%s/%s" % (
+ self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir1"],
+ self.services["paths"]["random_data"]
+ ))
returned_data_1 = ssh.execute(
- "cat %s/%s/%s/%s" % (
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir2"],
- self.services["paths"]["random_data"]
- ))
+ "cat %s/%s/%s/%s" % (
+ self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir2"],
+ self.services["paths"]["random_data"]
+ ))
except Exception as e:
self.fail("SSH access failed for VM: %s, Exception: %s" %
- (new_virtual_machine.ipaddress, e))
+ (new_virtual_machine.ipaddress, e))
self.debug("returned_data_0: %s" % returned_data_0[0])
self.debug("returned_data_1: %s" % returned_data_1[0])
- #Verify returned data
+ # Verify returned data
self.assertEqual(
- random_data_0,
- returned_data_0[0],
- "Verify newly attached volume contents with existing one"
- )
+ random_data_0,
+ returned_data_0[0],
+ "Verify newly attached volume contents with existing one"
+ )
self.assertEqual(
- random_data_1,
- returned_data_1[0],
- "Verify newly attached volume contents with existing one"
- )
+ random_data_1,
+ returned_data_1[0],
+ "Verify newly attached volume contents with existing one"
+ )
# Unmount the Sec Storage
cmds = [
- "umount %s" % (self.services["paths"]["mount_dir"]),
- ]
+ "umount %s" % (self.services["paths"]["mount_dir"]),
+ ]
for c in cmds:
self.debug("Command: %s" % c)
ssh_client.execute(c)
return
- @attr(speed = "slow")
+ @attr(speed="slow")
@attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
def test_04_delete_snapshot(self):
"""Test Delete Snapshot
"""
- #1. Snapshot the Volume
- #2. Delete the snapshot
- #3. Verify snapshot is removed by calling List Snapshots API
- #4. Verify snapshot was removed from image store
+ # 1. Snapshot the Volume
+ # 2. Delete the snapshot
+ # 3. Verify snapshot is removed by calling List Snapshots API
+ # 4. Verify snapshot was removed from image store
self.debug("Creating volume under account: %s" % self.account.name)
volume = Volume.create(
- self.apiclient,
- self.services["volume"],
- zoneid=self.zone.id,
- account=self.account.name,
- domainid=self.account.domainid,
- diskofferingid=self.disk_offering.id
- )
+ self.apiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=self.disk_offering.id
+ )
self.debug("Created volume: %s" % volume.id)
self.debug("Attaching volume to vm: %s" % self.virtual_machine.id)
self.virtual_machine.attach_volume(
- self.apiclient,
- volume
- )
+ self.apiclient,
+ volume
+ )
self.debug("Volume attached to vm")
volumes = list_volumes(
- self.apiclient,
- virtualmachineid=self.virtual_machine.id,
- type='DATADISK',
- id=volume.id
- )
+ self.apiclient,
+ virtualmachineid=self.virtual_machine.id,
+ type='DATADISK',
+ id=volume.id
+ )
self.assertEqual(
- isinstance(volumes, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(volumes, list),
+ True,
+ "Check list response returns a valid list"
+ )
snapshot = Snapshot.create(
- self.apiclient,
- volumes[0].id,
- account=self.account.name,
- domainid=self.account.domainid
- )
+ self.apiclient,
+ volumes[0].id,
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
snapshot.delete(self.apiclient)
snapshots = list_snapshots(
- self.apiclient,
- id=snapshot.id
- )
+ self.apiclient,
+ id=snapshot.id
+ )
self.assertEqual(
- snapshots,
- None,
- "Check if result exists in list item call"
- )
- self.assertFalse(is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot.id))
+ snapshots,
+ None,
+ "Check if result exists in list item call"
+ )
+ self.assertFalse(
+ is_snapshot_on_nfs(
+ self.apiclient,
+ self.dbclient,
+ self.config,
+ self.zone.id,
+ snapshot.id))
return
- @attr(speed = "slow")
- @attr(tags=["advanced", "advancedns", "basic", "sg"], required_hardware="true")
+ @attr(speed="slow")
+ @attr(
+ tags=[
+ "advanced",
+ "advancedns",
+ "basic",
+ "sg"],
+ required_hardware="true")
def test_03_snapshot_detachedDisk(self):
"""Test snapshot from detached disk
"""
@@ -609,167 +636,174 @@ class TestSnapshots(cloudstackTestCase):
# 6. verify backup_snap_id was non null in the `snapshots` table
volumes = list_volumes(
- self.apiclient,
- virtualmachineid=self.virtual_machine.id,
- type='DATADISK',
- listall=True
- )
+ self.apiclient,
+ virtualmachineid=self.virtual_machine.id,
+ type='DATADISK',
+ listall=True
+ )
self.assertEqual(
- isinstance(volumes, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(volumes, list),
+ True,
+ "Check list response returns a valid list"
+ )
volume = volumes[0]
random_data_0 = random_gen(size=100)
random_data_1 = random_gen(size=100)
try:
ssh_client = self.virtual_machine.get_ssh_client()
- #Format partition using ext3
+ # Format partition using ext3
format_volume_to_ext3(
- ssh_client,
- self.services["volume"][self.hypervisor]["datadiskdevice_1"]
- )
+ ssh_client,
+ self.services["volume"][self.hypervisor]["datadiskdevice_1"]
+ )
cmds = [
- "mkdir -p %s" % self.services["paths"]["mount_dir"],
- "mount %s1 %s" % (
- self.services["volume"][self.hypervisor]["datadiskdevice_1"],
- self.services["paths"]["mount_dir"]
- ),
- "pushd %s" % self.services["paths"]["mount_dir"],
- "mkdir -p %s/{%s,%s} " % (
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir1"],
- self.services["paths"]["sub_lvl_dir2"]
- ),
- "echo %s > %s/%s/%s" % (
- random_data_0,
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir1"],
- self.services["paths"]["random_data"]
- ),
- "echo %s > %s/%s/%s" % (
- random_data_1,
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir2"],
- self.services["paths"]["random_data"]
- ),
- "sync",
- "umount %s" % (self.services["paths"]["mount_dir"]),
- ]
+ "mkdir -p %s" %
+ self.services["paths"]["mount_dir"],
+ "mount %s1 %s" %
+ (self.services["volume"][
+ self.hypervisor]["datadiskdevice_1"],
+ self.services["paths"]["mount_dir"]),
+ "pushd %s" %
+ self.services["paths"]["mount_dir"],
+ "mkdir -p %s/{%s,%s} " %
+ (self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir1"],
+ self.services["paths"]["sub_lvl_dir2"]),
+ "echo %s > %s/%s/%s" %
+ (random_data_0,
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir1"],
+ self.services["paths"]["random_data"]),
+ "echo %s > %s/%s/%s" %
+ (random_data_1,
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir2"],
+ self.services["paths"]["random_data"]),
+ "sync",
+ "umount %s" %
+ (self.services["paths"]["mount_dir"]),
+ ]
for c in cmds:
self.debug(ssh_client.execute(c))
- #detach volume from VM
+ # detach volume from VM
cmd = detachVolume.detachVolumeCmd()
cmd.id = volume.id
self.apiclient.detachVolume(cmd)
- #Create snapshot from detached volume
+ # Create snapshot from detached volume
snapshot = Snapshot.create(self.apiclient, volume.id)
volumes = list_volumes(
- self.apiclient,
- virtualmachineid=self.virtual_machine.id,
- type='DATADISK',
- listall=True
- )
+ self.apiclient,
+ virtualmachineid=self.virtual_machine.id,
+ type='DATADISK',
+ listall=True
+ )
self.assertEqual(
- volumes,
- None,
- "Check Volume is detached"
- )
+ volumes,
+ None,
+ "Check Volume is detached"
+ )
# Verify the snapshot was created or not
snapshots = list_snapshots(
- self.apiclient,
- id=snapshot.id
- )
+ self.apiclient,
+ id=snapshot.id
+ )
self.assertNotEqual(
- snapshots,
- None,
- "Check if result exists in list snapshots call"
- )
+ snapshots,
+ None,
+ "Check if result exists in list snapshots call"
+ )
self.assertEqual(
- snapshots[0].id,
- snapshot.id,
- "Check snapshot id in list resources call"
- )
+ snapshots[0].id,
+ snapshot.id,
+ "Check snapshot id in list resources call"
+ )
except Exception as e:
self.fail("SSH failed for VM with IP: %s - %s" %
- (self.virtual_machine.ssh_ip, e))
+ (self.virtual_machine.ssh_ip, e))
qresultset = self.dbclient.execute(
- "select id from snapshots where uuid = '%s';" \
- % snapshot.id
- )
+ "select id from snapshots where uuid = '%s';"
+ % snapshot.id
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = qresultset[0]
self.assertNotEqual(
- str(qresult[0]),
- 'NULL',
- "Check if backup_snap_id is not null"
- )
+ str(qresult[0]),
+ 'NULL',
+ "Check if backup_snap_id is not null"
+ )
return
- @attr(speed = "slow")
- @attr(tags=["advanced", "advancedns", "smoke", "xen"], required_hardware="true")
+ @attr(speed="slow")
+ @attr(
+ tags=[
+ "advanced",
+ "advancedns",
+ "smoke",
+ "xen"],
+ required_hardware="true")
def test_07_template_from_snapshot(self):
"""Create Template from snapshot
"""
- #1. Login to machine; create temp/test directories on data volume
- #2. Snapshot the Volume
- #3. Create Template from snapshot
- #4. Deploy Virtual machine using this template
- #5. Login to newly created virtual machine
- #6. Compare data in the root disk with the one that was written on the volume, it should match
+ # 1. Login to machine; create temp/test directories on data volume
+ # 2. Snapshot the Volume
+ # 3. Create Template from snapshot
+ # 4. Deploy Virtual machine using this template
+ # 5. Login to newly created virtual machine
+ # 6. Compare data in the root disk with the one that was written on the
+ # volume, it should match
userapiclient = self.testClient.getUserApiClient(
- UserName=self.account.name,
- DomainName=self.account.domain)
+ UserName=self.account.name,
+ DomainName=self.account.domain)
random_data_0 = random_gen(size=100)
random_data_1 = random_gen(size=100)
try:
- #Login to virtual machine
+ # Login to virtual machine
ssh_client = self.virtual_machine.get_ssh_client()
cmds = [
- "mkdir -p %s" % self.services["paths"]["mount_dir"],
- "mount %s1 %s" % (
- self.services["volume"][self.hypervisor]["rootdiskdevice"],
- self.services["paths"]["mount_dir"]
- ),
- "mkdir -p %s/%s/{%s,%s} " % (
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir1"],
- self.services["paths"]["sub_lvl_dir2"]
- ),
- "echo %s > %s/%s/%s/%s" % (
- random_data_0,
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir1"],
- self.services["paths"]["random_data"]
- ),
- "echo %s > %s/%s/%s/%s" % (
- random_data_1,
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir2"],
- self.services["paths"]["random_data"]
- ),
- "sync",
- ]
+ "mkdir -p %s" % self.services["paths"]["mount_dir"],
+ "mount %s1 %s" % (
+ self.services["volume"][self.hypervisor]["rootdiskdevice"],
+ self.services["paths"]["mount_dir"]
+ ),
+ "mkdir -p %s/%s/{%s,%s} " % (
+ self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir1"],
+ self.services["paths"]["sub_lvl_dir2"]
+ ),
+ "echo %s > %s/%s/%s/%s" % (
+ random_data_0,
+ self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir1"],
+ self.services["paths"]["random_data"]
+ ),
+ "echo %s > %s/%s/%s/%s" % (
+ random_data_1,
+ self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir2"],
+ self.services["paths"]["random_data"]
+ ),
+ "sync",
+ ]
for c in cmds:
self.debug(c)
@@ -778,125 +812,124 @@ class TestSnapshots(cloudstackTestCase):
except Exception as e:
self.fail("SSH failed for VM with IP address: %s" %
- self.virtual_machine.ipaddress)
+ self.virtual_machine.ipaddress)
# Unmount the Volume
cmds = [
- "umount %s" % (self.services["paths"]["mount_dir"]),
- ]
+ "umount %s" % (self.services["paths"]["mount_dir"]),
+ ]
for c in cmds:
self.debug(c)
ssh_client.execute(c)
volumes = list_volumes(
- userapiclient,
- virtualmachineid=self.virtual_machine.id,
- type='ROOT',
- listall=True
- )
+ userapiclient,
+ virtualmachineid=self.virtual_machine.id,
+ type='ROOT',
+ listall=True
+ )
self.assertEqual(
- isinstance(volumes, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(volumes, list),
+ True,
+ "Check list response returns a valid list"
+ )
volume = volumes[0]
- #Create a snapshot of volume
+ # Create a snapshot of volume
snapshot = Snapshot.create(
- userapiclient,
- volume.id,
- account=self.account.name,
- domainid=self.account.domainid
- )
+ userapiclient,
+ volume.id,
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
self.debug("Snapshot created from volume ID: %s" % volume.id)
# Generate template from the snapshot
template = Template.create_from_snapshot(
- userapiclient,
- snapshot,
- self.services["templates"]
- )
+ userapiclient,
+ snapshot,
+ self.services["templates"]
+ )
self.cleanup.append(template)
self.debug("Template created from snapshot ID: %s" % snapshot.id)
# Verify created template
templates = list_templates(
- userapiclient,
- templatefilter=\
- self.services["templates"]["templatefilter"],
- id=template.id
- )
+ userapiclient,
+ templatefilter=self.services["templates"]["templatefilter"],
+ id=template.id
+ )
self.assertNotEqual(
- templates,
- None,
- "Check if result exists in list item call"
- )
+ templates,
+ None,
+ "Check if result exists in list item call"
+ )
self.assertEqual(
- templates[0].id,
- template.id,
- "Check new template id in list resources call"
- )
+ templates[0].id,
+ template.id,
+ "Check new template id in list resources call"
+ )
self.debug("Deploying new VM from template: %s" % template.id)
# Deploy new virtual machine using template
new_virtual_machine = VirtualMachine.create(
- userapiclient,
- self.services["server_without_disk"],
- templateid=template.id,
- accountid=self.account.name,
- domainid=self.account.domainid,
- serviceofferingid=self.service_offering.id,
- mode=self.services["mode"]
- )
+ userapiclient,
+ self.services["server_without_disk"],
+ templateid=template.id,
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ serviceofferingid=self.service_offering.id,
+ mode=self.services["mode"]
+ )
try:
- #Login to VM & mount directory
+ # Login to VM & mount directory
ssh = new_virtual_machine.get_ssh_client()
cmds = [
- "mkdir -p %s" % self.services["paths"]["mount_dir"],
- "mount %s1 %s" % (
- self.services["volume"][self.hypervisor]["rootdiskdevice"],
- self.services["paths"]["mount_dir"]
- )
- ]
+ "mkdir -p %s" % self.services["paths"]["mount_dir"],
+ "mount %s1 %s" % (
+ self.services["volume"][self.hypervisor]["rootdiskdevice"],
+ self.services["paths"]["mount_dir"]
+ )
+ ]
for c in cmds:
ssh.execute(c)
returned_data_0 = ssh.execute("cat %s/%s/%s/%s" % (
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir1"],
- self.services["paths"]["random_data"]
- ))
+ self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir1"],
+ self.services["paths"]["random_data"]
+ ))
self.debug(returned_data_0)
returned_data_1 = ssh.execute("cat %s/%s/%s/%s" % (
- self.services["paths"]["mount_dir"],
- self.services["paths"]["sub_dir"],
- self.services["paths"]["sub_lvl_dir2"],
- self.services["paths"]["random_data"]
- ))
+ self.services["paths"]["mount_dir"],
+ self.services["paths"]["sub_dir"],
+ self.services["paths"]["sub_lvl_dir2"],
+ self.services["paths"]["random_data"]
+ ))
self.debug(returned_data_1)
except Exception as e:
self.fail("SSH failed for VM with IP address: %s" %
- new_virtual_machine.ipaddress)
- #Verify returned data
+ new_virtual_machine.ipaddress)
+ # Verify returned data
self.assertEqual(
- random_data_0,
- returned_data_0[0],
- "Verify newly attached volume contents with existing one"
- )
+ random_data_0,
+ returned_data_0[0],
+ "Verify newly attached volume contents with existing one"
+ )
self.assertEqual(
- random_data_1,
- returned_data_1[0],
- "Verify newly attached volume contents with existing one"
- )
+ random_data_1,
+ returned_data_1[0],
+ "Verify newly attached volume contents with existing one"
+ )
# Unmount the volume
cmds = [
- "umount %s" % (self.services["paths"]["mount_dir"]),
- ]
+ "umount %s" % (self.services["paths"]["mount_dir"]),
+ ]
try:
for c in cmds:
self.debug(c)
@@ -904,7 +937,7 @@ class TestSnapshots(cloudstackTestCase):
except Exception as e:
self.fail("SSH failed for VM with IP address: %s, Exception: %s" %
- (new_virtual_machine.ipaddress, e))
+ (new_virtual_machine.ipaddress, e))
return
@@ -912,9 +945,11 @@ class TestCreateVMSnapshotTemplate(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.testClient = super(TestCreateVMSnapshotTemplate, cls).getClsTestClient()
+ cls.testClient = super(
+ TestCreateVMSnapshotTemplate,
+ cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
-
+ cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
@@ -922,35 +957,34 @@ class TestCreateVMSnapshotTemplate(cloudstackTestCase):
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["domainid"] = cls.domain.id
cls.services["server"]["zoneid"] = cls.zone.id
-
# Create VMs, NAT Rules etc
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls._cleanup = [
- cls.service_offering,
- cls.account,
- ]
+ cls.service_offering,
+ cls.account,
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -965,13 +999,13 @@ class TestCreateVMSnapshotTemplate(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created instance, volumes and snapshots
+ # Clean up, terminate the created instance, volumes and snapshots
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(speed = "slow")
+ @attr(speed="slow")
@attr(tags=["advanced", "advancedns"], required_hardware="true")
def test_01_createVM_snapshotTemplate(self):
"""Test create VM, Snapshot and Template
@@ -984,35 +1018,39 @@ class TestCreateVMSnapshotTemplate(cloudstackTestCase):
# 4. Create a instance from above created template.
# 5. listSnapshots should list the snapshot that was created.
# 6. verify that secondary storage NFS share contains the reqd
- # volume under /secondary/snapshots/$accountid/$volumeid/$snapshot_uuid
+ # volume under /secondary/snapshots/$accountid/
+ # $volumeid/$snapshot_uuid
# 7. verify backup_snap_id was non null in the `snapshots` table
# 8. listTemplates() should return the newly created Template,
# and check for template state as READY"
# 9. listVirtualMachines() command should return the deployed VM.
# State of this VM should be Running.
- #Create Virtual Machine
+ # Create Virtual Machine
+
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
userapiclient = self.testClient.getUserApiClient(
- UserName=self.account.name,
- DomainName=self.account.domain)
+ UserName=self.account.name,
+ DomainName=self.account.domain)
self.virtual_machine = VirtualMachine.create(
- userapiclient,
- self.services["server"],
- templateid=self.template.id,
- accountid=self.account.name,
- domainid=self.account.domainid,
- serviceofferingid=self.service_offering.id
- )
+ userapiclient,
+ self.services["server"],
+ templateid=self.template.id,
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ serviceofferingid=self.service_offering.id
+ )
self.debug("Created VM with ID: %s" % self.virtual_machine.id)
# Get the Root disk of VM
volumes = list_volumes(
- userapiclient,
- virtualmachineid=self.virtual_machine.id,
- type='ROOT',
- listall=True
- )
+ userapiclient,
+ virtualmachineid=self.virtual_machine.id,
+ type='ROOT',
+ listall=True
+ )
volume = volumes[0]
# Create a snapshot from the ROOTDISK
@@ -1021,105 +1059,111 @@ class TestCreateVMSnapshotTemplate(cloudstackTestCase):
self.cleanup.append(snapshot)
snapshots = list_snapshots(
- userapiclient,
- id=snapshot.id
- )
+ userapiclient,
+ id=snapshot.id
+ )
self.assertEqual(
- isinstance(snapshots, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(snapshots, list),
+ True,
+ "Check list response returns a valid list"
+ )
self.assertNotEqual(
- snapshots,
- None,
- "Check if result exists in list snapshots call"
- )
+ snapshots,
+ None,
+ "Check if result exists in list snapshots call"
+ )
self.assertEqual(
- snapshots[0].id,
- snapshot.id,
- "Check snapshot id in list resources call"
- )
- self.debug("select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
- % snapshot.id)
+ snapshots[0].id,
+ snapshot.id,
+ "Check snapshot id in list resources call"
+ )
+ self.debug(
+ "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" %
+ snapshot.id)
snapshot_uuid = snapshot.id
# Generate template from the snapshot
template = Template.create_from_snapshot(
- userapiclient,
- snapshot,
- self.services["templates"]
- )
+ userapiclient,
+ snapshot,
+ self.services["templates"]
+ )
self.debug("Created template from snapshot: %s" % template.id)
self.cleanup.append(template)
templates = list_templates(
- userapiclient,
- templatefilter=\
- self.services["templates"]["templatefilter"],
- id=template.id
- )
+ userapiclient,
+ templatefilter=self.services["templates"]["templatefilter"],
+ id=template.id
+ )
self.assertNotEqual(
- templates,
- None,
- "Check if result exists in list item call"
- )
+ templates,
+ None,
+ "Check if result exists in list item call"
+ )
self.assertEqual(
- templates[0].isready,
- True,
- "Check new template state in list templates call"
- )
+ templates[0].isready,
+ True,
+ "Check new template state in list templates call"
+ )
# Deploy new virtual machine using template
new_virtual_machine = VirtualMachine.create(
- userapiclient,
- self.services["server"],
- templateid=template.id,
- accountid=self.account.name,
- domainid=self.account.domainid,
- serviceofferingid=self.service_offering.id
- )
+ userapiclient,
+ self.services["server"],
+ templateid=template.id,
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ serviceofferingid=self.service_offering.id
+ )
self.debug("Created VM with ID: %s from template: %s" % (
- new_virtual_machine.id,
- template.id
- ))
+ new_virtual_machine.id,
+ template.id
+ ))
self.cleanup.append(new_virtual_machine)
# Newly deployed VM should be 'Running'
virtual_machines = list_virtual_machines(
- userapiclient,
- id=new_virtual_machine.id,
- account=self.account.name,
- domainid=self.account.domainid
- )
+ userapiclient,
+ id=new_virtual_machine.id,
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
self.assertEqual(
- isinstance(virtual_machines, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(virtual_machines, list),
+ True,
+ "Check list response returns a valid list"
+ )
self.assertNotEqual(
- len(virtual_machines),
- 0,
- "Check list virtual machines response"
- )
+ len(virtual_machines),
+ 0,
+ "Check list virtual machines response"
+ )
for virtual_machine in virtual_machines:
self.assertEqual(
- virtual_machine.state,
- 'Running',
- "Check list VM response for Running state"
- )
- self.assertTrue(is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot_uuid))
+ virtual_machine.state,
+ 'Running',
+ "Check list VM response for Running state"
+ )
+ self.assertTrue(
+ is_snapshot_on_nfs(
+ self.apiclient,
+ self.dbclient,
+ self.config,
+ self.zone.id,
+ snapshot_uuid))
return
+
class TestSnapshotEvents(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls.testClient = super(TestSnapshotEvents, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
-
-
+ cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
@@ -1127,46 +1171,46 @@ class TestSnapshotEvents(cloudstackTestCase):
cls.services['mode'] = cls.zone.networktype
template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["template"] = template.id
# Create VMs, NAT Rules etc
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
- templateid=template.id,
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id
- )
+ cls.api_client,
+ cls.services["server"],
+ templateid=template.id,
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id
+ )
cls._cleanup = [
- cls.service_offering,
- cls.account,
- ]
+ cls.service_offering,
+ cls.account,
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -1181,34 +1225,38 @@ class TestSnapshotEvents(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created instance, volumes and snapshots
+ # Clean up, terminate the created instance, volumes and snapshots
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(speed = "slow")
+ @attr(speed="slow")
@attr(tags=["advanced", "advancedns"], required_hardware="false")
def test_05_snapshot_events(self):
"""Test snapshot events
"""
# Validate the following
- # 1. Perform snapshot on the root disk of this VM and check the events/alerts.
+ # 1. Perform snapshot on the root disk of this VM and
+ # check the events/alerts.
# 2. delete the snapshots and check the events/alerts
# 3. listEvents() shows created/deleted snapshot events
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
+
# Get the Root disk of VM
volumes = list_volumes(
- self.apiclient,
- virtualmachineid=self.virtual_machine.id,
- type='ROOT',
- listall=True
- )
+ self.apiclient,
+ virtualmachineid=self.virtual_machine.id,
+ type='ROOT',
+ listall=True
+ )
self.assertEqual(
- isinstance(volumes, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(volumes, list),
+ True,
+ "Check list response returns a valid list"
+ )
volume = volumes[0]
# Create a snapshot from the ROOTDISK
@@ -1216,47 +1264,47 @@ class TestSnapshotEvents(cloudstackTestCase):
self.debug("Snapshot created with ID: %s" % snapshot.id)
snapshots = list_snapshots(
- self.apiclient,
- id=snapshot.id
- )
+ self.apiclient,
+ id=snapshot.id
+ )
self.assertEqual(
- isinstance(snapshots, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(snapshots, list),
+ True,
+ "Check list response returns a valid list"
+ )
self.assertNotEqual(
- snapshots,
- None,
- "Check if result exists in list snapshots call"
- )
+ snapshots,
+ None,
+ "Check if result exists in list snapshots call"
+ )
self.assertEqual(
- snapshots[0].id,
- snapshot.id,
- "Check snapshot id in list resources call"
- )
+ snapshots[0].id,
+ snapshot.id,
+ "Check snapshot id in list resources call"
+ )
snapshot.delete(self.apiclient)
# Sleep to ensure that snapshot is deleted properly
time.sleep(self.services["sleep"])
events = list_events(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- type='SNAPSHOT.DELETE'
- )
+ self.apiclient,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ type='SNAPSHOT.DELETE'
+ )
self.assertEqual(
- isinstance(events, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(events, list),
+ True,
+ "Check list response returns a valid list"
+ )
self.assertNotEqual(
- events,
- None,
- "Check if event exists in list events call"
- )
+ events,
+ None,
+ "Check if event exists in list events call"
+ )
self.assertIn(
- events[0].state,
- ['Completed', 'Scheduled'],
- "Check events state in list events call"
- )
+ events[0].state,
+ ['Completed', 'Scheduled'],
+ "Check events state in list events call"
+ )
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/214d63ee/test/integration/component/test_ss_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ss_limits.py b/test/integration/component/test_ss_limits.py
index c498302..22ab99c 100644
--- a/test/integration/component/test_ss_limits.py
+++ b/test/integration/component/test_ss_limits.py
@@ -58,6 +58,7 @@ class TestSecondaryStorageLimits(cloudstackTestCase):
cloudstackTestClient = super(TestSecondaryStorageLimits,
cls).getClsTestClient()
cls.api_client = cloudstackTestClient.getApiClient()
+ cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
# Fill services from the external config file
cls.services = cloudstackTestClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
@@ -201,6 +202,9 @@ class TestSecondaryStorageLimits(cloudstackTestCase):
5. Verify that the secondary storage count of the account equals
the size of the template"""
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
+
response = self.setupAccount(value)
self.assertEqual(response[0], PASS, response[1])
[10/10] git commit: updated refs/heads/master to 22d6565
Posted by ta...@apache.org.
CLOUDSATCK-8138: Fixed VmSnapshot revert issue in test_escalations_instances.py
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/22d65654
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/22d65654
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/22d65654
Branch: refs/heads/master
Commit: 22d6565434e31a8c65953a9eb1b8bfeea1c0f1d0
Parents: eae9f0f
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Wed Dec 31 15:19:22 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Mon Jan 5 18:42:07 2015 +0530
----------------------------------------------------------------------
test/integration/component/test_escalations_instances.py | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/22d65654/test/integration/component/test_escalations_instances.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_escalations_instances.py b/test/integration/component/test_escalations_instances.py
index 15eb6f1..ddae154 100644
--- a/test/integration/component/test_escalations_instances.py
+++ b/test/integration/component/test_escalations_instances.py
@@ -2622,9 +2622,6 @@ class TestInstances(cloudstackTestCase):
"Latest snapshot taken is not marked as current"
)
- # Stop Virtual machine befor reverting VM to a snapshot taken without memory
- vm_created.stop(self.userapiclient)
-
# Reverting the VM to Snapshot 1
VmSnapshot.revertToSnapshot(
self.userapiclient,
[06/10] git commit: updated refs/heads/master to 22d6565
Posted by ta...@apache.org.
CLOUDSTACK-8130: Fixed test_escalations_templates.py - Removed test case dependency on each other
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/17da2e9c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/17da2e9c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/17da2e9c
Branch: refs/heads/master
Commit: 17da2e9ce9894b67c32306fb36d02786d34ad0d0
Parents: 214d63e
Author: Ashutosh K <as...@clogeny.com>
Authored: Fri Dec 26 12:24:29 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Mon Jan 5 18:05:17 2015 +0530
----------------------------------------------------------------------
.../component/test_escalations_templates.py | 1001 +++++++++---------
1 file changed, 509 insertions(+), 492 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17da2e9c/test/integration/component/test_escalations_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_escalations_templates.py b/test/integration/component/test_escalations_templates.py
index 3dc24c1..a7787c7 100644
--- a/test/integration/component/test_escalations_templates.py
+++ b/test/integration/component/test_escalations_templates.py
@@ -16,15 +16,23 @@
# under the License.
# Import Local Modules
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
+from marvin.cloudstackTestCase import cloudstackTestCase, unittest
+from marvin.lib.utils import (cleanup_resources,
+ validateList)
+from marvin.lib.base import (Account,
+ Zone,
+ Template,
+ Hypervisor)
+from marvin.lib.common import (get_domain,
+ get_zone,
+ get_template,
+ list_os_types,
+ get_builtin_template_info)
from marvin.codes import PASS
from nose.plugins.attrib import attr
import time
+
class TestTemplates(cloudstackTestCase):
@classmethod
@@ -36,23 +44,21 @@ class TestTemplates(cloudstackTestCase):
cls.services = cls.testClient.getParsedTestDataConfig()
# Get Domain, Zone, Template
cls.domain = get_domain(cls.api_client)
- cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.zone = get_zone(
+ cls.api_client,
+ cls.testClient.getZoneForTests())
cls.template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services['mode'] = cls.zone.networktype
- cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
- # Getting authentication for user in newly created Account
- cls.user = cls.account.user[0]
- cls.userapiclient = cls.testClient.getUserApiClient(cls.user.username, cls.domain.name)
- cls._cleanup.append(cls.account)
+
+ builtin_info = get_builtin_template_info(cls.api_client, cls.zone.id)
+ cls.services["privatetemplate"]["url"] = builtin_info[0]
+ cls.services["privatetemplate"]["hypervisor"] = builtin_info[1]
+ cls.services["privatetemplate"]["format"] = builtin_info[2]
except Exception as e:
cls.tearDownClass()
raise Exception("Warning: Exception in setup : %s" % e)
@@ -62,6 +68,17 @@ class TestTemplates(cloudstackTestCase):
self.apiClient = self.testClient.getApiClient()
self.cleanup = []
+ self.account = Account.create(
+ self.apiClient,
+ self.services["account"],
+ domainid=self.domain.id
+ )
+ # Getting authentication for user in newly created Account
+ self.user = self.account.user[0]
+ self.userapiclient = self.testClient.getUserApiClient(
+ self.user.username,
+ self.domain.name)
+ self.cleanup.append(self.account)
def tearDown(self):
# Clean up, terminate the created resources
@@ -102,10 +119,9 @@ class TestTemplates(cloudstackTestCase):
return_flag = return_flag and True
else:
return_flag = return_flag and False
- self.debug("expected Value: %s, is not matching with actual value: %s" % (
- exp_val,
- act_val
- ))
+ self.debug(
+ "expected Value: %s, is not matching with actual value: %s" %
+ (exp_val, act_val))
return return_flag
@attr(tags=["advanced", "basic"], required_hardware="true")
@@ -132,105 +148,104 @@ class TestTemplates(cloudstackTestCase):
"""
# Listing all the Templates for a User
list_templates_before = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"]
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"]
+ )
# Verifying that no Templates are listed
self.assertIsNone(
- list_templates_before,
- "Templates listed for newly created User"
- )
- self.services["templateregister"]["ostype"] = self.services["ostype"]
+ list_templates_before,
+ "Templates listed for newly created User"
+ )
+ self.services["privatetemplate"]["ostype"] = self.services["ostype"]
# Creating pagesize + 1 number of Templates
for i in range(0, (self.services["pagesize"] + 1)):
template_created = Template.register(
- self.userapiclient,
- self.services["templateregister"],
- self.zone.id,
- hypervisor=self.hypervisor
- )
+ self.userapiclient,
+ self.services["privatetemplate"],
+ self.zone.id,
+ hypervisor=self.hypervisor
+ )
self.assertIsNotNone(
- template_created,
- "Template creation failed"
- )
- if(i < self.services["pagesize"]):
- self.cleanup.append(template_created)
+ template_created,
+ "Template creation failed"
+ )
# Listing all the Templates for a User
list_templates_after = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"]
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"]
+ )
status = validateList(list_templates_after)
self.assertEquals(
- PASS,
- status[0],
- "Templates creation failed"
- )
+ PASS,
+ status[0],
+ "Templates creation failed"
+ )
# Verifying that list size is pagesize + 1
self.assertEquals(
- self.services["pagesize"] + 1,
- len(list_templates_after),
- "Failed to create pagesize + 1 number of Templates"
- )
+ self.services["pagesize"] + 1,
+ len(list_templates_after),
+ "Failed to create pagesize + 1 number of Templates"
+ )
# Listing all the Templates in page 1
list_templates_page1 = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- page=1,
- pagesize=self.services["pagesize"]
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ page=1,
+ pagesize=self.services["pagesize"]
+ )
status = validateList(list_templates_page1)
self.assertEquals(
- PASS,
- status[0],
- "Failed to list Templates in page 1"
- )
+ PASS,
+ status[0],
+ "Failed to list Templates in page 1"
+ )
# Verifying the list size to be equal to pagesize
self.assertEquals(
- self.services["pagesize"],
- len(list_templates_page1),
- "Size of Templates in page 1 is not matching"
- )
+ self.services["pagesize"],
+ len(list_templates_page1),
+ "Size of Templates in page 1 is not matching"
+ )
# Listing all the Templates in page 2
list_templates_page2 = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- page=2,
- pagesize=self.services["pagesize"]
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ page=2,
+ pagesize=self.services["pagesize"]
+ )
status = validateList(list_templates_page2)
self.assertEquals(
- PASS,
- status[0],
- "Failed to list Templates in page 2"
- )
+ PASS,
+ status[0],
+ "Failed to list Templates in page 2"
+ )
# Verifying the list size to be equal to 1
self.assertEquals(
- 1,
- len(list_templates_page2),
- "Size of Templates in page 2 is not matching"
- )
- # Verifying the state of the template to be ready. If not waiting for state to become ready
+ 1,
+ len(list_templates_page2),
+ "Size of Templates in page 2 is not matching"
+ )
+ # Verifying the state of the template to be ready. If not waiting for
+ # state to become ready
template_ready = False
count = 0
while template_ready is False:
list_template = Template.list(
- self.userapiclient,
- id=template_created.id,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- )
+ self.userapiclient,
+ id=template_created.id,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ )
status = validateList(list_template)
self.assertEquals(
- PASS,
- status[0],
- "Failed to list Templates by Id"
- )
+ PASS,
+ status[0],
+ "Failed to list Templates by Id"
+ )
if list_template[0].isready is True:
template_ready = True
elif (str(list_template[0].status) == "Error"):
@@ -245,23 +260,23 @@ class TestTemplates(cloudstackTestCase):
# Deleting the Template present in page 2
Template.delete(
- template_created,
- self.userapiclient
- )
+ template_created,
+ self.userapiclient
+ )
# Listing all the Templates in page 2 again
list_templates_page2 = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- page=2,
- pagesize=self.services["pagesize"]
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ page=2,
+ pagesize=self.services["pagesize"]
+ )
# Verifying that there are no Templates listed
self.assertIsNone(
- list_templates_page2,
- "Templates not deleted from page 2"
- )
- del self.services["templateregister"]["ostype"]
+ list_templates_page2,
+ "Templates not deleted from page 2"
+ )
+ del self.services["privatetemplate"]["ostype"]
return
@attr(tags=["advanced", "basic"], required_hardware="true")
@@ -282,63 +297,63 @@ class TestTemplates(cloudstackTestCase):
"""
# Listing all the Templates for a User
list_templates_before = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"]
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"]
+ )
# Verifying that no Templates are listed
self.assertIsNone(
- list_templates_before,
- "Templates listed for newly created User"
- )
- self.services["templateregister"]["ostype"] = self.services["ostype"]
- self.services["templateregister"]["isextractable"] = True
+ list_templates_before,
+ "Templates listed for newly created User"
+ )
+ self.services["privatetemplate"]["ostype"] = self.services["ostype"]
+ self.services["privatetemplate"]["isextractable"] = True
# Creating aTemplate
template_created = Template.register(
- self.userapiclient,
- self.services["templateregister"],
- self.zone.id,
- hypervisor=self.hypervisor
- )
+ self.userapiclient,
+ self.services["privatetemplate"],
+ self.zone.id,
+ hypervisor=self.hypervisor
+ )
self.assertIsNotNone(
- template_created,
- "Template creation failed"
- )
- self.cleanup.append(template_created)
+ template_created,
+ "Template creation failed"
+ )
# Listing all the Templates for a User
list_templates_after = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"]
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"]
+ )
status = validateList(list_templates_after)
self.assertEquals(
- PASS,
- status[0],
- "Templates creation failed"
- )
+ PASS,
+ status[0],
+ "Templates creation failed"
+ )
# Verifying that list size is 1
self.assertEquals(
- 1,
- len(list_templates_after),
- "Failed to create a Template"
- )
- # Verifying the state of the template to be ready. If not waiting for state to become ready till time out
+ 1,
+ len(list_templates_after),
+ "Failed to create a Template"
+ )
+ # Verifying the state of the template to be ready. If not waiting for
+ # state to become ready till time out
template_ready = False
count = 0
while template_ready is False:
list_template = Template.list(
- self.userapiclient,
- id=template_created.id,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- )
+ self.userapiclient,
+ id=template_created.id,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ )
status = validateList(list_template)
self.assertEquals(
- PASS,
- status[0],
- "Failed to list Templates by Id"
- )
+ PASS,
+ status[0],
+ "Failed to list Templates by Id"
+ )
if list_template[0].isready is True:
template_ready = True
elif (str(list_template[0].status) == "Error"):
@@ -353,32 +368,32 @@ class TestTemplates(cloudstackTestCase):
# Downloading the Template name
download_template = Template.extract(
- self.userapiclient,
- template_created.id,
- mode="HTTP_DOWNLOAD",
- zoneid=self.zone.id
- )
+ self.userapiclient,
+ template_created.id,
+ mode="HTTP_DOWNLOAD",
+ zoneid=self.zone.id
+ )
self.assertIsNotNone(
- download_template,
- "Download Template failed"
- )
- # Verifying the details of downloaded template
+ download_template,
+ "Download Template failed"
+ )
+ # Verifying the details of downloaded template
self.assertEquals(
- "DOWNLOAD_URL_CREATED",
- download_template.state,
- "Download URL not created for Template"
- )
+ "DOWNLOAD_URL_CREATED",
+ download_template.state,
+ "Download URL not created for Template"
+ )
self.assertIsNotNone(
- download_template.url,
- "Download URL not created for Template"
- )
+ download_template.url,
+ "Download URL not created for Template"
+ )
self.assertEquals(
- template_created.id,
- download_template.id,
- "Download Template details are not same as Template created"
- )
- del self.services["templateregister"]["ostype"]
- del self.services["templateregister"]["isextractable"]
+ template_created.id,
+ download_template.id,
+ "Download Template details are not same as Template created"
+ )
+ del self.services["privatetemplate"]["ostype"]
+ del self.services["privatetemplate"]["isextractable"]
return
@attr(tags=["advanced", "basic"], required_hardware="true")
@@ -407,62 +422,62 @@ class TestTemplates(cloudstackTestCase):
"""
# Listing all the Templates for a User
list_templates_before = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"]
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"]
+ )
# Verifying that no Templates are listed
self.assertIsNone(
- list_templates_before,
- "Templates listed for newly created User"
- )
- self.services["templateregister"]["ostype"] = self.services["ostype"]
+ list_templates_before,
+ "Templates listed for newly created User"
+ )
+ self.services["privatetemplate"]["ostype"] = self.services["ostype"]
# Creating aTemplate
template_created = Template.register(
- self.userapiclient,
- self.services["templateregister"],
- self.zone.id,
- hypervisor=self.hypervisor
- )
+ self.userapiclient,
+ self.services["privatetemplate"],
+ self.zone.id,
+ hypervisor=self.hypervisor
+ )
self.assertIsNotNone(
- template_created,
- "Template creation failed"
- )
- self.cleanup.append(template_created)
+ template_created,
+ "Template creation failed"
+ )
# Listing all the Templates for a User
list_templates_after = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"]
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"]
+ )
status = validateList(list_templates_after)
self.assertEquals(
- PASS,
- status[0],
- "Templates creation failed"
- )
+ PASS,
+ status[0],
+ "Templates creation failed"
+ )
# Verifying that list size is 1
self.assertEquals(
- 1,
- len(list_templates_after),
- "Failed to create a Template"
- )
- # Verifying the state of the template to be ready. If not waiting for state to become ready till time out
+ 1,
+ len(list_templates_after),
+ "Failed to create a Template"
+ )
+ # Verifying the state of the template to be ready. If not waiting for
+ # state to become ready till time out
template_ready = False
count = 0
while template_ready is False:
list_template = Template.list(
- self.userapiclient,
- id=template_created.id,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- )
+ self.userapiclient,
+ id=template_created.id,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ )
status = validateList(list_template)
self.assertEquals(
- PASS,
- status[0],
- "Failed to list Templates by Id"
- )
+ PASS,
+ status[0],
+ "Failed to list Templates by Id"
+ )
if list_template[0].isready is True:
template_ready = True
elif (str(list_template[0].status) == "Error"):
@@ -477,220 +492,220 @@ class TestTemplates(cloudstackTestCase):
# Editing the Template name
edited_template = Template.update(
- template_created,
- self.userapiclient,
- name="NewTemplateName"
- )
+ template_created,
+ self.userapiclient,
+ name="NewTemplateName"
+ )
self.assertIsNotNone(
- edited_template,
- "Editing Template failed"
- )
- # Verifying the details of edited template
+ edited_template,
+ "Editing Template failed"
+ )
+ # Verifying the details of edited template
expected_dict = {
- "id":template_created.id,
- "name":"NewTemplateName",
- "displaytest":template_created.displaytext,
- "account":template_created.account,
- "domainid":template_created.domainid,
- "format":template_created.format,
- "ostypeid":template_created.ostypeid,
- "templatetype":template_created.templatetype,
- }
+ "id": template_created.id,
+ "name": "NewTemplateName",
+ "displaytest": template_created.displaytext,
+ "account": template_created.account,
+ "domainid": template_created.domainid,
+ "format": template_created.format,
+ "ostypeid": template_created.ostypeid,
+ "templatetype": template_created.templatetype,
+ }
actual_dict = {
- "id":edited_template.id,
- "name":edited_template.name,
- "displaytest":edited_template.displaytext,
- "account":edited_template.account,
- "domainid":edited_template.domainid,
- "format":edited_template.format,
- "ostypeid":edited_template.ostypeid,
- "templatetype":edited_template.templatetype,
- }
+ "id": edited_template.id,
+ "name": edited_template.name,
+ "displaytest": edited_template.displaytext,
+ "account": edited_template.account,
+ "domainid": edited_template.domainid,
+ "format": edited_template.format,
+ "ostypeid": edited_template.ostypeid,
+ "templatetype": edited_template.templatetype,
+ }
edit_template_status = self.__verify_values(
- expected_dict,
- actual_dict
- )
+ expected_dict,
+ actual_dict
+ )
self.assertEqual(
- True,
- edit_template_status,
- "Edited Template details are not as expected"
- )
+ True,
+ edit_template_status,
+ "Edited Template details are not as expected"
+ )
# Editing the Template displaytext
edited_template = Template.update(
- template_created,
- self.userapiclient,
- displaytext="TemplateDisplaytext"
- )
+ template_created,
+ self.userapiclient,
+ displaytext="TemplateDisplaytext"
+ )
self.assertIsNotNone(
- edited_template,
- "Editing Template failed"
- )
- # Verifying the details of edited template
+ edited_template,
+ "Editing Template failed"
+ )
+ # Verifying the details of edited template
expected_dict = {
- "id":template_created.id,
- "name":"NewTemplateName",
- "displaytest":"TemplateDisplaytext",
- "account":template_created.account,
- "domainid":template_created.domainid,
- "format":template_created.format,
- "ostypeid":template_created.ostypeid,
- "templatetype":template_created.templatetype,
- }
+ "id": template_created.id,
+ "name": "NewTemplateName",
+ "displaytest": "TemplateDisplaytext",
+ "account": template_created.account,
+ "domainid": template_created.domainid,
+ "format": template_created.format,
+ "ostypeid": template_created.ostypeid,
+ "templatetype": template_created.templatetype,
+ }
actual_dict = {
- "id":edited_template.id,
- "name":edited_template.name,
- "displaytest":edited_template.displaytext,
- "account":edited_template.account,
- "domainid":edited_template.domainid,
- "format":edited_template.format,
- "ostypeid":edited_template.ostypeid,
- "templatetype":edited_template.templatetype,
- }
+ "id": edited_template.id,
+ "name": edited_template.name,
+ "displaytest": edited_template.displaytext,
+ "account": edited_template.account,
+ "domainid": edited_template.domainid,
+ "format": edited_template.format,
+ "ostypeid": edited_template.ostypeid,
+ "templatetype": edited_template.templatetype,
+ }
edit_template_status = self.__verify_values(
- expected_dict,
- actual_dict
- )
+ expected_dict,
+ actual_dict
+ )
self.assertEqual(
- True,
- edit_template_status,
- "Edited Template details are not as expected"
- )
+ True,
+ edit_template_status,
+ "Edited Template details are not as expected"
+ )
# Editing the Template ostypeid
ostype_list = list_os_types(self.userapiclient)
status = validateList(ostype_list)
self.assertEquals(
- PASS,
- status[0],
- "Failed to list OS Types"
- )
+ PASS,
+ status[0],
+ "Failed to list OS Types"
+ )
for i in range(0, len(ostype_list)):
if ostype_list[i].id != template_created.ostypeid:
newostypeid = ostype_list[i].id
break
edited_template = Template.update(
- template_created,
- self.userapiclient,
- ostypeid=newostypeid
- )
+ template_created,
+ self.userapiclient,
+ ostypeid=newostypeid
+ )
self.assertIsNotNone(
- edited_template,
- "Editing Template failed"
- )
- # Verifying the details of edited template
+ edited_template,
+ "Editing Template failed"
+ )
+ # Verifying the details of edited template
expected_dict = {
- "id":template_created.id,
- "name":"NewTemplateName",
- "displaytest":"TemplateDisplaytext",
- "account":template_created.account,
- "domainid":template_created.domainid,
- "format":template_created.format,
- "ostypeid":newostypeid,
- "templatetype":template_created.templatetype,
- }
+ "id": template_created.id,
+ "name": "NewTemplateName",
+ "displaytest": "TemplateDisplaytext",
+ "account": template_created.account,
+ "domainid": template_created.domainid,
+ "format": template_created.format,
+ "ostypeid": newostypeid,
+ "templatetype": template_created.templatetype,
+ }
actual_dict = {
- "id":edited_template.id,
- "name":edited_template.name,
- "displaytest":edited_template.displaytext,
- "account":edited_template.account,
- "domainid":edited_template.domainid,
- "format":edited_template.format,
- "ostypeid":edited_template.ostypeid,
- "templatetype":edited_template.templatetype,
- }
+ "id": edited_template.id,
+ "name": edited_template.name,
+ "displaytest": edited_template.displaytext,
+ "account": edited_template.account,
+ "domainid": edited_template.domainid,
+ "format": edited_template.format,
+ "ostypeid": edited_template.ostypeid,
+ "templatetype": edited_template.templatetype,
+ }
edit_template_status = self.__verify_values(
- expected_dict,
- actual_dict
- )
+ expected_dict,
+ actual_dict
+ )
self.assertEqual(
- True,
- edit_template_status,
- "Edited Template details are not as expected"
- )
+ True,
+ edit_template_status,
+ "Edited Template details are not as expected"
+ )
# Editing the Template name, displaytext
edited_template = Template.update(
- template_created,
- self.userapiclient,
- name=template_created.name,
- displaytext=template_created.displaytext
- )
+ template_created,
+ self.userapiclient,
+ name=template_created.name,
+ displaytext=template_created.displaytext
+ )
self.assertIsNotNone(
- edited_template,
- "Editing Template failed"
- )
- # Verifying the details of edited template
+ edited_template,
+ "Editing Template failed"
+ )
+ # Verifying the details of edited template
expected_dict = {
- "id":template_created.id,
- "name":template_created.name,
- "displaytest":template_created.displaytext,
- "account":template_created.account,
- "domainid":template_created.domainid,
- "format":template_created.format,
- "ostypeid":newostypeid,
- "templatetype":template_created.templatetype,
- }
+ "id": template_created.id,
+ "name": template_created.name,
+ "displaytest": template_created.displaytext,
+ "account": template_created.account,
+ "domainid": template_created.domainid,
+ "format": template_created.format,
+ "ostypeid": newostypeid,
+ "templatetype": template_created.templatetype,
+ }
actual_dict = {
- "id":edited_template.id,
- "name":edited_template.name,
- "displaytest":edited_template.displaytext,
- "account":edited_template.account,
- "domainid":edited_template.domainid,
- "format":edited_template.format,
- "ostypeid":edited_template.ostypeid,
- "templatetype":edited_template.templatetype,
- }
+ "id": edited_template.id,
+ "name": edited_template.name,
+ "displaytest": edited_template.displaytext,
+ "account": edited_template.account,
+ "domainid": edited_template.domainid,
+ "format": edited_template.format,
+ "ostypeid": edited_template.ostypeid,
+ "templatetype": edited_template.templatetype,
+ }
edit_template_status = self.__verify_values(
- expected_dict,
- actual_dict
- )
+ expected_dict,
+ actual_dict
+ )
self.assertEqual(
- True,
- edit_template_status,
- "Edited Template details are not as expected"
- )
+ True,
+ edit_template_status,
+ "Edited Template details are not as expected"
+ )
# Editing the Template name, displaytext, ostypeid
edited_template = Template.update(
- template_created,
- self.userapiclient,
- name="NewTemplateName",
- displaytext="TemplateDisplaytext",
- ostypeid=template_created.ostypeid
- )
+ template_created,
+ self.userapiclient,
+ name="NewTemplateName",
+ displaytext="TemplateDisplaytext",
+ ostypeid=template_created.ostypeid
+ )
self.assertIsNotNone(
- edited_template,
- "Editing Template failed"
- )
- # Verifying the details of edited template
+ edited_template,
+ "Editing Template failed"
+ )
+ # Verifying the details of edited template
expected_dict = {
- "id":template_created.id,
- "name":"NewTemplateName",
- "displaytest":"TemplateDisplaytext",
- "account":template_created.account,
- "domainid":template_created.domainid,
- "format":template_created.format,
- "ostypeid":template_created.ostypeid,
- "templatetype":template_created.templatetype,
- }
+ "id": template_created.id,
+ "name": "NewTemplateName",
+ "displaytest": "TemplateDisplaytext",
+ "account": template_created.account,
+ "domainid": template_created.domainid,
+ "format": template_created.format,
+ "ostypeid": template_created.ostypeid,
+ "templatetype": template_created.templatetype,
+ }
actual_dict = {
- "id":edited_template.id,
- "name":edited_template.name,
- "displaytest":edited_template.displaytext,
- "account":edited_template.account,
- "domainid":edited_template.domainid,
- "format":edited_template.format,
- "ostypeid":edited_template.ostypeid,
- "templatetype":edited_template.templatetype,
- }
+ "id": edited_template.id,
+ "name": edited_template.name,
+ "displaytest": edited_template.displaytext,
+ "account": edited_template.account,
+ "domainid": edited_template.domainid,
+ "format": edited_template.format,
+ "ostypeid": edited_template.ostypeid,
+ "templatetype": edited_template.templatetype,
+ }
edit_template_status = self.__verify_values(
- expected_dict,
- actual_dict
- )
+ expected_dict,
+ actual_dict
+ )
self.assertEqual(
- True,
- edit_template_status,
- "Edited Template details are not as expected"
- )
- del self.services["templateregister"]["ostype"]
+ True,
+ edit_template_status,
+ "Edited Template details are not as expected"
+ )
+ del self.services["privatetemplate"]["ostype"]
return
@attr(tags=["advanced", "basic"], required_hardware="true")
@@ -719,120 +734,122 @@ class TestTemplates(cloudstackTestCase):
"""
# Listing Zones available for a user
zones_list = Zone.list(
- self.userapiclient,
- available=True
- )
+ self.userapiclient,
+ available=True
+ )
status = validateList(zones_list)
self.assertEquals(
- PASS,
- status[0],
- "Failed to list Zones"
- )
+ PASS,
+ status[0],
+ "Failed to list Zones"
+ )
if not len(zones_list) > 1:
raise unittest.SkipTest("Not enough zones exist to copy template")
else:
# Listing all the Templates for a User in Zone 1
list_templates_zone1 = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- zoneid=zones_list[0].id
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ zoneid=zones_list[0].id
+ )
# Verifying that no Templates are listed
self.assertIsNone(
- list_templates_zone1,
- "Templates listed for newly created User in Zone1"
- )
+ list_templates_zone1,
+ "Templates listed for newly created User in Zone1"
+ )
# Listing all the Templates for a User in Zone 2
list_templates_zone2 = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- zoneid=zones_list[1].id
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ zoneid=zones_list[1].id
+ )
# Verifying that no Templates are listed
self.assertIsNone(
- list_templates_zone2,
- "Templates listed for newly created User in Zone2"
- )
- self.services["templateregister"]["ostype"] = self.services["ostype"]
+ list_templates_zone2,
+ "Templates listed for newly created User in Zone2"
+ )
+ self.services["privatetemplate"][
+ "ostype"] = self.services["ostype"]
# Listing Hypervisors in Zone 1
hypervisor_list = Hypervisor.list(
- self.apiClient,
- zoneid=zones_list[0].id
- )
+ self.apiClient,
+ zoneid=zones_list[0].id
+ )
status = validateList(zones_list)
self.assertEquals(
- PASS,
- status[0],
- "Failed to list Hypervisors in Zone 1"
- )
+ PASS,
+ status[0],
+ "Failed to list Hypervisors in Zone 1"
+ )
# Creating aTemplate in Zone 1
template_created = Template.register(
- self.userapiclient,
- self.services["templateregister"],
- zones_list[0].id,
- hypervisor=hypervisor_list[0].name
- )
+ self.userapiclient,
+ self.services["privatetemplate"],
+ zones_list[0].id,
+ hypervisor=hypervisor_list[0].name
+ )
self.assertIsNotNone(
- template_created,
- "Template creation failed"
- )
- self.cleanup.append(template_created)
+ template_created,
+ "Template creation failed"
+ )
# Listing all the Templates for a User in Zone 1
list_templates_zone1 = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- zoneid=zones_list[0].id
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ zoneid=zones_list[0].id
+ )
status = validateList(list_templates_zone1)
self.assertEquals(
- PASS,
- status[0],
- "Templates creation failed in Zone1"
- )
+ PASS,
+ status[0],
+ "Templates creation failed in Zone1"
+ )
# Verifying that list size is 1
self.assertEquals(
- 1,
- len(list_templates_zone1),
- "Failed to create a Template"
- )
+ 1,
+ len(list_templates_zone1),
+ "Failed to create a Template"
+ )
# Listing all the Templates for a User in Zone 2
list_templates_zone2 = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- zoneid=zones_list[1].id
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ zoneid=zones_list[1].id
+ )
# Verifying that no Templates are listed
self.assertIsNone(
- list_templates_zone2,
- "Templates listed for newly created User in Zone2"
- )
- # Verifying the state of the template to be ready. If not waiting for state to become ready till time out
+ list_templates_zone2,
+ "Templates listed for newly created User in Zone2"
+ )
+ # Verifying the state of the template to be ready. If not waiting
+ # for state to become ready till time out
template_ready = False
count = 0
while template_ready is False:
list_template = Template.list(
- self.userapiclient,
- id=template_created.id,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- )
+ self.userapiclient,
+ id=template_created.id,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ )
status = validateList(list_template)
self.assertEquals(
- PASS,
- status[0],
- "Failed to list Templates by Id"
- )
+ PASS,
+ status[0],
+ "Failed to list Templates by Id"
+ )
if list_template[0].isready is True:
template_ready = True
elif (str(list_template[0].status) == "Error"):
self.fail("Created Template is in Errored state")
break
elif count > 10:
- self.fail("Timed out before Template came into ready state")
+ self.fail(
+ "Timed out before Template came into ready state")
break
else:
time.sleep(self.services["sleep"])
@@ -840,61 +857,61 @@ class TestTemplates(cloudstackTestCase):
# Copying the Template from Zone1 to Zone2
copied_template = template_created.copy(
- self.userapiclient,
- sourcezoneid=template_created.zoneid,
- destzoneid=zones_list[1].id
- )
+ self.userapiclient,
+ sourcezoneid=template_created.zoneid,
+ destzoneid=zones_list[1].id
+ )
self.assertIsNotNone(
- copied_template,
- "Copying Template from Zone1 to Zone2 failed"
- )
+ copied_template,
+ "Copying Template from Zone1 to Zone2 failed"
+ )
# Listing all the Templates for a User in Zone 1
list_templates_zone1 = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- zoneid=zones_list[0].id
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ zoneid=zones_list[0].id
+ )
status = validateList(list_templates_zone1)
self.assertEquals(
- PASS,
- status[0],
- "Templates creation failed in Zone1"
- )
+ PASS,
+ status[0],
+ "Templates creation failed in Zone1"
+ )
# Verifying that list size is 1
self.assertEquals(
- 1,
- len(list_templates_zone1),
- "Failed to create a Template"
- )
+ 1,
+ len(list_templates_zone1),
+ "Failed to create a Template"
+ )
# Listing all the Templates for a User in Zone 2
list_templates_zone2 = Template.list(
- self.userapiclient,
- listall=self.services["listall"],
- templatefilter=self.services["templatefilter"],
- zoneid=zones_list[1].id
- )
+ self.userapiclient,
+ listall=self.services["listall"],
+ templatefilter=self.services["templatefilter"],
+ zoneid=zones_list[1].id
+ )
status = validateList(list_templates_zone2)
self.assertEquals(
- PASS,
- status[0],
- "Template failed to copy into Zone2"
- )
+ PASS,
+ status[0],
+ "Template failed to copy into Zone2"
+ )
# Verifying that list size is 1
self.assertEquals(
- 1,
- len(list_templates_zone2),
- "Template failed to copy into Zone2"
- )
+ 1,
+ len(list_templates_zone2),
+ "Template failed to copy into Zone2"
+ )
self.assertNotEquals(
- "Connection refused",
- list_templates_zone2[0].status,
- "Failed to copy Template"
- )
+ "Connection refused",
+ list_templates_zone2[0].status,
+ "Failed to copy Template"
+ )
self.assertEquals(
- True,
- list_templates_zone2[0].isready,
- "Failed to copy Template"
- )
- del self.services["templateregister"]["ostype"]
+ True,
+ list_templates_zone2[0].isready,
+ "Failed to copy Template"
+ )
+ del self.services["privatetemplate"]["ostype"]
return
[05/10] git commit: updated refs/heads/master to 22d6565
Posted by ta...@apache.org.
CLOUDSTACK-8124: Skipping snapshot tests on hyperv hypervisor
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/214d63ee
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/214d63ee
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/214d63ee
Branch: refs/heads/master
Commit: 214d63ee1eb393168c2f91a646a775cdaeb5cae8
Parents: 7f10e6f
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Wed Dec 24 16:30:28 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Mon Jan 5 18:04:37 2015 +0530
----------------------------------------------------------------------
.../component/test_project_limits.py | 6 +-
.../component/test_ps_domain_limits.py | 480 +--
test/integration/component/test_ps_limits.py | 4 +-
.../component/test_resource_limits.py | 11 +-
test/integration/component/test_snapshots.py | 1504 +++++-----
test/integration/component/test_ss_limits.py | 4 +
test/integration/component/test_tags.py | 2774 +++++++++---------
test/integration/component/test_templates.py | 5 +-
test/integration/component/test_usage.py | 1469 +++++-----
9 files changed, 3240 insertions(+), 3017 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/214d63ee/test/integration/component/test_project_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_limits.py b/test/integration/component/test_project_limits.py
index d4fb92d..adae047 100644
--- a/test/integration/component/test_project_limits.py
+++ b/test/integration/component/test_project_limits.py
@@ -18,7 +18,7 @@
"""
#Import Local Modules
from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackTestCase import cloudstackTestCase,unittest
#from marvin.cloudstackAPI import *
from marvin.lib.utils import (cleanup_resources,
validateList)
@@ -522,7 +522,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
def setUpClass(cls):
cls.testClient = super(TestResourceLimitsProject, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
-
+ cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
@@ -758,6 +758,8 @@ class TestResourceLimitsProject(cloudstackTestCase):
# 5. Try to create another snapshot in this project. It should give
# user an appropriate error and an alert should be generated.
+ if self.hypervisor.lower() in ['hyperv']:
+ raise self.skipTest("Snapshots feature is not supported on Hyper-V")
self.debug(
"Updating snapshot resource limits for project: %s" %
self.project.id)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/214d63ee/test/integration/component/test_ps_domain_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ps_domain_limits.py b/test/integration/component/test_ps_domain_limits.py
index 268174f..f9aa023 100644
--- a/test/integration/component/test_ps_domain_limits.py
+++ b/test/integration/component/test_ps_domain_limits.py
@@ -46,25 +46,29 @@ from marvin.codes import (PASS,
FAILED,
RESOURCE_PRIMARY_STORAGE)
+
class TestMultipleChildDomain(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cloudstackTestClient = super(TestMultipleChildDomain,
- cls).getClsTestClient()
+ cls).getClsTestClient()
cls.api_client = cloudstackTestClient.getApiClient()
+ cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
# Fill services from the external config file
cls.services = cloudstackTestClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
- cls.zone = get_zone(cls.api_client, cloudstackTestClient.getZoneForTests())
+ cls.zone = get_zone(
+ cls.api_client,
+ cloudstackTestClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
@@ -72,8 +76,9 @@ class TestMultipleChildDomain(cloudstackTestCase):
cls._cleanup = []
try:
- cls.service_offering = ServiceOffering.create(cls.api_client,
- cls.services["service_offering"])
+ cls.service_offering = ServiceOffering.create(
+ cls.api_client,
+ cls.services["service_offering"])
cls._cleanup.append(cls.service_offering)
except Exception as e:
cls.tearDownClass()
@@ -96,11 +101,11 @@ class TestMultipleChildDomain(cloudstackTestCase):
self.services["disk_offering"]["disksize"] = 5
try:
self.disk_offering = DiskOffering.create(
- self.apiclient,
- self.services["disk_offering"]
- )
- self.assertNotEqual(self.disk_offering, None, \
- "Disk offering is None")
+ self.apiclient,
+ self.services["disk_offering"]
+ )
+ self.assertNotEqual(self.disk_offering, None,
+ "Disk offering is None")
self.cleanup.append(self.disk_offering)
except Exception as e:
self.tearDown()
@@ -121,44 +126,56 @@ class TestMultipleChildDomain(cloudstackTestCase):
child domains"""
try:
- #Update resource limit for domain
+ # Update resource limit for domain
Resources.updateLimit(self.apiclient, resourcetype=10,
- max=parentdomainlimit,
- domainid=self.parent_domain.id)
+ max=parentdomainlimit,
+ domainid=self.parent_domain.id)
# Update Resource limit for sub-domains
Resources.updateLimit(self.apiclient, resourcetype=10,
- max=subdomainlimit,
- domainid=self.cadmin_1.domainid)
+ max=subdomainlimit,
+ domainid=self.cadmin_1.domainid)
Resources.updateLimit(self.apiclient, resourcetype=10,
- max=subdomainlimit,
- domainid=self.cadmin_2.domainid)
+ max=subdomainlimit,
+ domainid=self.cadmin_2.domainid)
except Exception as e:
return [FAIL, e]
return [PASS, None]
def setupAccounts(self):
try:
- self.parent_domain = Domain.create(self.apiclient,
- services=self.services["domain"],
- parentdomainid=self.domain.id)
- self.parentd_admin = Account.create(self.apiclient, self.services["account"],
- admin=True, domainid=self.parent_domain.id)
+ self.parent_domain = Domain.create(
+ self.apiclient,
+ services=self.services["domain"],
+ parentdomainid=self.domain.id)
+ self.parentd_admin = Account.create(
+ self.apiclient,
+ self.services["account"],
+ admin=True,
+ domainid=self.parent_domain.id)
# Create sub-domains and their admin accounts
- self.cdomain_1 = Domain.create(self.apiclient,
- services=self.services["domain"],
- parentdomainid=self.parent_domain.id)
- self.cdomain_2 = Domain.create(self.apiclient,
- services=self.services["domain"],
- parentdomainid=self.parent_domain.id)
-
- self.cadmin_1 = Account.create(self.apiclient, self.services["account"],
- admin=True, domainid=self.cdomain_1.id)
-
- self.cadmin_2 = Account.create(self.apiclient, self.services["account"],
- admin=True, domainid=self.cdomain_2.id)
+ self.cdomain_1 = Domain.create(
+ self.apiclient,
+ services=self.services["domain"],
+ parentdomainid=self.parent_domain.id)
+ self.cdomain_2 = Domain.create(
+ self.apiclient,
+ services=self.services["domain"],
+ parentdomainid=self.parent_domain.id)
+
+ self.cadmin_1 = Account.create(
+ self.apiclient,
+ self.services["account"],
+ admin=True,
+ domainid=self.cdomain_1.id)
+
+ self.cadmin_2 = Account.create(
+ self.apiclient,
+ self.services["account"],
+ admin=True,
+ domainid=self.cdomain_2.id)
# Cleanup the resources created at end of test
self.cleanup.append(self.cadmin_1)
@@ -169,14 +186,14 @@ class TestMultipleChildDomain(cloudstackTestCase):
self.cleanup.append(self.parent_domain)
users = {
- self.cdomain_1: self.cadmin_1,
- self.cdomain_2: self.cadmin_2
- }
+ self.cdomain_1: self.cadmin_1,
+ self.cdomain_2: self.cadmin_2
+ }
except Exception as e:
return [FAIL, e, None]
return [PASS, None, users]
- @attr(tags=["advanced","selfservice"])
+ @attr(tags=["advanced", "selfservice"])
def test_01_multiple_domains_primary_storage_limits(self):
"""Test primary storage limit of domain and its sub-domains
@@ -204,73 +221,97 @@ class TestMultipleChildDomain(cloudstackTestCase):
# Setting up account and domain hierarchy
result = self.setupAccounts()
- self.assertEqual(result[0], PASS,\
- "Failure while setting up accounts and domains: %s" % result[1])
+ self.assertEqual(
+ result[0],
+ PASS,
+ "Failure while setting up accounts and domains: %s" %
+ result[1])
- templatesize = (self.template.size / (1024**3))
+ templatesize = (self.template.size / (1024 ** 3))
disksize = 10
subdomainlimit = (templatesize + disksize)
- result = self.updateDomainResourceLimits(((subdomainlimit*3)- 1), subdomainlimit)
- self.assertEqual(result[0], PASS,\
- "Failure while updating resource limits: %s" % result[1])
+ result = self.updateDomainResourceLimits(
+ ((subdomainlimit * 3) - 1),
+ subdomainlimit)
+ self.assertEqual(
+ result[0],
+ PASS,
+ "Failure while updating resource limits: %s" %
+ result[1])
try:
self.services["disk_offering"]["disksize"] = disksize
- disk_offering_custom = DiskOffering.create(self.apiclient,
- services=self.services["disk_offering"])
+ disk_offering_custom = DiskOffering.create(
+ self.apiclient,
+ services=self.services["disk_offering"])
self.cleanup.append(disk_offering_custom)
except Exception as e:
self.fail("Failed to create disk offering")
# Get API clients of parent and child domain admin accounts
api_client_admin = self.testClient.getUserApiClient(
- UserName=self.parentd_admin.name,
- DomainName=self.parentd_admin.domain)
- self.assertNotEqual(api_client_admin, FAILED,\
- "Failed to create api client for account: %s" % self.parentd_admin.name)
+ UserName=self.parentd_admin.name,
+ DomainName=self.parentd_admin.domain)
+ self.assertNotEqual(
+ api_client_admin,
+ FAILED,
+ "Failed to create api client for account: %s" %
+ self.parentd_admin.name)
api_client_cadmin_1 = self.testClient.getUserApiClient(
- UserName=self.cadmin_1.name,
- DomainName=self.cadmin_1.domain)
- self.assertNotEqual(api_client_cadmin_1, FAILED,\
- "Failed to create api client for account: %s" % self.cadmin_1.name)
+ UserName=self.cadmin_1.name,
+ DomainName=self.cadmin_1.domain)
+ self.assertNotEqual(
+ api_client_cadmin_1,
+ FAILED,
+ "Failed to create api client for account: %s" %
+ self.cadmin_1.name)
api_client_cadmin_2 = self.testClient.getUserApiClient(
- UserName=self.cadmin_2.name,
- DomainName=self.cadmin_2.domain)
- self.assertNotEqual(api_client_cadmin_2, FAILED,\
- "Failed to create api client for account: %s" % self.cadmin_2.name)
+ UserName=self.cadmin_2.name,
+ DomainName=self.cadmin_2.domain)
+ self.assertNotEqual(
+ api_client_cadmin_2,
+ FAILED,
+ "Failed to create api client for account: %s" %
+ self.cadmin_2.name)
VirtualMachine.create(
- api_client_cadmin_1, self.services["virtual_machine"],
- accountid=self.cadmin_1.name, domainid=self.cadmin_1.domainid,
- diskofferingid=disk_offering_custom.id, serviceofferingid=self.service_offering.id
- )
+ api_client_cadmin_1,
+ self.services["virtual_machine"],
+ accountid=self.cadmin_1.name,
+ domainid=self.cadmin_1.domainid,
+ diskofferingid=disk_offering_custom.id,
+ serviceofferingid=self.service_offering.id)
self.initialResourceCount = (templatesize + disksize)
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.parent_domain.id,
- self.initialResourceCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.parent_domain.id,
+ self.initialResourceCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
# Create VM in second child domain
vm_2 = VirtualMachine.create(
- api_client_cadmin_2, self.services["virtual_machine"],
- accountid=self.cadmin_2.name, domainid=self.cadmin_2.domainid,
- diskofferingid=disk_offering_custom.id, serviceofferingid=self.service_offering.id
- )
+ api_client_cadmin_2,
+ self.services["virtual_machine"],
+ accountid=self.cadmin_2.name,
+ domainid=self.cadmin_2.domainid,
+ diskofferingid=disk_offering_custom.id,
+ serviceofferingid=self.service_offering.id)
# Now the VMs in two child domains have exhausted the primary storage limit
# of parent domain, hence VM creation in parent domain with custom disk offering
# should fail
with self.assertRaises(Exception):
VirtualMachine.create(
- api_client_admin, self.services["virtual_machine"],
- accountid=self.parentd_admin.name, domainid=self.parentd_admin.domainid,
- diskofferingid=disk_offering_custom.id, serviceofferingid=self.service_offering.id
- )
+ api_client_admin,
+ self.services["virtual_machine"],
+ accountid=self.parentd_admin.name,
+ domainid=self.parentd_admin.domainid,
+ diskofferingid=disk_offering_custom.id,
+ serviceofferingid=self.service_offering.id)
# Deleting user account
self.cadmin_1.delete(self.apiclient)
@@ -278,8 +319,8 @@ class TestMultipleChildDomain(cloudstackTestCase):
expectedCount = self.initialResourceCount
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.parent_domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.parent_domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
@@ -293,8 +334,8 @@ class TestMultipleChildDomain(cloudstackTestCase):
expectedCount = 0
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.parent_domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.parent_domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
return
@@ -315,68 +356,79 @@ class TestMultipleChildDomain(cloudstackTestCase):
# Setting up account and domain hierarchy
result = self.setupAccounts()
- self.assertEqual(result[0], PASS,\
- "Failure while setting up accounts and domains: %s" % result[1])
+ self.assertEqual(
+ result[0],
+ PASS,
+ "Failure while setting up accounts and domains: %s" %
+ result[1])
users = result[2]
- templatesize = (self.template.size / (1024**3))
+ templatesize = (self.template.size / (1024 ** 3))
for domain, admin in users.items():
self.account = admin
self.domain = domain
apiclient = self.testClient.getUserApiClient(
- UserName=self.account.name,
- DomainName=self.account.domain)
- self.assertNotEqual(apiclient, FAILED,\
- "Failed to create api client for account: %s" % self.account.name)
+ UserName=self.account.name,
+ DomainName=self.account.domain)
+ self.assertNotEqual(
+ apiclient,
+ FAILED,
+ "Failed to create api client for account: %s" %
+ self.account.name)
try:
vm = VirtualMachine.create(
- apiclient, self.services["virtual_machine"],
- accountid=self.account.name, domainid=self.account.domainid,
- diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id
- )
+ apiclient,
+ self.services["virtual_machine"],
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=self.disk_offering.id,
+ serviceofferingid=self.service_offering.id)
expectedCount = templatesize + self.disk_offering.disksize
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
# Creating service offering with 10 GB volume
self.services["disk_offering"]["disksize"] = 10
- disk_offering_10_GB = DiskOffering.create(self.apiclient,
- services=self.services["disk_offering"])
+ disk_offering_10_GB = DiskOffering.create(
+ self.apiclient,
+ services=self.services["disk_offering"])
self.cleanup.append(disk_offering_10_GB)
volume = Volume.create(
- apiclient, self.services["volume"],
- zoneid=self.zone.id, account=self.account.name,
- domainid=self.account.domainid, diskofferingid=disk_offering_10_GB.id
- )
-
- volumeSize = (volume.size / (1024**3))
+ apiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=disk_offering_10_GB.id)
+
+ volumeSize = (volume.size / (1024 ** 3))
expectedCount += volumeSize
- vm.attach_volume(apiclient, volume=volume)
+ vm.attach_volume(apiclient, volume=volume)
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
expectedCount -= volumeSize
vm.detach_volume(apiclient, volume=volume)
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
except Exception as e:
self.fail("Failure: %s" % e)
- return
+ return
@attr(tags=["advanced"], required_hardware="false")
def test_03_multiple_domains_multiple_volumes(self):
@@ -397,67 +449,80 @@ class TestMultipleChildDomain(cloudstackTestCase):
# Setting up account and domain hierarchy
result = self.setupAccounts()
if result[0] == FAIL:
- self.fail("Failure while setting up accounts and domains: %s" % result[1])
+ self.fail(
+ "Failure while setting up accounts and domains: %s" %
+ result[1])
else:
users = result[2]
- templatesize = (self.template.size / (1024**3))
+ templatesize = (self.template.size / (1024 ** 3))
for domain, admin in users.items():
self.account = admin
self.domain = domain
apiclient = self.testClient.getUserApiClient(
- UserName=self.account.name,
- DomainName=self.account.domain)
- self.assertNotEqual(apiclient, FAILED,\
- "Failed to create api client for account: %s" % self.account.name)
+ UserName=self.account.name,
+ DomainName=self.account.domain)
+ self.assertNotEqual(
+ apiclient,
+ FAILED,
+ "Failed to create api client for account: %s" %
+ self.account.name)
try:
vm = VirtualMachine.create(
- apiclient, self.services["virtual_machine"],
- accountid=self.account.name, domainid=self.account.domainid,
- diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id
- )
+ apiclient,
+ self.services["virtual_machine"],
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=self.disk_offering.id,
+ serviceofferingid=self.service_offering.id)
expectedCount = templatesize + self.disk_offering.disksize
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
volume1size = self.services["disk_offering"]["disksize"] = 15
- disk_offering_15_GB = DiskOffering.create(self.apiclient,
- services=self.services["disk_offering"])
+ disk_offering_15_GB = DiskOffering.create(
+ self.apiclient,
+ services=self.services["disk_offering"])
self.cleanup.append(disk_offering_15_GB)
volume2size = self.services["disk_offering"]["disksize"] = 20
- disk_offering_20_GB = DiskOffering.create(self.apiclient,
- services=self.services["disk_offering"])
+ disk_offering_20_GB = DiskOffering.create(
+ self.apiclient,
+ services=self.services["disk_offering"])
self.cleanup.append(disk_offering_20_GB)
volume_1 = Volume.create(
- apiclient, self.services["volume"],
- zoneid=self.zone.id, account=self.account.name,
- domainid=self.account.domainid, diskofferingid=disk_offering_15_GB.id
- )
+ apiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=disk_offering_15_GB.id)
volume_2 = Volume.create(
- apiclient, self.services["volume"],
- zoneid=self.zone.id, account=self.account.name,
- domainid=self.account.domainid, diskofferingid=disk_offering_20_GB.id
- )
+ apiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=disk_offering_20_GB.id)
vm.attach_volume(apiclient, volume=volume_1)
vm.attach_volume(apiclient, volume=volume_2)
expectedCount += volume1size + volume2size
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
@@ -466,16 +531,16 @@ class TestMultipleChildDomain(cloudstackTestCase):
expectedCount -= volume1size
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
expectedCount -= volume2size
vm.detach_volume(apiclient, volume=volume_2)
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
except Exception as e:
@@ -498,9 +563,14 @@ class TestMultipleChildDomain(cloudstackTestCase):
# 5. Delete volume which was created from snapshot and verify primary storage
resource count"""
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
+
result = self.setupAccounts()
if result[0] == FAIL:
- self.fail("Failure while setting up accounts and domains: %s" % result[1])
+ self.fail(
+ "Failure while setting up accounts and domains: %s" %
+ result[1])
users = result[2]
for domain, admin in users.items():
@@ -509,62 +579,75 @@ class TestMultipleChildDomain(cloudstackTestCase):
try:
apiclient = self.testClient.getUserApiClient(
- UserName=self.account.name,
- DomainName=self.account.domain)
- self.assertNotEqual(apiclient, FAILED,\
- "Failed to create api client for account: %s" % self.account.name)
+ UserName=self.account.name,
+ DomainName=self.account.domain)
+ self.assertNotEqual(
+ apiclient,
+ FAILED,
+ "Failed to create api client for account: %s" %
+ self.account.name)
vm = VirtualMachine.create(
- apiclient, self.services["virtual_machine"],
- accountid=self.account.name, domainid=self.account.domainid,
- diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id
- )
+ apiclient,
+ self.services["virtual_machine"],
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=self.disk_offering.id,
+ serviceofferingid=self.service_offering.id)
- templatesize = (self.template.size / (1024**3))
+ templatesize = (self.template.size / (1024 ** 3))
- initialResourceCount = expectedCount = templatesize + self.disk_offering.disksize
+ initialResourceCount = expectedCount = templatesize + \
+ self.disk_offering.disksize
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- initialResourceCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ initialResourceCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
vm.stop(self.apiclient)
- response = createSnapshotFromVirtualMachineVolume(apiclient, self.account, vm.id)
+ response = createSnapshotFromVirtualMachineVolume(
+ apiclient,
+ self.account,
+ vm.id)
self.assertEqual(response[0], PASS, response[1])
snapshot = response[1]
- response = snapshot.validateState(apiclient, Snapshot.BACKED_UP)
+ response = snapshot.validateState(
+ apiclient,
+ Snapshot.BACKED_UP)
self.assertEqual(response[0], PASS, response[1])
- self.services["volume"]["size"] = self.services["disk_offering"]["disksize"]
- volume = Volume.create_from_snapshot(apiclient,
- snapshot_id=snapshot.id,
- services=self.services["volume"],
- account=self.account.name,
- domainid=self.account.domainid)
- volumeSize = (volume.size / (1024**3))
+ self.services["volume"]["size"] = self.services[
+ "disk_offering"]["disksize"]
+ volume = Volume.create_from_snapshot(
+ apiclient,
+ snapshot_id=snapshot.id,
+ services=self.services["volume"],
+ account=self.account.name,
+ domainid=self.account.domainid)
+ volumeSize = (volume.size / (1024 ** 3))
vm.attach_volume(apiclient, volume)
expectedCount = initialResourceCount + (volumeSize)
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
expectedCount -= volumeSize
vm.detach_volume(apiclient, volume)
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
volume.delete(apiclient)
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.domain.id,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.domain.id,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
except Exception as e:
@@ -573,7 +656,7 @@ class TestMultipleChildDomain(cloudstackTestCase):
@attr(tags=["advanced"], required_hardware="false")
def test_05_assign_virtual_machine_different_domain(self):
- """Test assign virtual machine to account belonging to different domain
+ """Test assign virtual machine to account belonging to different domain
# Steps
1. Create a parent domain and two sub-domains in it (also admin accounts
@@ -590,41 +673,48 @@ class TestMultipleChildDomain(cloudstackTestCase):
self.assertEqual(result[0], PASS, result[1])
apiclient = self.testClient.getUserApiClient(
- UserName=self.cadmin_1.name,
- DomainName=self.cadmin_1.domain)
- self.assertNotEqual(apiclient, FAILED,\
- "Failed to create api client for account: %s" % self.cadmin_1.name)
+ UserName=self.cadmin_1.name,
+ DomainName=self.cadmin_1.domain)
+ self.assertNotEqual(
+ apiclient,
+ FAILED,
+ "Failed to create api client for account: %s" %
+ self.cadmin_1.name)
try:
vm_1 = VirtualMachine.create(
- apiclient, self.services["virtual_machine"],
- accountid=self.cadmin_1.name, domainid=self.cadmin_1.domainid,
- diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id
- )
+ apiclient,
+ self.services["virtual_machine"],
+ accountid=self.cadmin_1.name,
+ domainid=self.cadmin_1.domainid,
+ diskofferingid=self.disk_offering.id,
+ serviceofferingid=self.service_offering.id)
- templatesize = (self.template.size / (1024**3))
+ templatesize = (self.template.size / (1024 ** 3))
expectedCount = templatesize + self.disk_offering.disksize
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.cadmin_1.domainid,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.cadmin_1.domainid,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
vm_1.stop(apiclient)
- vm_1.assign_virtual_machine(self.apiclient, account=self.cadmin_2.name,
- domainid=self.cadmin_2.domainid)
+ vm_1.assign_virtual_machine(
+ self.apiclient,
+ account=self.cadmin_2.name,
+ domainid=self.cadmin_2.domainid)
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.cadmin_2.domainid,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.cadmin_2.domainid,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
expectedCount = 0
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.cadmin_1.domainid,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.cadmin_1.domainid,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
except Exception as e:
@@ -633,7 +723,7 @@ class TestMultipleChildDomain(cloudstackTestCase):
@attr(tags=["advanced"], required_hardware="false")
def test_06_destroy_recover_vm(self):
- """Test primary storage counts while destroying and recovering VM
+ """Test primary storage counts while destroying and recovering VM
# Steps
1. Create a parent domain and two sub-domains in it (also admin accounts
of each domain)
@@ -656,33 +746,35 @@ class TestMultipleChildDomain(cloudstackTestCase):
self.domain = domain
try:
vm_1 = VirtualMachine.create(
- self.apiclient, self.services["virtual_machine"],
- accountid=self.account.name, domainid=self.account.domainid,
- diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id
- )
+ self.apiclient,
+ self.services["virtual_machine"],
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=self.disk_offering.id,
+ serviceofferingid=self.service_offering.id)
- templatesize = (self.template.size / (1024**3))
+ templatesize = (self.template.size / (1024 ** 3))
expectedCount = templatesize + self.disk_offering.disksize
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.account.domainid,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.account.domainid,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
vm_1.delete(self.apiclient, expunge=False)
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.account.domainid,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.account.domainid,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
vm_1.recover(self.apiclient)
result = isDomainResourceCountEqualToExpectedCount(
- self.apiclient, self.account.domainid,
- expectedCount, RESOURCE_PRIMARY_STORAGE)
+ self.apiclient, self.account.domainid,
+ expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
except Exception as e:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/214d63ee/test/integration/component/test_ps_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ps_limits.py b/test/integration/component/test_ps_limits.py
index e557249..c9a754b 100644
--- a/test/integration/component/test_ps_limits.py
+++ b/test/integration/component/test_ps_limits.py
@@ -56,6 +56,7 @@ class TestVolumeLimits(cloudstackTestCase):
cloudstackTestClient = super(TestVolumeLimits,
cls).getClsTestClient()
cls.api_client = cloudstackTestClient.getApiClient()
+ cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
# Fill services from the external config file
cls.services = cloudstackTestClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
@@ -505,7 +506,8 @@ class TestVolumeLimits(cloudstackTestCase):
# 3. Create volume againt from this snapshto and attach to VM
# 4. Verify that primary storage count increases by the volume size
# 5. Detach and delete volume, verify primary storage count decreaes by volume size"""
-
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
response = self.setupAccount(value)
self.debug(response[0])
self.debug(response[1])
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/214d63ee/test/integration/component/test_resource_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_resource_limits.py b/test/integration/component/test_resource_limits.py
index f7fecb0..5f29d70 100644
--- a/test/integration/component/test_resource_limits.py
+++ b/test/integration/component/test_resource_limits.py
@@ -18,7 +18,7 @@
"""
#Import Local Modules
from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackTestCase import cloudstackTestCase,unittest
from marvin.lib.base import (VirtualMachine,
Snapshot,
Template,
@@ -129,7 +129,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
def setUpClass(cls):
cls.testClient = super(TestResourceLimitsAccount, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
-
+ cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
@@ -448,6 +448,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
# 5. Create 2 snapshot in account 2. Verify account 2 should be able to
# create snapshots without any warning
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
self.debug(
"Updating public IP resource limit for account: %s" %
self.account_1.name)
@@ -914,7 +916,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
def setUpClass(cls):
cls.testClient = super(TestResourceLimitsDomain, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
-
+ cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
@@ -1132,7 +1134,8 @@ class TestResourceLimitsDomain(cloudstackTestCase):
# created
# 5. Try to create another snapshot in this domain. It should give the
# user an appropriate error and an alert should be generated.
-
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
self.debug(
"Updating snapshot resource limits for domain: %s" %
self.account.domainid)
[03/10] git commit: updated refs/heads/master to 22d6565
Posted by ta...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/214d63ee/test/integration/component/test_tags.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_tags.py b/test/integration/component/test_tags.py
index 2b05fbb..e323578 100644
--- a/test/integration/component/test_tags.py
+++ b/test/integration/component/test_tags.py
@@ -16,7 +16,7 @@
# under the License.
""" P1 tests for tags
"""
-#Import Local Modules
+# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.lib.utils import cleanup_resources
@@ -43,147 +43,149 @@ from marvin.lib.common import (get_zone,
from marvin.codes import FAILED
import time
+
class Services:
+
"""Test tags Services
"""
def __init__(self):
self.services = {
- "domain": {
- "name": "Domain",
- },
- "project": {
- "name": "Project",
- "displaytext": "Test project",
- },
- "account": {
- "email": "administrator@clogeny.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "user": {
- "email": "user@clogeny.com",
- "firstname": "User",
- "lastname": "User",
- "username": "User",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "other_user": {
- "email": "otheruser@clogeny.com",
- "firstname": "Other",
- "lastname": "User",
- "username": "User",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- # in MHz
- "memory": 128,
- # In MBs
- },
- "disk_offering": {
- "displaytext": "Tiny Disk Offering",
- "name": "Tiny Disk Offering",
- "disksize": 1
- },
- "volume": {
- "diskname": "Test Volume",
- },
- "virtual_machine": {
- "displayname": "TestVM",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "template": {
- "displaytext": "Cent OS Template",
- "name": "Cent OS Template",
- "ostype": 'CentOS 5.3 (64-bit)',
- "templatefilter": 'self',
- },
- "iso":
- {
- "displaytext": "Dummy ISO",
- "name": "Dummy ISO",
- "url": "http://people.apache.org/~tsp/dummy.iso",
- # Source URL where ISO is located
- "isextractable": True,
- "isfeatured": True,
- "ispublic": False,
- "ostype": 'CentOS 5.3 (64-bit)',
- "mode": 'HTTP_DOWNLOAD',
- # Used in Extract template, value must be HTTP_DOWNLOAD
- },
- "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",
- },
- "lbrule": {
- "name": "SSH",
- "alg": "leastconn",
- # Algorithm used for load balancing
- "privateport": 22,
- "publicport": 22,
- "openfirewall": False,
- },
- "natrule": {
- "privateport": 22,
- "publicport": 22,
- "protocol": "TCP"
- },
- "fw_rule": {
- "startport": 1,
- "endport": 6000,
- "cidr": '55.55.0.0/11',
- # Any network (For creating FW rule)
- },
- "security_group": {
- "name": 'SSH',
- "protocol": 'TCP',
- "startport": 22,
- "endport": 22,
- "cidrlist": '0.0.0.0/0',
- },
- # Cent OS 5.3 (64 bit)
- "sleep": 60,
- "ostype": 'CentOS 5.3 (64-bit)',
- "timeout": 10,
- "mode": 'advanced',
- }
+ "domain": {
+ "name": "Domain",
+ },
+ "project": {
+ "name": "Project",
+ "displaytext": "Test project",
+ },
+ "account": {
+ "email": "administrator@clogeny.com",
+ "firstname": "Test",
+ "lastname": "User",
+ "username": "test",
+ # Random characters are appended for unique
+ # username
+ "password": "password",
+ },
+ "user": {
+ "email": "user@clogeny.com",
+ "firstname": "User",
+ "lastname": "User",
+ "username": "User",
+ # Random characters are appended for unique
+ # username
+ "password": "password",
+ },
+ "other_user": {
+ "email": "otheruser@clogeny.com",
+ "firstname": "Other",
+ "lastname": "User",
+ "username": "User",
+ # Random characters are appended for unique
+ # username
+ "password": "password",
+ },
+ "service_offering": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ # in MHz
+ "memory": 128,
+ # In MBs
+ },
+ "disk_offering": {
+ "displaytext": "Tiny Disk Offering",
+ "name": "Tiny Disk Offering",
+ "disksize": 1
+ },
+ "volume": {
+ "diskname": "Test Volume",
+ },
+ "virtual_machine": {
+ "displayname": "TestVM",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "template": {
+ "displaytext": "Cent OS Template",
+ "name": "Cent OS Template",
+ "ostype": 'CentOS 5.3 (64-bit)',
+ "templatefilter": 'self',
+ },
+ "iso":
+ {
+ "displaytext": "Dummy ISO",
+ "name": "Dummy ISO",
+ "url": "http://people.apache.org/~tsp/dummy.iso",
+ # Source URL where ISO is located
+ "isextractable": True,
+ "isfeatured": True,
+ "ispublic": False,
+ "ostype": 'CentOS 5.3 (64-bit)',
+ "mode": 'HTTP_DOWNLOAD',
+ # Used in Extract template, value must be HTTP_DOWNLOAD
+ },
+ "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",
+ },
+ "lbrule": {
+ "name": "SSH",
+ "alg": "leastconn",
+ # Algorithm used for load balancing
+ "privateport": 22,
+ "publicport": 22,
+ "openfirewall": False,
+ },
+ "natrule": {
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": "TCP"
+ },
+ "fw_rule": {
+ "startport": 1,
+ "endport": 6000,
+ "cidr": '55.55.0.0/11',
+ # Any network (For creating FW rule)
+ },
+ "security_group": {
+ "name": 'SSH',
+ "protocol": 'TCP',
+ "startport": 22,
+ "endport": 22,
+ "cidrlist": '0.0.0.0/0',
+ },
+ # Cent OS 5.3 (64 bit)
+ "sleep": 60,
+ "ostype": 'CentOS 5.3 (64-bit)',
+ "timeout": 10,
+ "mode": 'advanced',
+ }
class TestResourceTags(cloudstackTestCase):
@@ -192,7 +194,7 @@ class TestResourceTags(cloudstackTestCase):
def setUpClass(cls):
cls.testClient = super(TestResourceTags, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
-
+ cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
# Get Zone, Domain and templates
@@ -200,65 +202,66 @@ class TestResourceTags(cloudstackTestCase):
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.domain = get_domain(cls.api_client)
cls.template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
if cls.template == FAILED:
- assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+ assert False, "get_template() failed to return template\
+ with description %s" % cls.services["ostype"]
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- admin=True,
- )
-
+ cls.api_client,
+ cls.services["account"],
+ admin=True,
+ )
+
cls.user_api_client = cls.testClient.getUserApiClient(
- UserName=cls.account.name,
- DomainName=cls.account.domain
- )
-
+ UserName=cls.account.name,
+ DomainName=cls.account.domain
+ )
+
# Create service offerings, disk offerings etc
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls.disk_offering = DiskOffering.create(
- cls.api_client,
- cls.services["disk_offering"]
- )
-
+ cls.api_client,
+ cls.services["disk_offering"]
+ )
+
cls.services["iso"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.vm_1 = VirtualMachine.create(
- cls.api_client,
- cls.services["virtual_machine"],
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id,
- mode=cls.zone.networktype
- )
+ cls.api_client,
+ cls.services["virtual_machine"],
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id,
+ mode=cls.zone.networktype
+ )
cls.vm_2 = VirtualMachine.create(
- cls.api_client,
- cls.services["virtual_machine"],
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id,
- mode=cls.zone.networktype
- )
+ cls.api_client,
+ cls.services["virtual_machine"],
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id,
+ mode=cls.zone.networktype
+ )
cls._cleanup = [
- cls.account,
- cls.service_offering,
- cls.disk_offering
- ]
+ cls.account,
+ cls.service_offering,
+ cls.disk_offering
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
print("Cleanup resources used")
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
@@ -274,18 +277,18 @@ class TestResourceTags(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created accounts, domains etc
+ # Clean up, terminate the created accounts, domains etc
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
-
+
for tag in self.rm_tags:
tag['tag_obj'].delete(self.apiclient, tag['resid'],
- tag['restype'],
- {tag['key']: tag['value']})
+ tag['restype'],
+ {tag['key']: tag['value']})
return
-
+
@attr(tags=["advanced"], required_hardware="false")
def test_01_lbrule_tag(self):
""" Test Create tag on LB rule and remove the LB rule
@@ -296,131 +299,131 @@ class TestResourceTags(cloudstackTestCase):
# 3. Delete the LB rule
self.debug("Fetching the network details for account: %s" %
- self.account.name)
+ self.account.name)
networks = Network.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- self.assertEqual(
- isinstance(networks, list),
- True,
- "List networks should not return an empty response"
- )
+ self.apiclient,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ listall=True
+ )
+ self.assertEqual(
+ isinstance(networks, list),
+ True,
+ "List networks should not return an empty response"
+ )
network = networks[0]
self.debug("Network for the account: %s is %s" %
- (self.account.name, network.name))
+ (self.account.name, network.name))
self.debug("Associating public IP for network: %s" % network.id)
public_ip = PublicIPAddress.create(
- self.apiclient,
- accountid=self.account.name,
- zoneid=self.zone.id,
- domainid=self.account.domainid,
- networkid=network.id
- )
+ self.apiclient,
+ accountid=self.account.name,
+ zoneid=self.zone.id,
+ domainid=self.account.domainid,
+ networkid=network.id
+ )
self.cleanup.append(public_ip)
self.debug("Trying to create LB rule on IP: %s" %
- public_ip.ipaddress.ipaddress)
+ public_ip.ipaddress.ipaddress)
# Create Load Balancer rule on the public ip
lb_rule = LoadBalancerRule.create(
- self.apiclient,
- self.services["lbrule"],
- ipaddressid=public_ip.ipaddress.id,
- accountid=self.account.name
- )
+ self.apiclient,
+ self.services["lbrule"],
+ ipaddressid=public_ip.ipaddress.id,
+ accountid=self.account.name
+ )
# Check if the LB rule created successfully
lb_rules = LoadBalancerRule.list(
- self.apiclient,
- id=lb_rule.id
- )
+ self.apiclient,
+ id=lb_rule.id
+ )
self.assertEqual(
- isinstance(lb_rules, list),
- True,
- "List LB rules should return valid list"
- )
+ isinstance(lb_rules, list),
+ True,
+ "List LB rules should return valid list"
+ )
self.debug("Assigning the virtual machines (%s, %s) to lb rule: %s" %
- (self.vm_1.name,
- self.vm_2.name,
- lb_rule.name))
+ (self.vm_1.name,
+ self.vm_2.name,
+ lb_rule.name))
lb_rule.assign(self.apiclient, [self.vm_1, self.vm_2])
self.debug("Creating a tag for load balancer rule")
tag = Tag.create(
- self.apiclient,
- resourceIds=lb_rule.id,
- resourceType='LoadBalancer',
- tags={'LB': 40}
- )
+ self.apiclient,
+ resourceIds=lb_rule.id,
+ resourceType='LoadBalancer',
+ tags={'LB': 40}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='LoadBalancer',
- key='LB',
- account=self.account.name,
- domainid=self.account.domainid,
- value=40
- )
+ self.apiclient,
+ listall=True,
+ resourceType='LoadBalancer',
+ key='LB',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ value=40
+ )
self.debug("Tag created: %s" % str(tags))
self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
self.assertEqual(
- int(tags[0].value),
- 40,
- "The tag value should match with the original value"
- )
-
+ int(tags[0].value),
+ 40,
+ "The tag value should match with the original value"
+ )
+
lb_rules = LoadBalancerRule.list(
- self.apiclient,
- listall=True,
- key='FW',
- value=40
- )
+ self.apiclient,
+ listall=True,
+ key='FW',
+ value=40
+ )
self.assertEqual(
- isinstance(lb_rules, list),
- True,
- "List LB rules should return valid list"
- )
+ isinstance(lb_rules, list),
+ True,
+ "List LB rules should return valid list"
+ )
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.apiclient,
- resourceIds=lb_rule.id,
- resourceType='LoadBalancer',
- tags={'LB': 40}
- )
+ self.apiclient,
+ resourceIds=lb_rule.id,
+ resourceType='LoadBalancer',
+ tags={'LB': 40}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='LoadBalancer',
- key='LB',
- account=self.account.name,
- domainid=self.account.domainid
- )
-
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='LoadBalancer',
+ key='LB',
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
+
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
self.debug("Deleting the Load balancer rule")
try:
@@ -439,126 +442,126 @@ class TestResourceTags(cloudstackTestCase):
# 3. Delete the PF rule
self.debug("Fetching the network details for account: %s" %
- self.account.name)
+ self.account.name)
networks = Network.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- self.assertEqual(
- isinstance(networks, list),
- True,
- "List networks should not return an empty response"
- )
+ self.apiclient,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ listall=True
+ )
+ self.assertEqual(
+ isinstance(networks, list),
+ True,
+ "List networks should not return an empty response"
+ )
network = networks[0]
self.debug("Network for the account: %s is %s" %
- (self.account.name, network.name))
+ (self.account.name, network.name))
self.debug("Associating public IP for network: %s" % network.id)
public_ip = PublicIPAddress.create(
- self.apiclient,
- accountid=self.account.name,
- zoneid=self.zone.id,
- domainid=self.account.domainid,
- networkid=network.id
- )
+ self.apiclient,
+ accountid=self.account.name,
+ zoneid=self.zone.id,
+ domainid=self.account.domainid,
+ networkid=network.id
+ )
self.cleanup.append(public_ip)
self.debug("Trying to create LB rule on IP: %s" %
- public_ip.ipaddress.ipaddress)
+ public_ip.ipaddress.ipaddress)
self.debug("Creating PF rule for vm: %s on Ip: %s" %
- (self.vm_1.name, public_ip.ipaddress.ipaddress))
+ (self.vm_1.name, public_ip.ipaddress.ipaddress))
nat_rule = NATRule.create(
- self.apiclient,
- self.vm_1,
- self.services["natrule"],
- ipaddressid=public_ip.ipaddress.id
- )
+ self.apiclient,
+ self.vm_1,
+ self.services["natrule"],
+ ipaddressid=public_ip.ipaddress.id
+ )
# Check if NAT rule created successfully
nat_rules = NATRule.list(
- self.apiclient,
- id=nat_rule.id
- )
+ self.apiclient,
+ id=nat_rule.id
+ )
self.assertEqual(
- isinstance(nat_rules, list),
- True,
- "List NAT rules should return valid list"
- )
+ isinstance(nat_rules, list),
+ True,
+ "List NAT rules should return valid list"
+ )
self.debug("Creating a tag for port forwarding rule")
tag = Tag.create(
- self.apiclient,
- resourceIds=nat_rule.id,
- resourceType='portForwardingRule',
- tags={'PF': 40}
- )
+ self.apiclient,
+ resourceIds=nat_rule.id,
+ resourceType='portForwardingRule',
+ tags={'PF': 40}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='portForwardingRule',
- account=self.account.name,
- domainid=self.account.domainid,
- key='PF',
- value=40
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='portForwardingRule',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='PF',
+ value=40
+ )
self.assertEqual(
- int(tags[0].value),
- 40,
- "The tag value should match with the original value"
- )
-
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
+ self.assertEqual(
+ int(tags[0].value),
+ 40,
+ "The tag value should match with the original value"
+ )
+
nat_rules = NATRule.list(
- self.apiclient,
- listall=True,
- key='FW',
- value=40
- )
+ self.apiclient,
+ listall=True,
+ key='FW',
+ value=40
+ )
self.assertEqual(
- isinstance(nat_rules, list),
- True,
- "List NAT rules should return valid list"
- )
-
+ isinstance(nat_rules, list),
+ True,
+ "List NAT rules should return valid list"
+ )
+
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.apiclient,
- resourceIds=nat_rule.id,
- resourceType='portForwardingRule',
- tags={'PF': 40}
- )
+ self.apiclient,
+ resourceIds=nat_rule.id,
+ resourceType='portForwardingRule',
+ tags={'PF': 40}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='portForwardingRule',
- account=self.account.name,
- domainid=self.account.domainid,
- key='PF',
- value=40
- )
-
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='portForwardingRule',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='PF',
+ value=40
+ )
+
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
self.debug("Deleting the port forwarding rule")
try:
nat_rule.delete(self.apiclient)
@@ -576,131 +579,131 @@ class TestResourceTags(cloudstackTestCase):
# 3. Delete the firewall rule
self.debug("Fetching the network details for account: %s" %
- self.account.name)
+ self.account.name)
networks = Network.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- self.assertEqual(
- isinstance(networks, list),
- True,
- "List networks should not return an empty response"
- )
+ self.apiclient,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ listall=True
+ )
+ self.assertEqual(
+ isinstance(networks, list),
+ True,
+ "List networks should not return an empty response"
+ )
network = networks[0]
self.debug("Network for the account: %s is %s" %
- (self.account.name, network.name))
+ (self.account.name, network.name))
self.debug("Associating public IP for network: %s" % network.id)
public_ip = PublicIPAddress.create(
- self.apiclient,
- accountid=self.account.name,
- zoneid=self.zone.id,
- domainid=self.account.domainid,
- networkid=network.id
- )
+ self.apiclient,
+ accountid=self.account.name,
+ zoneid=self.zone.id,
+ domainid=self.account.domainid,
+ networkid=network.id
+ )
self.cleanup.append(public_ip)
self.debug("Creating firewall rule on public IP: %s" %
- public_ip.ipaddress.ipaddress)
+ public_ip.ipaddress.ipaddress)
# Create Firewall rule on public IP
fw_rule = FireWallRule.create(
- self.apiclient,
- ipaddressid=public_ip.ipaddress.id,
- protocol='TCP',
- cidrlist=[self.services["fw_rule"]["cidr"]],
- startport=self.services["fw_rule"]["startport"],
- endport=self.services["fw_rule"]["endport"]
- )
+ self.apiclient,
+ ipaddressid=public_ip.ipaddress.id,
+ protocol='TCP',
+ cidrlist=[self.services["fw_rule"]["cidr"]],
+ startport=self.services["fw_rule"]["startport"],
+ endport=self.services["fw_rule"]["endport"]
+ )
self.debug("Created firewall rule: %s" % fw_rule.id)
fw_rules = FireWallRule.list(
- self.apiclient,
- id=fw_rule.id
- )
+ self.apiclient,
+ id=fw_rule.id
+ )
self.assertEqual(
- isinstance(fw_rules, list),
- True,
- "List fw rules should return a valid firewall rules"
- )
+ isinstance(fw_rules, list),
+ True,
+ "List fw rules should return a valid firewall rules"
+ )
self.assertNotEqual(
- len(fw_rules),
- 0,
- "Length of fw rules response should not be zero"
- )
+ len(fw_rules),
+ 0,
+ "Length of fw rules response should not be zero"
+ )
self.debug("Creating a tag for firewall rule")
tag = Tag.create(
- self.apiclient,
- resourceIds=fw_rule.id,
- resourceType='FirewallRule',
- tags={'FW': '40'}
- )
+ self.apiclient,
+ resourceIds=fw_rule.id,
+ resourceType='FirewallRule',
+ tags={'FW': '40'}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='FirewallRule',
- account=self.account.name,
- domainid=self.account.domainid,
- key='FW',
- value='40'
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
-
+ self.apiclient,
+ listall=True,
+ resourceType='FirewallRule',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='FW',
+ value='40'
+ )
self.assertEqual(
- tags[0].value,
- '40',
- "The tag value should match with the original value"
- )
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
+
+ self.assertEqual(
+ tags[0].value,
+ '40',
+ "The tag value should match with the original value"
+ )
fw_rules = FireWallRule.list(
- self.apiclient,
- listall=True,
- key='FW',
- value='40'
- )
- self.assertEqual(
- isinstance(fw_rules, list),
- True,
- "List fw rules should return a valid firewall rules"
- )
+ self.apiclient,
+ listall=True,
+ key='FW',
+ value='40'
+ )
+ self.assertEqual(
+ isinstance(fw_rules, list),
+ True,
+ "List fw rules should return a valid firewall rules"
+ )
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.apiclient,
- resourceIds=fw_rule.id,
- resourceType='FirewallRule',
- tags={'FW': '40'}
- )
+ self.apiclient,
+ resourceIds=fw_rule.id,
+ resourceType='FirewallRule',
+ tags={'FW': '40'}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='FirewallRule',
- account=self.account.name,
- domainid=self.account.domainid,
- key='FW',
- value='40'
- )
-
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='FirewallRule',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='FW',
+ value='40'
+ )
+
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
self.debug("Deleting the firewall rule")
try:
@@ -720,139 +723,139 @@ class TestResourceTags(cloudstackTestCase):
self.skipTest("VPN resource tags are unsupported in 4.0")
self.debug("Fetching the network details for account: %s" %
- self.account.name)
+ self.account.name)
networks = Network.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- self.assertEqual(
- isinstance(networks, list),
- True,
- "List networks should not return an empty response"
- )
+ self.apiclient,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ listall=True
+ )
+ self.assertEqual(
+ isinstance(networks, list),
+ True,
+ "List networks should not return an empty response"
+ )
network = networks[0]
self.debug("Network for the account: %s is %s" %
- (self.account.name, network.name))
+ (self.account.name, network.name))
self.debug("Associating public IP for network: %s" % network.id)
public_ip = PublicIPAddress.create(
- self.apiclient,
- accountid=self.account.name,
- zoneid=self.zone.id,
- domainid=self.account.domainid,
- networkid=network.id
- )
+ self.apiclient,
+ accountid=self.account.name,
+ zoneid=self.zone.id,
+ domainid=self.account.domainid,
+ networkid=network.id
+ )
self.cleanup.append(public_ip)
nat_rule = NATRule.create(
- self.apiclient,
- self.vm_1,
- self.services["natrule"],
- ipaddressid=public_ip.ipaddress.id
- )
+ self.apiclient,
+ self.vm_1,
+ self.services["natrule"],
+ ipaddressid=public_ip.ipaddress.id
+ )
# Check if NAT rule created successfully
nat_rules = NATRule.list(
- self.apiclient,
- id=nat_rule.id
- )
+ self.apiclient,
+ id=nat_rule.id
+ )
self.assertEqual(
- isinstance(nat_rules, list),
- True,
- "List NAT rules should return valid list"
- )
+ isinstance(nat_rules, list),
+ True,
+ "List NAT rules should return valid list"
+ )
# User should be able to enable VPN on source NAT
self.debug("Creating VPN with public NAT IP: %s" %
- public_ip.ipaddress.ipaddress)
+ public_ip.ipaddress.ipaddress)
# Assign VPN to source NAT
try:
vpn = Vpn.create(
- self.apiclient,
- public_ip.ipaddress.id,
- account=self.account.name,
- domainid=self.account.domainid
- )
+ self.apiclient,
+ public_ip.ipaddress.id,
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
except Exception as e:
print e
vpns = Vpn.list(
- self.apiclient,
- publicipid=public_ip.ipaddress.id,
- listall=True,
- )
+ self.apiclient,
+ publicipid=public_ip.ipaddress.id,
+ listall=True,
+ )
self.assertEqual(
- isinstance(vpns, list),
- True,
- "List VPNs should return a valid VPN list"
- )
+ isinstance(vpns, list),
+ True,
+ "List VPNs should return a valid VPN list"
+ )
self.assertNotEqual(
- len(vpns),
- 0,
- "Length of list VPN response should not be zero"
- )
+ len(vpns),
+ 0,
+ "Length of list VPN response should not be zero"
+ )
self.debug("Creating a tag for VPN rule")
tag = Tag.create(
- self.apiclient,
- resourceIds=nat_rule.id,
- resourceType='VPN',
- tags={'protocol': 'L2TP'}
- )
+ self.apiclient,
+ resourceIds=nat_rule.id,
+ resourceType='VPN',
+ tags={'protocol': 'L2TP'}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='VPN',
- account=self.account.name,
- domainid=self.account.domainid,
- key='protocol',
- value='L2TP'
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='VPN',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='protocol',
+ value='L2TP'
+ )
self.assertEqual(
- tags[0].value,
- 'L2TP',
- "The tag value should match with the original value"
- )
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
+ self.assertEqual(
+ tags[0].value,
+ 'L2TP',
+ "The tag value should match with the original value"
+ )
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.apiclient,
- resourceIds=vpn.id,
- resourceType='VPN',
- tags={'protocol': 'L2TP'}
- )
+ self.apiclient,
+ resourceIds=vpn.id,
+ resourceType='VPN',
+ tags={'protocol': 'L2TP'}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='VPN',
- account=self.account.name,
- domainid=self.account.domainid,
- key='protocol',
- value='L2TP'
- )
-
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='VPN',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='protocol',
+ value='L2TP'
+ )
+
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
self.debug("Disabling the VPN")
try:
@@ -871,71 +874,71 @@ class TestResourceTags(cloudstackTestCase):
self.debug("Creating a tag for user VM")
tag = Tag.create(
- self.apiclient,
- resourceIds=self.vm_1.id,
- resourceType='userVM',
- tags={'region': 'India'}
- )
+ self.apiclient,
+ resourceIds=self.vm_1.id,
+ resourceType='userVM',
+ tags={'region': 'India'}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='userVM',
- account=self.account.name,
- domainid=self.account.domainid,
- key='region',
- value='India'
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='userVM',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='region',
+ value='India'
+ )
self.assertEqual(
- tags[0].value,
- 'India',
- "The tag value should match with the original value"
- )
-
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
+ self.assertEqual(
+ tags[0].value,
+ 'India',
+ "The tag value should match with the original value"
+ )
+
vms = VirtualMachine.list(
- self.apiclient,
- listall=True,
- key='region',
- value='India'
- )
-
+ self.apiclient,
+ listall=True,
+ key='region',
+ value='India'
+ )
+
self.assertEqual(
- isinstance(vms, list),
- True,
- "Tag based VMs listing failed")
-
+ isinstance(vms, list),
+ True,
+ "Tag based VMs listing failed")
+
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.apiclient,
- resourceIds=self.vm_1.id,
- resourceType='userVM',
- tags={'region': 'India'}
- )
+ self.apiclient,
+ resourceIds=self.vm_1.id,
+ resourceType='userVM',
+ tags={'region': 'India'}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='userVM',
- account=self.account.name,
- domainid=self.account.domainid,
- key='region',
- value='India'
- )
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='userVM',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='region',
+ value='India'
+ )
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
return
@attr(tags=["advanced", "basic"], required_hardware="false")
@@ -948,7 +951,7 @@ class TestResourceTags(cloudstackTestCase):
try:
self.debug("Stopping the virtual machine: %s" % self.vm_1.name)
- #Stop virtual machine
+ # Stop virtual machine
self.vm_1.stop(self.user_api_client)
except Exception as e:
self.fail("Failed to stop VM: %s" % e)
@@ -956,11 +959,11 @@ class TestResourceTags(cloudstackTestCase):
timeout = self.services["timeout"]
while True:
list_volume = Volume.list(
- self.user_api_client,
- virtualmachineid=self.vm_1.id,
- type='ROOT',
- listall=True
- )
+ self.user_api_client,
+ virtualmachineid=self.vm_1.id,
+ type='ROOT',
+ listall=True
+ )
if isinstance(list_volume, list):
break
elif timeout == 0:
@@ -972,78 +975,77 @@ class TestResourceTags(cloudstackTestCase):
self.volume = list_volume[0]
self.debug("Creating template from ROOT disk of virtual machine: %s" %
- self.vm_1.name)
- #Create template from volume
+ self.vm_1.name)
+ # Create template from volume
template = Template.create(
- self.user_api_client,
- self.services["template"],
- self.volume.id
- )
+ self.user_api_client,
+ self.services["template"],
+ self.volume.id
+ )
self.cleanup.append(template)
self.debug("Created the template(%s). Now restarting the userVm: %s" %
- (template.name, self.vm_1.name))
+ (template.name, self.vm_1.name))
self.vm_1.start(self.user_api_client)
self.debug("Creating a tag for the template")
tag = Tag.create(
- self.user_api_client,
- resourceIds=template.id,
- resourceType='Template',
- tags={'OS': 'CentOS'}
- )
+ self.user_api_client,
+ resourceIds=template.id,
+ resourceType='Template',
+ tags={'OS': 'CentOS'}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.user_api_client,
- listall=True,
- resourceType='Template',
- key='OS',
- value='CentOS'
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ self.user_api_client,
+ listall=True,
+ resourceType='Template',
+ key='OS',
+ value='CentOS'
+ )
self.assertEqual(
- tags[0].value,
- 'CentOS',
- 'The tag should have original value'
- )
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
+ self.assertEqual(
+ tags[0].value,
+ 'CentOS',
+ 'The tag should have original value'
+ )
Template.list(
- self.user_api_client,
- templatefilter=\
- self.services["template"]["templatefilter"],
- listall=True,
- key='OS',
- value='CentOS'
- )
+ self.user_api_client,
+ templatefilter=self.services["template"]["templatefilter"],
+ listall=True,
+ key='OS',
+ value='CentOS'
+ )
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.user_api_client,
- resourceIds=template.id,
- resourceType='Template',
- tags={'OS': 'CentOS'}
- )
+ self.user_api_client,
+ resourceIds=template.id,
+ resourceType='Template',
+ tags={'OS': 'CentOS'}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.user_api_client,
- listall=True,
- resourceType='Template',
- key='OS',
- value='CentOS'
- )
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.user_api_client,
+ listall=True,
+ resourceType='Template',
+ key='OS',
+ value='CentOS'
+ )
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
return
@attr(tags=["advanced", "basic"], required_hardware="false")
@@ -1055,90 +1057,90 @@ class TestResourceTags(cloudstackTestCase):
# 2. Delete above created tag using deleteTags API
iso = Iso.create(
- self.apiclient,
- self.services["iso"],
- account=self.account.name,
- domainid=self.account.domainid
- )
+ self.apiclient,
+ self.services["iso"],
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
self.debug("ISO created with ID: %s" % iso.id)
list_iso_response = Iso.list(self.apiclient,
id=iso.id)
self.assertEqual(
- isinstance(list_iso_response, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(list_iso_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
self.debug("Creating a tag for the ISO")
tag = Tag.create(
- self.apiclient,
- resourceIds=iso.id,
- resourceType='ISO',
- tags={'OS': 'CentOS'}
- )
+ self.apiclient,
+ resourceIds=iso.id,
+ resourceType='ISO',
+ tags={'OS': 'CentOS'}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='ISO',
- account=self.account.name,
- domainid=self.account.domainid,
- key='OS',
- value='CentOS'
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='ISO',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='OS',
+ value='CentOS'
+ )
self.assertEqual(
- tags[0].value,
- 'CentOS',
- 'The tag should have original value'
- )
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
+ self.assertEqual(
+ tags[0].value,
+ 'CentOS',
+ 'The tag should have original value'
+ )
isos = Iso.list(
- self.apiclient,
- key='OS',
- value='CentOS',
- account=self.account.name,
- domainid=self.account.domainid,
- isofilter='all'
- )
-
- self.assertEqual(
- isinstance(isos, list),
- True,
- "List isos should not return an empty response"
- )
+ self.apiclient,
+ key='OS',
+ value='CentOS',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ isofilter='all'
+ )
+
+ self.assertEqual(
+ isinstance(isos, list),
+ True,
+ "List isos should not return an empty response"
+ )
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.apiclient,
- resourceIds=iso.id,
- resourceType='ISO',
- tags={'OS': 'CentOS'}
- )
+ self.apiclient,
+ resourceIds=iso.id,
+ resourceType='ISO',
+ tags={'OS': 'CentOS'}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='ISO',
- account=self.account.name,
- domainid=self.account.domainid,
- key='OS',
- value='CentOS'
- )
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='ISO',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='OS',
+ value='CentOS'
+ )
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
return
@attr(tags=["advanced", "basic"], required_hardware="false")
@@ -1150,84 +1152,84 @@ class TestResourceTags(cloudstackTestCase):
# 2. Delete above created tag using deleteTags API
self.debug("Creating volume for account: %s " %
- self.account.name)
+ self.account.name)
volume = Volume.create(
- self.apiclient,
- self.services["volume"],
- zoneid=self.zone.id,
- account=self.account.name,
- domainid=self.account.domainid,
- diskofferingid=self.disk_offering.id
- )
+ self.apiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=self.disk_offering.id
+ )
self.cleanup.append(volume)
self.debug("Volume created in account: %s" % volume.name)
self.debug("Creating a tag for the volume")
tag = Tag.create(
- self.apiclient,
- resourceIds=volume.id,
- resourceType='volume',
- tags={'region': 'India'}
- )
+ self.apiclient,
+ resourceIds=volume.id,
+ resourceType='volume',
+ tags={'region': 'India'}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='volume',
- account=self.account.name,
- domainid=self.account.domainid,
- key='region',
- value='India'
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='volume',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='region',
+ value='India'
+ )
self.assertEqual(
- tags[0].value,
- 'India',
- 'The tag should have original value'
- )
-
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
+ self.assertEqual(
+ tags[0].value,
+ 'India',
+ 'The tag should have original value'
+ )
+
vols = Volume.list(self.apiclient,
- listall=True,
- key='region',
- value='India'
- )
- self.assertEqual(
- isinstance(vols, list),
- True,
- "List volumes should not return empty response"
- )
-
+ listall=True,
+ key='region',
+ value='India'
+ )
+ self.assertEqual(
+ isinstance(vols, list),
+ True,
+ "List volumes should not return empty response"
+ )
+
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.apiclient,
- resourceIds=volume.id,
- resourceType='volume',
- tags={'region': 'India'}
- )
+ self.apiclient,
+ resourceIds=volume.id,
+ resourceType='volume',
+ tags={'region': 'India'}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='volume',
- account=self.account.name,
- domainid=self.account.domainid,
- key='region'
- )
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='volume',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='region'
+ )
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
return
@attr(tags=["advanced", "basic"], required_hardware="false")
@@ -1238,8 +1240,11 @@ class TestResourceTags(cloudstackTestCase):
# 1. Create a tag on snapshot using createTags API
# 2. Delete above created tag using deleteTags API
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
+
self.debug("Creating snapshot on ROOT volume for VM: %s " %
- self.vm_1.name)
+ self.vm_1.name)
# Get the Root disk of VM
volumes = Volume.list(self.apiclient,
virtualmachineid=self.vm_1.id,
@@ -1255,80 +1260,80 @@ class TestResourceTags(cloudstackTestCase):
snapshots = Snapshot.list(self.apiclient,
id=snapshot.id)
self.assertEqual(
- isinstance(snapshots, list),
- True,
- "Tag based snapshot listing failed")
+ isinstance(snapshots, list),
+ True,
+ "Tag based snapshot listing failed")
self.debug("Creating a tag for the snapshot")
tag = Tag.create(
- self.apiclient,
- resourceIds=snapshot.id,
- resourceType='snapshot',
- tags={'type': 'manual'}
- )
+ self.apiclient,
+ resourceIds=snapshot.id,
+ resourceType='snapshot',
+ tags={'type': 'manual'}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='snapshot',
- account=self.account.name,
- domainid=self.account.domainid,
- key='type',
- value='manual'
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='snapshot',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='type',
+ value='manual'
+ )
self.assertEqual(
- tags[0].value,
- 'manual',
- 'The tag should have original value'
- )
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
+ self.assertEqual(
+ tags[0].value,
+ 'manual',
+ 'The tag should have original value'
+ )
snapshots = Snapshot.list(self.apiclient,
listall=True,
key='type',
value='manual')
self.assertEqual(
- isinstance(snapshots, list),
- True,
- "Check list response returns a valid list"
- )
+ isinstance(snapshots, list),
+ True,
+ "Check list response returns a valid list"
+ )
self.assertNotEqual(
- snapshots,
- None,
- "Check if result exists in list snapshots call"
- )
+ snapshots,
+ None,
+ "Check if result exists in list snapshots call"
+ )
self.debug("Listing snapshots by tag was successful")
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.apiclient,
- resourceIds=snapshot.id,
- resourceType='snapshot',
- tags={'type': 'manual'}
- )
+ self.apiclient,
+ resourceIds=snapshot.id,
+ resourceType='snapshot',
+ tags={'type': 'manual'}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='snapshot',
- account=self.account.name,
- domainid=self.account.domainid,
- key='type',
- value='manual'
- )
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='snapshot',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='type',
+ value='manual'
+ )
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
return
@@ -1341,91 +1346,91 @@ class TestResourceTags(cloudstackTestCase):
# 2. Delete above created tag using deleteTags API
self.debug("Fetching the network details for account: %s" %
- self.account.name)
+ self.account.name)
networks = Network.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- self.assertEqual(
- isinstance(networks, list),
- True,
- "List networks should not return an empty response"
- )
+ self.apiclient,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ listall=True
+ )
+ self.assertEqual(
+ isinstance(networks, list),
+ True,
+ "List networks should not return an empty response"
+ )
network = networks[0]
self.debug("Network for the account: %s is %s" %
- (self.account.name, network.name))
+ (self.account.name, network.name))
self.debug("Creating a tag for load balancer rule")
tag = Tag.create(
- self.apiclient,
- resourceIds=network.id,
- resourceType='Network',
- tags={'region': 'India'}
- )
+ self.apiclient,
+ resourceIds=network.id,
+ resourceType='Network',
+ tags={'region': 'India'}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='Network',
- account=self.account.name,
- domainid=self.account.domainid,
- key='region',
- value='India'
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='Network',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='region',
+ value='India'
+ )
self.assertEqual(
- tags[0].value,
- 'India',
- 'The tag should have original value'
- )
-
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
+ self.assertEqual(
+ tags[0].value,
+ 'India',
+ 'The tag should have original value'
+ )
+
networks = Network.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True,
- key='region',
- value='India'
- )
- self.assertEqual(
- isinstance(networks, list),
- True,
- "List networks should not return an empty response"
- )
+ self.apiclient,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ listall=True,
+ key='region',
+ value='India'
+ )
+ self.assertEqual(
+ isinstance(networks, list),
+ True,
+ "List networks should not return an empty response"
+ )
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.apiclient,
- resourceIds=network.id,
- resourceType='Network',
- tags={'region': 'India'}
- )
+ self.apiclient,
+ resourceIds=network.id,
+ resourceType='Network',
+ tags={'region': 'India'}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='Network',
- account=self.account.name,
- domainid=self.account.domainid,
- key='region',
- value='India'
- )
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='Network',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='region',
+ value='India'
+ )
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
return
@attr(tags=["basic", "sg"])
@@ -1437,29 +1442,29 @@ class TestResourceTags(cloudstackTestCase):
# 2. Delete above created tag using deleteTags API
vms = VirtualMachine.list(
- self.apiclient,
- id=self.vm_1.id,
- listall=True
- )
+ self.apiclient,
+ id=self.vm_1.id,
+ listall=True
+ )
self.assertEqual(
- isinstance(vms, list),
- True,
- "List vms should not return empty response"
- )
+ isinstance(vms, list),
+ True,
+ "List vms should not return empty response"
+ )
source_host = vms[0].hostid
-
+
hosts = Host.list(
- self.apiclient,
- zoneid=self.zone.id,
- resourcestate='Enabled',
- type='Routing'
- )
- self.assertEqual(
- isinstance(hosts, list),
- True,
- "List hosts should return valid host response"
- )
+ self.apiclient,
+ zoneid=self.zone.id,
+ resourcestate='Enabled',
+ type='Routing'
+ )
+ self.assertEqual(
+ isinstance(hosts, list),
+ True,
+ "List hosts should return valid host response"
+ )
self.debug("Available hosts: ")
for host in hosts:
@@ -1474,64 +1479,64 @@ class TestResourceTags(cloudstackTestCase):
self.debug("Creating a tag for user VM")
tag = Tag.create(
- self.apiclient,
- resourceIds=self.vm_1.id,
- resourceType='userVM',
- tags={'region': 'India'}
- )
+ self.apiclient,
+ resourceIds=self.vm_1.id,
+ resourceType='userVM',
+ tags={'region': 'India'}
+ )
self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='userVM',
- account=self.account.name,
- domainid=self.account.domainid,
- key='region',
- value='India'
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='userVM',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='region',
+ value='India'
+ )
+ self.assertEqual(
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
self.assertEqual(
- tags[0].value,
- 'India',
- 'The tag should have original value'
- )
+ tags[0].value,
+ 'India',
+ 'The tag should have original value'
+ )
self.debug("Migrating the instance from: %s to %s" %
- (source_host, dest_host.id))
+ (source_host, dest_host.id))
self.vm_1.migrate(self.apiclient, hostid=dest_host.id)
self.debug("Deleting the created tag..")
try:
tag.delete(
- self.apiclient,
- resourceIds=self.vm_1.id,
- resourceType='userVM',
- tags={'region': 'India'}
- )
+ self.apiclient,
+ resourceIds=self.vm_1.id,
+ resourceType='userVM',
+ tags={'region': 'India'}
+ )
except Exception as e:
self.fail("Failed to delete the tag - %s" % e)
self.debug("Verifying if tag is actually deleted!")
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='userVM',
- account=self.account.name,
- domainid=self.account.domainid,
- key='region',
- value='India'
- )
- self.assertEqual(
- tags,
- None,
- "List tags should return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='userVM',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='region',
+ value='India'
+ )
+ self.assertEqual(
+ tags,
+ None,
+ "List tags should return empty response"
+ )
return
@attr(tags=["advanced", "basic"], required_hardware="false")
@@ -1545,33 +1550,33 @@ class TestResourceTags(cloudstackTestCase):
self.debug("Creating a tag for user VM")
tag_1 = Tag.create(
- self.apiclient,
- resourceIds=self.vm_1.id,
- resourceType='userVM',
- tags={'region': 'India'}
- )
+ self.apiclient,
+ resourceIds=self.vm_1.id,
+ resourceType='userVM',
+ tags={'region': 'India'}
+ )
self.debug("Tag created: %s" % tag_1.__dict__)
tags = Tag.list(
- self.apiclient,
- listall=True,
- resourceType='userVM',
- account=self.account.name,
- domainid=self.account.domainid,
- key='region',
- value='India'
- )
- self.assertEqual(
- isinstance(tags, list),
- True,
- "List tags should not return empty response"
- )
+ self.apiclient,
+ listall=True,
+ resourceType='userVM',
+ account=self.account.name,
+ domainid=self.account.domainid,
+ key='region',
+ value='India'
+ )
+ self.assertEqual(
+ isinstance(tags, list),
+ True,
+ "List tags should not return empty response"
+ )
self.assertEqual(
- tags[0].value,
-
<TRUNCATED>
[02/10] git commit: updated refs/heads/master to 22d6565
Posted by ta...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/214d63ee/test/integration/component/test_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_templates.py b/test/integration/component/test_templates.py
index 753e71a..06b8c5f 100644
--- a/test/integration/component/test_templates.py
+++ b/test/integration/component/test_templates.py
@@ -284,7 +284,7 @@ class TestTemplates(cloudstackTestCase):
cls.testClient = super(TestTemplates, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
-
+ cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
@@ -495,6 +495,9 @@ class TestTemplates(cloudstackTestCase):
# 4. Deploy Virtual machine using this template
# 5. VM should be in running state
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
+
userapiclient = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/214d63ee/test/integration/component/test_usage.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_usage.py b/test/integration/component/test_usage.py
index 58cfbed..262a371 100644
--- a/test/integration/component/test_usage.py
+++ b/test/integration/component/test_usage.py
@@ -16,7 +16,7 @@
# under the License.
""" P1 tests for Snapshots
"""
-#Import Local Modules
+# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.cloudstackAPI import deleteVolume
@@ -39,84 +39,86 @@ from marvin.lib.common import (get_zone,
get_domain,
get_template)
+
class Services:
+
"""Test Snapshots Services
"""
def __init__(self):
self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100, # in MHz
- "memory": 128, # In MBs
- },
- "disk_offering": {
- "displaytext": "Small",
- "name": "Small",
- "disksize": 1
- },
- "volume": {
- "diskname": "TestDiskServ",
- },
- "server": {
- "displayname": "TestVM",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "templates": {
- "displaytext": 'Template',
- "name": 'Template',
- "ostype": 'CentOS 5.3 (64-bit)',
- "templatefilter": 'self',
- "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.qcow2.bz2"
- },
- "iso": {
- "displaytext": "Test ISO",
- "name": "Test ISO",
- "url": "http://people.apache.org/~tsp/dummy.iso",
- # Source URL where ISO is located
- "isextractable": True,
- "isfeatured": True,
- "ispublic": True,
- "ostype": 'CentOS 5.3 (64-bit)',
- },
- "lbrule": {
- "name": "SSH",
- "alg": "roundrobin",
- # Algorithm used for load balancing
- "privateport": 22,
- "publicport": 2222,
- },
- "natrule": {
- "privateport": 22,
- "publicport": 22,
- "protocol": "TCP"
- },
- "vpn_user": {
- "username": "test",
- "password": "test",
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- # Cent OS 5.3 (64 bit)
- "sleep": 60,
- "timeout": 10,
- }
+ "account": {
+ "email": "test@test.com",
+ "firstname": "Test",
+ "lastname": "User",
+ "username": "test",
+ # Random characters are appended for unique
+ # username
+ "password": "password",
+ },
+ "service_offering": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100, # in MHz
+ "memory": 128, # In MBs
+ },
+ "disk_offering": {
+ "displaytext": "Small",
+ "name": "Small",
+ "disksize": 1
+ },
+ "volume": {
+ "diskname": "TestDiskServ",
+ },
+ "server": {
+ "displayname": "TestVM",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "templates": {
+ "displaytext": 'Template',
+ "name": 'Template',
+ "ostype": 'CentOS 5.3 (64-bit)',
+ "templatefilter": 'self',
+ "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.qcow2.bz2"
+ },
+ "iso": {
+ "displaytext": "Test ISO",
+ "name": "Test ISO",
+ "url": "http://people.apache.org/~tsp/dummy.iso",
+ # Source URL where ISO is located
+ "isextractable": True,
+ "isfeatured": True,
+ "ispublic": True,
+ "ostype": 'CentOS 5.3 (64-bit)',
+ },
+ "lbrule": {
+ "name": "SSH",
+ "alg": "roundrobin",
+ # Algorithm used for load balancing
+ "privateport": 22,
+ "publicport": 2222,
+ },
+ "natrule": {
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": "TCP"
+ },
+ "vpn_user": {
+ "username": "test",
+ "password": "test",
+ },
+ "ostype": 'CentOS 5.3 (64-bit)',
+ # Cent OS 5.3 (64 bit)
+ "sleep": 60,
+ "timeout": 10,
+ }
class TestVmUsage(cloudstackTestCase):
@@ -133,45 +135,45 @@ class TestVmUsage(cloudstackTestCase):
cls.services['mode'] = cls.zone.networktype
template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["template"] = template.id
# Create Account, VMs etc
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
- templateid=template.id,
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id
- )
+ cls.api_client,
+ cls.services["server"],
+ templateid=template.id,
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id
+ )
cls._cleanup = [
- cls.service_offering,
- cls.account,
- ]
+ cls.service_offering,
+ cls.account,
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -185,13 +187,21 @@ class TestVmUsage(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created instance, volumes and snapshots
+ # Clean up, terminate the created instance, volumes and snapshots
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+ @attr(
+ tags=[
+ "advanced",
+ "basic",
+ "sg",
+ "eip",
+ "advancedns",
+ "simulator"],
+ required_hardware="false")
def test_01_vm_usage(self):
"""Test Create/Destroy VM and verify usage calculation
"""
@@ -219,94 +229,94 @@ class TestVmUsage(cloudstackTestCase):
self.fail("Failed to destroy VM: %s" % e)
# Fetch account ID from account_uuid
- self.debug("select id from account where uuid = '%s';" \
- % self.account.id)
+ self.debug("select id from account where uuid = '%s';"
+ % self.account.id)
qresultset = self.dbclient.execute(
- "select id from account where uuid = '%s';" \
- % self.account.id
- )
+ "select id from account where uuid = '%s';"
+ % self.account.id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = qresultset[0]
account_id = qresult[0]
- self.debug("select type from usage_event where account_id = '%s';" \
- % account_id)
+ self.debug("select type from usage_event where account_id = '%s';"
+ % account_id)
qresultset = self.dbclient.execute(
- "select type from usage_event where account_id = '%s';" \
- % account_id
- )
+ "select type from usage_event where account_id = '%s';"
+ % account_id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = str(qresultset)
self.debug("Query result: %s" % qresult)
# Check if VM.CREATE, VM.DESTROY events present in usage_event table
self.assertEqual(
- qresult.count('VM.START'),
- 1,
- "Check VM.START event in events table"
- )
+ qresult.count('VM.START'),
+ 1,
+ "Check VM.START event in events table"
+ )
self.assertEqual(
- qresult.count('NETWORK.OFFERING.ASSIGN'),
- 1,
- "Check NETWORK.OFFERING.ASSIGN in events table"
- )
+ qresult.count('NETWORK.OFFERING.ASSIGN'),
+ 1,
+ "Check NETWORK.OFFERING.ASSIGN in events table"
+ )
self.assertEqual(
- qresult.count('VM.CREATE'),
- 1,
- "Check VM.CREATE in list events"
- )
+ qresult.count('VM.CREATE'),
+ 1,
+ "Check VM.CREATE in list events"
+ )
self.assertEqual(
- qresult.count('VOLUME.CREATE'),
- 1,
- "Check VOLUME.CREATE in events table"
- )
+ qresult.count('VOLUME.CREATE'),
+ 1,
+ "Check VOLUME.CREATE in events table"
+ )
self.assertEqual(
- qresult.count('VM.STOP'),
- 1,
- "Check VM.STOP in events table"
- )
+ qresult.count('VM.STOP'),
+ 1,
+ "Check VM.STOP in events table"
+ )
self.assertEqual(
- qresult.count('NETWORK.OFFERING.REMOVE'),
- 1,
- "Check NETWORK.OFFERING.REMOVE in list events"
- )
+ qresult.count('NETWORK.OFFERING.REMOVE'),
+ 1,
+ "Check NETWORK.OFFERING.REMOVE in list events"
+ )
self.assertEqual(
- qresult.count('VM.DESTROY'),
- 1,
- "Check VM.DESTROY in events table"
- )
+ qresult.count('VM.DESTROY'),
+ 1,
+ "Check VM.DESTROY in events table"
+ )
self.assertEqual(
- qresult.count('VOLUME.DELETE'),
- 1,
- "Check VOLUME.DELETE in events table"
- )
+ qresult.count('VOLUME.DELETE'),
+ 1,
+ "Check VOLUME.DELETE in events table"
+ )
return
@@ -324,53 +334,53 @@ class TestPublicIPUsage(cloudstackTestCase):
cls.services['mode'] = cls.zone.networktype
template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["template"] = template.id
# Create VMs, Assign Public IP etc
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
- templateid=template.id,
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id
- )
+ cls.api_client,
+ cls.services["server"],
+ templateid=template.id,
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id
+ )
cls.public_ip = PublicIPAddress.create(
- cls.api_client,
- accountid=cls.virtual_machine.account,
- zoneid=cls.virtual_machine.zoneid,
- domainid=cls.virtual_machine.domainid,
- services=cls.services["server"]
- )
+ cls.api_client,
+ accountid=cls.virtual_machine.account,
+ zoneid=cls.virtual_machine.zoneid,
+ domainid=cls.virtual_machine.domainid,
+ services=cls.services["server"]
+ )
cls._cleanup = [
- cls.service_offering,
- cls.account,
- ]
+ cls.service_offering,
+ cls.account,
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -384,13 +394,19 @@ class TestPublicIPUsage(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created instance
+ # Clean up, terminate the created instance
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(tags=["advanced", "eip", "advancedns", "simulator"], required_hardware="false")
+ @attr(
+ tags=[
+ "advanced",
+ "eip",
+ "advancedns",
+ "simulator"],
+ required_hardware="false")
def test_01_public_ip_usage(self):
"""Test Assign new IP and verify usage calculation
"""
@@ -402,65 +418,65 @@ class TestPublicIPUsage(cloudstackTestCase):
# 3. Delete the newly created account
self.debug("Deleting public IP: %s" %
- self.public_ip.ipaddress)
+ self.public_ip.ipaddress)
# Release one of the IP
self.public_ip.delete(self.apiclient)
# Fetch account ID from account_uuid
- self.debug("select id from account where uuid = '%s';" \
- % self.account.id)
+ self.debug("select id from account where uuid = '%s';"
+ % self.account.id)
qresultset = self.dbclient.execute(
- "select id from account where uuid = '%s';" \
- % self.account.id
- )
+ "select id from account where uuid = '%s';"
+ % self.account.id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = qresultset[0]
account_id = qresult[0]
- self.debug("select type from usage_event where account_id = '%s';" \
- % account_id)
+ self.debug("select type from usage_event where account_id = '%s';"
+ % account_id)
qresultset = self.dbclient.execute(
- "select type from usage_event where account_id = '%s';" \
- % account_id
- )
+ "select type from usage_event where account_id = '%s';"
+ % account_id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = str(qresultset)
# Check if NET.IPASSIGN, NET.IPRELEASE events present in usage_event
# table
self.assertEqual(
- qresult.count('NET.IPASSIGN') > 0,
- True,
- "Check NET.IPASSIGN event in events table"
- )
+ qresult.count('NET.IPASSIGN') > 0,
+ True,
+ "Check NET.IPASSIGN event in events table"
+ )
self.assertEqual(
- qresult.count('NET.IPRELEASE') > 0,
- True,
- "Check NET.IPRELEASE in events table"
- )
+ qresult.count('NET.IPRELEASE') > 0,
+ True,
+ "Check NET.IPRELEASE in events table"
+ )
return
@@ -477,50 +493,50 @@ class TestVolumeUsage(cloudstackTestCase):
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
- cls.api_client,
- cls.services["disk_offering"]
- )
+ cls.api_client,
+ cls.services["disk_offering"]
+ )
template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["server"]["diskoffering"] = cls.disk_offering.id
cls.services["template"] = template.id
# Create Account, VMs etc
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
- templateid=template.id,
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id
- )
+ cls.api_client,
+ cls.services["server"],
+ templateid=template.id,
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id
+ )
cls._cleanup = [
- cls.service_offering,
- cls.disk_offering,
- cls.account,
- ]
+ cls.service_offering,
+ cls.disk_offering,
+ cls.account,
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -534,13 +550,21 @@ class TestVolumeUsage(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created instance, volumes
+ # Clean up, terminate the created instance, volumes
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+ @attr(
+ tags=[
+ "advanced",
+ "basic",
+ "sg",
+ "eip",
+ "advancedns",
+ "simulator"],
+ required_hardware="false")
def test_01_volume_usage(self):
"""Test Create/delete a volume and verify correct usage is recorded
"""
@@ -560,22 +584,22 @@ class TestVolumeUsage(cloudstackTestCase):
self.fail("Failed to stop instance: %s" % e)
volume_response = Volume.list(
- self.apiclient,
- virtualmachineid=self.virtual_machine.id,
- type='DATADISK',
- listall=True)
+ self.apiclient,
+ virtualmachineid=self.virtual_machine.id,
+ type='DATADISK',
+ listall=True)
self.assertEqual(
- isinstance(volume_response, list),
- True,
- "Check for valid list volumes response"
- )
+ isinstance(volume_response, list),
+ True,
+ "Check for valid list volumes response"
+ )
data_volume = volume_response[0]
# Detach data Disk
self.debug("Detaching volume ID: %s VM with ID: %s" % (
- data_volume.id,
- self.virtual_machine.id
- ))
+ data_volume.id,
+ self.virtual_machine.id
+ ))
self.virtual_machine.detach_volume(self.apiclient, data_volume)
# Delete Data disk
@@ -585,60 +609,60 @@ class TestVolumeUsage(cloudstackTestCase):
self.apiclient.deleteVolume(cmd)
# Fetch account ID from account_uuid
- self.debug("select id from account where uuid = '%s';" \
- % self.account.id)
+ self.debug("select id from account where uuid = '%s';"
+ % self.account.id)
qresultset = self.dbclient.execute(
- "select id from account where uuid = '%s';" \
- % self.account.id
- )
+ "select id from account where uuid = '%s';"
+ % self.account.id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = qresultset[0]
account_id = qresult[0]
- self.debug("select type from usage_event where account_id = '%s';" \
- % account_id)
+ self.debug("select type from usage_event where account_id = '%s';"
+ % account_id)
qresultset = self.dbclient.execute(
- "select type from usage_event where account_id = '%s';" \
- % account_id
- )
+ "select type from usage_event where account_id = '%s';"
+ % account_id
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
qresult = str(qresultset)
self.debug("Query result: %s" % qresult)
# Check VOLUME.CREATE, VOLUME.DESTROY events in cloud.usage_event table
self.assertEqual(
- qresult.count('VOLUME.CREATE'),
- 2,
- "Check VOLUME.CREATE event in events table"
- )
+ qresult.count('VOLUME.CREATE'),
+ 2,
+ "Check VOLUME.CREATE event in events table"
+ )
self.assertEqual(
- qresult.count('VOLUME.DELETE'),
- 1,
- "Check VOLUME.DELETE in events table"
- )
+ qresult.count('VOLUME.DELETE'),
+ 1,
+ "Check VOLUME.DELETE in events table"
+ )
return
@@ -656,48 +680,48 @@ class TestTemplateUsage(cloudstackTestCase):
cls.services['mode'] = cls.zone.networktype
cls.services["server"]["zoneid"] = cls.zone.id
template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["server"]["zoneid"] = cls.zone.id
cls._cleanup = []
try:
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
cls._cleanup.append(cls.account)
cls.userapiclient = cls.testClient.getUserApiClient(
- UserName=cls.account.name,
- DomainName=cls.account.domain)
+ UserName=cls.account.name,
+ DomainName=cls.account.domain)
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls._cleanup.append(cls.service_offering)
- #create virtual machine
+ # create virtual machine
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
- templateid=template.id,
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id,
- mode=cls.services["mode"]
- )
-
- #Stop virtual machine
+ cls.api_client,
+ cls.services["server"],
+ templateid=template.id,
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id,
+ mode=cls.services["mode"]
+ )
+
+ # Stop virtual machine
cls.virtual_machine.stop(cls.api_client)
list_volume = Volume.list(
- cls.api_client,
- virtualmachineid=cls.virtual_machine.id,
- type='ROOT',
- listall=True)
+ cls.api_client,
+ virtualmachineid=cls.virtual_machine.id,
+ type='ROOT',
+ listall=True)
if isinstance(list_volume, list):
cls.volume = list_volume[0]
else:
@@ -710,7 +734,7 @@ class TestTemplateUsage(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -724,13 +748,20 @@ class TestTemplateUsage(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created instance, templates
+ # Clean up, terminate the created instance, templates
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(tags=["advanced", "basic", "sg", "eip", "advancedns"], required_hardware="false")
+ @attr(
+ tags=[
+ "advanced",
+ "basic",
+ "sg",
+ "eip",
+ "advancedns"],
+ required_hardware="false")
def test_01_template_usage(self):
"""Test Upload/ delete a template and verify correct usage is generated
for the template uploaded
@@ -743,75 +774,75 @@ class TestTemplateUsage(cloudstackTestCase):
# cloud.usage_event tables for this account
# 4. Destroy the account
- #Create template from Virtual machine and Volume ID
+ # Create template from Virtual machine and Volume ID
self.template = Template.create(
- self.userapiclient,
- self.services["templates"],
- self.volume.id,
- TestTemplateUsage.account.name,
- TestTemplateUsage.account.domainid
- )
+ self.userapiclient,
+ self.services["templates"],
+ self.volume.id,
+ TestTemplateUsage.account.name,
+ TestTemplateUsage.account.domainid
+ )
self.debug("Created template with ID: %s" % self.template.id)
# Delete template
self.template.delete(self.userapiclient)
self.debug("Deleted template with ID: %s" % self.template.id)
# Fetch account ID from account_uuid
- self.debug("select id from account where uuid = '%s';" \
- % self.account.id)
+ self.debug("select id from account where uuid = '%s';"
+ % self.account.id)
qresultset = self.dbclient.execute(
- "select id from account where uuid = '%s';" \
- % self.account.id
- )
+ "select id from account where uuid = '%s';"
+ % self.account.id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = qresultset[0]
account_id = qresult[0]
- self.debug("select type from usage_event where account_id = '%s';" \
- % account_id)
+ self.debug("select type from usage_event where account_id = '%s';"
+ % account_id)
qresultset = self.dbclient.execute(
- "select type from usage_event where account_id = '%s';" \
- % account_id
- )
+ "select type from usage_event where account_id = '%s';"
+ % account_id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = str(qresultset)
self.debug("Query result: %s" % qresult)
# Check for TEMPLATE.CREATE, TEMPLATE.DELETE in cloud.usage_event table
self.assertEqual(
- qresult.count('TEMPLATE.CREATE'),
- 1,
- "Check TEMPLATE.CREATE event in events table"
- )
+ qresult.count('TEMPLATE.CREATE'),
+ 1,
+ "Check TEMPLATE.CREATE event in events table"
+ )
self.assertEqual(
- qresult.count('TEMPLATE.DELETE'),
- 1,
- "Check TEMPLATE.DELETE in events table"
- )
+ qresult.count('TEMPLATE.DELETE'),
+ 1,
+ "Check TEMPLATE.DELETE in events table"
+ )
return
@@ -831,34 +862,34 @@ class TestISOUsage(cloudstackTestCase):
cls.services["iso"]["zoneid"] = cls.zone.id
# Create Account, ISO image etc
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
cls.services["account"] = cls.account.name
cls.iso = Iso.create(
- cls.api_client,
- cls.services["iso"],
- account=cls.account.name,
- domainid=cls.account.domainid
- )
+ cls.api_client,
+ cls.services["iso"],
+ account=cls.account.name,
+ domainid=cls.account.domainid
+ )
try:
# Wait till ISO gets downloaded
cls.iso.download(cls.api_client)
except Exception as e:
raise Exception("%s: Failed to download ISO: %s" % (
- e,
- cls.iso.id
- ))
+ e,
+ cls.iso.id
+ ))
cls._cleanup = [
- cls.account,
- ]
+ cls.account,
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -872,13 +903,20 @@ class TestISOUsage(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created ISO images
+ # Clean up, terminate the created ISO images
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(tags=["advanced", "basic", "sg", "eip", "advancedns"], required_hardware="false")
+ @attr(
+ tags=[
+ "advanced",
+ "basic",
+ "sg",
+ "eip",
+ "advancedns"],
+ required_hardware="false")
def test_01_ISO_usage(self):
"""Test Create/Delete a ISO and verify its usage is generated correctly
"""
@@ -895,62 +933,62 @@ class TestISOUsage(cloudstackTestCase):
self.iso.delete(self.apiclient)
# Fetch account ID from account_uuid
- self.debug("select id from account where uuid = '%s';" \
- % self.account.id)
+ self.debug("select id from account where uuid = '%s';"
+ % self.account.id)
qresultset = self.dbclient.execute(
- "select id from account where uuid = '%s';" \
- % self.account.id
- )
+ "select id from account where uuid = '%s';"
+ % self.account.id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = qresultset[0]
account_id = qresult[0]
- self.debug("select type from usage_event where account_id = '%s';" \
- % account_id)
+ self.debug("select type from usage_event where account_id = '%s';"
+ % account_id)
qresultset = self.dbclient.execute(
- "select type from usage_event where account_id = '%s';" \
- % account_id
- )
+ "select type from usage_event where account_id = '%s';"
+ % account_id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = str(qresultset)
self.debug("Query result: %s" % qresult)
- imageStores = ImageStore.list(self.api_client,zoneid=self.zone.id)
+ imageStores = ImageStore.list(self.api_client, zoneid=self.zone.id)
# Check for ISO.CREATE, ISO.DELETE events in cloud.usage_event table
self.assertEqual(
- qresult.count('ISO.CREATE'),
- len(imageStores),
- "Check ISO.CREATE event in events table"
- )
+ qresult.count('ISO.CREATE'),
+ len(imageStores),
+ "Check ISO.CREATE event in events table"
+ )
self.assertEqual(
- qresult.count('ISO.DELETE'),
- len(imageStores),
- "Check ISO.DELETE in events table"
- )
+ qresult.count('ISO.DELETE'),
+ len(imageStores),
+ "Check ISO.DELETE in events table"
+ )
return
@@ -967,52 +1005,52 @@ class TestLBRuleUsage(cloudstackTestCase):
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["template"] = template.id
# Create VMs, LB Rules etc
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
- templateid=template.id,
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id
- )
+ cls.api_client,
+ cls.services["server"],
+ templateid=template.id,
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id
+ )
cls.public_ip_1 = PublicIPAddress.create(
- cls.api_client,
- accountid=cls.virtual_machine.account,
- zoneid=cls.virtual_machine.zoneid,
- domainid=cls.virtual_machine.domainid,
- services=cls.services["server"]
- )
+ cls.api_client,
+ accountid=cls.virtual_machine.account,
+ zoneid=cls.virtual_machine.zoneid,
+ domainid=cls.virtual_machine.domainid,
+ services=cls.services["server"]
+ )
cls._cleanup = [
- cls.service_offering,
- cls.account,
- ]
+ cls.service_offering,
+ cls.account,
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -1026,13 +1064,19 @@ class TestLBRuleUsage(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created instance, LB rules
+ # Clean up, terminate the created instance, LB rules
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(tags=["advanced", "eip", "advancedns", "simulator"], required_hardware="false")
+ @attr(
+ tags=[
+ "advanced",
+ "eip",
+ "advancedns",
+ "simulator"],
+ required_hardware="false")
def test_01_lb_usage(self):
"""Test Create/Delete a LB rule and verify correct usage is recorded
"""
@@ -1046,75 +1090,75 @@ class TestLBRuleUsage(cloudstackTestCase):
self.debug(
"Creating load balancer rule for public IP: %s" %
- self.public_ip_1.ipaddress.id)
- #Create Load Balancer rule and assign VMs to rule
+ self.public_ip_1.ipaddress.id)
+ # Create Load Balancer rule and assign VMs to rule
lb_rule = LoadBalancerRule.create(
- self.apiclient,
- self.services["lbrule"],
- self.public_ip_1.ipaddress.id,
- accountid=self.account.name
- )
+ self.apiclient,
+ self.services["lbrule"],
+ self.public_ip_1.ipaddress.id,
+ accountid=self.account.name
+ )
# Delete LB Rule
self.debug("Deleting LB rule with ID: %s" % lb_rule.id)
lb_rule.delete(self.apiclient)
# Fetch account ID from account_uuid
- self.debug("select id from account where uuid = '%s';" \
- % self.account.id)
+ self.debug("select id from account where uuid = '%s';"
+ % self.account.id)
qresultset = self.dbclient.execute(
- "select id from account where uuid = '%s';" \
- % self.account.id
- )
+ "select id from account where uuid = '%s';"
+ % self.account.id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = qresultset[0]
account_id = qresult[0]
- self.debug("select type from usage_event where account_id = '%s';" \
- % account_id)
+ self.debug("select type from usage_event where account_id = '%s';"
+ % account_id)
qresultset = self.dbclient.execute(
- "select type from usage_event where account_id = '%s';" \
- % account_id
- )
+ "select type from usage_event where account_id = '%s';"
+ % account_id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = str(qresultset)
self.debug("Query result: %s" % qresult)
# Check for LB.CREATE, LB.DELETE in cloud.usage_event table
self.assertEqual(
- qresult.count('LB.CREATE'),
- 1,
- "Check LB.CREATE event in events table"
- )
+ qresult.count('LB.CREATE'),
+ 1,
+ "Check LB.CREATE event in events table"
+ )
self.assertEqual(
- qresult.count('LB.DELETE'),
- 1,
- "Check LB.DELETE in events table"
- )
+ qresult.count('LB.DELETE'),
+ 1,
+ "Check LB.DELETE in events table"
+ )
return
@@ -1124,7 +1168,7 @@ class TestSnapshotUsage(cloudstackTestCase):
def setUpClass(cls):
cls.testClient = super(TestSnapshotUsage, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
-
+ cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
@@ -1132,45 +1176,45 @@ class TestSnapshotUsage(cloudstackTestCase):
cls.services['mode'] = cls.zone.networktype
template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["template"] = template.id
# Create Account, VMs etc
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
- templateid=template.id,
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id
- )
+ cls.api_client,
+ cls.services["server"],
+ templateid=template.id,
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id
+ )
cls._cleanup = [
- cls.service_offering,
- cls.account,
- ]
+ cls.service_offering,
+ cls.account,
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -1184,14 +1228,22 @@ class TestSnapshotUsage(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created instance and snapshots
+ # Clean up, terminate the created instance and snapshots
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(speed = "slow")
- @attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"], required_hardware="false")
+ @attr(speed="slow")
+ @attr(
+ tags=[
+ "advanced",
+ "basic",
+ "sg",
+ "eip",
+ "advancedns",
+ "simulator"],
+ required_hardware="false")
def test_01_snapshot_usage(self):
"""Test Create/Delete a manual snap shot and verify
correct usage is recorded
@@ -1204,16 +1256,20 @@ class TestSnapshotUsage(cloudstackTestCase):
# 3. Delete the account
# Get the Root disk of VM
+
+ if self.hypervisor.lower() in ['hyperv']:
+ self.skipTest("Snapshots feature is not supported on Hyper-V")
+
volumes = Volume.list(
- self.apiclient,
- virtualmachineid=self.virtual_machine.id,
- type='ROOT',
- listall=True)
+ self.apiclient,
+ virtualmachineid=self.virtual_machine.id,
+ type='ROOT',
+ listall=True)
self.assertEqual(
- isinstance(volumes, list),
- True,
- "Check if list volumes return a valid data"
- )
+ isinstance(volumes, list),
+ True,
+ "Check if list volumes return a valid data"
+ )
# Create a snapshot from the ROOTDISK
self.debug("Creating snapshot from volume: %s" % volumes[0].id)
@@ -1224,63 +1280,63 @@ class TestSnapshotUsage(cloudstackTestCase):
snapshot.delete(self.apiclient)
# Fetch account ID from account_uuid
- self.debug("select id from account where uuid = '%s';" \
- % self.account.id)
+ self.debug("select id from account where uuid = '%s';"
+ % self.account.id)
qresultset = self.dbclient.execute(
- "select id from account where uuid = '%s';" \
- % self.account.id
- )
+ "select id from account where uuid = '%s';"
+ % self.account.id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = qresultset[0]
account_id = qresult[0]
- self.debug("select type from usage_event where account_id = '%s';" \
- % account_id)
+ self.debug("select type from usage_event where account_id = '%s';"
+ % account_id)
qresultset = self.dbclient.execute(
- "select type from usage_event where account_id = '%s';" \
- % account_id
- )
+ "select type from usage_event where account_id = '%s';"
+ % account_id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check if database query returns a valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check if database query returns a valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = str(qresultset)
self.debug("Query Result: %s" % qresult)
- # Check for SNAPSHOT.CREATE, SNAPSHOT.DELETE events in cloud.usage_event
- # table
+ # Check for SNAPSHOT.CREATE, SNAPSHOT.DELETE events in
+ # cloud.usage_event table
self.assertEqual(
- qresult.count('SNAPSHOT.CREATE'),
- 1,
- "Check SNAPSHOT.CREATE event in events table"
- )
+ qresult.count('SNAPSHOT.CREATE'),
+ 1,
+ "Check SNAPSHOT.CREATE event in events table"
+ )
self.assertEqual(
- qresult.count('SNAPSHOT.DELETE'),
- 1,
- "Check SNAPSHOT.DELETE in events table"
- )
+ qresult.count('SNAPSHOT.DELETE'),
+ 1,
+ "Check SNAPSHOT.DELETE in events table"
+ )
return
@@ -1297,52 +1353,52 @@ class TestNatRuleUsage(cloudstackTestCase):
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["template"] = template.id
# Create VMs, NAT Rules etc
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
- templateid=template.id,
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id
- )
+ cls.api_client,
+ cls.services["server"],
+ templateid=template.id,
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id
+ )
cls.public_ip_1 = PublicIPAddress.create(
- cls.api_client,
- accountid=cls.virtual_machine.account,
- zoneid=cls.virtual_machine.zoneid,
- domainid=cls.virtual_machine.domainid,
- services=cls.services["server"]
- )
+ cls.api_client,
+ accountid=cls.virtual_machine.account,
+ zoneid=cls.virtual_machine.zoneid,
+ domainid=cls.virtual_machine.domainid,
+ services=cls.services["server"]
+ )
cls._cleanup = [
- cls.service_offering,
- cls.account,
- ]
+ cls.service_offering,
+ cls.account,
+ ]
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -1356,13 +1412,18 @@ class TestNatRuleUsage(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created instance, NAT rules
+ # Clean up, terminate the created instance, NAT rules
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(tags=["advanced", "advancedns", "simulator"], required_hardware="false")
+ @attr(
+ tags=[
+ "advanced",
+ "advancedns",
+ "simulator"],
+ required_hardware="false")
def test_01_nat_usage(self):
"""Test Create/Delete a PF rule and verify correct usage is recorded
"""
@@ -1376,75 +1437,75 @@ class TestNatRuleUsage(cloudstackTestCase):
# 4. Delete this account.
self.debug("Creating NAT rule with public IP: %s" %
- self.public_ip_1.ipaddress.id)
- #Create NAT rule
+ self.public_ip_1.ipaddress.id)
+ # Create NAT rule
nat_rule = NATRule.create(
- self.apiclient,
- self.virtual_machine,
- self.services["natrule"],
- self.public_ip_1.ipaddress.id
- )
+ self.apiclient,
+ self.virtual_machine,
+ self.services["natrule"],
+ self.public_ip_1.ipaddress.id
+ )
# Delete NAT Rule
self.debug("Deleting NAT rule: %s" % nat_rule.id)
nat_rule.delete(self.apiclient)
# Fetch account ID from account_uuid
- self.debug("select id from account where uuid = '%s';" \
- % self.account.id)
+ self.debug("select id from account where uuid = '%s';"
+ % self.account.id)
qresultset = self.dbclient.execute(
- "select id from account where uuid = '%s';" \
- % self.account.id
- )
+ "select id from account where uuid = '%s';"
+ % self.account.id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = qresultset[0]
account_id = qresult[0]
- self.debug("select type from usage_event where account_id = '%s';" \
- % account_id)
+ self.debug("select type from usage_event where account_id = '%s';"
+ % account_id)
qresultset = self.dbclient.execute(
- "select type from usage_event where account_id = '%s';" \
- % account_id
- )
+ "select type from usage_event where account_id = '%s';"
+ % account_id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = str(qresultset)
self.debug("Query result: %s" % qresult)
# Check for NET.RULEADD, NET.RULEDELETE in cloud.usage_event table
self.assertEqual(
- qresult.count('NET.RULEADD'),
- 1,
- "Check NET.RULEADD event in events table"
- )
+ qresult.count('NET.RULEADD'),
+ 1,
+ "Check NET.RULEADD event in events table"
+ )
self.assertEqual(
- qresult.count('NET.RULEDELETE'),
- 1,
- "Check NET.RULEDELETE in events table"
- )
+ qresult.count('NET.RULEDELETE'),
+ 1,
+ "Check NET.RULEDELETE in events table"
+ )
return
@@ -1461,10 +1522,10 @@ class TestVpnUsage(cloudstackTestCase):
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["template"] = template.id
@@ -1472,41 +1533,41 @@ class TestVpnUsage(cloudstackTestCase):
# Create Service offerings, VMs etc
cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- admin=True,
- domainid=cls.domain.id
- )
+ cls.api_client,
+ cls.services["account"],
+ admin=True,
+ domainid=cls.domain.id
+ )
cls._cleanup.append(cls.account)
cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
- )
+ cls.api_client,
+ cls.services["service_offering"]
+ )
cls._cleanup.append(cls.service_offering)
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
- templateid=template.id,
- accountid=cls.account.name,
- domainid=cls.account.domainid,
- serviceofferingid=cls.service_offering.id
- )
+ cls.api_client,
+ cls.services["server"],
+ templateid=template.id,
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id
+ )
cls.public_ip = PublicIPAddress.create(
- cls.api_client,
- accountid=cls.virtual_machine.account,
- zoneid=cls.virtual_machine.zoneid,
- domainid=cls.virtual_machine.domainid,
- services=cls.services["server"]
- )
+ cls.api_client,
+ accountid=cls.virtual_machine.account,
+ zoneid=cls.virtual_machine.zoneid,
+ domainid=cls.virtual_machine.domainid,
+ services=cls.services["server"]
+ )
return
@classmethod
def tearDownClass(cls):
try:
- #Cleanup resources used
+ # Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -1520,7 +1581,7 @@ class TestVpnUsage(cloudstackTestCase):
def tearDown(self):
try:
- #Clean up, terminate the created instance, VPN users
+ # Clean up, terminate the created instance, VPN users
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -1539,25 +1600,25 @@ class TestVpnUsage(cloudstackTestCase):
# 4. Delete this account.
self.debug("Created VPN with public IP: %s" %
- self.public_ip.ipaddress.id)
- #Assign VPN to Public IP
+ self.public_ip.ipaddress.id)
+ # Assign VPN to Public IP
vpn = Vpn.create(
- self.apiclient,
- self.public_ip.ipaddress.id,
- account=self.account.name,
- domainid=self.account.domainid
- )
+ self.apiclient,
+ self.public_ip.ipaddress.id,
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
self.debug("Created VPN user for account: %s" %
- self.account.name)
+ self.account.name)
vpnuser = VpnUser.create(
- self.apiclient,
- self.services["vpn_user"]["username"],
- self.services["vpn_user"]["password"],
- account=self.account.name,
- domainid=self.account.domainid
- )
+ self.apiclient,
+ self.services["vpn_user"]["username"],
+ self.services["vpn_user"]["password"],
+ account=self.account.name,
+ domainid=self.account.domainid
+ )
# Remove VPN user
self.debug("Deleting VPN user: %s" % vpnuser.id)
@@ -1568,59 +1629,59 @@ class TestVpnUsage(cloudstackTestCase):
vpn.delete(self.apiclient)
# Fetch account ID from account_uuid
- self.debug("select id from account where uuid = '%s';" \
- % self.account.id)
+ self.debug("select id from account where uuid = '%s';"
+ % self.account.id)
qresultset = self.dbclient.execute(
- "select id from account where uuid = '%s';" \
- % self.account.id
- )
+ "select id from account where uuid = '%s';"
+ % self.account.id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = qresultset[0]
account_id = qresult[0]
- self.debug("select type from usage_event where account_id = '%s';" \
- % account_id)
+ self.debug("select type from usage_event where account_id = '%s';"
+ % account_id)
qresultset = self.dbclient.execute(
- "select type from usage_event where account_id = '%s';" \
- % account_id
- )
+ "select type from usage_event where account_id = '%s';"
+ % account_id
+ )
self.assertEqual(
- isinstance(qresultset, list),
- True,
- "Check DB query result set for valid data"
- )
+ isinstance(qresultset, list),
+ True,
+ "Check DB query result set for valid data"
+ )
self.assertNotEqual(
- len(qresultset),
- 0,
- "Check DB Query result set"
- )
+ len(qresultset),
+ 0,
+ "Check DB Query result set"
+ )
qresult = str(qresultset)
self.debug("Query result: %s" % qresult)
# Check for VPN user related events
self.assertEqual(
- qresult.count('VPN.USER.ADD'),
- 1,
- "Check VPN.USER.ADD event in events table"
- )
+ qresult.count('VPN.USER.ADD'),
+ 1,
+ "Check VPN.USER.ADD event in events table"
+ )
self.assertEqual(
- qresult.count('VPN.USER.ADD'),
- 1,
- "Check VPN.USER.ADD in events table"
- )
+ qresult.count('VPN.USER.ADD'),
+ 1,
+ "Check VPN.USER.ADD in events table"
+ )
return
[09/10] git commit: updated refs/heads/master to 22d6565
Posted by ta...@apache.org.
CLOUDSTACK-8137: Fixed cleanup issue in sec group tests in test_escalations_instances.py
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/eae9f0f0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/eae9f0f0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/eae9f0f0
Branch: refs/heads/master
Commit: eae9f0f0b0904a9dad025d4278b5e9b4fdf02b5e
Parents: 1ee4188
Author: K@clogeny.com <K...@clogeny.com>
Authored: Tue Dec 30 15:04:38 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Mon Jan 5 18:32:30 2015 +0530
----------------------------------------------------------------------
test/integration/component/test_escalations_instances.py | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eae9f0f0/test/integration/component/test_escalations_instances.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_escalations_instances.py b/test/integration/component/test_escalations_instances.py
index b089ed5..15eb6f1 100644
--- a/test/integration/component/test_escalations_instances.py
+++ b/test/integration/component/test_escalations_instances.py
@@ -3652,7 +3652,6 @@ class TestInstances(cloudstackTestCase):
security_group,
"Security Group creation failed"
)
- self.cleanup.append(security_group)
security_groups_list_size = security_groups_list_size + 1
# Listing the networks again
[08/10] git commit: updated refs/heads/master to 22d6565
Posted by ta...@apache.org.
CLOUDSTACK-8135: Fixed cleanup issue in test_escalations_instances.py
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1ee41888
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1ee41888
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1ee41888
Branch: refs/heads/master
Commit: 1ee41888353d87f4972e6ccb492817133805a88e
Parents: f938a5e
Author: Ashutosh K <as...@clogeny.com>
Authored: Tue Dec 30 12:55:06 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Mon Jan 5 18:31:52 2015 +0530
----------------------------------------------------------------------
test/integration/component/test_escalations_instances.py | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1ee41888/test/integration/component/test_escalations_instances.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_escalations_instances.py b/test/integration/component/test_escalations_instances.py
index 1e5ec53..b089ed5 100644
--- a/test/integration/component/test_escalations_instances.py
+++ b/test/integration/component/test_escalations_instances.py
@@ -2238,7 +2238,6 @@ class TestInstances(cloudstackTestCase):
vm_created,
"VM creation failed"
)
- self.cleanup.append(vm_created)
# Listing all the VMs for a user again for matching zone
list_vms_after = VirtualMachine.list(
self.userapiclient,