Re: Ridding unpredictable predictable interface names
"'Nick Anderson' via help-cfengine" <[email protected]>
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
Martin Simons <[email protected]> writes: > Dear CFEngineer, At times one needs a dirty trick. Hey Martin, I tweaked your policy slightly to collect the map back into a classic array leveraging `useresult' and `bundle_return_value_index': ,---- | bundle agent __main__ | { | methods: | "nic_mac_map"; | } | bundle agent nic_mac_map { | vars: | | "macs" slist => { "52:54:00:40:13:98", "52:54:00:40:13:99", "52:54:00:40:13:9a" }; | "macs_string" string => join(",", "macs"); | "mac_list_len" int => length("macs"); | | "nic[support]" string => "eth1"; | "nic[admin]" string => "eth2"; | "nic[life]" string => "eth5"; | | "nics" slist => getvalues("nic"); | "nics_sort" slist => sort("nics", lex); | "nics_string" string => join(",", "nics_sort"); | | "dirty_trick" slist => { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; | | methods: | | "map nics and macs" | usebundle => ugly_policy($(dirty_trick)), | useresult => "nic2mac_map"; | | reports: | | # "$(this.bundle) macs sort: $(macs)"; | # "$(this.bundle) macs length: $(mac_list_len)"; | # "$(this.bundle) nics_sort: $(nics_sort)"; | | } | | bundle agent ugly_policy (pos) { | vars: | | "nic" string => nth("nic_mac_map.nics_sort", "$(pos)"); | "mac" string => nth("nic_mac_map.macs", "$(pos)"); | | reports: | | # "$(this.bundle) pair : $(nic), $(mac)"; | "$(mac)" | bundle_return_value_index => "$(nic)"; | } `---- Listing 1: Example Policy ,---- | # cf-agent --no-lock --log-level info --show-evaluated-vars=default:nic_mac_map\\.nic2mac_map --file /tmp/martin-nic2mac-map.cf | Variable name Variable value Meta tags Comment | default:nic_mac_map.nic2mac_map[eth1] 52:54:00:40:13:98 source=bundle | default:nic_mac_map.nic2mac_map[eth2] 52:54:00:40:13:99 source=bundle | default:nic_mac_map.nic2mac_map[eth5] 52:54:00:40:13:9a source=bundle `---- -- You received this message because you are subscribed to the Google Groups "help-cfengine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/87fst3bjdy.fsf%40northern.tech. -- Nick Anderson | Doer of Things | (+1) 785-550-1767 | https://northern.tech -- You received this message because you are subscribed to the Google Groups "help-cfengine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/87fst3bjdy.fsf%40northern.tech.