def create_obj(sess, path, kind=NF4DIR, attrs={FATTR4_MODE:0755}): """Return ops needed to create given non-file object""" # Ensure using createtype4 if not hasattr(kind, "type"): kind = createtype4(kind) ops = use_obj(path[:-1]) + [op.create(kind, path[-1], attrs)] return sess.compound(ops)
def make_root(self, attrs={FATTR4_MODE:0777}): existing_path = [] kind = createtype4(NF4DIR) for comp in self.path: existing_path.append(comp) res = self.execute(nfs4lib.use_obj(existing_path), exceptions=[NFS4ERR_NOENT]) if res.status == NFS4ERR_NOENT: cr_ops = nfs4lib.use_obj(existing_path[:-1]) + \ [op.create(kind, comp, attrs)] self.execute(cr_ops) res = self.execute(nfs4lib.use_obj(self.path) + [op.getfh()]) self.path_fh = res.resarray[-1].object need = ACCESS4_READ | ACCESS4_LOOKUP | ACCESS4_MODIFY | ACCESS4_EXTEND res = self.execute(nfs4lib.use_obj(self.path_fh) + [op.access(need)]) if res.resarray[-1].access != need: raise RuntimeError
def make_root(self, attrs={FATTR4_MODE: 0777}): existing_path = [] kind = createtype4(NF4DIR) for comp in self.path: existing_path.append(comp) res = self.execute(nfs4lib.use_obj(existing_path), exceptions=[NFS4ERR_NOENT]) if res.status == NFS4ERR_NOENT: cr_ops = nfs4lib.use_obj(existing_path[:-1]) + \ [op.create(kind, comp, attrs)] self.execute(cr_ops) res = self.execute(nfs4lib.use_obj(self.path) + [op.getfh()]) self.path_fh = res.resarray[-1].object need = ACCESS4_READ | ACCESS4_LOOKUP | ACCESS4_MODIFY | ACCESS4_EXTEND res = self.execute(nfs4lib.use_obj(self.path_fh) + [op.access(need)]) if res.resarray[-1].access != need: raise RuntimeError