Updated generator plugin implementations
This commit is contained in:
parent
22195fa00a
commit
121c7b9f9c
5 changed files with 47 additions and 24 deletions
|
|
@ -40,6 +40,7 @@ func (g *DnsMasq) Generate(config *configurator.Config, opts ...util.Option) ([]
|
|||
// set all the defaults for variables
|
||||
var (
|
||||
params = generator.GetParams(opts...)
|
||||
client = generator.GetClient(params)
|
||||
template = params["template"].(string) // required param
|
||||
path = config.TemplatePaths[template]
|
||||
eths []configurator.EthernetInterface = nil
|
||||
|
|
@ -47,7 +48,7 @@ func (g *DnsMasq) Generate(config *configurator.Config, opts ...util.Option) ([]
|
|||
)
|
||||
|
||||
// if we have a client, try making the request for the ethernet interfaces
|
||||
if client, ok := params["client"].(configurator.SmdClient); ok {
|
||||
if client != nil {
|
||||
eths, err = client.FetchEthernetInterfaces(opts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to fetch ethernet interfaces with client: %v", err)
|
||||
|
|
@ -70,7 +71,7 @@ func (g *DnsMasq) Generate(config *configurator.Config, opts ...util.Option) ([]
|
|||
}
|
||||
|
||||
// format output to write to config file
|
||||
output := "# ========== GENERATED BY OCHAMI CONFIGURATOR ==========\n"
|
||||
output := "# ========== DYNAMICALLY GENERATED BY OPENCHAMI CONFIGURATOR ==========\n"
|
||||
for _, eth := range eths {
|
||||
if eth.Type == "NodeBMC" {
|
||||
output += "dhcp-host=" + eth.MacAddress + "," + eth.ComponentId + "," + eth.IpAddresses[0].IpAddress + "\n"
|
||||
|
|
@ -78,11 +79,12 @@ func (g *DnsMasq) Generate(config *configurator.Config, opts ...util.Option) ([]
|
|||
output += "dhcp-host=" + eth.MacAddress + "," + eth.ComponentId + "," + eth.IpAddresses[0].IpAddress + "\n"
|
||||
}
|
||||
}
|
||||
output += "# ======================================================"
|
||||
output += "# ====================================================================="
|
||||
|
||||
// apply template substitutions and return output as byte array
|
||||
return generator.ApplyTemplate(path, generator.Mappings{
|
||||
"hosts": output,
|
||||
"name": g.GetName(),
|
||||
"output": output,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue