aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/mass-pnf-sim/MassPnfSim.py
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-06-05 15:07:56 +0200
committerMorgan Richomme <morgan.richomme@orange.com>2020-06-05 13:47:18 +0000
commita3737ae0e71cc2658fd4a673cfa91001b03b3680 (patch)
treedb4797cd876c55e541ed60cd03e2c9b9c57f1116 /test/mocks/mass-pnf-sim/MassPnfSim.py
parentdf5004b094fb34c72eb7c96961a466a2b6f69f22 (diff)
Support stopping sending PNF registration messages in Python module
Change-Id: Iae7d300e6e09d152b6e7daaebd9c85ba763fc077 Issue-ID: INT-1613 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test/mocks/mass-pnf-sim/MassPnfSim.py')
-rwxr-xr-xtest/mocks/mass-pnf-sim/MassPnfSim.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py
index 77076a6e2..e4b19fd9e 100755
--- a/test/mocks/mass-pnf-sim/MassPnfSim.py
+++ b/test/mocks/mass-pnf-sim/MassPnfSim.py
@@ -59,6 +59,9 @@ def get_parser():
# Trigger command 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=0)
+ # Stop-simulator command parser
+ parser_stopsimulator = subparsers.add_parser('stop_simulator', help='Stop sending PNF registration messages')
+ parser_stopsimulator.add_argument('--count', help='Instance count to stop', type=int, metavar='INT', default=0)
# Trigger-custom command parser
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,
@@ -108,6 +111,7 @@ class MassPnfSim:
sim_base_url = 'http://{}:' + str(sim_port) + '/simulator'
sim_start_url = sim_base_url + '/start'
sim_status_url = sim_base_url + '/status'
+ sim_stop_url = sim_base_url + '/stop'
sim_container_name = 'pnf-simulator'
rop_script_name = 'ROP_file_creator.sh'
@@ -127,7 +131,7 @@ class MassPnfSim:
exit(1)
# Validate --count option for subcommands that support it
- if self.args.subcommand in ['start', 'stop', 'trigger', 'status']:
+ if self.args.subcommand in ['start', 'stop', 'trigger', 'status', 'stop_simulator']:
if self.args.count > self.existing_sim_instances:
self.logger.error('--count value greater that existing instance count')
exit(1)
@@ -345,3 +349,15 @@ class MassPnfSim:
# Make the 'trigger_custom' an alias to the 'trigger' method
trigger_custom = trigger
+
+ def stop_simulator(self):
+ self.logger.info("Stopping sending PNF registration messages:")
+ for i in range(*self._get_iter_range()):
+ sim_ip = self._get_sim_instance_data(i)
+ self.logger.info(f'Stopping {self.sim_dirname_pattern}{i} instance:')
+ self.logger.info(f' PNF-Sim IP: {sim_ip}')
+ sim_response = post('{}'.format(self.sim_stop_url).format(sim_ip))
+ if sim_response.status_code == codes.ok:
+ self.logger.info(' Simulator response: ' + sim_response.text)
+ else:
+ self.logger.warning(' Simulator response ' + sim_response.text)