+ # MassPnfSim class actions decorator
+ class _MassPnfSim_Decorators:
+ @staticmethod
+ def validate_subcommand(method):
+ def wrapper(self):
+ # Validate 'trigger_custom' subcommand options
+ if self.args.subcommand == 'trigger_custom':
+ if (self.args.triggerend + 1) > self._enum_sim_instances():
+ self.logger.error('--triggerend value greater than existing instance count.')
+ exit(1)
+
+ # Validate --count option for subcommands that support it
+ if self.args.subcommand in ['start', 'stop', 'trigger', 'status', 'stop_simulator']:
+ if self.args.count > self._enum_sim_instances():
+ self.logger.error('--count value greater that existing instance count')
+ exit(1)
+ if not self._enum_sim_instances():
+ self.logger.error('No bootstrapped instance found')
+ exit(1)
+
+ # Validate 'bootstrap' subcommand
+ if (self.args.subcommand == 'bootstrap') and self._enum_sim_instances():
+ self.logger.error('Bootstrapped instances detected, not overwiriting, clean first')
+ exit(1)
+ method(self)
+ return wrapper
+