# HG changeset patch # User Goffi # Date 1550265223 -3600 # Node ID f61a50790faef35255d42e376be96856e10865e4 # Parent ae127e14b0405bb93b4b5050951abdf7acce280b jp (pubsub/node): added purge command diff -r ae127e14b040 -r f61a50790fae sat_frontends/jp/cmd_pubsub.py --- a/sat_frontends/jp/cmd_pubsub.py Fri Feb 15 22:13:43 2019 +0100 +++ b/sat_frontends/jp/cmd_pubsub.py Fri Feb 15 22:13:43 2019 +0100 @@ -161,6 +161,57 @@ ) +class NodePurge(base.CommandBase): + + def __init__(self, host): + super(NodePurge, self).__init__( + host, + "purge", + use_pubsub=True, + pubsub_flags={C.NODE}, + help=_(u"purge a node (i.e. remove all items from it)"), + ) + self.need_loop = True + + def add_parser_options(self): + self.parser.add_argument( + "-f", + "--force", + action="store_true", + help=_(u"purge node without confirmation"), + ) + + def psNodePurgeCb(self): + self.disp(_(u"node [{node}] purged successfully").format(node=self.args.node)) + self.host.quit() + + def start(self): + if not self.args.force: + if not self.args.service: + message = _(u"Are you sure to purge PEP node [{node_id}]? " + u"This will delete ALL items from it!").format( + node_id=self.args.node + ) + else: + message = _( + u"Are you sure to delete node [{node_id}] on service [{service}]? " + u"This will delete ALL items from it!" + ).format(node_id=self.args.node, service=self.args.service) + self.host.confirmOrQuit(message, _(u"node purge cancelled")) + + self.host.bridge.psNodePurge( + self.args.service, + self.args.node, + self.profile, + callback=self.psNodePurgeCb, + errback=partial( + self.errback, + msg=_(u"can't purge node: {}"), + exit_code=C.EXIT_BRIDGE_ERRBACK, + ), + ) + + class NodeDelete(base.CommandBase): def __init__(self, host): base.CommandBase.__init__( @@ -188,7 +239,7 @@ def start(self): if not self.args.force: if not self.args.service: - message = _(u"Are you sure to delete pep node [{node_id}] ?").format( + message = _(u"Are you sure to delete PEP node [{node_id}] ?").format( node_id=self.args.node ) else: @@ -642,6 +693,7 @@ subcommands = ( NodeInfo, NodeCreate, + NodePurge, NodeDelete, NodeSet, NodeAffiliations,