本文整理汇总了Python中marvin.lib.common.get_builtin_template_info函数的典型用法代码示例。如果您正苦于以下问题:Python get_builtin_template_info函数的具体用法?Python get_builtin_template_info怎么用?Python get_builtin_template_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_builtin_template_info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
self.services = Services().services
self.services["virtual_machine"]["zoneid"] = self.zone.id
self.account = Account.create(self.apiclient, self.services["account"], domainid=self.domain.id)
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["template"]["url"] = builtin_info[0]
self.services["template"]["hypervisor"] = builtin_info[1]
self.services["template"]["format"] = builtin_info[2]
# Register new template
self.template = Template.register(
self.apiclient,
self.services["template"],
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
hypervisor=self.hypervisor,
)
self.debug(
"Registered a template of format: %s with ID: %s" % (self.services["template"]["format"], self.template.id)
)
try:
self.template.download(self.apiclient)
except Exception as e:
raise Exception("Template download failed: %s" % e)
self.cleanup = [self.account]
return
开发者ID:rafaelthedevops,项目名称:cloudstack,代码行数:32,代码来源:test_stopped_vm.py
示例2: registerTemplate
def registerTemplate(self, inProject=False):
"""Register and download template by default in the account/domain,
in project if stated so"""
try:
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["template_2"]["url"] = builtin_info[0]
self.services["template_2"]["hypervisor"] = builtin_info[1]
self.services["template_2"]["format"] = builtin_info[2]
template = Template.register(self.apiclient,
self.services["template_2"],
zoneid=self.zone.id,
account=self.child_do_admin.name if not inProject else None,
domainid=self.child_do_admin.domainid if not inProject else None,
projectid=self.project.id if inProject else None)
template.download(self.apiclient)
templates = Template.list(self.apiclient,
templatefilter=\
self.services["template_2"]["templatefilter"],
id=template.id)
self.assertEqual(validateList(templates)[0], PASS,\
"templates list validation failed")
self.templateSize = (templates[0].size / (1024**3))
except Exception as e:
return [FAIL, e]
return [PASS, None]
开发者ID:Skotha,项目名称:cloudstack,代码行数:30,代码来源:test_ss_max_limits.py
示例3: setUpClass
def setUpClass(cls):
testClient = super(TestlistTemplatesDomainAdmin, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.testdata = testClient.getParsedTestDataConfig()
cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls.hypervisor = cls.testClient.getHypervisorInfo()
builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id)
cls.testdata["privatetemplate"]["url"] = builtin_info[0]
cls.testdata["privatetemplate"]["hypervisor"] = builtin_info[1]
cls.testdata["privatetemplate"]["format"] = builtin_info[2]
cls.cleanup = []
# Create 2 domain admin accounts
cls.domain1 = Domain.create(cls.apiclient, cls.testdata["domain"])
cls.domain2 = Domain.create(cls.apiclient, cls.testdata["domain"])
cls.account1 = Account.create(cls.apiclient, cls.testdata["account"], admin=True, domainid=cls.domain1.id)
cls.account2 = Account.create(cls.apiclient, cls.testdata["account2"], admin=True, domainid=cls.domain2.id)
cls.debug("Created account %s in domain %s" % (cls.account1.name, cls.domain1.id))
cls.debug("Created account %s in domain %s" % (cls.account2.name, cls.domain2.id))
cls.cleanup.append(cls.account1)
cls.cleanup.append(cls.account2)
cls.cleanup.append(cls.domain1)
cls.cleanup.append(cls.domain2)
开发者ID:ikarin,项目名称:cloudstack,代码行数:30,代码来源:test_escalation_listTemplateDomainAdmin.py
示例4: setUpClass
def setUpClass(cls):
try:
cls._cleanup = []
cls.testClient = super(TestTemplates, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = cls.testClient.getParsedTestDataConfig()
# Get Domain, Zone, Template
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(
cls.api_client,
cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services['mode'] = cls.zone.networktype
builtin_info = get_builtin_template_info(cls.api_client, cls.zone.id)
cls.services["privatetemplate"]["url"] = builtin_info[0]
cls.services["privatetemplate"]["hypervisor"] = builtin_info[1]
cls.services["privatetemplate"]["format"] = builtin_info[2]
except Exception as e:
cls.tearDownClass()
raise Exception("Warning: Exception in setup : %s" % e)
return
开发者ID:K0zka,项目名称:cloudstack,代码行数:27,代码来源:test_escalations_templates.py
示例5: test_01_register_template
def test_01_register_template(self, value):
"""Test register template
# Validate the following:
1. Create a root domain admin/ child domain admin account
2. Register and download a template according to hypervisor type
3. Verify that the template is listed
4. Verify that the secondary storage count for the account equals the size
of the template
5. Delete the template
6. Verify that the secondary storage resource count of the account equals 0
"""
response = self.setupAccount(value)
self.assertEqual(response[0], PASS, response[1])
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["template_2"]["url"] = builtin_info[0]
self.services["template_2"]["hypervisor"] = builtin_info[1]
self.services["template_2"]["format"] = builtin_info[2]
try:
template = Template.register(self.apiclient,
self.services["template_2"],
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
hypervisor=self.hypervisor)
template.download(self.apiclient)
except Exception as e:
self.fail("Failed to register template: %s" % e)
templates = Template.list(self.apiclient,
templatefilter=\
self.services["template_2"]["templatefilter"],
id=template.id)
self.assertEqual(validateList(templates)[0],PASS,\
"templates list validation failed")
templateSize = (templates[0].size / (1024**3))
expectedCount = templateSize
response = matchResourceCount(
self.apiclient, expectedCount,
RESOURCE_SECONDARY_STORAGE,
accountid=self.account.id)
self.assertEqual(response[0], PASS, response[1])
try:
template.delete(self.apiclient)
except Exception as e:
self.fail("Failed to delete template: %s" % e)
expectedCount = 0
response = matchResourceCount(
self.apiclient, expectedCount,
RESOURCE_SECONDARY_STORAGE,
accountid=self.account.id)
self.assertEqual(response[0], PASS, response[1])
return
开发者ID:Skotha,项目名称:cloudstack,代码行数:58,代码来源:test_ss_limits.py
示例6: setUpClass
def setUpClass(cls):
testClient = super(
TestlistTemplates, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.testdata = testClient.getParsedTestDataConfig()
cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.apiclient,
cls.zone.id,
cls.testdata["ostype"]
)
cls.hypervisor = cls.testClient.getHypervisorInfo()
builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id)
cls.testdata["templates"]["url"] = builtin_info[0]
cls.testdata["templates"]["hypervisor"] = builtin_info[1]
cls.testdata["templates"]["format"] = builtin_info[2]
if cls.zone.localstorageenabled:
cls.storagetype = 'local'
cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'local'
cls.testdata["disk_offering"]["storagetype"] = 'local'
else:
cls.storagetype = 'shared'
cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'shared'
cls.testdata["disk_offering"]["storagetype"] = 'shared'
cls.testdata["virtual_machine"]["hypervisor"] = cls.hypervisor
cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id
cls.testdata["virtual_machine"]["template"] = cls.template.id
cls.testdata["custom_volume"]["zoneid"] = cls.zone.id
cls.service_offering = ServiceOffering.create(
cls.apiclient,
cls.testdata["service_offerings"]["tiny"]
)
cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
cls.cleanup = []
# Create 1 domain admin account
cls.domain = Domain.create(
cls.apiclient,
cls.testdata["domain"])
cls.account = Account.create(
cls.apiclient,
cls.testdata["account"],
admin=True,
domainid=cls.domain.id)
cls.debug("Created account %s in domain %s" %
(cls.account.name, cls.domain.id))
cls.cleanup.append(cls.account)
cls.cleanup.append(cls.domain)
开发者ID:EdwardBetts,项目名称:blackhole,代码行数:53,代码来源:test_escalation_templates.py
示例7: setUpClass
def setUpClass(cls):
try:
cls._cleanup = []
cls.testClient = super(TestTemplates, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = cls.testClient.getParsedTestDataConfig()
# Get Domain, Zone, Template
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(
cls.api_client,
cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services['mode'] = cls.zone.networktype
cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
builtin_info = get_builtin_template_info(cls.api_client, cls.zone.id)
cls.services["privatetemplate"]["url"] = builtin_info[0]
cls.services["privatetemplate"]["hypervisor"] = builtin_info[1]
cls.services["privatetemplate"]["format"] = builtin_info[2]
cls.services["templates"]["url"] = builtin_info[0]
cls.services["templates"]["hypervisor"] = builtin_info[1]
cls.services["templates"]["format"] = builtin_info[2]
if cls.zone.localstorageenabled:
cls.storagetype = 'local'
cls.services["service_offerings"][
"tiny"]["storagetype"] = 'local'
cls.services["disk_offering"]["storagetype"] = 'local'
else:
cls.storagetype = 'shared'
cls.services["service_offerings"][
"tiny"]["storagetype"] = 'shared'
cls.services["disk_offering"]["storagetype"] = 'shared'
cls.services["virtual_machine"]["hypervisor"] = cls.hypervisor
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.services["custom_volume"]["zoneid"] = cls.zone.id
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offerings"]["tiny"]
)
cls._cleanup.append(cls.service_offering)
except Exception as e:
cls.tearDownClass()
raise Exception("Warning: Exception in setup : %s" % e)
return
开发者ID:Tosta-Mixta,项目名称:cloudstack,代码行数:51,代码来源:test_escalations_templates.py
示例8: test_07_templates_per_project
def test_07_templates_per_project(self):
"""Test Templates limit per project
"""
# 1. set max no of templates per project to 1.
# 2. Create a template in this project. Both template should be in
# ready state
# 3. Try create 2nd template in the project. It should give the user
# appropriate error and an alert should be generated.
# Reset the volume limits
update_resource_limit(
self.apiclient,
2, # Volume
max=5,
projectid=self.project.id
)
self.debug(
"Updating template resource limits for domain: %s" %
self.account.domainid)
# Set usage_vm=1 for Account 1
update_resource_limit(
self.apiclient,
4, # Template
max=1,
projectid=self.project.id
)
# Register the First Template in the project
self.debug("Register the First Template in the project")
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["template"]["url"] = builtin_info[0]
self.services["template"]["hypervisor"] = builtin_info[1]
self.services["template"]["format"] = builtin_info[2]
# Register new template
template = Template.register(
self.userapiclient,
self.services["template"],
zoneid=self.zone.id,
projectid=self.project.id
)
self.debug(
"Registered a template of format: %s with ID: %s" % (
self.services["template"]["format"],
template.id
))
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 = Template.list(
self.apiclient,
templatefilter='all',
id=template.id,
zoneid=self.zone.id,
projectid=self.project.id,
)
if list_template_response[0].isready is True:
break
elif timeout == 0:
raise Exception("Template state is not ready, it is %s" % list_template_response[0].isready)
time.sleep(self.services["sleep"])
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,
"Template state is not ready, it is %s" % template_response.isready
)
# Exception should be raised for second template
with self.assertRaises(Exception):
Template.register(
self.userapiclient,
self.services["template"],
zoneid=self.zone.id,
projectid=self.project.id
)
return
开发者ID:diejiazhao,项目名称:cloudstack,代码行数:96,代码来源:test_project_limits.py
示例9: test_04_create_template_delete_account
def test_04_create_template_delete_account(self):
"""Test secondary storage limit of domain and its sub-domains
# Steps
1. Create a parent domain and two sub-domains in it (also admin accounts
of each domain)
2. Register template in child domain 1
3. Verify that the secondary storage count for child domain 1 equals
the template size
4. Register template in child domain 2
5. Vreify that the seconday storage count for child domain 2 equals
the template size
6. Verify that the secondary storage count for parent domain equals
double of template size
7. Delete child domain 1 admin account
8. Verify that secondary storage count for parent domain now equals
to only 1 template size
"""
# Setting up account and domain hierarchy
result = self.setupAccounts()
self.assertEqual(result[0], PASS, result[1])
try:
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["template_2"]["url"] = builtin_info[0]
self.services["template_2"]["hypervisor"] = builtin_info[1]
self.services["template_2"]["format"] = builtin_info[2]
template = Template.register(self.apiclient,
self.services["template_2"],
zoneid=self.zone.id,
account=self.cadmin_1.name,
domainid=self.cadmin_1.domainid)
template.download(self.apiclient)
templates = Template.list(self.apiclient,
templatefilter=\
self.services["template_2"]["templatefilter"],
id=template.id)
if validateList(templates)[0] == FAIL:
raise Exception("templates list validation failed")
self.templateSize = int(int(templates[0].size) / (1024**3))
except Exception as e:
self.fail("Failed with exception as ee: %s" % e)
# Checking Primary Storage count of Parent domain admin before deleting child domain user account
expectedCount = self.templateSize
result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.cadmin_1.domainid,
expectedCount, RESOURCE_SECONDARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
try:
template = Template.register(self.apiclient,
self.services["template_2"],
zoneid=self.zone.id,
account=self.cadmin_2.name,
domainid=self.cadmin_2.domainid)
template.download(self.apiclient)
except Exception as e:
self.fail("Failed while registering/downloading template: %s" % e)
result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.cadmin_2.domainid,
expectedCount, RESOURCE_SECONDARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
expectedCount *= 2
result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.parent_domain.id,
expectedCount, RESOURCE_SECONDARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
try:
self.cadmin_1.delete(self.apiclient)
except Exception as e:
self.fail("Failed to delete account: %s" % e)
expectedCount /= 2
result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.parent_domain.id,
expectedCount, RESOURCE_SECONDARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
return
开发者ID:Skotha,项目名称:cloudstack,代码行数:92,代码来源:test_ss_domain_limits.py
示例10: test_03_copy_template
def test_03_copy_template(self):
"""Test secondary storage counts in multiple child domains
# Steps
1. Create a parent domain and two sub-domains in it (also admin accounts
of each domain)
Repeat following steps for both the child domains
2. Register template in child domain
3. Check if the resource count for domain is updated correctly
4. Copy template to other zone
5. Verify that secondary storage count for the domain is doubled
as there are two templates now
"""
zones = list_zones(self.apiclient)
self.assertEqual(validateList(zones)[0], PASS, "zones list validation faield")
if len(zones) < 2:
self.skipTest("At least 2 zones should be present for this test case")
users = None
# Setting up account and domain hierarchy
result = self.setupAccounts()
self.assertEqual(result[0], PASS, result[1])
users = result[2]
for domain, admin in users.items():
self.account = admin
self.domain = domain
try:
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["template_2"]["url"] = builtin_info[0]
self.services["template_2"]["hypervisor"] = builtin_info[1]
self.services["template_2"]["format"] = builtin_info[2]
template = Template.register(self.apiclient,
self.services["template_2"],
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid)
template.download(self.apiclient)
templates = Template.list(self.apiclient,
templatefilter=\
self.services["template_2"]["templatefilter"],
id=template.id)
if validateList(templates)[0] == FAIL:
raise Exception("templates list validation failed")
templateSize = int(int(templates[0].size) / (1024**3))
expectedCount = templateSize
result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id,
expectedCount, RESOURCE_SECONDARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
templateDestinationZoneId = None
for zone in zones:
if template.zoneid != zone.id :
templateDestinationZoneId = zone.id
break
template.copy(self.apiclient, destzoneid=templateDestinationZoneId,
sourcezoneid = template.zoneid)
expectedCount *= 2
result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id,
expectedCount, RESOURCE_SECONDARY_STORAGE)
self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match")
except Exception as e:
self.fail("Failed to get zone list: %s" % e)
return
开发者ID:Skotha,项目名称:cloudstack,代码行数:76,代码来源:test_ss_domain_limits.py
示例11: test_01_disable_enable_zone
def test_01_disable_enable_zone(self):
"""disable enable zone
1. Disable zone and verify following things:
For admin user:
1. Should be create to start/stop exsiting vms
2. Should be create to deploy new vm, snapshot,volume,
template,iso in the same zone
For Non-admin user:
1. Should be create to start/stop exsiting vms
2. Should not be create to deploy new vm, snapshot,volume,
template,iso in the same zone
2. Enable the above disabled zone and verify that:
-All users should be create to deploy new vm,
snapshot,volume,template,iso in the same zone
3. Try to delete the zone and it should fail with error message:
-"The zone is not deletable because there are
servers running in this zone"
"""
# Step 1
vm_user = VirtualMachine.create(
self.userapiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
zoneid=self.zone.id,
)
vm_root = VirtualMachine.create(
self.apiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.admin_account.name,
domainid=self.admin_account.domainid,
serviceofferingid=self.service_offering.id,
zoneid=self.zone.id,
)
cmd = updateZone.updateZoneCmd()
cmd.id = self.zone.id
cmd.allocationstate = DISABLED
self.apiclient.updateZone(cmd)
zoneList = Zone.list(self.apiclient, id=self.zone.id)
self.assertEqual(zoneList[0].allocationstate, DISABLED, "Check if the zone is in disabled state")
# Both user and admin vms shoul be running
self.assertEqual(vm_user.state.lower(), "running", "Verify that the user vm is running")
self.assertEqual(vm_root.state.lower(), "running", "Verify that the admin vm is running")
vm_root.stop(self.apiclient)
vm_user.stop(self.apiclient)
root_state = self.dbclient.execute("select state from vm_instance where name='%s'" % vm_root.name)[0][0]
user_state = self.dbclient.execute("select state from vm_instance where name='%s'" % vm_user.name)[0][0]
self.assertEqual(root_state.lower(), "stopped", "verify that vm is Stopped")
self.assertEqual(user_state.lower(), "stopped", "verify that vm is stopped")
root_volume = list_volumes(self.apiclient, virtualmachineid=vm_root.id, type="ROOT", listall=True)
self.assertEqual(validateList(root_volume)[0], PASS, "list volume is empty for vmid %s" % vm_root.id)
root_vm_new = VirtualMachine.create(
self.apiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.admin_account.name,
domainid=self.admin_account.domainid,
serviceofferingid=self.service_offering.id,
zoneid=self.zone.id,
)
self.assertEqual(root_vm_new.state.lower(), "running", "Verify that admin should create new VM")
if self.snapshotSupported:
Snapshot.create(self.apiclient, root_volume[0].id)
snapshots = list_snapshots(self.apiclient, volumeid=root_volume[0].id, listall=True)
self.assertEqual(
validateList(snapshots)[0], PASS, "list snapshot is empty for volume id %s" % root_volume[0].id
)
Template.create_from_snapshot(self.apiclient, snapshots[0], self.testdata["privatetemplate"])
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.testdata["privatetemplate"]["url"] = builtin_info[0]
self.testdata["privatetemplate"]["hypervisor"] = builtin_info[1]
self.testdata["privatetemplate"]["format"] = builtin_info[2]
"""
//commenting it for now will uncomment once expected behaviour is known
Template.register(
self.apiclient,
self.testdata["privatetemplate"],
zoneid=self.zone.id)
"""
#.........这里部分代码省略.........
开发者ID:MissionCriticalCloudOldRepos,项目名称:cosmic-core,代码行数:101,代码来源:testpath_disable_enable_zone.py
示例12: test_01_create_template
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
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["templates"][0]["url"] = builtin_info[0]
self.services["templates"][0]["hypervisor"] = builtin_info[1]
self.services["templates"][0]["format"] = builtin_info[2]
# Register new template
template = Template.register(
self.apiclient,
self.services["templates"][0],
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
hypervisor=self.hypervisor
)
self.debug(
"Registered a template of format: %s with ID: %s" % (
self.services["templates"][0]["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 = Template.list(
self.apiclient,
templatefilter='all',
id=template.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.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,
"Template state is not ready, it is %s" % template_response.isready
)
# Deploy new virtual machine using template
virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
templateid=template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
mode=self.services["mode"]
)
self.debug("creating an instance with template ID: %s" % template.id)
vm_response = VirtualMachine.list(self.apiclient,
id=virtual_machine.id,
account=self.account.name,
domainid=self.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),
#.........这里部分代码省略.........
开发者ID:HitherTech,项目名称:cloudstack,代码行数:101,代码来源:test_templates.py
示例13: test_01_create_template_snampshot
def test_01_create_template_snampshot(self):
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["templates"][0]["url"] = builtin_info[0]
self.services["templates"][0]["hypervisor"] = builtin_info[1]
self.services["templates"][0]["format"] = builtin_info[2]
# Register new template
template = Template.register(
self.apiclient,
self.services["templates"][0],
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
hypervisor=self.hypervisor,
details=[{"keyboard":"us","nicAdapter":"e1000","rootDiskController":"scsi"}]
)
self.debug(
"Registered a template of format: %s with ID: %s" % (
self.services["templates"][0]["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 = Template.list(
self.apiclient,
templatefilter='all',
id=template.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.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,
"Template state is not ready, it is %s" % template_response.isready
)
self.assertIsNotNone(
template_response.details,
"Template details is %s" % template_response.details
)
# Deploy new virtual machine using template
virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
templateid=template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
mode=self.services["mode"]
)
self.debug("creating an instance with template ID: %s" % template.id)
vm_response = VirtualMachine.list(self.apiclient,
id=virtual_machine.id,
account=self.account.name,
domainid=self.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"
#.........这里部分代码省略.........
开发者ID:PCextreme,项目名称:cloudstack,代码行数:101,代码来源:test_template_from_snapshot_with_template_details.py
示例14: test_01_disable_enable_cluster
def test_01_disable_enable_cluster(self):
"""disable enable cluster
1. Disable cluster and verify following things:
For admin user:
--Should be able to create new vm, snapshot,
volume,template,iso in the same cluster
For Non-admin user:
--Should not be able create new vm, snapshot,
volume,template,iso in the same cluster
2. Enable the above disabled cluster and verify that:
-All users should be create to deploy new vm, snapshot,
volume,template,iso in the same cluster
3. Disable the managestate of the cluster and verify that:
--Host in the cluster should get disconnected
--VM's in the cluster are ping-able and ssh to
--Creation of new VM in the cluster should fail
4. Enable the managestate of the cluster and verify that:
--Hosts in the cluster get connected
--VM's in the cluster are accessible
5. Try to delete the cluster and it should fail with error message:
-"The cluster is not deletable because there are
servers running in this cluster"
"""
# Step 1
vm_user = VirtualMachine.create(
self.userapiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
zoneid=self.zone.id,
mode=self.zone.networktype,
)
self.vm_list.append(vm_user)
vm_root = VirtualMachine.create(
self.apiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.admin_account.name,
domainid=self.admin_account.domainid,
serviceofferingid=self.service_offering.id,
zoneid=self.zone.id,
mode=self.zone.networktype,
)
self.vm_list.append(vm_root)
cmd = updateCluster.updateClusterCmd()
cmd.id = self.cluster.id
cmd.allocationstate = DISABLED
self.apiclient.updateCluster(cmd)
clusterList = Cluster.list(self.apiclient, id=self.cluster.id)
self.assertEqual(clusterList[0].allocationstate, DISABLED, "Check if the cluster is in disabled state")
# Verify the existing vms should be running
self.assertEqual(vm_user.state.lower(), "running", "Verify that the user vm is running")
self.assertEqual(vm_root.state.lower(), "running", "Verify that the root vm is running")
VirtualMachine.create(
self.apiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.admin_account.name,
domainid=self.admin_account.domainid,
serviceofferingid=self.service_offering.id,
zoneid=self.zone.id,
)
root_volume = list_volumes(self.apiclient, virtualmachineid=vm_root.id, type="ROOT", listall=True)
self.assertEqual(
validateList(root_volume)[0], PASS, "list root volume response is empty for volume id %s" % vm_root.id
)
if self.snapshotSupported:
Snapshot.create(self.apiclient, root_volume[0].id)
snapshots = list_snapshots(self.apiclient, volumeid=root_volume[0].id, listall=True)
self.assertEqual(
validateList(snapshots)[0], PASS, "list snapshot is empty for volume id %s" % root_volume[0].id
)
Template.create_from_snapshot(self.apiclient, snapshots[0], self.testdata["privatetemplate"])
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.testdata["privatetemplate"]["url"] = builtin_info[0]
self.testdata["privatetemplate"]["hypervisor"] = builtin_info[1]
self.testdata["privatetemplate"]["format"] = builtin_info[2]
Template.register(self.ap
|
请发表评论