<!--
  User's Guide  Chapter
  $Header$

  <chapter>
    <title>Title of the chapter</title>
    <filename>Filename of the chapter</filename>
    <shortname>Shortname for the chapter</shortname>
    <stylesheet>stylesheet filename (optional)</stylesheet>
    <scripts>script filename (optional)</scripts>
    <contents>
      <section>
        <title>Heading of the section</title>
        <tag>Tag used to reference (optional)</tag>
        <updated>Date last updated</updated>
        <contents>
          Contents of the section.
          May include either HTML within paragraphs ("p")
          or more section's
        </contents>
      </section>
    </contents>
  </chapter>
  
-->
<chapter>
  <title>DSMT User Guide</title>
  <filename>DSMTUserGuide.php</filename>
  <shortname>DSMTUserGuide</shortname>
  <contents>
    <section>
      <title>Overview</title>
      <tag>Overview</tag>
      <contents>
        <p>
        The Distributed Services Management Toolkit (DSMT) 
        provides the tools for easy
        deployment and operation of an application on 
        multiple PlanetLab nodes.  
        DSMT contains make it easy to create PlanetLab 
        slices, create slivers on PlanetLab
        nodes, install an application on the 
        multiple nodes and monitor the operation
        on the nodes.
        </p>
        <p>
          DSMT will:
          <ul>
            <li>select the PlanetLab nodes for your application</li>
            <li>install your application on those nodes</li>
            <li>monitor the operation of your application and</li>
            <li>restart nodes or reallocate nodes as necessary</li>
          </ul>
        </p>
        <p>
        This guide gives step-by-step instructions on using DSMT
        to get an application installed and run on PlanetLab.
        </p>
        <p>
          Some references that you will find useful:
          <ul>
            <li><a href="http://psepr.org/">Planetary Scale Event Propagation
            and Routing</a>
            ( aka "PsEPR"): 
            this is the eventing system used behind the DSMT scenes;</li>
            <li><a href="http://www.dsmt.org/docs/DSMTCGuide.php">
            DSMTC Reference Guide</a>:
            detailed documentation on the dsmtc command;</li>
            <li><a href="http://www.dsmt.org/docs/DSMTArchGuide.php">
            DSMT Overview</a>:
            gives the overall architecture and design of the
            Distributed Services Management Toolkit.</li>
          </ul>
        </p>
      </contents>
    </section>
    <section>
      <title>Getting Your Application Distributed</title>
      <tag>GettingYourApplicationDistributed</tag>
      <contents>
        <p>
          The steps to use DSMT are:
          <ul>
            <li>have PI create a managed node
            (or, make an existing node 'managed')</li>
            <li>select the deployment system you're using</li>
            <li>load your application into the deployment repository</li>
            <li>specify the node selection rules you wish</li>
            <li>watch your application be installed and run</li>
          </ul>
        </p>
        <p>
          Using <code>dsmtc</code> to run an rpm on 10 randomly selected
          PlanetLab nodes and keep selecting nodes until 10 are running, 
          the steps look like:
          <pre>
# Assuming the PI has created a slice 'my_slice' for user 'me@example.com'
> <b>dsmtc --cli --slice my_slice</b>
dsmtc me@example.com [user] my_slice> <b>manage</b>
dsmtc me@example.com [user] my_slice> <b>depot put my-application.rpm</b>
dsmtc me@example.com [user] my_slice> <b>setagent --agent deployment-agent</b>
dsmtc me@example.com [user] my_slice> <b>plan set --plan goodNodes --base minus left=all_nodes right=failed</b>
dsmtc me@example.com [user] my_slice> <b>plan set --plan only10 --base limit parent=goodNodes count=10</b>
dsmtc me@example.com [user] my_slice> <b>setplan --plan only10</b>
dsmtc me@example.com [user] my_slice> 
dsmtc me@example.com [user] my_slice> <b>status</b>
...
</pre>
        </p>
        <p>
          DSMT is for building a service on PlanetLab.
          A service is made up of instances that run on multiple
          PlanetLab nodes.
          Independent of these instances is a (possibly distributed)
          <i>Service Planner</i>.
          The Service Planner makes placement and control decisions
          for the overall service.
          For instance, the service planner would decide that, because
          of an increased load on the service, new instances need
          to be created.
        </p>
        <p>
          DSMT does not implement a Service Planner -- later versions
          will include the tools for building these
          (this is an interesting research area that we hope will be
          filled by someone)
          but it does provide a command line interface for an
          individual to act as the service planner.
          Additionally, DSMT includes a <i>Container Manager</i>
          that can allocate and install the service instances
          on PlanetLab nodes.
          For instance, the Container Manager can install a service
          on 10 geographically dispersed PlanetLab nodes and
          re-install the instances and nodes go down.
        </p>
        <section>
          <title>Creation of Slice</title>
          <tag>CreationofSlice</tag>
          <contents>
            <p>
              PlanetLab requires a slice to be created by a site's
              principle investigator ("PI").
              If you don't know the PI for your site, visit the
              <a href="http://planet-lab.org/institutions/">PlanetLab
              institiutions</a>
              page.
            </p>
            <p>
              There are two ways to create a slice that will be
              managed by DSMT: the PI can use the <code>dsmtc</code>
              command to create a managed slice or the user can
              use the <code>dsmtc</code> command to make an
              existing slice managed.
            </p>
            <section>
              <title>PI Creation of a Managed Slice</title>
              <tag>PICreationofaManagedSlice</tag>
              <contents>
                <p>
                  After <a href="/download.php">installing</a>
                  <code>dsmtc</code>,
                  the PI creates the slice with:
                </p>
                <pre>
