-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpu.go
68 lines (61 loc) · 1.69 KB
/
gpu.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
65
66
67
68
package main
import (
"context"
"fmt"
"os"
"github.com/projecteru2/core/resource/plugins"
coretypes "github.com/projecteru2/core/types"
"github.com/projecteru2/resource-gpu/cmd"
"github.com/projecteru2/resource-gpu/cmd/calculate"
"github.com/projecteru2/resource-gpu/cmd/gpu"
"github.com/projecteru2/resource-gpu/cmd/metrics"
"github.com/projecteru2/resource-gpu/cmd/node"
gpulib "github.com/projecteru2/resource-gpu/gpu"
"github.com/projecteru2/resource-gpu/version"
"github.com/urfave/cli/v2"
)
func NewPlugin(ctx context.Context, config coretypes.Config) (plugins.Plugin, error) {
p, err := gpulib.NewPlugin(ctx, config, nil)
return p, err
}
func main() {
cli.VersionPrinter = func(_ *cli.Context) {
fmt.Print(version.String())
}
app := cli.NewApp()
app.Name = version.NAME
app.Usage = "Run eru resource GPU plugin"
app.Version = version.VERSION
app.Commands = []*cli.Command{
gpu.Name(),
metrics.Description(),
metrics.GetMetrics(),
node.AddNode(),
node.RemoveNode(),
node.GetNodesDeployCapacity(),
node.SetNodeResourceCapacity(),
node.GetNodeResourceInfo(),
node.SetNodeResourceInfo(),
node.SetNodeResourceUsage(),
node.GetMostIdleNode(),
node.FixNodeResource(),
calculate.CalculateDeploy(),
calculate.CalculateRealloc(),
calculate.CalculateRemap(),
}
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "config",
Value: "gpu.yaml",
Usage: "config file path for plugin, in yaml",
Destination: &cmd.ConfigPath,
EnvVars: []string{"ERU_RESOURCE_CONFIG_PATH"},
},
&cli.BoolFlag{
Name: "embedded-storage",
Usage: "active embedded storage",
Destination: &cmd.EmbeddedStorage,
},
}
_ = app.Run(os.Args)
}