-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathnode_name.go
37 lines (28 loc) · 984 Bytes
/
node_name.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
package nodename
import (
"context"
"github.com/k8s-proxmox/proxmox-go/api"
"github.com/k8s-proxmox/cluster-api-provider-proxmox/cloud/scheduler/framework"
"github.com/k8s-proxmox/cluster-api-provider-proxmox/cloud/scheduler/plugins/names"
)
type NodeName struct{}
var _ framework.NodeFilterPlugin = &NodeName{}
const (
Name = names.NodeName
ErrReason = "node didn't match the requested node name"
)
func (pl *NodeName) Name() string {
return Name
}
func (pl *NodeName) Filter(ctx context.Context, _ *framework.CycleState, config api.VirtualMachineCreateOptions, nodeInfo *framework.NodeInfo) *framework.Status {
if !Fits(config, nodeInfo) {
status := framework.NewStatus()
status.SetCode(1)
return status
}
return &framework.Status{}
}
// return true if config.Node is empty or match with node name
func Fits(config api.VirtualMachineCreateOptions, nodeInfo *framework.NodeInfo) bool {
return config.Node == "" || config.Node == nodeInfo.Node().Node
}