dsmtc create --user PIACCOUNT --password PIPASSWORD --role PI 
         --user SLICEUSER --slice SLICENAME 
                </pre>
                <p>
                  This will create the slice named <code>SLICENAME</code>
                  and add the PlanetLab user <code>SLICEUSER</code>
                  to it.
                  The <code>SLICEUSER</code> must be specified as the
                  person the PI is creating the slice for.
                  This will allow that user to <code>ssh</code>
                  to the slice.
                </p>
              </contents>
            </section>
            <section>
              <title>Making an Existing Slice Managed</title>
              <tag>MakinganExistingSliceManaged</tag>
              <contents>
                <p>
                  If the site's PI has already created a slice for
                  a user, that user can make the slice managed by
                  <code>DSMT</code> with the command:
                </p>
                <pre>
dsmtc manage -slice SLICENAME 
                </pre>
              </contents>
            </section>
          </contents>
        </section>
        <section>
          <title>Setting Accounts and Passwords</title>
          <tag>SettingAccountsandPasswords</tag>
          <contents>
            <p>
              <code>dsmtc</code> requires accounts and passwords
              for access to PlanetLab for the user.
              There are two of these: the PlanetLab
              account name and password
              (the ones the user uses to log into PlanetLab) and the 
              public/private key pair that is associated with the
              PlanetLab account.
            </p>
            <p>
              The PlanetLab account and password can be entered
              everytime <code>dsmtc</code> is used.  The parameters
              are:
            </p>
            <pre>
dsmtc op --user ACCOUNT --password PASSWORD --role user otherParameters
            </pre>
            <p>
              One can save this input by creating a file named
              <code>$HOME/.slices</code>.
              This file contains:
            </p>
            <pre>
account: planetlabuser@user.example.com
password: PASSWORD
role: user
            </pre>
            <p>
              Where <code>planetlabuser@user.example.com</code>
              and <code>PASSWORD</code> are replaced with your
              account specifics.
              Once this file is created, it will be read by
              <code>dsmtc</code> every time it is run.
            </p>
            <p>
              <code>dsmtc</code> also uses the PlanetLab
              account's public/private key to provide additional
              authorization.
              Invoking <code>dsmtc</code> will ask for the
              passphrase for the private key associated with
              the PlanetLab account's key.
              <code>dsmtc</code> currently does not use
              <code>ssh-agent</code> so the passphrase
              must be entered every time.
            </p>
          </contents>
        </section>
        <section>
          <title>Preparing Application</title>
          <tag>PreparingApplication</tag>
          <contents>
            <p>
              The installation of your application on the PlanetLab
              nodes is done by the installation agent you set.
              These are instructions for using
              <code>deployment-agent</code>.
              The steps will be different for other installation
              agents.
            </p>
            <p>
              <code>deployment-agent</code>
              will take your application in two ways:
              as your own rpm package or as a tarball that
              is converted into an installable rpm with
              <code>rpmgen</code>.
            </p>
            <p>
              Once the rpms are created, they are uploaded to
              the repositry using the <code>dsmtc depot</code> commands.
            </p>
            <section>
              <title>Deploying Your Application RPM</title>
              <tag>DeployingYourApplicationRPM</tag>
              <contents>
              </contents>
            </section>
            <section>
              <title>Deploying Your Application with <cdoe>rpmgen</cdoe></title>
              <tag>DeployingYourApplicationwithrpmgen</tag>
              <contents>
                <p>
                  <code>rpmgen</code> takes an application tarball
                  and some scripts that start and stop the application
                  and creates an rpm for the managed applicaiton.
                </p>
                <p>
                  One way of building your application is to place
                  the application in a deployment tree and 
                  add to that tree the files
                  <code>start.sh</code>
                  <code>stop.sh</code> and
                  <code>status.sh</code>.
                </p>
                <p>
                  Assume the application is named <code>pinger</code>
                  and it will be installed, on the PlanetLab nodes,
                  in the directory <code>/usr/local</code>.
                  We create the tar file that, in part, contains:
                </p>
                <pre>
