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

Method create

tools/marvin/marvin/lib/base.py:205–242  ·  view source on GitHub ↗

Creates an account

(cls, apiclient, services, admin=False, domainid=None, roleid=None, account=None)

Source from the content-addressed store, hash-verified

203
204 @classmethod
205 def create(cls, apiclient, services, admin=False, domainid=None, roleid=None, account=None):
206 """Creates an account"""
207 cmd = createAccount.createAccountCmd()
208
209 # 0 - User, 1 - Root Admin, 2 - Domain Admin
210 cmd.accounttype = 2 if (admin and domainid) else int(admin)
211
212 cmd.email = services["email"]
213 cmd.firstname = services["firstname"]
214 cmd.lastname = services["lastname"]
215
216 cmd.password = services["password"]
217 username = services["username"]
218 # Limit account username to 99 chars to avoid failure
219 # 6 chars start string + 85 chars apiclientid + 6 chars random string + 2 chars joining hyphen string = 99
220 username = username[:6]
221 apiclientid = apiclient.id[-85:] if len(apiclient.id) > 85 else apiclient.id
222 cmd.username = "-".join([username,
223 random_gen(id=apiclientid, size=6)])
224
225 if "accountUUID" in services:
226 cmd.accountid = "-".join([services["accountUUID"], random_gen()])
227
228 if "userUUID" in services:
229 cmd.userid = "-".join([services["userUUID"], random_gen()])
230
231 if domainid:
232 cmd.domainid = domainid
233
234 if roleid:
235 cmd.roleid = roleid
236
237 if account:
238 cmd.account = account
239
240 account = apiclient.createAccount(cmd)
241
242 return Account(account.__dict__)
243
244 def delete(self, apiclient):
245 """Delete an account"""

Callers

nothing calls this directly

Implementers 1

AccountVOengine/schema/src/main/java/com/cloud/

Calls 5

random_genFunction · 0.90
intFunction · 0.85
AccountClass · 0.70
createAccountMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected