CORD-1181 include DHCP reservations when harvesting from DHCP
Change-Id: I5e148a5d92f275455681033d402b413beef8a537
(cherry picked from commit 8b52a9cc5db0a8614b70b1137a2fd132d78aac50)
diff --git a/harvester/harvester.go b/harvester/harvester.go
index e0314e6..3a16817 100644
--- a/harvester/harvester.go
+++ b/harvester/harvester.go
@@ -33,26 +33,27 @@
// application application configuration and internal state
type application struct {
- Port int `default:"4246" desc:"port on which the service will listen for requests"`
- Listen string `default:"0.0.0.0" desc:"IP on which the service will listen for requests"`
- LogLevel string `default:"warning" envconfig:"LOG_LEVEL" desc:"log output level"`
- LogFormat string `default:"text" envconfig:"LOG_FORMAT" desc:"format of log messages"`
- DHCPLeaseFile string `default:"/harvester/dhcpd.leases" envconfig:"DHCP_LEASE_FILE" desc:"lease file to parse for lease information"`
- OutputFile string `envconfig:"OUTPUT_FILE" desc:"name of file to output discovered lease in bind9 format"`
- OutputFormat string `default:"{{.ClientHostname}}\tIN A {{.IPAddress}}\t; {{.HardwareAddress}}" envconfig:"OUTPUT_FORMAT" desc:"specifies the single entry format when outputing to a file"`
- VerifyLeases bool `default:"true" envconfig:"VERIFY_LEASES" desc:"verifies leases with a ping"`
- VerifyTimeout time.Duration `default:"1s" envconfig:"VERIFY_TIMEOUT" desc:"max timeout (RTT) to wait for verification pings"`
- VerifyWithUDP bool `default:"false" envconfig:"VERIFY_WITH_UDP" desc:"use UDP instead of raw sockets for ping verification"`
- QueryPeriod time.Duration `default:"30s" envconfig:"QUERY_PERIOD" desc:"period at which the DHCP lease file is processed"`
- QuietPeriod time.Duration `default:"2s" envconfing:"QUIET_PERIOD" desc:"period to wait between accepting parse requests"`
- RequestTimeout time.Duration `default:"10s" envconfig:"REQUEST_TIMEOUT" desc:"period to wait for processing when requesting a DHCP lease database parsing"`
- RNDCUpdate bool `default:"false" envconfig:"RNDC_UPDATE" desc:"determines if the harvester reloads the DNS servers after harvest"`
- RNDCAddress string `default:"127.0.0.1" envconfig:"RNDC_ADDRESS" desc:"IP address of the DNS server to contact via RNDC"`
- RNDCPort int `default:"954" envconfig:"RNDC_PORT" desc:"port of the DNS server to contact via RNDC"`
- RNDCKeyFile string `default:"/key/rndc.conf.maas" envconfig:"RNDC_KEY_FILE" desc:"key file, with default, to contact DNS server"`
- RNDCZone string `default:"cord.lab" envconfig:"RNDC_ZONE" desc:"zone to reload"`
- BadClientNames []string `default:"localhost" envconfig:"BAD_CLIENT_NAMES" desc:"list of invalid hostnames for clients"`
- ClientNameTemplate string `default:"UKN-{{with $x:=.HardwareAddress|print}}{{regex $x \":\" \"\"}}{{end}}" envconfig:"CLIENT_NAME_TEMPLATE" desc:"template for generated host name"`
+ Port int `default:"4246" desc:"port on which the service will listen for requests"`
+ Listen string `default:"0.0.0.0" desc:"IP on which the service will listen for requests"`
+ LogLevel string `default:"warning" envconfig:"LOG_LEVEL" desc:"log output level"`
+ LogFormat string `default:"text" envconfig:"LOG_FORMAT" desc:"format of log messages"`
+ DHCPLeaseFile string `default:"/harvester/dhcpd.leases" envconfig:"DHCP_LEASE_FILE" desc:"lease file to parse for lease information"`
+ DHCPReservationFile string `default:"/reservations/dhcpd.reservations" envconfig:"DHCP_RESERVATION_FILE" desc:"lease reservation file for IP information"`
+ OutputFile string `envconfig:"OUTPUT_FILE" desc:"name of file to output discovered lease in bind9 format"`
+ OutputFormat string `default:"{{.ClientHostname}}\tIN A {{.IPAddress}}\t; {{.HardwareAddress}}" envconfig:"OUTPUT_FORMAT" desc:"specifies the single entry format when outputing to a file"`
+ VerifyLeases bool `default:"true" envconfig:"VERIFY_LEASES" desc:"verifies leases with a ping"`
+ VerifyTimeout time.Duration `default:"1s" envconfig:"VERIFY_TIMEOUT" desc:"max timeout (RTT) to wait for verification pings"`
+ VerifyWithUDP bool `default:"false" envconfig:"VERIFY_WITH_UDP" desc:"use UDP instead of raw sockets for ping verification"`
+ QueryPeriod time.Duration `default:"30s" envconfig:"QUERY_PERIOD" desc:"period at which the DHCP lease file is processed"`
+ QuietPeriod time.Duration `default:"2s" envconfing:"QUIET_PERIOD" desc:"period to wait between accepting parse requests"`
+ RequestTimeout time.Duration `default:"10s" envconfig:"REQUEST_TIMEOUT" desc:"period to wait for processing when requesting a DHCP lease database parsing"`
+ RNDCUpdate bool `default:"false" envconfig:"RNDC_UPDATE" desc:"determines if the harvester reloads the DNS servers after harvest"`
+ RNDCAddress string `default:"127.0.0.1" envconfig:"RNDC_ADDRESS" desc:"IP address of the DNS server to contact via RNDC"`
+ RNDCPort int `default:"954" envconfig:"RNDC_PORT" desc:"port of the DNS server to contact via RNDC"`
+ RNDCKeyFile string `default:"/key/rndc.conf.maas" envconfig:"RNDC_KEY_FILE" desc:"key file, with default, to contact DNS server"`
+ RNDCZone string `default:"cord.lab" envconfig:"RNDC_ZONE" desc:"zone to reload"`
+ BadClientNames []string `default:"localhost" envconfig:"BAD_CLIENT_NAMES" desc:"list of invalid hostnames for clients"`
+ ClientNameTemplate string `default:"UKN-{{with $x:=.HardwareAddress|print}}{{regex $x \":\" \"\"}}{{end}}" envconfig:"CLIENT_NAME_TEMPLATE" desc:"template for generated host name"`
appFlags *flag.FlagSet `ignored:"true"`
log *logrus.Logger `ignored:"true"`
@@ -113,29 +114,30 @@
// output the configuration
app.log.Infof(`Configuration:
- LISTEN: %s
- PORT: %d
- LOG_LEVEL: %s
- LOG_FORMAT: %s
- DHCP_LEASE_FILE: %s
- OUTPUT_FILE: %s
- OUTPUT_FORMAT: %s
- VERIFY_LEASES: %t
- VERIFY_TIMEOUT: %s
- VERIFY_WITH_UDP: %t
- QUERY_PERIOD: %s
- QUIET_PERIOD: %s
- REQUEST_TIMEOUT: %s
- RNDC_UPDATE: %t
- RNDC_ADDRESS: %s
- RNDC_PORT: %d
- RNDC_KEY_FILE: %s
- RNDC_ZONE: %s
- BAD_CLIENT_NAMES: %s
- CLIENT_NAME_TEMPLATE: %s`,
+ LISTEN: %s
+ PORT: %d
+ LOG_LEVEL: %s
+ LOG_FORMAT: %s
+ DHCP_LEASE_FILE: %s
+ DHCP_RESERVATION_FILE: %s
+ OUTPUT_FILE: %s
+ OUTPUT_FORMAT: %s
+ VERIFY_LEASES: %t
+ VERIFY_TIMEOUT: %s
+ VERIFY_WITH_UDP: %t
+ QUERY_PERIOD: %s
+ QUIET_PERIOD: %s
+ REQUEST_TIMEOUT: %s
+ RNDC_UPDATE: %t
+ RNDC_ADDRESS: %s
+ RNDC_PORT: %d
+ RNDC_KEY_FILE: %s
+ RNDC_ZONE: %s
+ BAD_CLIENT_NAMES: %s
+ CLIENT_NAME_TEMPLATE: %s`,
app.Listen, app.Port,
app.LogLevel, app.LogFormat,
- app.DHCPLeaseFile, app.OutputFile, strconv.Quote(app.OutputFormat),
+ app.DHCPLeaseFile, app.DHCPReservationFile, app.OutputFile, strconv.Quote(app.OutputFormat),
app.VerifyLeases, app.VerifyTimeout, app.VerifyWithUDP,
app.QueryPeriod, app.QuietPeriod, app.RequestTimeout,
app.RNDCUpdate, app.RNDCAddress, app.RNDCPort, app.RNDCKeyFile, app.RNDCZone,