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

Class User

tools/marvin/marvin/lib/base.py:278–368  ·  view source on GitHub ↗

User Life Cycle

Source from the content-addressed store, hash-verified

276
277
278class User:
279 """ User Life Cycle """
280
281 def __init__(self, items):
282 self.__dict__.update(items)
283
284 @classmethod
285 def create(cls, apiclient, services, account, domainid):
286 cmd = createUser.createUserCmd()
287 """Creates an user"""
288
289 cmd.account = account
290 cmd.domainid = domainid
291 cmd.email = services["email"]
292 cmd.firstname = services["firstname"]
293 cmd.lastname = services["lastname"]
294
295 if "userUUID" in services:
296 cmd.userid = "-".join([services["userUUID"], random_gen()])
297
298 cmd.password = services["password"]
299 cmd.username = "-".join([services["username"], random_gen()])
300 user = apiclient.createUser(cmd)
301
302 return User(user.__dict__)
303
304 def delete(self, apiclient):
305 """Delete an account"""
306 cmd = deleteUser.deleteUserCmd()
307 cmd.id = self.id
308 apiclient.deleteUser(cmd)
309
310 def move(self, api_client, dest_accountid=None, dest_account=None, domain=None):
311
312 if all([dest_account, dest_accountid]) is None:
313 raise Exception("Please add either destination account or destination account ID.")
314
315 cmd = moveUser.moveUserCmd()
316 cmd.id = self.id
317 cmd.accountid = dest_accountid
318 cmd.account = dest_account
319 cmd.domain = domain
320
321 return api_client.moveUser(cmd)
322
323 @classmethod
324 def list(cls, apiclient, **kwargs):
325 """Lists users and provides detailed account information for
326 listed users"""
327
328 cmd = listUsers.listUsersCmd()
329 [setattr(cmd, k, v) for k, v in list(kwargs.items())]
330 if 'account' in list(kwargs.keys()) and 'domainid' in list(kwargs.keys()):
331 cmd.listall = True
332 return (apiclient.listUsers(cmd))
333
334 @classmethod
335 def registerUserKeys(cls, apiclient, userid):

Callers 3

test_03_syncMethod · 0.90
createMethod · 0.70

Implementers 1

UserVOengine/schema/src/main/java/com/cloud/

Calls

no outgoing calls

Tested by 2

test_03_syncMethod · 0.72