Allow asset tags in the profile.

Warn and ignore ip addresses and hardware addresses.
This commit is contained in:
MatthewHink
2022-02-16 11:41:44 -05:00
parent a29e9ed6be
commit a01e8319d2
3 changed files with 16 additions and 6 deletions

View File

@@ -70,6 +70,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
p.Root.Set(SetRoot)
}
if SetAssetKey != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting asset key to: %s\n", p.Id.Get(), SetAssetKey)
p.AssetKey.Set(SetAssetKey)
}
if SetKernel != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel to: %s\n", p.Id.Get(), SetKernel)
p.KernelVersion.Set(SetKernel)

View File

@@ -65,6 +65,7 @@ var (
SetKey string
SetTags []string
SetDelTags []string
SetAssetKey string
)
func init() {
@@ -88,7 +89,7 @@ func init() {
baseCmd.PersistentFlags().StringVarP(&SetIpxe, "ipxe", "P", "", "Set the node's iPXE template name")
baseCmd.PersistentFlags().StringVarP(&SetInit, "init", "i", "", "Define the init process to boot the container")
baseCmd.PersistentFlags().StringVar(&SetRoot, "root", "", "Define the rootfs")
baseCmd.PersistentFlags().StringVar(&SetAssetKey, "assetkey", "", "Set the node's Asset tag (key)")
baseCmd.PersistentFlags().StringVarP(&SetRuntimeOverlay, "runtime", "R", "", "Set the node's runtime overlay")
if err := baseCmd.RegisterFlagCompletionFunc("runtime", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, _ := overlay.FindOverlays()

View File

@@ -229,9 +229,7 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
p.RuntimeOverlay.Set(profile.RuntimeOverlay)
p.SystemOverlay.Set(profile.SystemOverlay)
p.Root.Set(profile.Root)
if profile.AssetKey != "" {
wwlog.Printf(wwlog.WARN, "Ignoring asset key %v in profile %v\n", profile.AssetKey, name)
}
p.AssetKey.Set(profile.AssetKey)
p.Discoverable.Set(profile.Discoverable)
for devname, netdev := range profile.NetDevs {
@@ -243,13 +241,19 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
wwlog.Printf(wwlog.DEBUG, "Updating profile netdev: %s\n", devname)
p.NetDevs[devname].Device.Set(netdev.Device)
p.NetDevs[devname].Ipaddr.Set(netdev.Ipaddr)
p.NetDevs[devname].Netmask.Set(netdev.Netmask)
p.NetDevs[devname].Hwaddr.Set(netdev.Hwaddr)
p.NetDevs[devname].Gateway.Set(netdev.Gateway)
p.NetDevs[devname].Type.Set(netdev.Type)
p.NetDevs[devname].OnBoot.Set(netdev.OnBoot)
p.NetDevs[devname].Default.Set(netdev.Default)
// The following should not be set in a profile.
if netdev.Ipaddr != "" {
wwlog.Printf(wwlog.WARN, "Ignoring ip address %v in profile %v\n", netdev.Ipaddr, name)
}
if netdev.Hwaddr != "" {
wwlog.Printf(wwlog.WARN, "Ignoring hardware address %v in profile %v\n", netdev.Hwaddr, name)
}
}
// Merge Keys into Tags for backwards compatibility