def main(conninfo, credentials, args): user_id = users.get_id(conninfo, credentials, args.id) if args.password is not None: password = args.password else: password = \ qumulo.lib.opts.read_password("New password for %s: " % args.id) users.set_user_password(conninfo, credentials, user_id.data, password) print "Changed password for %s" % args.id
def main(conninfo, credentials, args): # Get existing share share_info = {} share_info, share_info['if_match'] = \ shares.nfs_list_share(conninfo, credentials, args.id) # Modify share share_info['id_'] = share_info['id'] share_info['allow_fs_path_create'] = args.create_fs_path del share_info['id'] if args.export_path is not None: share_info['export_path'] = args.export_path if args.fs_path is not None: share_info['fs_path'] = args.fs_path if args.description is not None: share_info['description'] = args.description if args.read_only is not None: share_info['read_only'] = \ qumulo.lib.util.bool_from_string(args.read_only) if args.host_restrictions is not None: share_info['host_restrictions'] = args.host_restrictions.split(',') if args.user_mapping is not None: share_info['user_mapping'] = \ convert_nfs_user_mapping(args.user_mapping) if args.map_to_user_id is not None: # Allow either auth_id or user name user_id = users.get_id(conninfo, credentials, args.map_to_user_id) share_info['map_to_user_id'] = str(user_id.data) # Ensure mapping arguments are a valid combination if share_info['user_mapping'] == 'NFS_MAP_NONE': # Mapping = None: ensure ID arg wasn't specified. if args.map_to_user_id is not None: raise ValueError( '--map-to-user-id is only valid when mapping user') # If unspecified, clear it automatically. share_info['map_to_user_id'] = '0' else: # Mapping > None: ensure ID arg isn't 0. if share_info['map_to_user_id'] == '0': raise ValueError('--user-mapping requires --map-to-user-id') print shares.nfs_modify_share(conninfo, credentials, **share_info)
def main(conninfo, credentials, args): # Get the user object user_id = users.get_id(conninfo, credentials, args.id) user_info, etag = users.list_user(conninfo, credentials, user_id.data) # Modify the user object according to specified arguments name = user_info['name'] if args.name is not None: name = args.name primary_group = user_info['primary_group'] if args.primary_group is not None: primary_group = str(groups.get_id( conninfo, credentials, args.primary_group).data) uid = user_info['uid'] if args.uid is not None: uid = args.uid.strip() if uid.lower() == 'none': uid = '' # Set the user object, ignore output users.modify_user(conninfo, credentials, user_id.data, name, primary_group, uid, etag) # Add specified groups, ignore output if args.add_group: group_id = groups.get_id(conninfo, credentials, args.add_group) groups.group_add_member(conninfo, credentials, group_id.data, user_id.data) # Remove specified groups, ignore output if args.remove_group: group_id = groups.get_id(conninfo, credentials, args.remove_group) groups.group_remove_member(conninfo, credentials, group_id.data, user_id.data) # Print out the new user object list_user(conninfo, credentials, user_id.data)
def main(conninfo, credentials, args): user_mapping = convert_nfs_user_mapping(args.user_mapping) if user_mapping is not 'NFS_MAP_NONE' and not args.map_to_user_id: raise ValueError('--user-mapping requires --map-to-user-id') if user_mapping is 'NFS_MAP_NONE' and args.map_to_user_id: raise ValueError( '--map-to-user-id is only valid when mapping user') host_restrictions = [] if args.host_restrictions is None else \ args.host_restrictions.split(',') # Allow either auth_id or user name user_id = users.get_id(conninfo, credentials, args.map_to_user_id) print shares.nfs_add_share(conninfo, credentials, args.export_path, args.fs_path, args.description, args.read_only, host_restrictions, user_mapping, user_id.data, args.create_fs_path)
def main(conninfo, credentials, args): user_id = users.get_id(conninfo, credentials, args.id) users.delete_user(conninfo, credentials, user_id.data) print "User was deleted."
def main(conninfo, credentials, args): user_id = users.get_id(conninfo, credentials, args.id) list_user(conninfo, credentials, user_id.data)