tar -tzf pinger-1.8.tgz
pinger-1.8/
pinger-1.8/pinger
pinger-1.8/start.sh
pinger-1.8/stop.sh
pinger-1.8/status.sh
...
                </pre>
                <p>
                  The <code>start.sh</code> and <code>stop.sh</code>
                  scripts start and top the application while
                  <code>status.sh</code> returns the status of the
                  application and, specificly, returns the exit
                  code of zero if the application is healthy
                  and non-sero if something is wrong.
                </p>
                <p>
                  Then the following invocation of <code>rpmgen</code>
                  would create the deployable application.
                </p>
                <pre>
rpmgen --installdir /usr/local --file pinger-1.8.tgz 
           --start /usr/local/pinger/start.sh 
           --stop /usr/local/pinger/stop.sh 
           --status /usr/local/pinger/status.sh
                </pre>
                <p>
                  This invocation of <code>rpmgen</code>
                  will create the files
                  <code>pinger-1.8.i386.rpm</code>
                  and
                  <code>dsmtw_pinger-1.8.i386.rpm</code>.
                  These files are then uploaded to the deployment
                  repository with the following <code>dsmtc</code> commands:
                </p>
                <pre>
dsmtc depot put pinger-1.8.i386.rpm
dsmtc depot put dsmtw_pinger-1.8.i386.rpm
                </pre>
                <p>
                  You can view the contents of the repository with
                  <code>dsmtc depot ls</code>.
                </p>
              </contents>
            </section>
          </contents>
        </section>
        <section>
          <title>Selecting Nodes</title>
          <tag>Selecting Nodes</tag>
          <contents>
            <p>
              Once you have your application in the repository,
              you give the <code>container-mgr</code>
              the selection of PlanetLab nodes to add to the slice.
              Several examples of this is given in the
              DSMTC Reference Guide.
            </p>
            <p>
              Here are some examples of node selection:
            </p>
            <p>
              Selecting all nodes:
<pre>
dsmtc setplan --plan all_nodes                
</pre>
            </p>
            <p>
              Selecting 10 random nodes. Here we define our own
              plan ("only10") and then set it to the slice.
<pre>
dsmtc plan set --plan only10 --base limit count=10
dsmtc setplan --plan only10
</pre>
            </p>
            <p>
              Selecting 10 nodes but removing nodes that 'fail'.
              This uses the 'failed' set which collects nodes
              that timeout for various reasons.  This creates
              the set 'goodNodes' which are all the nodes minus
              the failed ones, then chooses 10 from that set.
<pre>
dsmtc plan set --plan myFailed --base failed
dsmtc plan set --plan goodNodes --base minus left=all_nodes right=myFailed
dsmtc plan set --plan only10GoodNodes --base limit parent=goodNodes count=10
dsmtc setplan --plan only10GoodNodes
</pre>
            </p>
            <p>
              One can select nodes based on geographic location,
              operational status and more complex rulesets
              by using query systems like
              <a href="">SWORD</a>
              .
              Refer to the <ref c="DSMTCGuide">DSMTC Reference Guide</ref>
              for detailed descriptions of all the functions
              available.
            </p>
          </contents>
        </section>
        <section>
          <title>Monitoring Deployment</title>
          <tag>MonitoringDeployment</tag>
          <contents>
          <p>
            As the containers are created and the application is
            installed, status events are created.
            These
            <ref c="DSMTArchGuide" t="StatusMessages">status events</ref>
            are sent over <psepr>PsEPR</psepr>
            and can be received by anyone listening to the
            <a href="Channels.php">status channels</a>.
          </p>
          <p>
            The <code>DSMTViewer</code> is an application that
            listens to the messages and displays the status of the
            application as it is installed.
            As each of the components are instantiated, initialized
            and set running, the status will be displayed as
            going from yellow to green.
            The <a href="DSMTArchGuide.php">architecture guide</a>
            has a
            <ref c="DSMTArchGuide" t="StatusMessages">section</ref>
            describing all the components and their installation
            status as well as giving a detailed list of all
            the events that will be output as the application
            is installed.
          </p>
          </contents>
        </section>
        <section>
          <title>Monitoring Application</title>
          <tag>MonitoringApplication</tag>
          <contents>
            <p>
              Once the application is installed, the
              deployment-agent periodically invokes
              <code>/etc/init.d/dsmtw_APPNAME.sh status</code>
              to get the status of the application.
              (Of course, "APPNAME" is replaced with the
              name of the application.)
              If this script has the exit status of zero,
              the application is happily running.
              If the exit status is non-zero, the application
              has failed for some reason.
              This will cause the
              deployment-agent to send out 'failed' events.
              Advanced application service planners can
              see this and change the appliction operation.
              This will also cause the 'running' timeout
              in the
              container-manager 
              <ref c="DSMTCGuide" t="failed">failed rule</ref>
              .
            </p>
            <p>
              This does not preclude the application having
              it's own status reporting and operation
              management function.
            </p>
          </contents>
        </section>
      </contents>
    </section>
  </contents>
</chapter>
<!-- vim: tabstop=2 shiftwidth=2 autoindent expandtab
-->

