diff --git a/README.md b/README.md index 1243785..7ce959a 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,9 @@ As for in-band, a kubernetes namespace shall be passed as a parameter. Further, The Metal plugin acts as a connection link between DHCP and the IronCore metal stack. It creates an `EndPoint` object for each machine with leased IP address. Those endpoints are then consumed by the metal operator, who then creates the corresponding `Machine` objects. ### Configuration -Path to an inventory yaml shall be passed as a string. Currently, there are two different ways to provide an inventory list: either by specifying a MAC address filter or by providing the inventory list explicitly. If both a static list and a filter are specified in the `inventory.yaml`, the static list gets a precedence, so the filter will be ignored. +The metal configuration consists of an inventory list. Currently, there are two different ways to provide an inventory list: either by specifying a MAC address filter or by providing the inventory list explicitly. If both a static list and a filter are specified in the `metal_config.yaml`, the static list gets a precedence, so the filter will be ignored. -Providing an explicit static inventory list in `inventory.yaml` goes as follows: +Providing an explicit static inventory list in `metal_config.yaml` goes as follows: ```yaml hosts: - name: server-01 @@ -84,7 +84,7 @@ hosts: ``` Providing a MAC address prefix filter list creates `Endpoint`s with a predefined prefix name. When the MAC address of an inventory does not match the prefix, the inventory will not be onboarded, so for now no "onboarding by default" occurs. Obviously a full MAC address is a valid prefix filter. -To get inventories with certain MACs onboarded, the following `inventory.yaml` shall be specified: +To get inventories with certain MACs onboarded, the following `metal_config.yaml` shall be specified: ```yaml namePrefix: server- # optional prefix, default: "compute-" filter: diff --git a/config.yaml b/config.yaml index 94abca9..6f2d703 100644 --- a/config.yaml +++ b/config.yaml @@ -18,4 +18,18 @@ server6: # implement (i)PXE boot - pxeboot: tftp://[2001:db8::1]/ipxe/x86_64/ipxe http://[2001:db8::1]/ipxe/boot6 # create Endpoint objects in kubernetes - - metal: inventory.yaml \ No newline at end of file + - metal: metal_config.yaml + +# metal_config.yaml +--- +hosts: + - name: server-01 + macAddress: 00:1A:2B:3C:4D:5E + - name: server-02 + macAddress: 00:1A:2B:3C:4D:5F +namePrefix: server- # optional prefix, default: "compute-" +filter: + macPrefix: + - 00:1A:2B:3C:4D:5E + - 00:1A:2B:3C:4D:5F + - 00:AA:BB diff --git a/internal/api/config.go b/internal/api/metal_config.go similarity index 94% rename from internal/api/config.go rename to internal/api/metal_config.go index b05e9e0..78b5a56 100644 --- a/internal/api/config.go +++ b/internal/api/metal_config.go @@ -12,7 +12,7 @@ type Filter struct { MacPrefix []string `yaml:"macPrefix"` } -type Config struct { +type MetalConfig struct { NamePrefix string `yaml:"namePrefix"` Inventories []Inventory `yaml:"hosts"` Filter Filter `yaml:"filter"` diff --git a/plugins/metal/plugin.go b/plugins/metal/plugin.go index cb7cc5a..b2d1eeb 100644 --- a/plugins/metal/plugin.go +++ b/plugins/metal/plugin.go @@ -88,7 +88,7 @@ func loadConfig(args ...string) (*Inventory, error) { return nil, fmt.Errorf("failed to read config file: %v", err) } - var config api.Config + var config api.MetalConfig if err = yaml.Unmarshal(configData, &config); err != nil { return nil, fmt.Errorf("failed to parse config file: %v", err) } diff --git a/plugins/metal/plugin_test.go b/plugins/metal/plugin_test.go index e5fcc51..8bca061 100644 --- a/plugins/metal/plugin_test.go +++ b/plugins/metal/plugin_test.go @@ -120,7 +120,7 @@ var _ = Describe("Endpoint", func() { It("Should return an empty inventory for an empty list", func() { configFile := inventoryConfigFile - data := api.Config{ + data := api.MetalConfig{ Inventories: []api.Inventory{ {}, }, @@ -145,7 +145,7 @@ var _ = Describe("Endpoint", func() { It("Should return a valid inventory list with default name prefix for non-empty MAC address filter", func() { configFile := inventoryConfigFile - data := api.Config{ + data := api.MetalConfig{ Filter: api.Filter{ MacPrefix: []string{ "aa:bb:cc:dd:ee:ff", @@ -171,7 +171,7 @@ var _ = Describe("Endpoint", func() { It("Should return an inventory list with custom name prefix for non-empty MAC address filter and set prefix", func() { configFile := inventoryConfigFile - data := api.Config{ + data := api.MetalConfig{ NamePrefix: "server-", Filter: api.Filter{ MacPrefix: []string{ @@ -198,7 +198,7 @@ var _ = Describe("Endpoint", func() { It("Should return a valid inventory list for a non-empty inventory section, precedence over MAC filter", func() { configFile := inventoryConfigFile - data := api.Config{ + data := api.MetalConfig{ NamePrefix: "server-", Inventories: []api.Inventory{ { @@ -262,7 +262,7 @@ var _ = Describe("Endpoint", func() { relayedRequest, _ := dhcpv6.EncapsulateRelay(req, dhcpv6.MessageTypeRelayForward, net.IPv6loopback, linkLocalIPV6Addr) configFile := inventoryConfigFile - data := api.Config{ + data := api.MetalConfig{ NamePrefix: "foobar-", Inventories: []api.Inventory{}, Filter: api.Filter{ @@ -396,7 +396,7 @@ var _ = Describe("Endpoint", func() { stub, _ := dhcpv4.NewReplyFromRequest(req) configFile := inventoryConfigFile - data := api.Config{ + data := api.MetalConfig{ NamePrefix: "", Inventories: []api.Inventory{}, Filter: api.Filter{ diff --git a/plugins/metal/suite_test.go b/plugins/metal/suite_test.go index 29ba743..6eb57cd 100644 --- a/plugins/metal/suite_test.go +++ b/plugins/metal/suite_test.go @@ -122,7 +122,7 @@ func SetupTest() *corev1.Namespace { DeferCleanup(k8sClient.Delete, ns) configFile := inventoryConfigFile - data := api.Config{ + data := api.MetalConfig{ NamePrefix: "server-", Inventories: []api.Inventory{ {