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": "administra...@clogeny.com", - "firstname": "Test", - "lastname": "User", - "username": "test", - # Random characters are appended for unique - # username - "password": "password", - }, - "user": { - "email": "u...@clogeny.com", - "firstname": "User", - "lastname": "User", - "username": "User", - # Random characters are appended for unique - # username - "password": "password", - }, - "other_user": { - "email": "otheru...@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": "administra...@clogeny.com", + "firstname": "Test", + "lastname": "User", + "username": "test", + # Random characters are appended for unique + # username + "password": "password", + }, + "user": { + "email": "u...@clogeny.com", + "firstname": "User", + "lastname": "User", + "username": "User", + # Random characters are appended for unique + # username + "password": "password", + }, + "other_user": { + "email": "otheru...@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>