def chown(self): new_user = '******' test_path = self.hdfs_paths[0] hdfs.dump(self.data, test_path, mode="wb") hdfs.chown(test_path, user=new_user) path_info = hdfs.lsl(test_path)[0] self.assertEqual(path_info['owner'], new_user) prev_owner = path_info['owner'] prev_grp = path_info['group'] # owner and group should remain unchanged hdfs.chown(test_path, user='', group='') path_info = hdfs.lsl(test_path)[0] self.assertEqual(path_info['owner'], prev_owner) self.assertEqual(path_info['group'], prev_grp)
def chown(self): new_user = '******' test_path = self.hdfs_paths[0] hdfs.dump(self.data, test_path) hdfs.chown(test_path, user=new_user) path_info = hdfs.lsl(test_path)[0] self.assertEqual(path_info['owner'], new_user) prev_owner = path_info['owner'] prev_grp = path_info['group'] # owner and group should remain unchanged hdfs.chown(test_path, user='', group='') path_info = hdfs.lsl(test_path)[0] self.assertEqual(path_info['owner'], prev_owner) self.assertEqual(path_info['group'], prev_grp)
def chown(hdfs_path, user, group, project=None): """ Change file owner and group. Args: :hdfs_path: You can specify either a full hdfs pathname or a relative one (relative to the given project path in HDFS). :user: New hdfs username :group: New hdfs group :project: If this value is not specified, it will get the path to your project. If you need to path to another project, you can specify the name of the project as a string. """ if project == None: project = project_name() hdfs_path = _expand_path(hdfs_path, project) return hdfs.chown(hdfs_path, user, group)
def chown(self, path, uid, gid): '''Filter for unchanged uids and gids (-1)''' st = hdfs.stat(path) if uid == -1: if gid == -1: hdfs.chown(path) else: group= self._G2h_g(gid) hdfs.chown(path,group=group) else: user = self._U2h_u(uid) if gid == -1: hdfs.chown(path,user) else: group= self._G2h_g(gid) hdfs.chown(path, user, group)