本文整理汇总了Python中marvin.lib.base.Domain类的典型用法代码示例。如果您正苦于以下问题:Python Domain类的具体用法?Python Domain怎么用?Python Domain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Domain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupAccounts
def setupAccounts(self):
self.debug("Creating a 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.debug("Creating a domain under: %s" % self.domain.name)
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
示例2: 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
示例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)
示例4: 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
示例5: setupAccounts
def setupAccounts(self):
try:
self.parent_domain = Domain.create(
self.apiclient,
services=self.services["domain"],
parentdomainid=self.domain.id)
self.parentd_admin = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.parent_domain.id)
# Create sub-domains and their admin accounts
self.cdomain_1 = Domain.create(
self.apiclient,
services=self.services["domain"],
parentdomainid=self.parent_domain.id)
self.cdomain_2 = Domain.create(
self.apiclient,
services=self.services["domain"],
parentdomainid=self.parent_domain.id)
self.cadmin_1 = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.cdomain_1.id)
self.cadmin_2 = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.cdomain_2.id)
# 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.cdomain_1: self.cadmin_1,
self.cdomain_2: self.cadmin_2
}
except Exception as e:
return [FAIL, e, None]
return [PASS, None, users]
示例6: test_01_ldap
def test_01_ldap(self):
"""Check the linkDomainToLdap functionality"""
self.domain1 = Domain.create(
self.apiclient,
services=self.services["domain"],
parentdomainid=self.domain.id)
self.ldaplink4 = linkDomainToLdap.linkDomainToLdapCmd()
self.ldaplink4.domainid = self.domain1.id
self.ldaplink4.accounttype = self.services[
"configurableData"]["link_ldap_details"]["accounttype"]
self.ldaplink4.name = self.services[
"configurableData"]["link_ldap_details"]["name"]
self.ldaplink4.type = self.services[
"configurableData"]["link_ldap_details"]["type"]
if self.services["configurableData"][
"link_ldap_details"]["admin"] is not None:
self.ldaplink4.admin = self.services[
"configurableData"]["link_ldap_details"]["admin"]
try:
self.ldaplinkRes4 = self.apiClient.linkDomainToLdap(self.ldaplink4)
except Exception as e:
raise Exception(
"Linking LDAP failed,please check the configuration")
try:
self.domain1.delete(self.apiclient)
except Exception as e:
raise Exception(
"Warning: Exception during deletion of domain : %s" % e)
示例7: setUpClass
def setUpClass(cls):
cls.testClient = super(TestResourceLimitsProject, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
cls.services["server"]["zoneid"] = cls.zone.id
# Create Domains, Account etc
cls.domain = Domain.create(cls.api_client, cls.services["domain"])
cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
cls.userapiclient = cls.testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.account.domain)
# Create project as a domain admin
cls.project = Project.create(
cls.api_client, cls.services["project"], account=cls.account.name, domainid=cls.account.domainid
)
cls.services["account"] = cls.account.name
# Create Service offering and disk offerings etc
cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"])
cls._cleanup = [cls.project, cls.service_offering, cls.disk_offering, cls.account, cls.domain]
return
示例8: test_es_1863_register_template_s3_domain_admin_user
def test_es_1863_register_template_s3_domain_admin_user(self):
"""
@Desc: Test whether cloudstack allows Domain admin or user
to register a template using S3/Swift object store.
@Steps:
Step1: create a Domain and users in it.
Step2: Register a template as Domain admin.
Step3: Register a template as Domain user.
Step4: Template should be registered successfully.
"""
# Step1: create a Domain and users in it.
self.newdomain = Domain.create(self.apiClient,
self.services["domain"])
# create account in the domain
self.account_domain = Account.create(
self.apiClient,
self.services["account"],
domainid=self.newdomain.id
)
self.cleanup.append(self.account_domain)
self.cleanup.append(self.newdomain)
# Getting authentication for user in newly created Account in domain
self.domain_user = self.account_domain.user[0]
self.domain_userapiclient = self.testClient.getUserApiClient(
self.domain_user.username, self.newdomain.name
)
# Step2: Register a template as Domain admin.
self.services["templateregister"]["ostype"] = self.services["ostype"]
self.domain_template = Template.register(
self.apiClient,
self.services["templateregister"],
zoneid=self.zone.id,
account=self.account_domain.name,
domainid=self.newdomain.id,
hypervisor=self.hypervisor
)
# Wait for template to download
self.domain_template.download(self.api_client)
# Wait for template status to be changed across
time.sleep(60)
# Step3: Register a template as Domain user.
self.domain_user_template = Template.register(
self.domain_userapiclient,
self.services["templateregister"],
zoneid=self.zone.id,
account=self.account_domain.name,
domainid=self.newdomain.id,
hypervisor=self.hypervisor
)
# Wait for template to download
self.domain_user_template.download(self.api_client)
# Wait for template status to be changed across
time.sleep(60)
# TODO: Step4: Template should be registered successfully.
return
示例9: setUpClass
def setUpClass(cls):
cls.testClient = super(TestPublicIpAddress, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
cls.services["server"]["zoneid"] = cls.zone.id
# Create Domains, Account etc
cls.domain = Domain.create(cls.api_client, cls.services["domain"])
cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
# Create project as a domain admin
cls.project = Project.create(
cls.api_client, cls.services["project"], account=cls.account.name, domainid=cls.account.domainid
)
cls.services["account"] = cls.account.name
# Create Service offering and disk offerings etc
cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
cls.virtual_machine = VirtualMachine.create(
cls.api_client,
cls.services["server"],
templateid=cls.template.id,
serviceofferingid=cls.service_offering.id,
projectid=cls.project.id,
)
cls._cleanup = [cls.project, cls.service_offering, cls.account, cls.domain]
return
示例10: setUpClass
def setUpClass(cls):
cls._cleanup = []
cls.testClient = super(TestEgressFWRules, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Get and set template id for VM creation.
cls.template = get_template(cls.api_client,
cls.zone.id,
cls.services["ostype"])
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
parentDomain = None
cls.domain = Domain.create(cls.api_client,
cls.services["domain"],
parentdomainid=parentDomain.id if parentDomain else None)
cls._cleanup.append(cls.domain)
# Create an Account associated with domain
cls.account = Account.create(cls.api_client,
cls.services["account"],
domainid=cls.domain.id)
cls._cleanup.append(cls.account)
# Create service offerings.
cls.service_offering = ServiceOffering.create(cls.api_client,
cls.services["service_offering"])
# Cleanup
cls._cleanup.append(cls.service_offering)
示例11: setupAccounts
def setupAccounts(self, account_limit=2, domain_limit=2, project_limit=2):
self.debug("Creating a domain under: %s" % self.domain.name)
self.child_domain = Domain.create(self.apiclient,
services=self.testdata["domain"],
parentdomainid=self.domain.id)
self.debug("domain crated with domain id %s" % self.child_domain.id)
self.child_do_admin = Account.create(self.apiclient,
self.testdata["account"],
admin=True,
domainid=self.child_domain.id)
self.debug("domain admin created for domain id %s" %
self.child_do_admin.domainid)
# Create project as a domain admin
self.project = Project.create(self.apiclient,
self.testdata["project"],
account=self.child_do_admin.name,
domainid=self.child_do_admin.domainid)
# Cleanup created project at end of test
self.cleanup.append(self.project)
# Cleanup accounts created
self.cleanup.append(self.child_do_admin)
self.cleanup.append(self.child_domain)
self.debug("Updating the CPU resource count for domain: %s" %
self.child_domain.name)
# Update resource limits for account 1
responses = Resources.updateLimit(self.apiclient,
resourcetype=8,
max=account_limit,
account=self.child_do_admin.name,
domainid=self.child_do_admin.domainid)
self.debug("CPU Resource count for child domain admin account is now: %s" %
responses.max)
self.debug("Updating the CPU limit for project")
responses = Resources.updateLimit(self.apiclient,
resourcetype=8,
max=project_limit,
projectid=self.project.id)
self.debug("CPU Resource count for project is now")
self.debug(responses.max)
self.debug("Updating the CPU limit for domain only")
responses = Resources.updateLimit(self.apiclient,
resourcetype=8,
max=domain_limit,
domainid=self.child_domain.id)
self.debug("CPU Resource count for domain %s with id %s is now %s" %
(responses.domain, responses.domainid, responses.max))
return
示例12: setupAccounts
def setupAccounts(self):
try:
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)
self.userapiclient = self.testClient.getUserApiClient(
UserName=self.child_do_admin.name,
DomainName=self.child_do_admin.domain)
# Create project as a domain admin
self.project = Project.create(self.apiclient, self.services["project"],
account=self.child_do_admin.name,
domainid=self.child_do_admin.domainid)
# Cleanup created project at end of test
self.cleanup.append(self.project)
# Cleanup accounts created
self.cleanup.append(self.child_do_admin)
self.cleanup.append(self.child_domain)
except Exception as e:
return [FAIL, e]
return [PASS, None]
示例13: setupAccount
def setupAccount(self, accountType):
"""Setup the account required for the test"""
try:
if accountType == CHILD_DOMAIN_ADMIN:
self.domain = Domain.create(self.apiclient,
services=self.services["domain"],
parentdomainid=self.domain.id)
self.account = Account.create(self.apiclient, self.services["account"],
domainid=self.domain.id, admin=True)
self.cleanup.append(self.account)
if accountType == CHILD_DOMAIN_ADMIN:
self.cleanup.append(self.domain)
self.virtualMachine = VirtualMachine.create(self.api_client, self.services["virtual_machine"],
accountid=self.account.name, domainid=self.account.domainid,
diskofferingid=self.disk_offering.id,
serviceofferingid=self.service_offering.id)
accounts = Account.list(self.apiclient, id=self.account.id)
self.assertEqual(validateList(accounts)[0], PASS,
"accounts list validation failed")
self.initialResourceCount = int(accounts[0].primarystoragetotal)
except Exception as e:
return [FAIL, e]
return [PASS, None]
示例14: create_domain_account_user
def create_domain_account_user(parentDomain=None):
domain = Domain.create(cls.api_client,
cls.services["domain"],
parentdomainid=parentDomain.id if parentDomain else None)
cls._cleanup.append(domain)
# Create an Account associated with domain
account = Account.create(cls.api_client,
cls.services["account"],
domainid=domain.id)
cls._cleanup.append(account)
# Create an User, Project, Volume associated with account
user = User.create(cls.api_client,
cls.services["user"],
account=account.name,
domainid=account.domainid)
cls._cleanup.append(user)
project = Project.create(cls.api_client,
cls.services["project"],
account=account.name,
domainid=account.domainid)
cls._cleanup.append(project)
volume = Volume.create(cls.api_client,
cls.services["volume"],
zoneid=cls.zone.id,
account=account.name,
domainid=account.domainid,
diskofferingid=cls.disk_offering.id)
cls._cleanup.append(volume)
return {'domain':domain, 'account':account, 'user':user, 'project':project, 'volume':volume}
示例15: setUp
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
self.services = Services().services
# Get Zone, Domain and templates
self.domain = get_domain(self.apiclient)
self.account = Account.create(
self.apiclient,
self.services["account"],
domainid=self.domain.id
)
self.newdomain = Domain.create(
self.apiclient,
self.services["testdomain"],
parentdomainid=self.domain.id
)
self.newdomain_account = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.newdomain.id
)
self.cleanup = [
self.account,
self.newdomain_account,
self.newdomain,
]