Recipe API

Module implementing the BaseRecipe class.

class lnst.Controller.Recipe.BaseRecipe(**kwargs)

Base class for LNST Recipe definition.

Every LNST Recipe written by testers should be inherited from this class. An LNST Recipe is composed of several parts:

  • Requirements definition - you define recipe requirements in a derived class by defining class attributes of the HostReq type. You can further specify Ethernet Device requirements by defining DeviceReq attributes of the lnst.Controller.Requirements.HostReq object. Example:

    class MyRecipe(BaseRecipe):
        m1 = HostReq(arch="x86_64")
        m1.eth0 = DeviceReq(driver="ixgbe")
    
  • Parameter definition (optional) - you can define paramaters of your Recipe by defining class attributes of the Param type (or inherited). These parameters can then be accessed from the test() method to change it’s behaviour. Parameter validity (type) is checked during the instantiation of the Recipe object by the base __init__ method. You can define your own __init__ method to implement more complex Parameter checking if needed, but you MUST call the base __init__ method first. Example:

    class MyRecipe(BaseRecipe):
        int_param = IntParam(mandatory=True)
        optional_param = IntParam()
    
        def test(self):
            x = self.params.int_param
            if "optional_param" in self.params:
                x += self.params.optional_param
    
    MyRecipe(int_param = 2, optional_param = 3)
    
  • Test definition - this is done by defining the test() method, in this method the tester has direct access to mapped LNST agent Hosts, can manipulate them and implement his tests.

Variables:
  • matched – When running the Recipe the Controller will fill this attribute with a Hosts object after the Mapper finds suitable agent hosts.

  • req – Instantiated Requirements object, you can optionally change the Recipe requirements through this object during runtime (e.g. variable number of hosts or devices of a host based on a Parameter)

  • params – Instantiated Parameters object, can be used to access the calculated parameters during Recipe initialization/execution

test()

Method to be implemented by the Tester