2.6. hook module

class hook.Hook(test)

Bases: object

Generic hooks before/after API/CLI calls

after_api(api_name, api_args)

Function called after API call

@param api_name: name of the API @param api_args: tuple containing the API arguments

after_cli(cli)

Function called after CLI call

before_api(api_name, api_args)

Function called before API call Emit a debug message describing the API name and arguments

@param api_name: name of the API @param api_args: tuple containing the API arguments

before_cli(cli)

Function called before CLI call Emit a debug message describing the CLI

@param cli: CLI string

class hook.PollHook(test)

Bases: hook.Hook

Hook which checks if the vpp subprocess is alive

before_api(api_name, api_args)

Check if VPP died before executing an API

Parameters
  • api_name – name of the API

  • api_args – tuple containing the API arguments

Raises

VppDiedError – exception if VPP is not running anymore

before_cli(cli)

Check if VPP died before executing a CLI

Parameters

cli – CLI string

Raises

Exception – exception if VPP is not running anymore

on_crash(core_path)
poll_vpp()

Poll the vpp status and throw an exception if it’s not running :raises VppDiedError: exception if VPP is not running anymore

class hook.StepHook(test)

Bases: hook.PollHook

Hook which requires user to press ENTER before doing any API/CLI

before_api(api_name, api_args)

Wait for ENTER before executing API

before_cli(cli)

Wait for ENTER before executing CLI

skip()
user_input()