本文整理汇总了Python中marvin.integration.lib.base.Account类的典型用法代码示例。如果您正苦于以下问题:Python Account类的具体用法?Python Account怎么用?Python Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Account类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_03_multiplecore_delete_instance
def test_03_multiplecore_delete_instance(self):
"""Test Deploy VM with multiple core CPU & verify the usage"""
# Validate the following
# 1. Deploy VM with multiple core CPU & verify the usage
# 2. Destroy VM & verify update resource count of Root Admin Account
# 3. Resource count should list properly.
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count = account_list[0].cputotal
expected_resource_count = int(self.services["service_offering"]["cpunumber"])
self.assertEqual(resource_count, expected_resource_count,
"Resource count should match with the expected resource count")
self.debug("Destroying instance: %s" % self.vm.name)
try:
self.vm.delete(self.apiclient)
except Exception as e:
self.fail("Failed to delete instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count = account_list[0].cputotal
self.assertEqual(resource_count, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
return
示例2: setupAccounts
def setupAccounts(self):
self.debug("Creating a sub-domain under: %s" % self.domain.name)
self.child_domain_1 = Domain.create(
self.apiclient,
services=self.services["domain"],
parentdomainid=self.domain.id)
self.child_do_admin_1 = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.child_domain_1.id)
# Cleanup the resources created at end of test
self.cleanup.append(self.child_do_admin_1)
self.cleanup.append(self.child_domain_1)
self.child_domain_2 = Domain.create(
self.apiclient,
services=self.services["domain"],
parentdomainid=self.domain.id)
self.child_do_admin_2 = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.child_domain_2.id)
# Cleanup the resources created at end of test
self.cleanup.append(self.child_do_admin_2)
self.cleanup.append(self.child_domain_2)
return
示例3: test_02_multiple_core_vm_migrate_instance
def test_02_multiple_core_vm_migrate_instance(self):
"""Test Deploy VM with 4 core CPU & verify the usage"""
# Validate the following
# 1. Create two domains and set specific resource (cpu) limit for them
# 2. Create compute offering with 4 core CPU & deploy vm
# 3. Update Resource count for the domains
# 4. Migrate instance to new host and check resource count
# 5. Resource count should list properly.
self.debug("Setting up account and domain hierarchy")
self.setupAccounts()
users = {self.domain: self.admin,
self.child_domain: self.child_do_admin
}
for domain, admin in users.items():
self.account = admin
self.domain = domain
api_client = self.testClient.createUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
self.debug("Creating an instance with service offering: %s" %
self.service_offering.name)
vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count = account_list[0].cputotal
expected_resource_count = int(self.services["service_offering"]["cpunumber"])
self.assertEqual(resource_count, expected_resource_count,
"Initial resource count should match with the expected resource count")
host = findSuitableHostForMigration(self.apiclient, vm.id)
if host is None:
self.skipTest(ERROR_NO_HOST_FOR_MIGRATION)
self.debug("Migrating instance: %s to host: %s" %
(vm.name, host.name))
try:
vm.migrate(self.apiclient, host.id)
except Exception as e:
self.fail("Failed to migrate instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_after_migrate = account_list[0].cputotal
self.assertEqual(resource_count, resource_count_after_migrate,
"Resource count should be same as before, after migrating the instance")
return
示例4: test_02_migrate_vm
def test_02_migrate_vm(self):
"""Test Deploy VM with specified RAM & verify the usage"""
# Validate the following
# 1. Create compute offering with specified RAM & Deploy VM in the created domain
# 2. List Resource count for the root admin Memory usage
# 3. Migrate vm to another host, resource count should list properly.
#Resetting memory count in service offering
self.services["service_offering"]["memory"] = 2048
self.debug("Setting up account and domain hierarchy")
self.setupAccounts()
users = { self.child_domain_1: self.child_do_admin_1,
self.child_domain_2: self.child_do_admin_2
}
for domain, admin in users.items():
self.account = admin
self.domain = domain
self.debug("Creating an instance with service offering: %s" %
self.service_offering.name)
api_client = self.testClient.createUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count = account_list[0].memorytotal
expected_resource_count = int(self.services["service_offering"]["memory"])
self.assertEqual(resource_count, expected_resource_count,
"Resource count should match with the expected resource count")
host = findSuitableHostForMigration(self.apiclient, vm.id)
if host is None:
self.skipTest(ERROR_NO_HOST_FOR_MIGRATION)
self.debug("Migrating instance: %s to host: %s" %
(vm.name, host.name))
try:
vm.migrate(self.apiclient, host.id)
except Exception as e:
self.fail("Failed to migrate instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_after_migrate = account_list[0].memorytotal
self.assertTrue(resource_count_after_migrate == resource_count,
"Resource count should be same after migrating the instance")
return
示例5: setupAccounts
def setupAccounts(self):
self.debug("Creating a domain under: %s" % self.domain.name)
self.parent_domain = Domain.create(
self.apiclient, services=self.services["domain"], parentdomainid=self.domain.id
)
self.parentd_admin = Account.create(
self.apiclient, self.services["account"], admin=True, domainid=self.domain.id
)
self.debug("Updating the Memory resource count for domain: %s" % self.domain.name)
Resources.updateLimit(
self.apiclient,
resourcetype=9,
max=4096,
account=self.parentd_admin.name,
domainid=self.parentd_admin.domainid,
)
self.debug("Creating a sub-domain under: %s" % self.parent_domain.name)
self.cdomain_1 = Domain.create(
self.apiclient, services=self.services["domain"], parentdomainid=self.parent_domain.id
)
self.debug("Creating a sub-domain under: %s" % self.parent_domain.name)
self.cdomain_2 = Domain.create(
self.apiclient, services=self.services["domain"], parentdomainid=self.parent_domain.id
)
self.cadmin_1 = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.cdomain_1.id)
self.debug("Updating the Memory resource count for domain: %s" % self.cdomain_1.name)
Resources.updateLimit(self.apiclient, resourcetype=9, max=2048, domainid=self.cadmin_1.domainid)
self.debug("Updating the Memory resource count for account: %s" % self.cadmin_1.name)
Resources.updateLimit(
self.apiclient, resourcetype=9, max=2048, account=self.cadmin_1.name, domainid=self.cadmin_1.domainid
)
self.cadmin_2 = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.cdomain_2.id)
self.debug("Updating the Memory resource count for domain: %s" % self.cdomain_2.name)
Resources.updateLimit(self.apiclient, resourcetype=9, max=2048, domainid=self.cadmin_2.domainid)
self.debug("Updating the Memory resource count for domain: %s" % self.cadmin_2.name)
Resources.updateLimit(
self.apiclient, resourcetype=9, max=2048, account=self.cadmin_2.name, domainid=self.cadmin_2.domainid
)
# Cleanup the resources created at end of test
self.cleanup.append(self.cadmin_1)
self.cleanup.append(self.cadmin_2)
self.cleanup.append(self.cdomain_1)
self.cleanup.append(self.cdomain_2)
self.cleanup.append(self.parentd_admin)
self.cleanup.append(self.parent_domain)
users = {self.parent_domain: self.parentd_admin, self.cdomain_1: self.cadmin_1, self.cdomain_2: self.cadmin_2}
return users
示例6: test_03_delete_vm
def test_03_delete_vm(self):
"""Test Deploy VM with specified RAM & verify the usage"""
# Validate the following
# 1. Create compute offering with specified RAM & Deploy VM in the created domain
# 2. List Resource count for the root admin Memory usage
# 3. Delete vm, resource count should list as 0 after delete operation.
# Resetting the memory count of service offering
self.services["service_offering"]["memory"] = 2048
self.debug("Setting up account and domain hierarchy")
self.setupAccounts()
users = { self.child_domain_1: self.child_do_admin_1,
self.child_domain_2: self.child_do_admin_2
}
for domain, admin in users.items():
self.account = admin
self.domain = domain
self.debug("Creating an instance with service offering: %s" %
self.service_offering.name)
api_client = self.testClient.createUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count = account_list[0].memorytotal
expected_resource_count = int(self.services["service_offering"]["memory"])
self.assertEqual(resource_count, expected_resource_count,
"Resource count should match with the expected resource count")
self.debug("Destroying instance: %s" % vm.name)
try:
vm.delete(self.apiclient)
except Exception as e:
self.fail("Failed to delete instance: %s" % e)
# Wait for expunge interval to cleanup Memory
wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_after_delete = account_list[0].memorytotal
self.assertEqual(resource_count_after_delete, 0 , "Resource count for %s should be 0" % get_resource_type(resource_id=9))#RAM
return
示例7: test_04_deploy_multiple_vm
def test_04_deploy_multiple_vm(self):
"""Test Deploy multiple VM with specified RAM & verify the usage"""
# Validate the following
# 1. Create compute offering with specified RAM
# 2. Deploy multiple VMs with this service offering
# 3. List Resource count for the root admin Memory usage
# 4. Memory usage should list properly
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count = account_list[0].memorytotal
expected_resource_count = int(self.services["service_offering"]["memory"])
self.assertEqual(resource_count, expected_resource_count,
"Resource count should match with the expected resource count")
self.debug("Creating two instances with service offering: %s" %
self.service_offering.name)
vm_1 = self.createInstance(service_off=self.service_offering)
self.createInstance(service_off=self.service_offering)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_new = account_list[0].memorytotal
expected_resource_count = int(self.services["service_offering"]["memory"]) * 3 #Total 3 VMs
self.assertEqual(resource_count_new, expected_resource_count,
"Resource count should match with the expected resource count")
self.debug("Destroying instance: %s" % vm_1.name)
try:
vm_1.delete(self.apiclient)
except Exception as e:
self.fail("Failed to delete instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_after_delete = account_list[0].memorytotal
expected_resource_count -= int(self.services["service_offering"]["memory"])
self.assertEqual(resource_count_after_delete, expected_resource_count,
"Resource count should match with the expected resource count")
return
示例8: test_02_migrate_instance
def test_02_migrate_instance(self):
"""Test Deploy VM with 4 core CPU & verify the usage"""
# Validate the following
# 1. Create compute offering with 4 core CPU & Deploy VM
# 2. List Resource count
# 3. Migrate instance to another host
# 4. Resource count should list properly.
self.debug("Setting up account and domain hierarchy")
self.setupAccounts()
users = {self.child_domain_1: self.child_do_admin_1,
self.child_domain_2: self.child_do_admin_2
}
for domain, admin in users.items():
self.account = admin
self.domain = domain
api_client = self.testClient.createUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
self.debug("Creating an instance with service offering: %s" %
self.service_offering.name)
vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count = account_list[0].cputotal
expected_resource_count = int(self.services["service_offering"]["cpunumber"])
self.assertEqual(resource_count, expected_resource_count,
"Initial resource count should with the expected resource count")
host = find_suitable_host(self.apiclient, vm)
self.debug("Migrating instance: %s to host: %s" %
(vm.name, host.name))
try:
vm.migrate(self.apiclient, host.id)
except Exception as e:
self.fail("Failed to migrate instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_after_migrate = account_list[0].cputotal
self.assertEqual(resource_count, resource_count_after_migrate,
"Resource count should be same after starting the instance")
return
示例9: test_03_multiple_core_vm_delete_instance
def test_03_multiple_core_vm_delete_instance(self):
"""Test Deploy VM with 4 core CPU & verify the usage"""
# Validate the following
# 1. Create two domains and set specific resource (cpu) limit for them
# 2. Create compute offering with 4 core CPU & deploy vm
# 3. Update Resource count for the domains
# 4. delete instance and check resource count
# 5. Resource count should list properly.
self.debug("Setting up account and domain hierarchy")
self.setupAccounts()
users = {self.domain: self.admin,
self.child_domain: self.child_do_admin
}
for domain, admin in users.items():
self.account = admin
self.domain = domain
api_client = self.testClient.createUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
self.debug("Creating an instance with service offering: %s" %
self.service_offering.name)
vm = self.createInstance(service_off=self.service_offering, api_client=api_client)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count = account_list[0].cputotal
expected_resource_count = int(self.services["service_offering"]["cpunumber"])
self.assertEqual(resource_count, expected_resource_count,
"Initial resource count should with the expected resource count")
self.debug("Destroying instance: %s" % vm.name)
try:
vm.delete(self.apiclient)
except Exception as e:
self.fail("Failed to delete instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_after_delete = account_list[0].cputotal
self.assertEqual(resource_count_after_delete, 0,
"Resource count for %s should be 0" % get_resource_type(resource_id=8))#CPU
return
示例10: test_01_multiplecore_start_stop_instance
def test_01_multiplecore_start_stop_instance(self):
"""Test Deploy VM with multiple core CPU & verify the usage"""
# Validate the following
# 1. Deploy VM with multiple core CPU & verify the usage
# 2. Stop VM & verify the update resource count of Root Admin Account
# 3. Start VM & verify the update resource count of Root Admin Account
# 4. Resource count should list properly.
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count = account_list[0].cputotal
expected_resource_count = int(self.services["service_offering"]["cpunumber"])
self.assertEqual(resource_count, expected_resource_count,
"Resource count should match with the expected resource count")
self.debug("Stopping instance: %s" % self.vm.name)
try:
self.vm.stop(self.apiclient)
except Exception as e:
self.fail("Failed to stop instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_after_stop = account_list[0].cputotal
self.assertEqual(resource_count, resource_count_after_stop,
"Resource count should be same after stopping the instance")
self.debug("Starting instance: %s" % self.vm.name)
try:
self.vm.start(self.apiclient)
except Exception as e:
self.fail("Failed to start instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_after_start = account_list[0].cputotal
self.assertEqual(resource_count, resource_count_after_start,
"Resource count should be same after stopping the instance")
return
示例11: test_03_delete_instance
def test_03_delete_instance(self):
"""Test Deploy VM with 4 core CPU & verify the usage"""
# Validate the following
# 1. Create compute offering with 4 core CPU & Deploy VM
# 2. List Resource count for the CPU usage
# 3. Delete instance
# 4. Resource count should list as 0
self.debug("Setting up account and domain hierarchy")
self.setupAccounts()
users = {
self.child_domain_1: self.child_do_admin_1,
self.child_domain_2: self.child_do_admin_2
}
for domain, admin in users.items():
self.account = admin
self.domain = domain
api_client = self.testClient.createUserApiClient(
UserName=self.account.name, DomainName=self.account.domain)
self.debug("Creating an instance with service offering: %s" %
self.service_offering.name)
vm = self.createInstance(
service_off=self.service_offering, api_client=api_client)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list, list,
"List Accounts should return a valid response")
resource_count = account_list[0].cputotal
expected_resource_count = int(
self.services["service_offering"]["cpunumber"])
self.assertEqual(
resource_count, expected_resource_count,
"Initial resource count should match with the expected resource count"
)
self.debug("Destroying instance: %s" % vm.name)
try:
vm.delete(self.apiclient)
except Exception as e:
self.fail("Failed to delete instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list, list,
"List Accounts should return a valid response")
resource_count = account_list[0].cputotal
self.assertEqual(resource_count, 0, "Resource count for %s should be 0"
% get_resource_type(resource_id=8)) #CPU
return
示例12: setupAccounts
def setupAccounts(self):
self.debug("Creating a sub-domain under: %s" % self.domain.name)
self.child_domain = Domain.create(
self.apiclient,
services=self.services["domain"],
parentdomainid=self.domain.id
)
self.child_do_admin = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.child_domain.id
)
# Cleanup the resources created at end of test
self.cleanup.append(self.child_do_admin)
self.cleanup.append(self.child_domain)
Resources.updateLimit(
self.apiclient,
resourcetype=8,
max=16,
account=self.child_do_admin.name,
domainid=self.child_do_admin.domainid
)
self.domain = Domain.create(
self.apiclient,
services=self.services["domain"],
parentdomainid=self.domain.id
)
self.admin = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.domain.id
)
# Cleanup the resources created at end of test
self.cleanup.append(self.admin)
self.cleanup.append(self.domain)
Resources.updateLimit(
self.apiclient,
resourcetype=8,
max=16,
account=self.admin.name,
domainid=self.admin.domainid
)
return
示例13: test_01_stop_start_instance
def test_01_stop_start_instance(self):
"""Test Deploy VM with specified RAM & verify the usage"""
# Validate the following
# 1. Create compute offering with specified RAM & Deploy VM as root admin
# 2 .List Resource count for the root admin Memory usage
# 3. Stop and start instance, resource count should list properly.
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count = account_list[0].memorytotal
expected_resource_count = int(self.services["service_offering"]["memory"])
self.assertEqual(resource_count, expected_resource_count,
"Resource count should match with the expected resource count")
self.debug("Stopping instance: %s" % self.vm.name)
try:
self.vm.stop(self.apiclient)
except Exception as e:
self.fail("Failed to stop instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_after_stop = account_list[0].memorytotal
self.assertEqual(resource_count, resource_count_after_stop,
"Resource count should be same after stopping the instance")
self.debug("Starting instance: %s" % self.vm.name)
try:
self.vm.start(self.apiclient)
except Exception as e:
self.fail("Failed to start instance: %s" % e)
account_list = Account.list(self.apiclient, id=self.account.id)
self.assertIsInstance(account_list,
list,
"List Accounts should return a valid response"
)
resource_count_after_start = account_list[0].memorytotal
self.assertEqual(resource_count, resource_count_after_start,
"Resource count should be same after stopping the instance")
return
示例14: setupProjectAccounts
def setupProjectAccounts(self):
self.debug("Creating a domain under: %s" % self.domain.name)
self.domain = Domain.create(self.apiclient,
services=self.services["domain"],
parentdomainid=self.domain.id)
self.admin = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.domain.id
)
# Create project as a domain admin
self.project = Project.create(self.apiclient,
self.services["project"],
account=self.admin.name,
domainid=self.admin.domainid)
# Cleanup created project at end of test
self.cleanup.append(self.project)
self.cleanup.append(self.admin)
self.cleanup.append(self.domain)
self.debug("Created project with domain admin with name: %s" %
self.project.name)
projects = Project.list(self.apiclient, id=self.project.id,
listall=True)
self.assertEqual(isinstance(projects, list), True,
"Check for a valid list projects response")
project = projects[0]
self.assertEqual(project.name, self.project.name,
"Check project name from list response")
return
示例15: setUp
def setUp(self):
self.testdata = TestData().testdata
self.apiclient = self.testClient.getApiClient()
# Get Zone, Domain and Default Built-in template
self.domain = get_domain(self.apiclient, self.testdata)
self.zone = get_zone(self.apiclient, self.testdata)
self.testdata["mode"] = self.zone.networktype
self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"])
#create a user account
self.account = Account.create(
self.apiclient,
self.testdata["account"],
domainid=self.domain.id
)
#create a service offering
self.service_offering = ServiceOffering.create(
self.apiclient,
self.testdata["service_offering"]["small"]
)
#build cleanup list
self.cleanup = [
self.service_offering,
self.account
]