How-to: Distribute a module to an agent

Overview

This example illustrates how the agent plugin can be used to distribute a module to a remote Pineapple agent.

Define the module

Pineapple's unit of work is modules. A module is a self contained unit which can contain models, scripts and binaries. Models serves to specify test cases, deployment of applications, configuration of devices or execution of scripts.

The default directory for modules is ${user.home}/.pineapple/modules. We create a module be creating a module directory named agent-distribute-module in the modules directory.

The module for this example will end up with the structure:

agent-distribute-module
 |
 +--- models     
       +--- local.xml 

Define the module model

The model file for distribution of the module planet-violet-001 is named local.xml and it has the content:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mmd:models xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0"       
    xmlns:pap="http://pineapple.dev.java.net/ns/plugin/agent_1_0" >
    <mmd:model target-resource="agent-node1">
        <mmd:content>
            <pap:agent>
                <pap:distribute-module module="planet-violet-001" />
            </pap:agent>                        
        </mmd:content>
    </mmd:model>
</mmd:models>

The configuration details

Two schema are used in the model file. The http://pineapple.dev.java.net/ns/module_model_1_0 is used to define the namespace mmd which defines the general infrastructure for models. The http://pineapple.dev.java.net/ns/plugin/agent_1_0 schema is used to define the namespace pap which is used to define the model for the agent plugin. Since multiple schemas are used to define the model file, the elements are qualified.

The target-resource attribute defines a reference to the resource which is targeted when the model executed. In this case, the value agent-node1 is a reference to a resource which defines a Pineapple agent.

The pap:agent element defines the root of model for the agent plugin. The pap:distribute-module element defines the module distribute command where the local module targeted for distribution to the remote Pineapple agent is identified by the value of module attribute.

Invoke Pineapple to execute model

Start your Pineapple client of choice:

  • Select the module named agent-distribute-module
  • Select the local model.
  • Invoke any operation to distribute the module.