mirror of https://github.com/apache/cloudstack.git
Refactored the code to fetch domainid from API calls.
Changed env. setup code in test accounts.
This commit is contained in:
parent
3579c47173
commit
99af149db7
|
|
@ -40,7 +40,7 @@ class Services:
|
|||
"isextractable": True,
|
||||
"isfeatured": True,
|
||||
"ispublic": True,
|
||||
"ostypeid": '5a5b5f64-de08-452d-9672-608a4946f754',
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
},
|
||||
"iso_2":
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ class Services:
|
|||
"isextractable": True,
|
||||
"isfeatured": True,
|
||||
"ispublic": True,
|
||||
"ostypeid": '5a5b5f64-de08-452d-9672-608a4946f754',
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
"mode": 'HTTP_DOWNLOAD',
|
||||
# Used in Extract template, value must be HTTP_DOWNLOAD
|
||||
},
|
||||
|
|
@ -64,12 +64,8 @@ class Services:
|
|||
"passwordenabled": True,
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
"ostypeid": '5a5b5f64-de08-452d-9672-608a4946f754',
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
# CentOS 5.3 (64 bit)
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
"zoneid": '4a6c0290-e64d-40fc-afbb-4a05cab6fa4b',
|
||||
# Optional, if specified the mentioned zone will be
|
||||
# used for tests
|
||||
"mode": 'advanced'
|
||||
# Networking mode: Basic or Advanced
|
||||
}
|
||||
|
|
@ -82,12 +78,15 @@ class TestCreateIso(cloudstackTestCase):
|
|||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
# Get Zone, Domain and templates
|
||||
self.domain = get_domain(self.apiclient, self.services)
|
||||
self.zone = get_zone(self.apiclient, self.services)
|
||||
self.services["domainid"] = self.domain.id
|
||||
self.services["iso_2"]["zoneid"] = self.zone.id
|
||||
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"]
|
||||
self.services["account"],
|
||||
domainid=self.domain.id
|
||||
)
|
||||
|
||||
self.cleanup = [self.account]
|
||||
|
|
@ -172,7 +171,10 @@ class TestISO(cloudstackTestCase):
|
|||
cls.api_client = fetch_api_client()
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
|
||||
cls.services["domainid"] = cls.domain.id
|
||||
cls.services["iso_1"]["zoneid"] = cls.zone.id
|
||||
cls.services["iso_2"]["zoneid"] = cls.zone.id
|
||||
cls.services["sourcezoneid"] = cls.zone.id
|
||||
|
|
@ -181,6 +183,7 @@ class TestISO(cloudstackTestCase):
|
|||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls.services["account"] = cls.account.account.name
|
||||
cls.iso_1 = Iso.create(
|
||||
|
|
@ -259,7 +262,6 @@ class TestISO(cloudstackTestCase):
|
|||
cmd.name = new_name
|
||||
cmd.bootable = self.services["bootable"]
|
||||
cmd.passwordenabled = self.services["passwordenabled"]
|
||||
cmd.ostypeid = self.services["ostypeid"]
|
||||
|
||||
self.apiclient.updateIso(cmd)
|
||||
|
||||
|
|
@ -485,4 +487,4 @@ class TestISO(cloudstackTestCase):
|
|||
cmd.id = iso_response.id
|
||||
cmd.zoneid = self.services["destzoneid"]
|
||||
self.apiclient.deleteIso(cmd)
|
||||
return
|
||||
return
|
||||
|
|
|
|||
|
|
@ -22,11 +22,8 @@ class Services:
|
|||
|
||||
def __init__(self):
|
||||
self.services = {
|
||||
"ostypeid": '0c2c5d19-525b-41be-a8c3-c6607412f82b',
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
# Cent OS 5.3 (64 bit)
|
||||
"zoneid": '4a6c0290-e64d-40fc-afbb-4a05cab6fa4b',
|
||||
# Optional, if specified the mentioned zone will be
|
||||
# used for tests
|
||||
"mode": 'advanced',
|
||||
# Networking mode: Basic or advanced
|
||||
"lb_switch_wait": 10,
|
||||
|
|
@ -36,7 +33,7 @@ class Services:
|
|||
"network": {
|
||||
"name": "Test Network",
|
||||
"displaytext": "Test Network",
|
||||
"networkoffering": '4c6dea7e-7aa8-4b17-bf1c-26c312586e7c',
|
||||
"networkoffering": '3d4e36f1-6b5f-40fc-bb63-fe9353419e91',
|
||||
},
|
||||
"service_offering": {
|
||||
"name": "Tiny Instance",
|
||||
|
|
@ -60,7 +57,6 @@ class Services:
|
|||
"username": "root",
|
||||
"password": "password",
|
||||
"hypervisor": 'XenServer',
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"ssh_port": 22,
|
||||
|
|
@ -94,18 +90,21 @@ class TestPublicIP(cloudstackTestCase):
|
|||
cls.api_client = fetch_api_client()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
|
||||
# Create Accounts & networks
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
admin=True
|
||||
admin=True,
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
cls.user = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls.services["network"]["zoneid"] = cls.zone.id
|
||||
cls.account_network = Network.create(
|
||||
|
|
@ -261,6 +260,7 @@ class TestPortForwarding(cloudstackTestCase):
|
|||
cls.services = Services().services
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
template = get_template(
|
||||
cls.api_client,
|
||||
|
|
@ -271,7 +271,8 @@ class TestPortForwarding(cloudstackTestCase):
|
|||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
admin=True
|
||||
admin=True,
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls.services["server"]["zoneid"] = cls.zone.id
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
|
|
@ -283,6 +284,7 @@ class TestPortForwarding(cloudstackTestCase):
|
|||
cls.services["server"],
|
||||
templateid=template.id,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id
|
||||
)
|
||||
cls._cleanup = [
|
||||
|
|
@ -537,6 +539,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
|
|||
cls.api_client = fetch_api_client()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
template = get_template(
|
||||
cls.api_client,
|
||||
|
|
@ -549,7 +552,8 @@ class TestLoadBalancingRule(cloudstackTestCase):
|
|||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
admin=True
|
||||
admin=True,
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
|
|
@ -560,6 +564,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
|
|||
cls.services["server"],
|
||||
templateid=template.id,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id
|
||||
)
|
||||
cls.vm_2 = VirtualMachine.create(
|
||||
|
|
@ -567,6 +572,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
|
|||
cls.services["server"],
|
||||
templateid=template.id,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id
|
||||
)
|
||||
cls.non_src_nat_ip = PublicIPAddress.create(
|
||||
|
|
@ -689,7 +695,12 @@ class TestLoadBalancingRule(cloudstackTestCase):
|
|||
0,
|
||||
"Check Load Balancer instances Rule in its List"
|
||||
)
|
||||
|
||||
self.debug("lb_instance_rules Ids: %s, %s" % (
|
||||
lb_instance_rules[0].id,
|
||||
lb_instance_rules[1].id
|
||||
))
|
||||
self.debug("VM ids: %s, %s" % (self.vm_1.id, self.vm_2.id))
|
||||
|
||||
self.assertIn(
|
||||
lb_instance_rules[0].id,
|
||||
[self.vm_1.id, self.vm_2.id],
|
||||
|
|
@ -744,6 +755,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
|
|||
self.fail("%s: SSH failed for VM with IP Address: %s" %
|
||||
(e, src_nat_ip_addr.ipaddress))
|
||||
|
||||
self.debug("Hostnames: %s" % str(hostnames))
|
||||
self.assertIn(
|
||||
self.vm_1.name,
|
||||
hostnames,
|
||||
|
|
@ -795,7 +807,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
|
|||
)
|
||||
ssh_1.execute("hostname")[0]
|
||||
return
|
||||
|
||||
|
||||
def test_02_create_lb_rule_non_nat(self):
|
||||
"""Test to create Load balancing rule with source NAT"""
|
||||
|
||||
|
|
@ -924,7 +936,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
|
|||
)
|
||||
|
||||
hostnames.append(ssh_2.execute("hostname")[0])
|
||||
|
||||
self.debug("Hostnames after adding 2 VMs to LB rule: %s" % str(hostnames))
|
||||
self.assertIn(
|
||||
self.vm_1.name,
|
||||
hostnames,
|
||||
|
|
@ -952,7 +964,7 @@ class TestLoadBalancingRule(cloudstackTestCase):
|
|||
)
|
||||
|
||||
hostnames.append(ssh_1.execute("hostname")[0])
|
||||
|
||||
self.debug("Hostnames after removing VM2: %s" % str(hostnames))
|
||||
except Exception as e:
|
||||
self.fail("%s: SSH failed for VM with IP Address: %s" %
|
||||
(e, self.non_src_nat_ip.ipaddress.ipaddress))
|
||||
|
|
@ -988,6 +1000,7 @@ class TestRebootRouter(cloudstackTestCase):
|
|||
self.services = Services().services
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
self.domain = get_domain(self.apiclient, self.services)
|
||||
self.zone = get_zone(self.apiclient, self.services)
|
||||
template = get_template(
|
||||
self.apiclient,
|
||||
|
|
@ -1000,7 +1013,8 @@ class TestRebootRouter(cloudstackTestCase):
|
|||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
admin=True
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
self.service_offering = ServiceOffering.create(
|
||||
self.apiclient,
|
||||
|
|
@ -1011,6 +1025,7 @@ class TestRebootRouter(cloudstackTestCase):
|
|||
self.services["server"],
|
||||
templateid=template.id,
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
|
||||
|
|
@ -1135,6 +1150,7 @@ class TestAssignRemoveLB(cloudstackTestCase):
|
|||
self.apiclient = self.testClient.getApiClient()
|
||||
self.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
self.domain = get_domain(self.apiclient, self.services)
|
||||
self.zone = get_zone(self.apiclient, self.services)
|
||||
template = get_template(
|
||||
self.apiclient,
|
||||
|
|
@ -1147,7 +1163,8 @@ class TestAssignRemoveLB(cloudstackTestCase):
|
|||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
admin=True
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
self.service_offering = ServiceOffering.create(
|
||||
self.apiclient,
|
||||
|
|
@ -1159,6 +1176,7 @@ class TestAssignRemoveLB(cloudstackTestCase):
|
|||
self.services["server"],
|
||||
templateid=template.id,
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
|
||||
|
|
@ -1167,6 +1185,7 @@ class TestAssignRemoveLB(cloudstackTestCase):
|
|||
self.services["server"],
|
||||
templateid=template.id,
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
|
||||
|
|
@ -1175,6 +1194,7 @@ class TestAssignRemoveLB(cloudstackTestCase):
|
|||
self.services["server"],
|
||||
templateid=template.id,
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
|
||||
|
|
@ -1378,6 +1398,7 @@ class TestReleaseIP(cloudstackTestCase):
|
|||
self.services = Services().services
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
self.domain = get_domain(self.apiclient, self.services)
|
||||
self.zone = get_zone(self.apiclient, self.services)
|
||||
template = get_template(
|
||||
self.apiclient,
|
||||
|
|
@ -1390,7 +1411,8 @@ class TestReleaseIP(cloudstackTestCase):
|
|||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
admin=True
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
|
||||
self.service_offering = ServiceOffering.create(
|
||||
|
|
@ -1403,6 +1425,7 @@ class TestReleaseIP(cloudstackTestCase):
|
|||
self.services["server"],
|
||||
templateid=template.id,
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
|
||||
|
|
@ -1514,6 +1537,7 @@ class TestDeleteAccount(cloudstackTestCase):
|
|||
self.services = Services().services
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
self.domain = get_domain(self.apiclient, self.services)
|
||||
self.zone = get_zone(self.apiclient, self.services)
|
||||
template = get_template(
|
||||
self.apiclient,
|
||||
|
|
@ -1526,7 +1550,8 @@ class TestDeleteAccount(cloudstackTestCase):
|
|||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
admin=True
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
self.service_offering = ServiceOffering.create(
|
||||
self.apiclient,
|
||||
|
|
@ -1537,6 +1562,7 @@ class TestDeleteAccount(cloudstackTestCase):
|
|||
self.services["server"],
|
||||
templateid=template.id,
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
|
||||
|
|
@ -1651,4 +1677,4 @@ class TestDeleteAccount(cloudstackTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
return
|
||||
return
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class Services:
|
|||
"password": "fr3sca",
|
||||
"ssh_port": 22,
|
||||
"hypervisor": 'XenServer',
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
|
|
@ -48,12 +47,9 @@ class Services:
|
|||
"username": "testuser",
|
||||
"password": "fr3sca",
|
||||
},
|
||||
"ostypeid":'0c2c5d19-525b-41be-a8c3-c6607412f82b',
|
||||
"ostypeid":'144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
"zoneid": '4a6c0290-e64d-40fc-afbb-4a05cab6fa4b',
|
||||
# Optional, if specified the mentioned zone will be
|
||||
# used for tests
|
||||
"mode": 'advanced', #Networking mode: Basic, Advanced
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +62,7 @@ class TestRouterServices(cloudstackTestCase):
|
|||
cls.api_client = fetch_api_client()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
template = get_template(
|
||||
cls.api_client,
|
||||
|
|
@ -77,7 +74,8 @@ class TestRouterServices(cloudstackTestCase):
|
|||
#Create an account, network, VM and IP addresses
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"]
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
|
|
@ -88,6 +86,7 @@ class TestRouterServices(cloudstackTestCase):
|
|||
cls.services["virtual_machine"],
|
||||
templateid=template.id,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id
|
||||
)
|
||||
cls.cleanup = [
|
||||
|
|
@ -754,7 +753,7 @@ class TestRouterServices(cloudstackTestCase):
|
|||
)
|
||||
response = config[0]
|
||||
|
||||
# Wait for network.gc.interval * 3 time
|
||||
# Wait for network.gc.interval * 3 time to cleanup all the resources
|
||||
time.sleep(int(response.value) * 3)
|
||||
|
||||
timeout = self.services["timeout"]
|
||||
|
|
|
|||
|
|
@ -40,10 +40,6 @@ class Services:
|
|||
},
|
||||
"sleep": 60,
|
||||
"timeout": 5,
|
||||
"zoneid": '4a6c0290-e64d-40fc-afbb-4a05cab6fa4b',
|
||||
# Optional, if specified the mentioned zone will be
|
||||
# used for tests
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
}
|
||||
|
||||
class TestSecStorageServices(cloudstackTestCase):
|
||||
|
|
@ -70,6 +66,7 @@ class TestSecStorageServices(cloudstackTestCase):
|
|||
self.cleanup = []
|
||||
self.services = Services().services
|
||||
# Get Zone and pod
|
||||
self.domain = get_domain(self.apiclient, self.services)
|
||||
self.zone = get_zone(self.apiclient, self.services)
|
||||
self.pod = get_pod(self.apiclient, self.zone.id)
|
||||
return
|
||||
|
|
@ -286,7 +283,7 @@ class TestSecStorageServices(cloudstackTestCase):
|
|||
templatefilter=v["templatefilter"],
|
||||
listall=True,
|
||||
account='system',
|
||||
domainid=self.services["domainid"]
|
||||
domainid=self.domain.id
|
||||
)
|
||||
|
||||
# Ensure all BUILTIN templates are downloaded
|
||||
|
|
@ -309,7 +306,7 @@ class TestSecStorageServices(cloudstackTestCase):
|
|||
templatefilter=v["templatefilter"],
|
||||
listall=True,
|
||||
account='system',
|
||||
domainid=self.services["domainid"]
|
||||
domainid=self.domain.id
|
||||
)
|
||||
|
||||
if isinstance(template_response, list):
|
||||
|
|
@ -345,7 +342,7 @@ class TestSecStorageServices(cloudstackTestCase):
|
|||
templatefilter=v["templatefilter"],
|
||||
listall=True,
|
||||
account='system',
|
||||
domainid=self.services["domainid"]
|
||||
domainid=self.domain.id
|
||||
)
|
||||
|
||||
if isinstance(template_response, list):
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ class Services:
|
|||
"password": "password",
|
||||
"ssh_port": 22,
|
||||
"hypervisor": 'XenServer',
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
|
|
@ -60,7 +59,6 @@ class Services:
|
|||
"password": "password",
|
||||
"ssh_port": 22,
|
||||
"hypervisor": 'XenServer',
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
"privateport": 22,
|
||||
# For NAT rule creation
|
||||
"publicport": 22,
|
||||
|
|
@ -81,17 +79,16 @@ class Services:
|
|||
{
|
||||
"displaytext": 'Template from snapshot',
|
||||
"name": 'Template from snapshot',
|
||||
"ostypeid": '0c2c5d19-525b-41be-a8c3-c6607412f82b',
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
"templatefilter": 'self',
|
||||
},
|
||||
"ostypeid": '0c2c5d19-525b-41be-a8c3-c6607412f82b',
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
# Cent OS 5.3 (64 bit)
|
||||
"diskdevice": "/dev/xvdb", # Data Disk
|
||||
"rootdisk": "/dev/xvda", # Root Disk
|
||||
|
||||
"diskname": "Test Disk",
|
||||
"size": 1, # GBs
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
|
||||
"mount_dir": "/mnt/tmp",
|
||||
"sub_dir": "test",
|
||||
|
|
@ -102,9 +99,6 @@ class Services:
|
|||
"username": "root",
|
||||
"password": "password",
|
||||
"ssh_port": 22,
|
||||
"zoneid": '4a6c0290-e64d-40fc-afbb-4a05cab6fa4b',
|
||||
# Optional, if specified the mentioned zone will be
|
||||
# used for tests
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
"mode": 'advanced',
|
||||
|
|
@ -119,6 +113,7 @@ class TestSnapshotRootDisk(cloudstackTestCase):
|
|||
cls.api_client = fetch_api_client()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
|
||||
template = get_template(
|
||||
|
|
@ -126,6 +121,7 @@ class TestSnapshotRootDisk(cloudstackTestCase):
|
|||
cls.zone.id,
|
||||
cls.services["ostypeid"]
|
||||
)
|
||||
cls.services["domainid"] = cls.domain.id
|
||||
cls.services["server_without_disk"]["zoneid"] = cls.zone.id
|
||||
cls.services["template"] = template.id
|
||||
cls.services["zoneid"] = cls.zone.id
|
||||
|
|
@ -133,7 +129,8 @@ class TestSnapshotRootDisk(cloudstackTestCase):
|
|||
# Create VMs, NAT Rules etc
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"]
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
cls.services["account"] = cls.account.account.name
|
||||
|
|
@ -148,6 +145,7 @@ class TestSnapshotRootDisk(cloudstackTestCase):
|
|||
cls.services["server_without_disk"],
|
||||
templateid=template.id,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
|
@ -329,6 +327,7 @@ class TestSnapshots(cloudstackTestCase):
|
|||
cls.api_client = fetch_api_client()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.disk_offering = DiskOffering.create(
|
||||
cls.api_client,
|
||||
|
|
@ -339,6 +338,8 @@ class TestSnapshots(cloudstackTestCase):
|
|||
cls.zone.id,
|
||||
cls.services["ostypeid"]
|
||||
)
|
||||
|
||||
cls.services["domainid"] = cls.domain.id
|
||||
cls.services["server_with_disk"]["zoneid"] = cls.zone.id
|
||||
cls.services["server_with_disk"]["diskoffering"] = cls.disk_offering.id
|
||||
|
||||
|
|
@ -351,7 +352,8 @@ class TestSnapshots(cloudstackTestCase):
|
|||
# Create VMs, NAT Rules etc
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"]
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
cls.services["account"] = cls.account.account.name
|
||||
|
|
@ -366,6 +368,7 @@ class TestSnapshots(cloudstackTestCase):
|
|||
cls.services["server_with_disk"],
|
||||
templateid=template.id,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
|
@ -375,6 +378,7 @@ class TestSnapshots(cloudstackTestCase):
|
|||
cls.services["server_without_disk"],
|
||||
templateid=template.id,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
|
@ -519,7 +523,7 @@ class TestSnapshots(cloudstackTestCase):
|
|||
self.debug(c)
|
||||
result = ssh_client.execute(c)
|
||||
self.debug(result)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
self.fail("SSH failed for VM with IP: %s" %
|
||||
self.virtual_machine_with_disk.ipaddress)
|
||||
|
|
@ -1062,6 +1066,7 @@ class TestSnapshots(cloudstackTestCase):
|
|||
self.services["server_without_disk"],
|
||||
templateid=template.id,
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
mode=self.services["mode"]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@ class Services:
|
|||
"password": 'fr3sca',
|
||||
"publicport": 22,
|
||||
},
|
||||
"zoneid": '4a6c0290-e64d-40fc-afbb-4a05cab6fa4b',
|
||||
# Optional, if specified the mentioned zone will be
|
||||
# used for tests
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ class Services:
|
|||
"virtual_machine": {
|
||||
"displayname": "testVM",
|
||||
"hypervisor": 'XenServer',
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
"protocol": 'TCP',
|
||||
"ssh_port": 22,
|
||||
"username": "root",
|
||||
|
|
@ -60,12 +59,12 @@ class Services:
|
|||
"template_1": {
|
||||
"displaytext": "Cent OS Template",
|
||||
"name": "Cent OS Template",
|
||||
"ostypeid": '0c2c5d19-525b-41be-a8c3-c6607412f82b',
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
},
|
||||
"template_2": {
|
||||
"displaytext": "Public Template",
|
||||
"name": "Public template",
|
||||
"ostypeid": '0c2c5d19-525b-41be-a8c3-c6607412f82b',
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
"isfeatured": True,
|
||||
"ispublic": True,
|
||||
"isextractable": True,
|
||||
|
|
@ -79,10 +78,7 @@ class Services:
|
|||
"isextractable": False,
|
||||
"bootable": True,
|
||||
"passwordenabled": True,
|
||||
"ostypeid": '0c2c5d19-525b-41be-a8c3-c6607412f82b',
|
||||
"zoneid": '4a6c0290-e64d-40fc-afbb-4a05cab6fa4b',
|
||||
# Optional, if specified the mentioned zone will be
|
||||
# used for tests
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
"mode": 'advanced',
|
||||
# Networking mode: Advanced, basic
|
||||
"sleep": 30,
|
||||
|
|
@ -115,6 +111,7 @@ class TestCreateTemplate(cloudstackTestCase):
|
|||
cls.api_client = fetch_api_client()
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.disk_offering = DiskOffering.create(
|
||||
cls.api_client,
|
||||
|
|
@ -132,7 +129,8 @@ class TestCreateTemplate(cloudstackTestCase):
|
|||
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"]
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls.services["account"] = cls.account.account.name
|
||||
|
||||
|
|
@ -146,6 +144,7 @@ class TestCreateTemplate(cloudstackTestCase):
|
|||
cls.services["virtual_machine"],
|
||||
templateid=template.id,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
|
@ -274,6 +273,7 @@ class TestTemplates(cloudstackTestCase):
|
|||
cls.api_client = fetch_api_client()
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.disk_offering = DiskOffering.create(
|
||||
cls.api_client,
|
||||
|
|
@ -292,12 +292,15 @@ class TestTemplates(cloudstackTestCase):
|
|||
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"]
|
||||
cls.services["account"],
|
||||
admin=True,
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
cls.user = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"]
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
cls.services["account"] = cls.account.account.name
|
||||
|
|
@ -312,6 +315,7 @@ class TestTemplates(cloudstackTestCase):
|
|||
cls.services["virtual_machine"],
|
||||
templateid=template.id,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
|
@ -426,7 +430,6 @@ class TestTemplates(cloudstackTestCase):
|
|||
cmd.name = new_name
|
||||
cmd.bootable = self.services["bootable"]
|
||||
cmd.passwordenabled = self.services["passwordenabled"]
|
||||
cmd.ostypeid = self.services["ostypeid"]
|
||||
|
||||
self.apiclient.updateTemplate(cmd)
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ class Services:
|
|||
"password": "password",
|
||||
"ssh_port": 22,
|
||||
"hypervisor": 'XenServer',
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
|
|
@ -55,7 +54,6 @@ class Services:
|
|||
"password": "password",
|
||||
"ssh_port": 22,
|
||||
"hypervisor": 'XenServer',
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
|
|
@ -97,7 +95,7 @@ class Services:
|
|||
"name": "testISO",
|
||||
"url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso",
|
||||
# Source URL where ISO is located
|
||||
"ostypeid": '0c2c5d19-525b-41be-a8c3-c6607412f82b',
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
"mode": 'HTTP_DOWNLOAD', # Downloading existing ISO
|
||||
},
|
||||
"diskdevice": '/dev/xvdd',
|
||||
|
|
@ -107,11 +105,8 @@ class Services:
|
|||
"timeout": 10,
|
||||
"hostid": 5,
|
||||
#Migrate VM to hostid
|
||||
"ostypeid": '0c2c5d19-525b-41be-a8c3-c6607412f82b',
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
# CentOS 5.3 (64-bit)
|
||||
"zoneid": '4a6c0290-e64d-40fc-afbb-4a05cab6fa4b',
|
||||
# Optional, if specified the mentioned zone will be
|
||||
# used for tests
|
||||
"mode":'advanced',
|
||||
# Networking mode: Basic or Advanced
|
||||
}
|
||||
|
|
@ -125,6 +120,7 @@ class TestDeployVM(cloudstackTestCase):
|
|||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
domain = get_domain(self.apiclient, self.services)
|
||||
zone = get_zone(self.apiclient, self.services)
|
||||
|
||||
template = get_template(
|
||||
|
|
@ -143,7 +139,8 @@ class TestDeployVM(cloudstackTestCase):
|
|||
# Create Account, VMs, NAT Rules etc
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"]
|
||||
self.services["account"],
|
||||
domainid=domain.id
|
||||
)
|
||||
|
||||
self.service_offering = ServiceOffering.create(
|
||||
|
|
@ -169,6 +166,7 @@ class TestDeployVM(cloudstackTestCase):
|
|||
self.apiclient,
|
||||
self.services["small"],
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
|
||||
|
|
@ -224,6 +222,7 @@ class TestVMLifeCycle(cloudstackTestCase):
|
|||
cls.services = Services().services
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
domain = get_domain(cls.api_client, cls.services)
|
||||
zone = get_zone(cls.api_client, cls.services)
|
||||
template = get_template(
|
||||
cls.api_client,
|
||||
|
|
@ -241,7 +240,8 @@ class TestVMLifeCycle(cloudstackTestCase):
|
|||
# Create VMs, NAT Rules etc
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"]
|
||||
cls.services["account"],
|
||||
domainid=domain.id
|
||||
)
|
||||
|
||||
cls.small_offering = ServiceOffering.create(
|
||||
|
|
@ -258,6 +258,7 @@ class TestVMLifeCycle(cloudstackTestCase):
|
|||
cls.api_client,
|
||||
cls.services["small"],
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.small_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
|
@ -265,6 +266,7 @@ class TestVMLifeCycle(cloudstackTestCase):
|
|||
cls.api_client,
|
||||
cls.services["medium"],
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.medium_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
|
@ -272,6 +274,7 @@ class TestVMLifeCycle(cloudstackTestCase):
|
|||
cls.api_client,
|
||||
cls.services["small"],
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.small_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
|
@ -322,7 +325,7 @@ class TestVMLifeCycle(cloudstackTestCase):
|
|||
self.assertNotEqual(
|
||||
len(list_vm_response),
|
||||
0,
|
||||
"Check VM avaliable in List Virtual Machines"
|
||||
"Check VM available in List Virtual Machines"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ class Services:
|
|||
"volume_offerings": {
|
||||
0: {
|
||||
"diskname": "TestDiskServ",
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
},
|
||||
},
|
||||
"customdisksize": 1, # GBs
|
||||
|
|
@ -57,15 +56,11 @@ class Services:
|
|||
"ssh_port": 22,
|
||||
"diskname": "TestDiskServ",
|
||||
"hypervisor": 'XenServer',
|
||||
"domainid": '9ee36d2e-8b8f-432e-a927-a678ebec1d6b',
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
"diskdevice": "/dev/xvdb",
|
||||
"ostypeid": '0c2c5d19-525b-41be-a8c3-c6607412f82b',
|
||||
"zoneid": '4a6c0290-e64d-40fc-afbb-4a05cab6fa4b',
|
||||
# Optional, if specified the mentioned zone will be
|
||||
# used for tests
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
"mode": 'advanced',
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
|
|
@ -80,6 +75,7 @@ class TestCreateVolume(cloudstackTestCase):
|
|||
cls.services = Services().services
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.disk_offering = DiskOffering.create(
|
||||
cls.api_client,
|
||||
|
|
@ -95,6 +91,7 @@ class TestCreateVolume(cloudstackTestCase):
|
|||
cls.zone.id,
|
||||
cls.services["ostypeid"]
|
||||
)
|
||||
cls.services["domainid"] = cls.domain.id
|
||||
cls.services["zoneid"] = cls.zone.id
|
||||
cls.services["template"] = template.id
|
||||
cls.services["customdiskofferingid"] = cls.custom_disk_offering.id
|
||||
|
|
@ -102,7 +99,8 @@ class TestCreateVolume(cloudstackTestCase):
|
|||
# Create VMs, NAT Rules etc
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"]
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
cls.services["account"] = cls.account.account.name
|
||||
|
|
@ -114,6 +112,7 @@ class TestCreateVolume(cloudstackTestCase):
|
|||
cls.api_client,
|
||||
cls.services,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
|
@ -263,6 +262,7 @@ class TestVolumes(cloudstackTestCase):
|
|||
cls.api_client = fetch_api_client()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.disk_offering = DiskOffering.create(
|
||||
cls.api_client,
|
||||
|
|
@ -273,6 +273,7 @@ class TestVolumes(cloudstackTestCase):
|
|||
cls.zone.id,
|
||||
cls.services["ostypeid"]
|
||||
)
|
||||
cls.services["domainid"] = cls.domain.id
|
||||
cls.services["zoneid"] = cls.zone.id
|
||||
cls.services["template"] = template.id
|
||||
cls.services["diskofferingid"] = cls.disk_offering.id
|
||||
|
|
@ -280,7 +281,8 @@ class TestVolumes(cloudstackTestCase):
|
|||
# Create VMs, VMs etc
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"]
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
cls.services["account"] = cls.account.account.name
|
||||
|
|
@ -292,6 +294,7 @@ class TestVolumes(cloudstackTestCase):
|
|||
cls.api_client,
|
||||
cls.services,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
|
|
@ -502,4 +505,4 @@ class TestVolumes(cloudstackTestCase):
|
|||
None,
|
||||
"Check if volume exists in ListVolumes"
|
||||
)
|
||||
return
|
||||
return
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
P1 Cases
|
||||
--------------------------------------
|
||||
These test cases are the core functionality tests that ensure the application is stable and can be tested thoroughly.
|
||||
These P1 cases definitions are located at : https://docs.google.com/a/clogeny.com/spreadsheet/ccc?key=0Aq5M2ldK6eyedDJBa0EzM0RPNmdVNVZOWnFnOVJJcHc&hl=en_US
|
||||
|
||||
|
||||
Guidelines
|
||||
----------
|
||||
P1 test cases are being developed using Python's unittests2. Following are certain guidelines being followed
|
||||
1. Tests exercised for the same resource should ideally be present under a single suite or file.
|
||||
|
||||
2. Time-consuming operations that create new cloud resources like server creation, volume creation etc
|
||||
should not necessarily be exercised per unit test. The resources can be shared by creating them at
|
||||
the class-level using setUpClass and shared across all instances during a single run.
|
||||
|
||||
3. Certain tests pertaining to NAT, Firewall and Load Balancing warrant fresh resources per test. Hence a call should be
|
||||
taken by the stakeholders regarding sharing resources.
|
||||
|
||||
4. Ensure that the tearDown/tearDownClass functions clean up all the resources created during the test run.
|
||||
|
||||
For more information about unittests: http://docs.python.org/library/unittest.html
|
||||
|
||||
|
||||
P1 Tests
|
||||
----------
|
||||
The following files contain these P1 cases:
|
||||
|
||||
1. test_snapshots.py - Snapshots related tests
|
||||
2. test_routers.py - Router related tests
|
||||
3. test_usage.py - Usage realted tests
|
||||
4. test_account.py - Account related tests
|
||||
5. test_resource_limits.py - Resource limits tests
|
||||
6. test_security_groups.py - Security groups related tests
|
||||
7. test_templates - templates related tests
|
||||
8. test_volumes - Volumes related tests
|
||||
9. test_blocker_bugs - Blocker bugs tests
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,602 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2012 Citrix. All rights reserved.
|
||||
#
|
||||
""" P1 tests for Templates
|
||||
"""
|
||||
#Import Local Modules
|
||||
from cloudstackTestCase import *
|
||||
from cloudstackAPI import *
|
||||
from testcase.libs.utils import *
|
||||
from testcase.libs.base import *
|
||||
from testcase.libs.common import *
|
||||
import urllib
|
||||
from random import random
|
||||
#Import System modules
|
||||
import time
|
||||
|
||||
|
||||
class Services:
|
||||
"""Test Templates 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": "fr3sca",
|
||||
},
|
||||
"service_offering": {
|
||||
"name": "Tiny Instance",
|
||||
"displaytext": "Tiny Instance",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100, # in MHz
|
||||
"memory": 64, # In MBs
|
||||
},
|
||||
"disk_offering": {
|
||||
"displaytext": "Small",
|
||||
"name": "Small",
|
||||
"disksize": 1
|
||||
},
|
||||
"virtual_machine": {
|
||||
"displayname": "testVM",
|
||||
"hypervisor": 'XenServer',
|
||||
"protocol": 'TCP',
|
||||
"ssh_port": 22,
|
||||
"username": "root",
|
||||
"password": "password",
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
},
|
||||
"volume": {
|
||||
"diskname": "Test Volume",
|
||||
},
|
||||
"templates": {
|
||||
# Configs for different Template formats
|
||||
# For Eg. raw image, zip etc
|
||||
0:{
|
||||
"displaytext": "Public Template",
|
||||
"name": "Public template",
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
"url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2",
|
||||
"hypervisor": 'XenServer',
|
||||
"format" : 'VHD',
|
||||
"isfeatured": True,
|
||||
"ispublic": True,
|
||||
"isextractable": True,
|
||||
},
|
||||
},
|
||||
"template": {
|
||||
"displaytext": "Cent OS Template",
|
||||
"name": "Cent OS Template",
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
"templatefilter": 'self',
|
||||
},
|
||||
"templatefilter": 'self',
|
||||
"destzoneid": 2, # For Copy template (Destination zone)
|
||||
"ostypeid": '144f66aa-7f74-4cfe-9799-80cc21439cb3',
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
"mode": 'advanced', # Networking mode: Advanced, basic
|
||||
}
|
||||
|
||||
|
||||
@unittest.skip("Open questions")
|
||||
class TestCreateTemplate(cloudstackTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.cleanup = []
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
self.dbclient.close()
|
||||
#Clean up, terminate the created templates
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.services = Services().services
|
||||
cls.api_client = fetch_api_client()
|
||||
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
)
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls.services["account"] = cls.account.account.name
|
||||
|
||||
cls._cleanup = [
|
||||
cls.account,
|
||||
cls.service_offering
|
||||
]
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
cls.api_client = fetch_api_client()
|
||||
#Cleanup resources used
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
|
||||
return
|
||||
|
||||
def test_01_create_template(self):
|
||||
"""Test create public & private template
|
||||
"""
|
||||
|
||||
# Validate the following:
|
||||
# 1. Upload a templates in raw img format. Create a Vm instances from
|
||||
# raw img template.
|
||||
# 2. Upload a templates in zip file format. Create a Vm instances from
|
||||
# zip template.
|
||||
# 3. Upload a templates in tar format.Create a Vm instances from tar
|
||||
# template.
|
||||
# 4. Upload a templates in tar gzip format.Create a Vm instances from
|
||||
# tar gzip template.
|
||||
# 5. Upload a templates in tar bzip format. Create a Vm instances from
|
||||
# tar bzip template.
|
||||
# 6. Verify VMs & Templates is up and in ready state
|
||||
|
||||
for k, v in self.services["templates"].items():
|
||||
|
||||
# Register new template
|
||||
template = Template.register(
|
||||
self.apiclient,
|
||||
v,
|
||||
zoneid=self.zone.id,
|
||||
account=self.account.account.name,
|
||||
domainid=self.account.account.domainid
|
||||
)
|
||||
self.debug(
|
||||
"Registered a template of format: %s with ID: %s" % (
|
||||
v["format"],
|
||||
template.id
|
||||
))
|
||||
# Wait for template to download
|
||||
template.download(self.apiclient)
|
||||
self.cleanup.append(template)
|
||||
|
||||
# Wait for template status to be changed across
|
||||
time.sleep(self.services["sleep"])
|
||||
timeout = self.services["timeout"]
|
||||
while True:
|
||||
list_template_response = list_templates(
|
||||
self.apiclient,
|
||||
templatefilter=\
|
||||
self.services["templatefilter"],
|
||||
id=template.id,
|
||||
zoneid=self.zone.id,
|
||||
account=self.account.account.name,
|
||||
domainid=self.account.account.domainid
|
||||
)
|
||||
if isinstance(list_template_response, list):
|
||||
break
|
||||
elif timeout == 0:
|
||||
raise Exception("List template failed!")
|
||||
|
||||
time.sleep(5)
|
||||
timeout = timeout - 1
|
||||
#Verify template response to check whether template added successfully
|
||||
self.assertEqual(
|
||||
isinstance(list_template_response, list),
|
||||
True,
|
||||
"Check for list template response return valid data"
|
||||
)
|
||||
|
||||
self.assertNotEqual(
|
||||
len(list_template_response),
|
||||
0,
|
||||
"Check template available in List Templates"
|
||||
)
|
||||
|
||||
template_response = list_template_response[0]
|
||||
self.assertEqual(
|
||||
template_response.isready,
|
||||
True,
|
||||
"Check display text of newly created template"
|
||||
)
|
||||
|
||||
# Deploy new virtual machine using template
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
templateid=template.id,
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
mode=self.services["mode"]
|
||||
)
|
||||
self.debug("creating an instance with template ID: %s" % template.id)
|
||||
vm_response = list_virtual_machines(
|
||||
self.apiclient,
|
||||
id=virtual_machine.id,
|
||||
account=self.account.account.name,
|
||||
domainid=self.account.account.domainid
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vm_response, list),
|
||||
True,
|
||||
"Check for list VMs response after VM deployment"
|
||||
)
|
||||
#Verify VM response to check whether VM deployment was successful
|
||||
self.assertNotEqual(
|
||||
len(vm_response),
|
||||
0,
|
||||
"Check VMs available in List VMs response"
|
||||
)
|
||||
vm = vm_response[0]
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
'Running',
|
||||
"Check the state of VM created from Template"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
class TestTemplates(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
cls.services = Services().services
|
||||
cls.api_client = fetch_api_client()
|
||||
|
||||
# Get Zone, templates etc
|
||||
cls.domain = get_domain(cls.api_client, cls.services)
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
|
||||
template = get_template(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.services["ostypeid"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
cls.services["account"] = cls.account.account.name
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
)
|
||||
|
||||
# create virtual machine
|
||||
cls.virtual_machine = VirtualMachine.create(
|
||||
cls.api_client,
|
||||
cls.services["virtual_machine"],
|
||||
templateid=template.id,
|
||||
accountid=cls.account.account.name,
|
||||
domainid=cls.account.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
)
|
||||
#Stop virtual machine
|
||||
cls.virtual_machine.stop(cls.api_client)
|
||||
|
||||
timeout = cls.services["timeout"]
|
||||
#Wait before server has be successfully stopped
|
||||
time.sleep(cls.services["sleep"])
|
||||
|
||||
while True:
|
||||
list_volume = list_volumes(
|
||||
cls.api_client,
|
||||
virtualmachineid=cls.virtual_machine.id,
|
||||
type='ROOT',
|
||||
listall=True
|
||||
)
|
||||
if isinstance(list_volume, list):
|
||||
break
|
||||
elif timeout == 0:
|
||||
raise Exception("List volumes failed.")
|
||||
|
||||
time.sleep(5)
|
||||
timeout = timeout -1
|
||||
|
||||
cls.volume = list_volume[0]
|
||||
|
||||
#Create template from volume
|
||||
cls.template = Template.create(
|
||||
cls.api_client,
|
||||
cls.services["template"],
|
||||
cls.volume.id
|
||||
)
|
||||
cls._cleanup = [
|
||||
cls.service_offering,
|
||||
cls.account,
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
cls.api_client = fetch_api_client()
|
||||
#Cleanup created resources such as templates and VMs
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.cleanup = []
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
#Clean up, terminate the created templates
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
|
||||
return
|
||||
|
||||
def test_01_create_template_volume(self):
|
||||
"""Test Create template from volume
|
||||
"""
|
||||
|
||||
# Validate the following:
|
||||
# 1. Deploy new VM using the template created from Volume
|
||||
# 2. VM should be in Up and Running state
|
||||
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
templateid=self.template.id,
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
)
|
||||
|
||||
self.debug("creating an instance with template ID: %s" % self.template.id)
|
||||
self.cleanup.append(virtual_machine)
|
||||
vm_response = list_virtual_machines(
|
||||
self.apiclient,
|
||||
id=virtual_machine.id,
|
||||
account=self.account.account.name,
|
||||
domainid=self.account.account.domainid
|
||||
)
|
||||
#Verify VM response to check whether VM deployment was successful
|
||||
self.assertNotEqual(
|
||||
len(vm_response),
|
||||
0,
|
||||
"Check VMs available in List VMs response"
|
||||
)
|
||||
vm = vm_response[0]
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
'Running',
|
||||
"Check the state of VM created from Template"
|
||||
)
|
||||
return
|
||||
|
||||
def test_02_copy_template(self):
|
||||
"""Test for copy template from one zone to another"""
|
||||
|
||||
# Validate the following
|
||||
# 1. copy template should be successful and
|
||||
# secondary storage should contain new copied template.
|
||||
|
||||
self.debug(
|
||||
"Copying template from zone: %s to %s" % (
|
||||
self.template.id,
|
||||
self.services["destzoneid"]
|
||||
))
|
||||
cmd = copyTemplate.copyTemplateCmd()
|
||||
cmd.id = self.template.id
|
||||
cmd.destzoneid = self.services["destzoneid"]
|
||||
cmd.sourcezoneid = self.zone.id
|
||||
self.apiclient.copyTemplate(cmd)
|
||||
|
||||
# Verify template is copied to another zone using ListTemplates
|
||||
list_template_response = list_templates(
|
||||
self.apiclient,
|
||||
templatefilter=\
|
||||
self.services["templatefilter"],
|
||||
id=self.template.id,
|
||||
zoneid=self.services["destzoneid"]
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(list_template_response, list),
|
||||
True,
|
||||
"Check for list template response return valid list"
|
||||
)
|
||||
|
||||
self.assertNotEqual(
|
||||
len(list_template_response),
|
||||
0,
|
||||
"Check template extracted in List Templates"
|
||||
)
|
||||
|
||||
template_response = list_template_response[0]
|
||||
self.assertEqual(
|
||||
template_response.id,
|
||||
self.template.id,
|
||||
"Check ID of the downloaded template"
|
||||
)
|
||||
self.assertEqual(
|
||||
template_response.zoneid,
|
||||
self.services["destzoneid"],
|
||||
"Check zone ID of the copied template"
|
||||
)
|
||||
|
||||
# Cleanup- Delete the copied template
|
||||
cmd = deleteTemplate.deleteTemplateCmd()
|
||||
cmd.id = self.template.id
|
||||
cmd.zoneid = self.services["destzoneid"]
|
||||
self.apiclient.deleteTemplate(cmd)
|
||||
return
|
||||
|
||||
def test_03_delete_template(self):
|
||||
"""Test Delete template
|
||||
"""
|
||||
|
||||
# Validate the following:
|
||||
# 1. Create a template and verify it is shown in list templates response
|
||||
# 2. Delete the created template and again verify list template response
|
||||
|
||||
# Verify template response for updated attributes
|
||||
list_template_response = list_templates(
|
||||
self.apiclient,
|
||||
templatefilter=\
|
||||
self.services["template"]["templatefilter"],
|
||||
id=self.template.id,
|
||||
zoneid=self.zone.id
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(list_template_response, list),
|
||||
True,
|
||||
"Check for list template response return valid list"
|
||||
)
|
||||
|
||||
self.assertNotEqual(
|
||||
len(list_template_response),
|
||||
0,
|
||||
"Check template available in List Templates"
|
||||
)
|
||||
template_response = list_template_response[0]
|
||||
|
||||
self.assertEqual(
|
||||
template_response.id,
|
||||
self.template.id,
|
||||
"Check display text of updated template"
|
||||
)
|
||||
|
||||
self.debug("Deleting template: %s" % self.template)
|
||||
# Delete the template
|
||||
self.template.delete(self.apiclient)
|
||||
self.debug("Delete template: %s successful" % self.template)
|
||||
|
||||
list_template_response = list_templates(
|
||||
self.apiclient,
|
||||
templatefilter=\
|
||||
self.services["template"]["templatefilter"],
|
||||
id=self.template.id,
|
||||
zoneid=self.zone.id
|
||||
)
|
||||
self.assertEqual(
|
||||
list_template_response,
|
||||
None,
|
||||
"Check template available in List Templates"
|
||||
)
|
||||
return
|
||||
|
||||
def test_04_template_from_snapshot(self):
|
||||
"""Create Template from snapshot
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
# 2. Snapshot the Root disk
|
||||
# 3. Create Template from snapshot
|
||||
# 4. Deploy Virtual machine using this template
|
||||
# 5. VM should be in running state
|
||||
|
||||
volumes = list_volumes(
|
||||
self.apiclient,
|
||||
virtualmachineid=self.virtual_machine.id,
|
||||
type='ROOT',
|
||||
listall=True
|
||||
)
|
||||
volume = volumes[0]
|
||||
|
||||
self.debug("Creating a snapshot from volume: %s" % volume.id)
|
||||
#Create a snapshot of volume
|
||||
snapshot = Snapshot.create(
|
||||
self.apiclient,
|
||||
volume.id,
|
||||
account=self.account.account.name,
|
||||
domainid=self.account.account.domainid
|
||||
)
|
||||
self.debug("Creating a template from snapshot: %s" % snapshot.id)
|
||||
# Generate template from the snapshot
|
||||
template = Template.create_from_snapshot(
|
||||
self.apiclient,
|
||||
snapshot,
|
||||
self.services["template"]
|
||||
)
|
||||
self.cleanup.append(template)
|
||||
# Verify created template
|
||||
templates = list_templates(
|
||||
self.apiclient,
|
||||
templatefilter=\
|
||||
self.services["template"]["templatefilter"],
|
||||
id=template.id
|
||||
)
|
||||
self.assertNotEqual(
|
||||
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"
|
||||
)
|
||||
self.debug("Deploying a VM from template: %s" % template.id)
|
||||
# Deploy new virtual machine using template
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
templateid=template.id,
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
)
|
||||
self.cleanup.append(virtual_machine)
|
||||
|
||||
vm_response = list_virtual_machines(
|
||||
self.apiclient,
|
||||
id=virtual_machine.id,
|
||||
account=self.account.account.name,
|
||||
domainid=self.account.account.domainid
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vm_response, list),
|
||||
True,
|
||||
"Check for list VM response return valid list"
|
||||
)
|
||||
|
||||
#Verify VM response to check whether VM deployment was successful
|
||||
self.assertNotEqual(
|
||||
len(vm_response),
|
||||
0,
|
||||
"Check VMs available in List VMs response"
|
||||
)
|
||||
vm = vm_response[0]
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
'Running',
|
||||
"Check the state of VM created from Template"
|
||||
)
|
||||
return
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -185,20 +185,10 @@ class VirtualMachine:
|
|||
elif "domainid" in services:
|
||||
cmd.domainid = services["domainid"]
|
||||
|
||||
# List Networks for that user
|
||||
command = listNetworks.listNetworksCmd()
|
||||
command.zoneid = services["zoneid"]
|
||||
command.account = accountid or services["account"]
|
||||
command.domainid = domainid or services["domainid"]
|
||||
network = apiclient.listNetworks(command)
|
||||
|
||||
if networkids:
|
||||
cmd.networkids = networkids
|
||||
elif "networkids" in services:
|
||||
cmd.networkids = services["networkids"]
|
||||
# elif network: #If user already has source NAT created, then use that
|
||||
# if hasattr(network[0], "account"):
|
||||
# cmd.networkids = str(network[0].id)
|
||||
|
||||
if templateid:
|
||||
cmd.templateid = templateid
|
||||
|
|
@ -274,13 +264,16 @@ class VirtualMachine:
|
|||
cmd.id = self.id
|
||||
apiclient.rebootVirtualMachine(cmd)
|
||||
|
||||
def get_ssh_client(self, ipaddress=None, reconnect=False):
|
||||
def get_ssh_client(self, ipaddress=None, reconnect=False, port=None):
|
||||
"""Get SSH object of VM"""
|
||||
|
||||
# If NAT Rules are not created while VM deployment in Advanced mode
|
||||
# then, IP address must be passed
|
||||
if ipaddress != None:
|
||||
self.ssh_ip = ipaddress
|
||||
if port:
|
||||
self.ssh_port = port
|
||||
|
||||
if reconnect:
|
||||
self.ssh_client = is_server_ssh_ready(
|
||||
self.ssh_ip,
|
||||
|
|
@ -479,7 +472,7 @@ class Template:
|
|||
return Template(apiclient.createTemplate(cmd).__dict__)
|
||||
|
||||
@classmethod
|
||||
def register(cls, apiclient, services, account=None, domainid=None):
|
||||
def register(cls, apiclient, services, zoneid=None, account=None, domainid=None):
|
||||
"""Create template from URL"""
|
||||
|
||||
#Create template from Virtual machine and Volume ID
|
||||
|
|
@ -490,7 +483,11 @@ class Template:
|
|||
cmd.hypervisor = services["hypervisor"]
|
||||
cmd.ostypeid = services["ostypeid"]
|
||||
cmd.url = services["url"]
|
||||
cmd.zoneid = services["zoneid"]
|
||||
|
||||
if zoneid:
|
||||
cmd.zoneid = zoneid
|
||||
else:
|
||||
cmd.zoneid = services["zoneid"]
|
||||
|
||||
cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
|
||||
cmd.ispublic = services["ispublic"] if "ispublic" in services else False
|
||||
|
|
@ -529,10 +526,10 @@ class Template:
|
|||
cmd.id = self.id
|
||||
apiclient.deleteTemplate(cmd)
|
||||
|
||||
def download(self, apiclient, timeout=5):
|
||||
def download(self, apiclient, timeout=5, interval=60):
|
||||
"""Download Template"""
|
||||
#Sleep to ensure template is in proper state before download
|
||||
time.sleep(30)
|
||||
time.sleep(interval)
|
||||
|
||||
while True:
|
||||
template_response = Template.list(
|
||||
|
|
@ -548,22 +545,20 @@ class Template:
|
|||
# template.status = Download Complete
|
||||
# Downloading - x% Downloaded
|
||||
# Error - Any other string
|
||||
|
||||
if template.status == 'Download Complete' :
|
||||
if template.status == 'Download Complete':
|
||||
break
|
||||
|
||||
elif 'Downloaded' not in template.status.split() or \
|
||||
'Installing' not in template.status.split():
|
||||
elif 'Downloaded' in template.status:
|
||||
time.sleep(interval)
|
||||
|
||||
elif 'Installing' not in template.status:
|
||||
raise Exception("ErrorInDownload")
|
||||
|
||||
elif 'Downloaded' in template.status.split():
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
elif timeout == 0:
|
||||
break
|
||||
|
||||
else:
|
||||
time.sleep(10)
|
||||
time.sleep(interval)
|
||||
timeout = timeout - 1
|
||||
return
|
||||
|
||||
|
|
@ -617,11 +612,11 @@ class Iso:
|
|||
apiclient.deleteIso(cmd)
|
||||
return
|
||||
|
||||
def download(self, apiclient, timeout=5):
|
||||
def download(self, apiclient, timeout=5, interval=60):
|
||||
"""Download an ISO"""
|
||||
#Ensuring ISO is successfully downloaded
|
||||
while True:
|
||||
time.sleep(60)
|
||||
time.sleep(interval)
|
||||
|
||||
cmd = listIsos.listIsosCmd()
|
||||
cmd.id = self.id
|
||||
|
|
@ -636,8 +631,9 @@ class Iso:
|
|||
# or ISO is 'Successfully Installed'
|
||||
if response.status == 'Successfully Installed':
|
||||
return
|
||||
elif 'Downloaded' not in response.status.split():
|
||||
elif 'Downloaded' not in response.status:
|
||||
raise Exception("ErrorInDownload")
|
||||
|
||||
elif timeout == 0:
|
||||
raise Exception("TimeoutException")
|
||||
else:
|
||||
|
|
@ -1083,6 +1079,13 @@ class Host:
|
|||
apiclient.deleteHost(cmd)
|
||||
return
|
||||
|
||||
def enableMaintenance(self, apiclient):
|
||||
"""enables maintainance mode Host"""
|
||||
|
||||
cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
|
||||
cmd.id = self.id
|
||||
return apiclient.prepareHostForMaintenance(cmd)
|
||||
|
||||
@classmethod
|
||||
def list(cls, apiclient, **kwargs):
|
||||
"""List all Hosts matching criteria"""
|
||||
|
|
@ -1136,6 +1139,13 @@ class StoragePool:
|
|||
apiclient.deleteStoragePool(cmd)
|
||||
return
|
||||
|
||||
def enableMaintenance(self, apiclient):
|
||||
"""enables maintainance mode Storage pool"""
|
||||
|
||||
cmd = enableStorageMaintenance.enableStorageMaintenanceCmd()
|
||||
cmd.id = self.id
|
||||
return apiclient.enableStorageMaintenance(cmd)
|
||||
|
||||
@classmethod
|
||||
def list(cls, apiclient, **kwargs):
|
||||
"""List all storage pools matching criteria"""
|
||||
|
|
@ -1233,6 +1243,8 @@ class VpnUser:
|
|||
|
||||
cmd = removeVpnUser.removeVpnUserCmd()
|
||||
cmd.username = self.username
|
||||
cmd.account = self.account
|
||||
cmd.domainid = self.domainid
|
||||
apiclient.removeVpnUser(cmd)
|
||||
|
||||
|
||||
|
|
@ -1267,6 +1279,15 @@ class Zone:
|
|||
cmd.id = self.id
|
||||
apiclient.deleteZone(cmd)
|
||||
|
||||
def update(self, apiclient, **kwargs):
|
||||
"""Update the zone"""
|
||||
|
||||
cmd = updateZone.updateZoneCmd()
|
||||
cmd.id = self.id
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return apiclient.updateZone(cmd)
|
||||
|
||||
|
||||
@classmethod
|
||||
def list(cls, apiclient, **kwargs):
|
||||
"""List all Zones matching criteria"""
|
||||
|
|
@ -1373,6 +1394,46 @@ class SecondaryStorage:
|
|||
apiclient.deleteHost(cmd)
|
||||
|
||||
|
||||
class PhysicalNetwork:
|
||||
"""Manage physical network storage"""
|
||||
|
||||
def __init__(self, items):
|
||||
self.__dict__.update(items)
|
||||
|
||||
@classmethod
|
||||
def create(cls, apiclient, services, zoneid, domainid=None):
|
||||
"""Create physical network"""
|
||||
cmd = createPhysicalNetwork.createPhysicalNetworkCmd()
|
||||
|
||||
cmd.name = services["name"]
|
||||
cmd.zoneid = zoneid
|
||||
if domainid:
|
||||
cmd.domainid = domainid
|
||||
return PhysicalNetwork(apiclient.createPhysicalNetwork(cmd).__dict__)
|
||||
|
||||
def delete(self, apiclient):
|
||||
"""Delete Physical Network"""
|
||||
|
||||
cmd = deletePhysicalNetwork.deletePhysicalNetworkCmd()
|
||||
cmd.id = self.id
|
||||
apiclient.deletePhysicalNetwork(cmd)
|
||||
|
||||
def update(self, apiclient, **kwargs):
|
||||
"""Update Physical network state"""
|
||||
|
||||
cmd = updatePhysicalNetwork.updatePhysicalNetworkCmd()
|
||||
cmd.id = self.id
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return apiclient.updatePhysicalNetwork(cmd)
|
||||
|
||||
def addTrafficType(self, apiclient, type):
|
||||
"""Add Traffic type to Physical network"""
|
||||
|
||||
cmd = addTrafficType.addTrafficTypeCmd()
|
||||
cmd.physicalnetworkid = self.id
|
||||
cmd.traffictype = type
|
||||
return apiclient.addTrafficType(cmd)
|
||||
|
||||
class SecurityGroup:
|
||||
"""Manage Security Groups"""
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,21 @@ from base import *
|
|||
#Import System modules
|
||||
import time
|
||||
|
||||
def get_domain(apiclient, services=None):
|
||||
"Returns a default domain"
|
||||
|
||||
cmd = listDomains.listDomainsCmd()
|
||||
if services:
|
||||
if "domainid" in services:
|
||||
cmd.id = services["domainid"]
|
||||
|
||||
domains = apiclient.listDomains(cmd)
|
||||
|
||||
if isinstance(domains, list):
|
||||
return domains[0]
|
||||
else:
|
||||
raise Exception("Failed to find specified domain.")
|
||||
|
||||
def get_zone(apiclient, services=None):
|
||||
"Returns a default zone"
|
||||
|
||||
|
|
@ -112,10 +127,10 @@ def download_systemplates_sec_storage(server, services):
|
|||
raise Exception("Failed to download System Templates on Sec Storage")
|
||||
return
|
||||
|
||||
def wait_for_ssvms(apiclient, zoneid, podid):
|
||||
def wait_for_ssvms(apiclient, zoneid, podid, interval=60):
|
||||
"""After setup wait for SSVMs to come Up"""
|
||||
|
||||
time.sleep(30)
|
||||
time.sleep(interval)
|
||||
timeout = 40
|
||||
while True:
|
||||
list_ssvm_response = list_ssvms(
|
||||
|
|
@ -127,15 +142,15 @@ def wait_for_ssvms(apiclient, zoneid, podid):
|
|||
ssvm = list_ssvm_response[0]
|
||||
if ssvm.state != 'Running':
|
||||
# Sleep to ensure SSVMs are Up and Running
|
||||
time.sleep(30)
|
||||
time.sleep(interval)
|
||||
timeout = timeout - 1
|
||||
elif ssvm.state == 'Running':
|
||||
break
|
||||
elif timeout == 0:
|
||||
raise Exception("SSVM failled to come up")
|
||||
raise Exception("SSVM failed to come up")
|
||||
break
|
||||
|
||||
timeout = 20
|
||||
timeout = 40
|
||||
while True:
|
||||
list_ssvm_response = list_ssvms(
|
||||
apiclient,
|
||||
|
|
@ -146,16 +161,16 @@ def wait_for_ssvms(apiclient, zoneid, podid):
|
|||
cpvm = list_ssvm_response[0]
|
||||
if cpvm.state != 'Running':
|
||||
# Sleep to ensure SSVMs are Up and Running
|
||||
time.sleep(30)
|
||||
time.sleep(interval)
|
||||
timeout = timeout - 1
|
||||
elif cpvm.state == 'Running':
|
||||
break
|
||||
elif timeout == 0:
|
||||
raise Exception("SSVM failled to come up")
|
||||
raise Exception("CPVM failed to come up")
|
||||
break
|
||||
return
|
||||
|
||||
def download_builtin_templates(apiclient, zoneid, hypervisor, host, linklocalip):
|
||||
def download_builtin_templates(apiclient, zoneid, hypervisor, host, linklocalip, interval=60):
|
||||
"""After setup wait till builtin templates are downloaded"""
|
||||
|
||||
# Change IPTABLES Rules
|
||||
|
|
@ -167,7 +182,7 @@ def download_builtin_templates(apiclient, zoneid, hypervisor, host, linklocalip)
|
|||
linklocalip,
|
||||
"iptables -P INPUT ACCEPT"
|
||||
)
|
||||
|
||||
time.sleep(interval)
|
||||
# Find the BUILTIN Templates for given Zone, Hypervisor
|
||||
list_template_response = list_templates(
|
||||
apiclient,
|
||||
|
|
@ -187,7 +202,7 @@ def download_builtin_templates(apiclient, zoneid, hypervisor, host, linklocalip)
|
|||
|
||||
# Sleep to ensure that template is in downloading state after adding
|
||||
# Sec storage
|
||||
time.sleep(30)
|
||||
time.sleep(interval)
|
||||
while True:
|
||||
template_response = list_templates(
|
||||
apiclient,
|
||||
|
|
@ -200,12 +215,15 @@ def download_builtin_templates(apiclient, zoneid, hypervisor, host, linklocalip)
|
|||
# template.status = Download Complete
|
||||
# Downloading - x% Downloaded
|
||||
# Error - Any other string
|
||||
if template.status == 'Download Complete' :
|
||||
if template.status == 'Download Complete':
|
||||
break
|
||||
elif 'Downloaded' not in template.status.split():
|
||||
|
||||
elif 'Downloaded' in template.status:
|
||||
time.sleep(interval)
|
||||
|
||||
elif 'Installing' not in template.status:
|
||||
raise Exception("ErrorInDownload")
|
||||
elif 'Downloaded' in template.status.split():
|
||||
time.sleep(30)
|
||||
|
||||
return
|
||||
|
||||
def update_resource_limit(apiclient, resourcetype, account=None, domainid=None,
|
||||
|
|
@ -413,3 +431,24 @@ def list_usage_records(apiclient, **kwargs):
|
|||
cmd = listUsageRecords.listUsageRecordsCmd()
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.listUsageRecords(cmd))
|
||||
|
||||
def list_nw_service_prividers(apiclient, **kwargs):
|
||||
"""Lists Network service providers"""
|
||||
|
||||
cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.listNetworkServiceProviders(cmd))
|
||||
|
||||
def list_virtual_router_elements(apiclient, **kwargs):
|
||||
"""Lists Virtual Router elements"""
|
||||
|
||||
cmd = listVirtualRouterElements.listVirtualRouterElementsCmd()
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.listVirtualRouterElements(cmd))
|
||||
|
||||
def list_network_offerings(apiclient, **kwargs):
|
||||
"""Lists network offerings"""
|
||||
|
||||
cmd = listNetworkOfferings.listNetworkOfferingsCmd()
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.listNetworkOfferings(cmd))
|
||||
Loading…
Reference in New Issue