def create_user(uname, db): """Helper function to create some system users we need in VH. uname will be owned by the system group andit will have been created by the system account. """ account = Account(db) constants = Factory.get("Constants")() try: account.find_by_name(uname) logger.debug("Found account with name=%s, id=%s", account.account_name, account.entity_id) return except Errors.NotFoundError: sys_group = get_system_group(db) sys_account = get_system_account(db) account.populate(uname, constants.entity_group, # owned by sys_group.entity_id, # ... system group constants.account_program, sys_account.entity_id, # created by system account None) # no expire (duh!) account.write_db() logger.debug("Created account uname=%s, id=%s", account.account_name, account.entity_id) logger.debug("Don't forget to set a password on uname=%s", account.account_name)
def create_user(uname, db): """Helper function to create some system users we need in VH. uname will be owned by the system group andit will have been created by the system account. """ account = Account(db) constants = Factory.get("Constants")() try: account.find_by_name(uname) logger.debug("Found account with name=%s, id=%s", account.account_name, account.entity_id) return except Errors.NotFoundError: sys_group = get_system_group(db) sys_account = get_system_account(db) account.populate( uname, constants.entity_group, # owned by sys_group.entity_id, # ... system group constants.account_program, sys_account.entity_id, # created by system account None) # no expire (duh!) account.write_db() logger.debug("Created account uname=%s, id=%s", account.account_name, account.entity_id) logger.debug("Don't forget to set a password on uname=%s", account.account_name)
def prepare_empty(db, args): """This function constructs a destination group if it doesn't exist.""" co = Factory.get('Constants')(db) gr = Factory.get('Group')(db) try: gr.find_by_name(args.destination_group) except Errors.NotFoundError: bootstrap_ac = Account(db) bootstrap_ac.find_by_name(cereconf.INITIAL_ACCOUNTNAME) gr.populate( creator_id=bootstrap_ac.entity_id, visibility=co.group_visibility_all, name=args.destination_group, description=('Flattened variant of %s' % args.target_group), group_type=co.group_type_derived, ) gr.write_db()