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

Class Account

tools/marvin/marvin/lib/base.py:198–275  ·  view source on GitHub ↗

Account Life Cycle

Source from the content-addressed store, hash-verified

196
197
198class Account:
199 """ Account Life Cycle """
200
201 def __init__(self, items):
202 self.__dict__.update(items)
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"""
246 cmd = deleteAccount.deleteAccountCmd()
247 cmd.id = self.id
248 apiclient.deleteAccount(cmd)
249
250 @classmethod
251 def list(cls, apiclient, **kwargs):
252 """Lists accounts and provides detailed account information for
253 listed accounts"""
254
255 cmd = listAccounts.listAccountsCmd()

Callers 6

create_accountMethod · 0.90
test_01_manualMethod · 0.90
test_02_importMethod · 0.90
bind_account_to_ldapMethod · 0.90
createMethod · 0.70
setUpClassMethod · 0.50

Implementers 1

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

Calls

no outgoing calls

Tested by 4

test_01_manualMethod · 0.72
test_02_importMethod · 0.72
bind_account_to_ldapMethod · 0.72
setUpClassMethod · 0.40