[Anthill-pro] Select a list of agents from an environment

Steve Boone sbb at urbancode.com
Tue May 27 11:06:32 CDT 2008


To make it truly dynamic, the way you have it set up is the best solution.

It is a bit tedious to have to type the names of the agents in, but this
does have some benefits.  It will ensure that only those agents are used,
and that an agent that should not get a job delegated to it, won't.

On Fri, May 9, 2008 at 7:38 PM, Peter Steele <psteele at maxiscale.com> wrote:

>  I am writing a deploy job that will be run as a non-originating workflow.
> We have set of machines that a build can potentially be deployed to, and I
> have these machines grouped in their own environment. On a given run of the
> deploy workflow I want to be able to filter the list of agents that will be
> selected from this environment, for example as a comma separated list that
> the user fills in when the secondary process is run:
>
>
>
>     Workflow:                  deploy server artifacts
>
>     Environment:             qa test servers
>
>     Servers to Populate:   qa-dataserv1,qa-dataserv2,qa-dataserv3
>
>>
>
>
> and so on. The "Servers to Populate" field is a simple text field which the
> user fills in with the list of servers (agents) that he wants to deploy the
> build to. So, although the "qa test servers" environment might have 50
> servers in it, on a given run the use can select the specific systems he's
> interested in.
>
>
>
> I created the agent filter below to accomplish this, and it seems to work
> well. My only issue is that requiring the user to enter the agent names is a
> bit tedious, especially if they have to enter more than three or four. Is
> there a better way I could accomplish what I'm trying to do here? Being able
> to present the user with a full list of agents that they could select
> multiple entries from would be better for example. As for the script itself,
> are there any improvements I could make?
>
>
>
> import com.urbancode.anthill3.domain.agent.Agent;
>
> import com.urbancode.anthill3.runtime.scripting.helpers.*;
>
>
>
> Where anyWhere = new Where()
>
> {
>
>     public Agent[] filter(Agent[] agents)
>
>     {
>
>         String agentNames = BuildRequestLookup.getCurrent().getProperty("agentNames");
>
>         List agentList = new ArrayList();
>
>
>
>         for (String agentName : (agentNames +",").split(","))
>
>         {
>
>             for (int i = 0; i < agents.length; i++)
>
>             {
>
>                 if (agents[i].equals(agentName))
>
>                 {
>
>                     agentList.add(agents[i]);
>
>                     break;
>
>                 }
>
>             }
>
>         }
>
>         Agent[] selectedAgents = new Agent[agentList.size()];
>
>         for (int i = 0; i < selectedAgents.length; i++)
>
>         {
>
>             selectedAgents[i] = (Agent)agentList.get(i);
>
>         }
>
>
>
>         return selectedAgents;
>
>     }
>
> };
>
>
>
> return Where.is(anyWhere);
>
>
> _______________________________________________
> Anthill-pro mailing list
> Anthill-pro at lists.urbancode.com
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.urbancode.com/pipermail/anthill-pro/attachments/20080527/08943752/attachment.htm


More information about the Anthill-pro mailing list