aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-05-11 06:00:00 -0700
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-05-12 05:50:41 +0000
commit950cbadbcc2376acc44af5595c8f60b68fc26c5c (patch)
treefedf43f91827ababc788585fcf197755ae01c6ae
parentc85faa46e105c7710bd89032c47ccad43b95d5c6 (diff)
Get the routine name to call with getattr
Each subcommand has a corresponding method in MassPnfSim class hence it can be called directly by it's name. Change-Id: Id7139a5f96cceac89559bd68d89085130703f4bd Issue-ID: INT-1577 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
-rwxr-xr-xtest/mocks/mass-pnf-sim/MassPnfSim.py2
-rwxr-xr-xtest/mocks/mass-pnf-sim/mass-pnf-sim.py17
2 files changed, 3 insertions, 16 deletions
diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py
index 48b1d7416..1a6ae8a78 100755
--- a/test/mocks/mass-pnf-sim/MassPnfSim.py
+++ b/test/mocks/mass-pnf-sim/MassPnfSim.py
@@ -53,7 +53,7 @@ def get_parser():
parser_trigger = subparsers.add_parser('trigger', help='Trigger one single VES event from each simulator')
parser_trigger.add_argument('--count', help='Instance count to trigger', type=int, metavar='INT', default=1)
# Trigger-custom command parser
- parser_triggerstart = subparsers.add_parser('trigger-custom', help='Trigger one single VES event from specific simulators')
+ parser_triggerstart = subparsers.add_parser('trigger_custom', help='Trigger one single VES event from specific simulators')
parser_triggerstart.add_argument('--triggerstart', help='First simulator id to trigger', type=int,
metavar='INT', required=True)
parser_triggerstart.add_argument('--triggerend', help='Last simulator id to trigger', type=int,
diff --git a/test/mocks/mass-pnf-sim/mass-pnf-sim.py b/test/mocks/mass-pnf-sim/mass-pnf-sim.py
index 1a57cbe04..fe6062637 100755
--- a/test/mocks/mass-pnf-sim/mass-pnf-sim.py
+++ b/test/mocks/mass-pnf-sim/mass-pnf-sim.py
@@ -18,20 +18,7 @@ if __name__ == '__main__':
MassPnfSim.log_lvl = log_lvl
if args.subcommand is not None:
- sim = MassPnfSim(args)
- if args.subcommand == 'bootstrap' :
- sim.bootstrap()
- if args.subcommand == 'clean':
- sim.clean()
- if args.subcommand == 'start':
- sim.start()
- if args.subcommand == 'status':
- sim.status()
- if args.subcommand == 'stop':
- sim.stop()
- if args.subcommand == 'trigger':
- sim.trigger()
- if args.subcommand == 'trigger-custom':
- sim.trigger_custom()
+ sim_routine = getattr(MassPnfSim(args), args.subcommand)
+ sim_routine()
else:
parser.print_usage()