jp (pubsub/node): added set command
This commit is contained in:
parent
34f6f89025
commit
afef209d70
1 changed files with 38 additions and 1 deletions
|
|
@ -63,9 +63,46 @@ class NodeInfo(base.CommandBase):
|
|||
callback=self.psNodeConfigurationGetCb,
|
||||
errback=self.psNodeConfigurationGetEb)
|
||||
|
||||
class NodeSet(base.CommandBase):
|
||||
|
||||
def __init__(self, host):
|
||||
base.CommandBase.__init__(self, host, 'set', use_output=C.OUTPUT_DICT, use_verbose=True, help=_(u'set node configuration'))
|
||||
self.need_loop=True
|
||||
|
||||
def add_parser_options(self):
|
||||
self.parser.add_argument("-f", "--field", type=base.unicode_decoder, action='append', nargs=2, dest='fields',
|
||||
required=True, metavar=(u"KEY", u"VALUE"), help=_(u"configuration field to set (required)"))
|
||||
self.parser.add_argument("node", type=base.unicode_decoder, help=_(u"node to request"))
|
||||
self.parser.add_argument("service", type=base.unicode_decoder, nargs='?', default=u'',
|
||||
help=_(u"JID of the PubSub service (default: request profile own pubsub)"))
|
||||
|
||||
def psNodeConfigurationSetCb(self):
|
||||
self.disp(_(u'node configuration successful'), 1)
|
||||
self.host.quit()
|
||||
|
||||
def psNodeConfigurationSetEb(self, failure_):
|
||||
self.disp(u"can't set node configuration: {reason}".format(
|
||||
reason=failure_), error=True)
|
||||
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
|
||||
|
||||
def getKeyName(self, k):
|
||||
if not k.startswith(u'pubsub#'):
|
||||
return u'pubsub#' + k
|
||||
else:
|
||||
return k
|
||||
|
||||
def start(self):
|
||||
self.host.bridge.psNodeConfigurationSet(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
{self.getKeyName(k): v for k,v in self.args.fields},
|
||||
self.profile,
|
||||
callback=self.psNodeConfigurationSetCb,
|
||||
errback=self.psNodeConfigurationSetEb)
|
||||
|
||||
|
||||
class Node(base.CommandBase):
|
||||
subcommands = (NodeInfo,)
|
||||
subcommands = (NodeInfo, NodeSet)
|
||||
|
||||
def __init__(self, host):
|
||||
super(Node, self).__init__(host, 'node', use_profile=False, help=_('node handling'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue