MCPcopy Create free account
hub / github.com/apache/cloudstack / Domain

Class Domain

tools/marvin/marvin/lib/base.py:36–91  ·  view source on GitHub ↗

Domain Life Cycle

Source from the content-addressed store, hash-verified

34
35
36class Domain:
37 """ Domain Life Cycle """
38
39 def __init__(self, items):
40 self.__dict__.update(items)
41
42 @classmethod
43 def create(cls, apiclient, services, name=None, networkdomain=None,
44 parentdomainid=None, domainid=None):
45 """Creates an domain"""
46
47 cmd = createDomain.createDomainCmd()
48
49 if "domainUUID" in services:
50 cmd.domainid = "-".join([services["domainUUID"], random_gen()])
51
52 if name:
53 cmd.name = "-".join([name, random_gen()])
54 elif "name" in services:
55 cmd.name = "-".join([services["name"], random_gen()])
56
57 if networkdomain:
58 cmd.networkdomain = networkdomain
59 elif "networkdomain" in services:
60 cmd.networkdomain = services["networkdomain"]
61
62 if parentdomainid:
63 cmd.parentdomainid = parentdomainid
64 elif "parentdomainid" in services:
65 cmd.parentdomainid = services["parentdomainid"]
66
67 if domainid:
68 cmd.domainid = domainid
69 try:
70 domain = apiclient.createDomain(cmd)
71 if domain is not None:
72 return Domain(domain.__dict__)
73 except Exception as e:
74 raise e
75
76 def delete(self, apiclient, cleanup=None):
77 """Delete an domain"""
78 cmd = deleteDomain.deleteDomainCmd()
79 cmd.id = self.id
80 if cleanup:
81 cmd.cleanup = cleanup
82 apiclient.deleteDomain(cmd)
83
84 @classmethod
85 def list(cls, apiclient, **kwargs):
86 """Lists domains"""
87 cmd = listDomains.listDomainsCmd()
88 [setattr(cmd, k, v) for k, v in list(kwargs.items())]
89 if 'account' in list(kwargs.keys()) and 'domainid' in list(kwargs.keys()):
90 cmd.listall = True
91 return (apiclient.listDomains(cmd))
92
93

Callers 1

createMethod · 0.70

Implementers 1

DomainVOengine/schema/src/main/java/com/cloud/

Calls

no outgoing calls

Tested by

no test coverage detected