Brian Finney
2007-Oct-30 09:23 UTC
append to static array (was: Re: Why External Node Classification is my future)
On 10/29/07, Luke Kanies <luke@madstop.com> wrote:> On Oct 29, 2007, at 2:35 PM, Brian Finney wrote: > > Although iteration would be really cool if we could also append to an > > array in a global fashion, but thats a completely different dream. > > What do you mean?Thinking some thing like: # define for simple firewall control define port($port, $status){ push $ports, [$port,$status]; # borrowing syntax from perl again include ports; } class ports{ use the array that has been created by instantiating port multiple times } I''m betting that this is much easier said than implemented and this likely wouldn''t be necessary if a native type where used for "port". However it also seems like this could take care of some (many?) situations that are currently done with: $ports=/some/file $def_dir=$ports.d define port($port, $status){ file{"$def_dir/$name": path => "$def_dir/$name", content => "some/template/using/port/status"; } include ports } class ports{ file{"$def_dir": path => "$def_dir", notify => Exec["ports"]; } exec{"ports": command => "cat $def_dir/* > $ports", refreshonly => true; } } Hopefully I will have some down time soon to dig deeper into the code base and have a better understanding of how my ideas could fit in. Thanks Brian
David Schmitt
2007-Oct-30 09:35 UTC
Re: append to static array (was: Re: Why External Node Classification is my future)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 30 October 2007, Brian Finney wrote:> On 10/29/07, Luke Kanies <luke@madstop.com> wrote: > > On Oct 29, 2007, at 2:35 PM, Brian Finney wrote: > > > Although iteration would be really cool if we could also append to an > > > array in a global fashion, but thats a completely different dream. > > > > What do you mean? > > Thinking some thing like: > > # define for simple firewall control > define port($port, $status){ > push $ports, [$port,$status]; # borrowing syntax from perl again > include ports; > } > class ports{ > use the array that has been created by instantiating port multiple > times } > > I''m betting that this is much easier said than implemented and this > likely wouldn''t be necessary if a native type where used for "port".Definitely! Using a native type, you can have a provider that flushes only at the end of the transaction, which is a often repeated pattern in my modules[1] e.g. using a concatenated_file. [1] git://git.black.co.at/manifests http://git.black.co.at/ - -- The primary freedom of open source is not the freedom from cost, but the free- dom to shape software to do what you want. This freedom is /never/ exercised without cost, but is available /at all/ only by accepting the very different costs associated with open source, costs not in money, but in time and effort. - -- http://www.schierer.org/~luke/log/20070710-1129/on-forks-and-forking -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFHJvrd/Pp1N6Uzh0URAqRrAJ0S4Oi1bFJYEhDewozlVU3b1JptYQCeKKu7 Zk6YFzxs6IIlNktlyFuL4Zw=JJnE -----END PGP SIGNATURE-----
Luke Kanies
2007-Nov-07 16:29 UTC
Re: append to static array (was: Re: Why External Node Classification is my future)
On Oct 30, 2007, at 4:23 AM, Brian Finney wrote:> > Thinking some thing like: > > # define for simple firewall control > define port($port, $status){ > push $ports, [$port,$status]; # borrowing syntax from perl again > include ports; > } > class ports{ > use the array that has been created by instantiating port > multiple times > } > > I''m betting that this is much easier said than implemented and this > likely wouldn''t be necessary if a native type where used for "port". > > However it also seems like this could take care of some (many?) > situations that are currently done with: > [...] > Hopefully I will have some down time soon to dig deeper into the code > base and have a better understanding of how my ideas could fit in.At this point I''ve got so much other development to do that I can''t really even think about the repercussions this would have on the language. Maybe check back once I''ve got the next couple of releases out. -- If there is anything the nonconformist hates worse than a conformist, it''s another nonconformist who doesn''t conform to the prevailing standard of nonconformity. --Bill Vaughan --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
Digant C Kasundra
2007-Nov-14 20:30 UTC
Re: append to static array (was: Re: Why External Node Classification is my future)
--On Tuesday, October 30, 2007 2:23 AM -0700 Brian Finney <y0gi636@gmail.com> wrote:># define for simple firewall control > define port($port, $status){ > push $ports, [$port,$status]; # borrowing syntax from perl again > include ports; > } > class ports{ > use the array that has been created by instantiating port multiple > times }Seems to me like this should be a native type and not something definable within Puppet. I''m really opposed to the idea of Puppet becoming yet-another-scripting-language. But a native-type would be awesome for this.
Matt Palmer
2007-Nov-14 21:27 UTC
Re: append to static array (was: Re: Why External Node Classification is my future)
On Wed, Nov 14, 2007 at 12:30:30PM -0800, Digant C Kasundra wrote:> --On Tuesday, October 30, 2007 2:23 AM -0700 Brian Finney > <y0gi636@gmail.com> wrote: > ># define for simple firewall control > > define port($port, $status){ > > push $ports, [$port,$status]; # borrowing syntax from perl again > > include ports; > > } > > class ports{ > > use the array that has been created by instantiating port multiple > > times } > > Seems to me like this should be a native type and not something definable > within Puppet. I''m really opposed to the idea of Puppet becoming > yet-another-scripting-language.Testify, brother! - Matt -- When the revolution comes, they won''t be able to FIND the wall. -- Brian Kantor, in the Monastery