-
Notifications
You must be signed in to change notification settings - Fork 228
/
null.go
63 lines (51 loc) · 1.09 KB
/
null.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
// Copyright 2017 Microsoft. All rights reserved.
// MIT License
package ipam
import (
"net"
)
// Null IPAM configuration source.
type nullSource struct {
name string
sink addressConfigSink
initialized bool
}
// Creates the null source.
func newNullSource() (*nullSource, error) {
return &nullSource{
name: "Null",
}, nil
}
// Starts the null source.
func (s *nullSource) start(sink addressConfigSink) error {
s.sink = sink
return nil
}
// Stops the null source.
func (s *nullSource) stop() {
s.sink = nil
return
}
// Refreshes configuration.
func (s *nullSource) refresh() error {
// Initialize once.
if s.initialized == true {
return nil
}
s.initialized = true
// Configure the local default address space.
local, err := s.sink.newAddressSpace(LocalDefaultAddressSpaceId, LocalScope)
if err != nil {
return err
}
subnet := net.IPNet{
IP: net.IPv4(0, 0, 0, 0),
Mask: net.IPv4Mask(0, 0, 0, 0),
}
_, err = local.newAddressPool("", 0, &subnet)
if err != nil {
return err
}
// Set the local address space as active.
return s.sink.setAddressSpace(local)
}