37
37
cache * Cache
38
38
baseURL * url.URL
39
39
bootScriptBaseURL * url.URL
40
- hostnamePrefix string
41
40
leaseDuration time.Duration
42
41
)
43
42
@@ -49,8 +48,8 @@ func setup4(args ...string) (handler.Handler4, error) {
49
48
log .Infof ("initializing coresmd/coresmd %s (%s), built %s" , version .Version , version .GitCommit , version .BuildTime )
50
49
51
50
// Ensure all required args were passed
52
- if len (args ) != 6 {
53
- return nil , errors .New ("expected 6 arguments: base URL, boot script base URL, CA certificate path, hostname prefix , cache duration, lease duration" )
51
+ if len (args ) != 5 {
52
+ return nil , errors .New ("expected 5 arguments: base URL, boot script base URL, CA certificate path, cache duration, lease duration" )
54
53
}
55
54
56
55
// Create new SmdClient using first argument (base URL)
@@ -82,25 +81,17 @@ func setup4(args ...string) (handler.Handler4, error) {
82
81
log .Infof ("CA certificate path was empty, not setting" )
83
82
}
84
83
85
- // Parse hostname prefix
86
- hostnamePrefix = strings .Trim (args [3 ], `"'` )
87
- log .Infof ("hostname prefix: %s" , hostnamePrefix )
88
- if hostnamePrefix == "" {
89
- log .Info ("no hostname prefix set, defaulting to 'nid'" )
90
- hostnamePrefix = "nid"
91
- }
92
-
93
84
// Create new Cache using fourth argument (cache validity duration) and new SmdClient
94
85
// pointer
95
86
log .Debug ("generating new Cache" )
96
- cache , err = NewCache (args [4 ], smdClient )
87
+ cache , err = NewCache (args [3 ], smdClient )
97
88
if err != nil {
98
89
return nil , fmt .Errorf ("failed to create new cache: %w" , err )
99
90
}
100
91
101
92
// Set lease duration from fifth argument
102
93
log .Debug ("setting lease duration" )
103
- leaseDuration , err = time .ParseDuration (args [5 ])
94
+ leaseDuration , err = time .ParseDuration (args [4 ])
104
95
if err != nil {
105
96
return nil , fmt .Errorf ("failed to parse lease duration: %w" , err )
106
97
}
@@ -140,7 +131,7 @@ func Handler4(req, resp *dhcpv4.DHCPv4) (*dhcpv4.DHCPv4, bool) {
140
131
141
132
// Set client hostname
142
133
if ifaceInfo .Type == "Node" {
143
- resp .Options .Update (dhcpv4 .OptHostName (fmt .Sprintf ("%s% 04d" , hostnamePrefix , ifaceInfo .CompNID )))
134
+ resp .Options .Update (dhcpv4 .OptHostName (fmt .Sprintf ("nid% 04d" , ifaceInfo .CompNID )))
144
135
}
145
136
146
137
// Set root path to this server's IP
0 commit comments