Difference between revisions of "ZenDMD Tip - Create Users in a Jiffy"

From Zenoss Wiki
Jump to: navigation, search
m
(Noting this is generally frowned upon)
 
Line 1: Line 1:
 +
'''Generally this sort of process is deprecated. Please use the Zenoss JSON API instead'''
 +
 
On the master, `su zenoss` then `zendmd`
 
On the master, `su zenoss` then `zendmd`
  

Latest revision as of 16:19, 9 December 2016

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:
    sync()
    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)
    commit()