# Licenses Guide

## Licenses Overview

Slurm can help with software license management by assigning available licenses to jobs at scheduling time. If the license are not available the jobs are kept pending until some other jobs using the licenses finishes freeing up the desired number of licenses. License in Slurm are essentially shared resources meaning configured resources that are not tied to a specific host, but are associated with the entire cluster.

License in Slurm can be configured in two ways.
- Local Licenses Local licenses means they are local to the cluster using the <it>slurm.conf</it> in which they are configured.
- Remote Licenses Remote licenses are served by the database and are configured using the <it>sacctmgr</it> command. This also makes them dynamic as upon running the command the <it>slurmdbd</it> updates all clusters the licenses are assigned to.

## Use Case

A site has two license servers, one provides by FlexNet serving 100 Nastran licenses and another one from Reprise License Management providing Matlab 50 licenses. The site has two clusters named fluid and pdf dedicated to run simulation jobs using both products. The managers want to split the number of Nastran licenses equally between clusters but assign 2/3 of Matlab to cluster pdf and the remaining 1/2 to fluid cluster.

## Solving using case with Slurm

Here we assume that both clusters have been configured correctly in the <it>slurmdbd</it> using the <it>sacctmgr command.

-     ->sacctmgr show clusters format=cluster,controlhost
         Cluster     ControlHost
      ---------- ---------------
           fluid     143.11.1.3
             pdf     144.12.3.2

- The licenses are added using the sacctmgr specifying the total count of licenses and the percentage that should allocated to each cluster.

-     sacctmgr add resource name=nastran cluster=fluid
      count=100 percentallowed=50 server=flex_host
      servertype=flexlm type=license
       Adding Resource(s)
        nastran@slurmdb
         Cluster - fluid      50%
       Settings
        Name           = nastran
        Server         = slurmdb
        Description    = nastran
        Manager        = flex_host
        Count          = 100
        Type           = License

  Identical command is issued to add the licenses to the other cluster pdf.
- The configured licenses are now visible in both cluster using the <it>scontrol</it> command. On cluster fluid:

      ->scontrol show lic
      LicenseName=nastran@slurmdb
          Total=50 Used=0 Free=50 Remote=yes

  On cluster pdf:

      ->scontrol show lic
      LicenseName=nastran@slurmdb
          Total=50 Used=0 Free=50 Remote=yes

Identical command have to be ran to add the matlab license to the cluster using different percentage and different license server as it different from the previous one.
- On cluster pdf

      scontrol show lic matlab@slurmdb
      LicenseName=matlab@slurmdb
          Total=35 Used=0 Free=35 Remote=yes

  On cluster fluid:

      scontrol show lic matlab@slurmdb
      LicenseName=matlab@slurmdb
          Total=15 Used=0 Free=15 Remote=yes

The <it>sacctmgr</it> command will not display the grand total of licenses.

    >sacctmgr show resource
          Name     Server     Type  Count % Allocated ServerType
    ---------- ---------- -------- ------ ----------- ----------
       nastran    slurmdb  License    100         100  flex_host
        matlab    slurmdb  License     50         100  flex_host

## Dynamic licenses

When the license counter and percentage is updated using the <it>sacctmgr</it> command the values are updated in the database and the updated values sent to the controller. In this way the remote licenses are also dynamic. It is possible for sites to write a script that detects global license counter changes due to new licenses being add or old licenses being removed and updates Slurm. Should the license count decrease the running jobs will not be affected only the dispatch of new job will reflect the new license count.

Last modified 30 May 2014