Skip to content

Commit

Permalink
make use of EosBinary and XrdcopyBinary (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
madsi1m authored and labkode committed Nov 8, 2019
1 parent e56ca76 commit fb46ee7
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pkg/eosclient/eosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (c *Client) AddACL(ctx context.Context, username, path string, a *acl.Entry
return err
}

cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "attr", "-r", "set", fmt.Sprintf("sys.acl=%s", sysACL), path)
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "attr", "-r", "set", fmt.Sprintf("sys.acl=%s", sysACL), path)
_, _, err = c.executeEOS(ctx, cmd)
return err

Expand All @@ -278,7 +278,7 @@ func (c *Client) RemoveACL(ctx context.Context, username, path string, aclType s
return err
}

cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "attr", "-r", "set", fmt.Sprintf("sys.acl=%s", sysACL), path)
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "attr", "-r", "set", fmt.Sprintf("sys.acl=%s", sysACL), path)
_, _, err = c.executeEOS(ctx, cmd)
return err

Expand Down Expand Up @@ -360,7 +360,7 @@ func (c *Client) GetFileInfoByInode(ctx context.Context, username string, inode
if err != nil {
return nil, err
}
cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "file", "info", fmt.Sprintf("inode:%d", inode), "-m")
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "file", "info", fmt.Sprintf("inode:%d", inode), "-m")
stdout, _, err := c.executeEOS(ctx, cmd)
if err != nil {
return nil, err
Expand All @@ -374,7 +374,7 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, username, path string) (
if err != nil {
return nil, err
}
cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "file", "info", path, "-m")
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "file", "info", path, "-m")
stdout, _, err := c.executeEOS(ctx, cmd)
if err != nil {
return nil, err
Expand All @@ -389,7 +389,7 @@ func (c *Client) GetQuota(ctx context.Context, username, path string) (int, int,
if err != nil {
return 0, 0, err
}
cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "quota", "ls", "-u", username, "-m")
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "quota", "ls", "-u", username, "-m")
stdout, _, err := c.executeEOS(ctx, cmd)
if err != nil {
return 0, 0, err
Expand All @@ -404,7 +404,7 @@ func (c *Client) CreateDir(ctx context.Context, username, path string) error {
return err
}

cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "mkdir", path)
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "mkdir", path)
_, _, err = c.executeEOS(ctx, cmd)
return err
}
Expand All @@ -415,7 +415,7 @@ func (c *Client) Remove(ctx context.Context, username, path string) error {
if err != nil {
return err
}
cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "rm", "-r", path)
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "rm", "-r", path)
_, _, err = c.executeEOS(ctx, cmd)
return err
}
Expand All @@ -426,7 +426,7 @@ func (c *Client) Rename(ctx context.Context, username, oldPath, newPath string)
if err != nil {
return err
}
cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "file", "rename", oldPath, newPath)
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "file", "rename", oldPath, newPath)
_, _, err = c.executeEOS(ctx, cmd)
return err
}
Expand All @@ -437,7 +437,7 @@ func (c *Client) List(ctx context.Context, username, path string) ([]*FileInfo,
if err != nil {
return nil, err
}
cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "find", "--fileinfo", "--maxdepth", "1", path)
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "find", "--fileinfo", "--maxdepth", "1", path)
stdout, _, err := c.executeEOS(ctx, cmd)
if err != nil {
return nil, errors.Wrapf(err, "error listing fn=%s", path)
Expand All @@ -455,7 +455,7 @@ func (c *Client) Read(ctx context.Context, username, path string) (io.ReadCloser
rand := "eosread-" + uuid.String()
localTarget := fmt.Sprintf("%s/%s", c.opt.CacheDirectory, rand)
xrdPath := fmt.Sprintf("%s//%s", c.opt.URL, path)
cmd := exec.CommandContext(ctx, "/usr/bin/xrdcopy", "--nopbar", "--silent", "-f", xrdPath, localTarget, fmt.Sprintf("-OSeos.ruid=%s&eos.rgid=%s", unixUser.Uid, unixUser.Gid))
cmd := exec.CommandContext(ctx, c.opt.XrdcopyBinary, "--nopbar", "--silent", "-f", xrdPath, localTarget, fmt.Sprintf("-OSeos.ruid=%s&eos.rgid=%s", unixUser.Uid, unixUser.Gid))
_, _, err = c.execute(ctx, cmd)
if err != nil {
return nil, err
Expand All @@ -482,7 +482,7 @@ func (c *Client) Write(ctx context.Context, username, path string, stream io.Rea
return err
}
xrdPath := fmt.Sprintf("%s//%s", c.opt.URL, path)
cmd := exec.CommandContext(ctx, "/usr/bin/xrdcopy", "--nopbar", "--silent", "-f", fd.Name(), xrdPath, fmt.Sprintf("-ODeos.ruid=%s&eos.rgid=%s", unixUser.Uid, unixUser.Gid))
cmd := exec.CommandContext(ctx, c.opt.XrdcopyBinary, "--nopbar", "--silent", "-f", fd.Name(), xrdPath, fmt.Sprintf("-ODeos.ruid=%s&eos.rgid=%s", unixUser.Uid, unixUser.Gid))
_, _, err = c.execute(ctx, cmd)
return err
}
Expand All @@ -495,7 +495,7 @@ func (c *Client) ListDeletedEntries(ctx context.Context, username string) ([]*De
}
// TODO(labkode): add protection if slave is configured and alive to count how many files are in the trashbin before
// triggering the recycle ls call that could break the instance because of unavailable memory.
cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "recycle", "ls", "-m")
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "recycle", "ls", "-m")
stdout, _, err := c.executeEOS(ctx, cmd)
if err != nil {
return nil, err
Expand All @@ -509,7 +509,7 @@ func (c *Client) RestoreDeletedEntry(ctx context.Context, username, key string)
if err != nil {
return err
}
cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "recycle", "restore", key)
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "recycle", "restore", key)
_, _, err = c.executeEOS(ctx, cmd)
return err
}
Expand All @@ -520,7 +520,7 @@ func (c *Client) PurgeDeletedEntries(ctx context.Context, username string) error
if err != nil {
return err
}
cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "recycle", "purge")
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "recycle", "purge")
_, _, err = c.executeEOS(ctx, cmd)
return err
}
Expand All @@ -543,7 +543,7 @@ func (c *Client) RollbackToVersion(ctx context.Context, username, path, version
if err != nil {
return err
}
cmd := exec.CommandContext(ctx, "/usr/bin/eos", "-r", unixUser.Uid, unixUser.Gid, "file", "versions", path, version)
cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", unixUser.Uid, unixUser.Gid, "file", "versions", path, version)
_, _, err = c.executeEOS(ctx, cmd)
return err
}
Expand Down

0 comments on commit fb46ee7

Please sign in to comment.