cfengine-develop
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Cfengine-develop] Re: Homework


From: Luke A. Kanies
Subject: Re: [Cfengine-develop] Re: Homework
Date: Tue, 4 Mar 2003 09:44:56 -0600 (CST)

On Tue, 4 Mar 2003, Andrew Stribblehill wrote:

> That said, I'm not sure we actually need associative arrays (or dicts
> or hashes, whatever you call them) in Cfengine, since for my example,
> the following already works:

One of the big reasons I think we need associative arrays is because they
are similar to objects in a lot of ways.  They would fit in well with
Hugo's mention earlier of process templates:

sshd = {
    "pattern" => "sshd",
    "initscript" => "/etc/init.d/sshd",
    "stop" => "$sshd{initscript} stop",
    "start" => "$sshd{initscript} start",
    "restart" => "$sshd{initscript} stop; $sshd{initscript} start",
    "runlevel" => "2",
    "runpriority" => "80",
}

# this would be a list...
processes = ( $sshd )

links:
  each(@processes) {
    /etc/init.d/$_{pattern} -> /etc/rc$_{runlevel}.d/S$_{runpriority}
  }

processes:
  each(@processes) {
    $_{pattern} restart=$_{restart} useshell=$_{useshell}
  }

#------------

You get the idea; there are details associated with a given concept or
object which are needed by multiple sections in cfengine.  Currently,
those details all need to be maintained independently, and we have to fake
separate namespaces by prefixing all variables with a string, and then we
have to man set up each section to look for the correct info for every
separate object.

Associative arrays are the next best thing to objects, and they give us
that separate namespace capability, allowing us to unify all of the
information about an object, and then use that info however we want later.

Obviously, the syntax was just a way to make a point; I'm not specifically
recommending that syntax....

Luke

-- 
"The Internet, of course, is more than just a place to find pictures of
people having sex with dogs."             -- Time Magazine, 3 July 1995




reply via email to

[Prev in Thread] Current Thread [Next in Thread]