-
Notifications
You must be signed in to change notification settings - Fork 291
/
cont.go
64 lines (52 loc) · 1.6 KB
/
cont.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// (C) Copyright 2020-2022 Intel Corporation.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
package control
import (
"context"
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
mgmtpb "github.com/daos-stack/daos/src/control/common/proto/mgmt"
)
// ContSetOwnerReq contains the parameters for the set owner request
type ContSetOwnerReq struct {
msRequest
unaryRequest
ContUUID string // Container UUID
PoolUUID string // UUID of the pool for the container
User string // User to own the container, or empty if none
Group string // Group to own the container, or empty if none
}
// ContSetOwner changes the owner user and/or group of a DAOS container.
func ContSetOwner(ctx context.Context, rpcClient UnaryInvoker, req *ContSetOwnerReq) error {
if req == nil {
return errors.New("nil request")
}
if err := checkUUID(req.ContUUID); err != nil {
return err
}
if err := checkUUID(req.PoolUUID); err != nil {
return err
}
if req.User == "" && req.Group == "" {
return errors.New("no user or group specified")
}
req.setRPC(func(ctx context.Context, conn *grpc.ClientConn) (proto.Message, error) {
return mgmtpb.NewMgmtSvcClient(conn).ContSetOwner(ctx, &mgmtpb.ContSetOwnerReq{
Sys: req.getSystem(rpcClient),
ContUUID: req.ContUUID,
PoolUUID: req.PoolUUID,
Owneruser: req.User,
Ownergroup: req.Group,
})
})
rpcClient.Debugf("Set DAOS container owner request: %+v\n", req)
ur, err := rpcClient.InvokeUnaryRPC(ctx, req)
if err != nil {
return err
}
return errors.Wrap(ur.getMSError(), "container set-owner failed")
}