Repository navigation
Expand file tree
/
Copy pathcellruntime.go
More file actions
108 lines (86 loc) · 2.53 KB
/
Copy pathcellruntime.go
File metadata and controls
108 lines (86 loc) · 2.53 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0
package cellruntime
import (
"context"
"errors"
"net/netip"
)
type CellMetadata struct {
Namespace string
Name string
UID string
Labels map[string]string
}
type CellConfig struct {
Metadata CellMetadata
ID string
Hostname string
LoopbackIPs []netip.Addr
Prefixes []netip.Prefix
Peers []Peer
}
type Peer struct {
Interface *Interface
DHCPRelay string
}
type InterfaceMetadata struct {
Name string
UID string
}
type Interface struct {
Metadata InterfaceMetadata
ID string
}
type Runtime interface {
// ProviderName is the name of the provider.
ProviderName() string
// NodeID returns the provider internal ID of the node specified with by the given node name.
NodeID(ctx context.Context, node string) (string, error)
// ApplyCell applies the given cell to the specified node.
ApplyCell(ctx context.Context, node string, cfg *CellConfig) error
// DeleteCell deletes the given cell from the specified node.
DeleteCell(ctx context.Context, node string) error
// CellStatus returns the current cell status from the specified node.
CellStatus(ctx context.Context, node string) (*CellStatus, error)
// InterfaceID returns the provider internal ID of the interface specified by the given interface name.
InterfaceID(ctx context.Context, iface string) (string, error)
// InterfaceState returns the state of the interface specified by the given interface name.
InterfaceState(ctx context.Context, iface string) (*InterfaceState, error)
// SetInterfaceAdminState sets the admin state of the interface specified by the given interface
// name to the given value.
SetInterfaceAdminState(ctx context.Context, iface string, adminState bool) error
}
type InterfaceState struct {
Up bool
}
type CellStatus struct {
Phase CellPhase
}
type CellPhase string
const (
CellPhaseCreated CellPhase = "Created"
CellPhaseActive CellPhase = "Active"
CellPhaseError CellPhase = "Error"
)
var ErrNotFound = errors.New("not found")
type terminalError struct {
err error
}
func TerminalError(err error) error {
return &terminalError{err: err}
}
// Unwrap returns nil if te.err is nil.
func (te *terminalError) Unwrap() error {
return te.err
}
func (te *terminalError) Error() string {
if te.err == nil {
return "nil terminal error"
}
return "terminal error: " + te.err.Error()
}
func (te *terminalError) Is(target error) bool {
tp := &terminalError{}
return errors.As(target, &tp)
}