Command Line Tools

The BonFIRE CLI tools are meant to provide users with a way to interact with the BonFIRE broker API from a command line interface. This usage might happen either manually or programatically (i.e. scripted).

APIs provided

The CLI tools provide a commandline script friendly wrapper around the BonFIRE Resource Manager API.

APIs used

The CLI tools use the BonFIRE Resource Manager API.

Message queue use

The CLI tools do not read or write from the message queue.

Assumptions

No documented assumptions.

Implementation details

The structure of these tools is inspired by the command line interface offered by the OpenNebula toolkit, in the sense that individual tools exists to interact with resources of a particular type. These individual tools are:

  • bfexperiment - to interact with experiments
  • bfcompute - to interact with compute resources
  • bfstorage - to interact with storage resources
  • bfnetwork - to interact with network resources
  • bfsitelink - to interact with Autobahn sitelinks
  • bfrouter - to interact with Federica routers
  • bffednet - to interact with Federica networks
  • bfphysicalrouter - to retrieve information on physical routers available through Federica
  • bfreservation - to create or retrieve reservations
  • bflocation - to retrieve information on BonFIRE sites

The general usage pattern is the same for all these tools:

# <clitool> <command> <arguments ...>  [<options ...>]

where <clitool> is one of the tools mentioned above, <command> is one of {info|list|show|create|update|delete}, <arguments ...> are command specific arguments and [<options ...>] are additional options. Both generic that apply to all command, as well as command specific options exist. Options are - as the name implies - always optional.

The meaning of the individual commands is as follows:

  • info - display configuration settings and some system information for diagnostic purposes. The output of this command is the same for all tools and should be included when reporting any issues.
  • list - list the items in question. (translated to a HTTP GET request on the broker)
  • show - display information on a particular item (also corresponds to a GET)
  • create - create an item. (corresponds to a POST)
  • update- change one or mor parameters of an item (corresponds to PUT)
  • delete - delete a particular item (corresponds to DELETE)
  • ssh - Open an SSH connection to a BonFIRE compute resource. Only applicable to the bfcompute tool.

Each tool is implemented as its own Python class. The name of this class and the file it is implemented in match the respective tool, i.e. the bfexperiment tool is implemented through the BFExperimentTool class in the file bfexperiment.py. A thin wrapper script is installed for each tool to invoke it (for bfexperiment this is called bfexperiment.bat on MS Windows and bfexperiment on other systems). All tool classes derive from a common base class (CLITool, implemented in ``CLITool).

The following functions are provided by the CLITool class and can be overridden to implement tool specific behaviour:

_get_arg_parser(action, parser):

This function will be called when initializing a tool, after generic options have been parsed and before any specific action takes places. action indicates the action chosen by the user. parser is an ArgumentParser object from the argparse module. The callee is responsible for adding additional options appropriate to the specific tool and command combination.

_action_create(args):

Called when the create action was specified on the command line. args is a Namespace object from the argparse module obtained by parsing the command line. The callee is responsible for enacting any operations neccessary to perform the requested action with the specified arguments. Must return a tuple consisting of the URL path for the subsequent OCCI POST request and the XML to be sent with it.

_action_update(args):

Called when the update action was specified on the command line. args is a Namespace object from the argparse module obtained by parsing the command line. The callee is responsible for enacting any operations neccessary to perform the requested action with the specified arguments. Must return a tuple consisting of the URL path for the subsequent OCCI PUT request and the XML to be sent with it.

_action_show(args):

Called when the show action was specified on the command line. args is a Namespace object from the argparse module obtained by parsing the command line. The callee is responsible for retrieving the specified resource. Must return the BonFIRE resource in question.

_action_list(args):

Called when the list action was specified on the command line. args is a Namespace object from the argparse module obtained by parsing the command line. The callee is responsible for retrieving the specified resources. Must return an iterable of the BonFIRE resources in question.

_action_delete(args):

Called when the delete action was specified on the command line. args is a Namespace object from the argparse module obtained by parsing the command line. The callee is responsible for enacting any operations neccessary to perform the requested action with the specified arguments. Must return the URL path for the subsequent OCCI DELETE request.

_action_ssh(args):

Called when the ssh action was specified on the command line. args is a Namespace object from the argparse module obtained by parsing the command line. The callee is responsible for retrieving the specified resource. Must return the BonFIRE resource in question.

_handle_result(action, args, result):

Called after the appropriate _action_* function has completed. action indicates the action chosen by the user, args is a Namespace object from the argparse module obtained by parsing the command line, result is the value returned by the corresponding _action_* call. The callee is responsible for handling the result accordingly. Usually, results are handled in a generic manner in the CLITool base class. Currently this is only used by the bfcompute tool to implement the ssh command.

Table Of Contents

Previous topic

Restfully

Next topic

Test Infrastructure

This Page