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

Peter Steele psteele at maxiscale.com
Fri May 9 18:38:19 CDT 2008


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);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.urbancode.com/pipermail/anthill-pro/attachments/20080509/b749ee58/attachment.htm


More information about the Anthill-pro mailing list