ZenDMD Tip - Create Users in a Jiffy

From Zenoss Wiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

Generally this sort of process is deprecated. Please use the Zenoss JSON API instead

On the master, `su zenoss` then `zendmd`

usersToAdd are the usernames to add, emailDomain is the second half of the users' email addresses, and the defaultRoles are the roles the users should have.

usersToAdd = ['testUserA', 'testUserB', 'testUserC']
emailDomain = 'company.com'
defaultRoles = ['ZenUser',]
roleManager = dmd.acl_users.roleManager
for user in usersToAdd:
    un = str(user)
    ue = '%s@%s' % (str(un), str(emailDomain))
    print 'Adding user %s, email %s' % (str(un), str(ue))
    userOb = dmd.ZenUsers.manage_addUser(un, email=ue, roles=defaultRoles)