Nir Soffer has uploaded a new change for review.
Change subject: contrib: Simple jsonrpc client ......................................................................
contrib: Simple jsonrpc client
This is a simple jsonrpc client for communicating with the jsonrpc server from the command line.
Arguments
method one of the mehtods described in json schema params optionl json object with message parameters
Examples
Calling method without arguements:
# jsonrpc Host.getVMList { "jsonrpc": "2.0", "id": "0e043d83-294a-4d31-b1b6-6dc2f2747494", "result": [ "b3f6fa00-b315-4ad4-8108-f73da817b5c5" ] }
Calling method with arguements:
# jsonrpc VM.getStats '{"vmID": "b3f6fa00-b315-4ad4-8108-f73da817b5c5"}' { "jsonrpc": "2.0", "id": "cefd25a3-6250-4123-8a56-d7047899e19e", "result": [ { "status": "Down", "exitMessage": "Admin shut down from the engine", "vmId": "b3f6fa00-b315-4ad4-8108-f73da817b5c5", "exitReason": 6, "timeOffset": "0", "exitCode": 0 } ] }
Requires stomp.py library: https://pypi.python.org/pypi/stomp.py
Change-Id: Ia6273eabf6f3601602659d1e4e748d8025ae8084 Signed-off-by: Nir Soffer nsoffer@redhat.com --- A contrib/jsonrpc 1 file changed, 104 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/81/35181/1
diff --git a/contrib/jsonrpc b/contrib/jsonrpc new file mode 100755 index 0000000..3080193 --- /dev/null +++ b/contrib/jsonrpc @@ -0,0 +1,104 @@ +#!/usr/bin/python +# +# Copyright 2014 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# +""" +jsonrpc-cli - Vdsm jsonrpc client +""" + +import json +import os +import signal +import sys +import time +import uuid +import optparse + +import stomp + +# Copied from lib/vdsm/vdscli.py +PKIDIR = '/etc/pki/vdsm' +KEYFILE = os.path.join(PKIDIR, 'keys/vdsmkey.pem') +CERTFILE = os.path.join(PKIDIR, 'certs/vdsmcert.pem') +CACERT = os.path.join(PKIDIR, 'certs/cacert.pem') + +PORT = 54321 +DESTINATION = "/queue/_local/vdsm/requests" + + +class Listener(stomp.ConnectionListener): + + def on_error(self, headers, message): + print 'Error: %s' % message + terminate() + + def on_message(self, headers, message): + msg = json.loads(message) + print json.dumps(msg, indent=4) + terminate() + + +def main(args): + parser = option_parser() + options, args = parser.parse_args(args) + if not args: + parser.error("method required") + + msg = { + "id": str(uuid.uuid4()), + "jsonrpc": "2.0", + "method": args[0] + } + + if len(args) > 1: + msg["params"] = json.loads(args[1]) + + conn = stomp.Connection10( + host_and_ports=((options.host, PORT),), + use_ssl=True, + ssl_key_file=KEYFILE, + ssl_cert_file=CERTFILE, + ssl_ca_certs=CACERT) + + conn.set_listener("", Listener()) + conn.start() + conn.send(body=json.dumps(msg), destination=DESTINATION) + + try: + signal.pause() + except KeyboardInterrupt: + pass + + conn.disconnect() + + +def option_parser(): + parser = optparse.OptionParser(usage='%prog [options] method [params]') + parser.add_option("-a", "--host", dest="host", + help="host address (default localhost)") + parser.set_defaults(host="localhost") + return parser + + +def terminate(): + os.kill(os.getpid(), signal.SIGINT) + + +if __name__ == "__main__": + main(sys.argv[1:])
oVirt Jenkins CI Server has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 1:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/13415/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/12625/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created_staging/191/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/13577/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 2:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/13416/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/12626/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created_staging/192/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/13578/ : FAILURE
Nir Soffer has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 2: Verified+1
Works for me for the few commands I tried.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 3:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/13417/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/12627/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created_staging/193/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/13579/ : FAILURE
Nir Soffer has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 3: Verified+1
Add option to read method parameters from standard input. can be useful for complex commands like creating a vm.
Nir Soffer has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 4: Verified+1
This version improve usability - no need to send raw json on the command line any more.
Simple (common) commands can be invoked with name=value syntax.
Complex commands can be constructed on standard input or read from file.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 4:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/12630/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/13582/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created_staging/196/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/13420/ : SUCCESS
Francesco Romani has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 4:
Nice start
Dan Kenigsberg has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 4: Code-Review+1
Nir Soffer has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 5: Verified+1
This version improve error handling when having connection issues or interrupting the tool during connection.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 5:
Build Failed
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/12768/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_unit-tests_created/13720/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/13557/ : SUCCESS
Jenkins CI RO has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 5:
Abandoned due to no activity - please restore if still relevant
Jenkins CI RO has abandoned this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Abandoned
Abandoned due to no activity - please restore if still relevant
automation@ovirt.org has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found
Nir Soffer has restored this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Restored
Unabandon
Francesco Romani has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 5: Code-Review+1
Francesco Romani has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 5:
ping, this is nice, useful and self contained, let's have it
Piotr Kliczewski has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 5:
It looks interesting but it seem to only send information to vdsm. I do not see the code to subscribe for responses nor there are no custom headers that we use from time to time.
I like the simplicity but there is a bit of code which needs to be added here.
Piotr Kliczewski has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 5:
I am missing ability to subscribe to messages. Looking at current code base I see only ability to send messages.
Can we customize stomp headers when we define which topic/queue should be use as response?
Piotr Kliczewski has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 5:
As I said I like the simplicity but why not to use our standalone client?
We could wrap it here instead of using plain stomp module and keep the simplicity.
Yaniv Bronhaim has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 10: Code-Review+1
Dan Kenigsberg has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 11: Code-Review-1
(2 comments)
https://gerrit.ovirt.org/#/c/35181/11/contrib/jsonrpc File contrib/jsonrpc:
Line 38: Line 39: For invokinng methods with many or complex parameters, you can read the Line 40: parameters from a file: Line 41: Line 42: # jsonrpc VM.create -f vm-create could you provide an example how does a complex input like this would look like?
I don't understand how can this possibly work without json-parsing the file. How would you represent the list of device dictionaries? Line 43: ... Line 44: Line 45: It is also possible to read parameters from standard input, creating complex Line 46: parameters interactively:
Line 111: Line 112: def option_parser(): Line 113: parser = argparse.ArgumentParser() Line 114: parser.add_argument('-a', '--host', dest="host", default="localhost", Line 115: help='host address (default localhost)') can you contact a host with ssl=True (which is the default, common installation)? I see no reference to our pki. Line 116: parser.add_argument('method', help='remote method name') Line 117: parser.add_argument('-f', '--file', dest='file', Line 118: help="read method parameters from json file. Set to" Line 119: " '-' to read from standard input")
Piotr Kliczewski has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 11:
(2 comments)
https://gerrit.ovirt.org/#/c/35181/11/contrib/jsonrpc File contrib/jsonrpc:
Line 38: Line 39: For invokinng methods with many or complex parameters, you can read the Line 40: parameters from a file: Line 41: Line 42: # jsonrpc VM.create -f vm-create
could you provide an example how does a complex input like this would look
File content should look the same as params provided in std input like below. Will update here. Line 43: ... Line 44: Line 45: It is also possible to read parameters from standard input, creating complex Line 46: parameters interactively:
Line 111: Line 112: def option_parser(): Line 113: parser = argparse.ArgumentParser() Line 114: parser.add_argument('-a', '--host', dest="host", default="localhost", Line 115: help='host address (default localhost)')
can you contact a host with ssl=True (which is the default, common installa
Actually we use ssl=True by default and we use cert location as defined in constants. Do you suggest that user should be able to provide cert location? Line 116: parser.add_argument('method', help='remote method name') Line 117: parser.add_argument('-f', '--file', dest='file', Line 118: help="read method parameters from json file. Set to" Line 119: " '-' to read from standard input")
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 12:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Piotr Kliczewski has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 12:
(1 comment)
https://gerrit.ovirt.org/#/c/35181/12//COMMIT_MSG Commit Message:
Line 23: Line 24: For invokinng methods with many or complex parameters, you can read the Line 25: parameters from a file: Line 26: Line 27: # jsonrpc VM.create -f vm-create Still need to update here Line 28: ... Line 29: Line 30: It is also possible to read parameters from standard input, creating Line 31: complex parameters interactively:
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 13:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 14:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Piotr Kliczewski has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 14: Verified+1
verified by running jsonrpc Host.getVMList
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 15:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 16:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Jenkins CI has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 16: Continuous-Integration+1
Propagate review hook: Continuous Integration value inherited from patch 15
Dan Kenigsberg has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 16: Code-Review-1
(1 comment)
https://gerrit.ovirt.org/#/c/35181/16/contrib/jsonrpc File contrib/jsonrpc:
Line 43: ... Line 44: Line 45: where file content is: Line 46: storagedomainID=75ab40e3-06b1-4a54-a825-2df7a40b93b2, Line 47: storagepoolID=b3f6fa00-b315-4ad4-8108-f73da817b5c5 thanks for this example, but what about the quite-important VM.create command. My worry is that there is no way to express the complex structure that is required by it. Line 48: Line 49: It is also possible to read parameters from standard input, creating complex Line 50: parameters interactively: Line 51:
Nir Soffer has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 16: Code-Review-1
(1 comment)
https://gerrit.ovirt.org/#/c/35181/16/contrib/jsonrpc File contrib/jsonrpc:
Line 43: ... Line 44: Line 45: where file content is: Line 46: storagedomainID=75ab40e3-06b1-4a54-a825-2df7a40b93b2, Line 47: storagepoolID=b3f6fa00-b315-4ad4-8108-f73da817b5c5
thanks for this example, but what about the quite-important VM.create comma
The original version of this client was reading plain json from the file. This is the only way to express complex structures.
The simple key=value format is useful only for command line argument, where it is less verbose than writing actual json in the command line.
See https://gerrit.ovirt.org/#/c/35181/5/contrib/jsonrpc,unified
I asked Piotr to maintain these semantics, and change only the jsonrpc infrastructure to use our client instead of stomp. Line 48: Line 49: It is also possible to read parameters from standard input, creating complex Line 50: parameters interactively: Line 51:
Piotr Kliczewski has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 16:
(1 comment)
https://gerrit.ovirt.org/#/c/35181/16/contrib/jsonrpc File contrib/jsonrpc:
Line 43: ... Line 44: Line 45: where file content is: Line 46: storagedomainID=75ab40e3-06b1-4a54-a825-2df7a40b93b2, Line 47: storagepoolID=b3f6fa00-b315-4ad4-8108-f73da817b5c5
The original version of this client was reading plain json from the file. T
The original structure was wrong because it stored whole message. We do not want to expose how we structure message. This format do not let us express nested dict as we have in vm.create so using json for parameters only seems like good idea. Line 48: Line 49: It is also possible to read parameters from standard input, creating complex Line 50: parameters interactively: Line 51:
Dan Kenigsberg has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 16:
(1 comment)
https://gerrit.ovirt.org/#/c/35181/16/contrib/jsonrpc File contrib/jsonrpc:
Line 43: ... Line 44: Line 45: where file content is: Line 46: storagedomainID=75ab40e3-06b1-4a54-a825-2df7a40b93b2, Line 47: storagepoolID=b3f6fa00-b315-4ad4-8108-f73da817b5c5
The original structure was wrong because it stored whole message. We do not
Piotr, but how would you suggest to start a VM using this command line?
PS, even if we are unable to start a VM (or pass any complex input) I think that this command line has merit within contrib. it is better than the absolute nothing that we currently have. Line 48: Line 49: It is also possible to read parameters from standard input, creating complex Line 50: parameters interactively: Line 51:
Piotr Kliczewski has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 16:
(1 comment)
https://gerrit.ovirt.org/#/c/35181/16/contrib/jsonrpc File contrib/jsonrpc:
Line 43: ... Line 44: Line 45: where file content is: Line 46: storagedomainID=75ab40e3-06b1-4a54-a825-2df7a40b93b2, Line 47: storagepoolID=b3f6fa00-b315-4ad4-8108-f73da817b5c5
Piotr, but how would you suggest to start a VM using this command line?
I will change it to have json containing only params not whole message as it was implemented originally. Line 48: Line 49: It is also possible to read parameters from standard input, creating complex Line 50: parameters interactively: Line 51:
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 17:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 18:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 19:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Piotr Kliczewski has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 18:
(3 comments)
https://gerrit.ovirt.org/#/c/35181/18//COMMIT_MSG Commit Message:
Line 27: # jsonrpc StorageDomain.activate -f sd-activate Line 28: ... Line 29: Line 30: where sd-activate file content is: Line 31: storagedomainID=75ab40e3-06b1-4a54-a825-2df7a40b93b2, Now we use json in the file. please update here as well. Line 32: storagepoolID=b3f6fa00-b315-4ad4-8108-f73da817b5c5 Line 33: Line 34: It is also possible to read parameters from standard input, creating Line 35: complex parameters interactively:
Line 34: It is also possible to read parameters from standard input, creating Line 35: complex parameters interactively: Line 36: Line 37: # jsonrpc StorageDomain.activate -f - Line 38: storagedomainID=75ab40e3-06b1-4a54-a825-2df7a40b93b2, and here Line 39: storagepoolID=b3f6fa00-b315-4ad4-8108-f73da817b5c5 Line 40: (Press Ctrl + D to finish) Line 41: Line 42: Change-Id: Ia6273eabf6f3601602659d1e4e748d8025ae8084
https://gerrit.ovirt.org/#/c/35181/18/contrib/jsonrpc File contrib/jsonrpc:
PS18, Line 72: import six why do we need it?
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 20:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Jenkins CI has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 20: Continuous-Integration+1
Propagate review hook: Continuous Integration value inherited from patch 18
Irit Goihman has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 20:
(2 comments)
https://gerrit.ovirt.org/#/c/35181/18//COMMIT_MSG Commit Message:
Line 27: # jsonrpc StorageDomain.activate -f sd-activate Line 28: ... Line 29: Line 30: where sd-activate file content is: Line 31: {
Now we use json in the file. please update here as well.
thanks, I lost the updated commit message during rebase Line 32: "storagedomainID": "75ab40e3-06b1-4a54-a825-2df7a40b93b2", Line 33: "storagepoolID": "b3f6fa00-b315-4ad4-8108-f73da817b5c5" Line 34: } Line 35:
Line 34: } Line 35: Line 36: It is also possible to read parameters from standard input, creating Line 37: complex parameters interactively: Line 38:
and here
Done Line 39: # jsonrpc StorageDomain.activate -f - Line 40: { Line 41: "storagedomainID": "75ab40e3-06b1-4a54-a825-2df7a40b93b2", Line 42: "storagepoolID": "b3f6fa00-b315-4ad4-8108-f73da817b5c5"
Jenkins CI has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 20:
Propagate review hook: Continuous Integration value inherited from patch 19
Irit Goihman has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 20: Verified+1
Piotr Kliczewski has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 20: Code-Review+1
Yaniv Bronhaim has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 20:
(1 comment)
https://gerrit.ovirt.org/#/c/35181/20/contrib/jsonrpc File contrib/jsonrpc:
Line 72: from yajsonrpc import stompreactor, JsonRpcRequest, JsonRpcError Line 73: Line 74: Line 75: # Suppress unhelpful warnings Line 76: warnings.simplefilter("ignore", DeprecationWarning) why do we need that? Line 77: Line 78: Line 79: class UsageError(Exception): Line 80: """ Raised when your hold it in the wrong way """
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 21:
* update_tracker: OK * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
gerrit-hooks has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 22:
* update_tracker: OK * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Yaniv Bronhaim has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 22: Code-Review-1
this one should be squeezed with https://gerrit.ovirt.org/#/c/64502
From Yaniv Bronhaim ybronhei@redhat.com:
Yaniv Bronhaim has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 22:
i dont see the purpose of having both.. please explain, how do we benefit from this tool when we have a simple client that works quite the same if not totally the same
From Yaniv Bronhaim ybronhei@redhat.com:
Yaniv Bronhaim has posted comments on this change.
Change subject: contrib: Simple jsonrpc client ......................................................................
Patch Set 24:
for some reason I thought that in the client.py we also added main and options to run it as a command line.. instead of reusing the code here.
its fine, but better to include in this effort a removal of vdsClient and do this one the official new cli .
From Dan Kenigsberg danken@redhat.com:
Dan Kenigsberg has submitted this change and it was merged.
Change subject: contrib: Simple jsonrpc client ......................................................................
contrib: Simple jsonrpc client
This is a simple generic client that does not know anything about the available methods and parameters. The user should consult the schema to construct request that makes sense. Future version should parse the schema and provide online help.
Invoking simple methods:
# jsonrpc Host getVMList ['b3f6fa00-b315-4ad4-8108-f73da817b5c5']
Invoking methods with simple parameters::
# jsonrpc VM getStats vmID=b3f6fa00-b315-4ad4-8108-f73da817b5c5 ...
For invokinng methods with many or complex parameters, you can read the parameters from a file:
# jsonrpc StorageDomain activate -f sd-activate ...
where sd-activate file content is: { "storagedomainID": "75ab40e3-06b1-4a54-a825-2df7a40b93b2", "storagepoolID": "b3f6fa00-b315-4ad4-8108-f73da817b5c5" }
It is also possible to read parameters from standard input, creating complex parameters interactively:
# jsonrpc StorageDomain activate -f - { "storagedomainID": "75ab40e3-06b1-4a54-a825-2df7a40b93b2", "storagepoolID": "b3f6fa00-b315-4ad4-8108-f73da817b5c5" } (Press Ctrl + D to finish)
Change-Id: Ia6273eabf6f3601602659d1e4e748d8025ae8084 Signed-off-by: Nir Soffer nsoffer@redhat.com Signed-off-by: pkliczewski piotr.kliczewski@gmail.com Signed-off-by: Irit Goihman igoihman@redhat.com --- A contrib/jsonrpc 1 file changed, 169 insertions(+), 0 deletions(-)
Approvals: Piotr Kliczewski: Looks good to me, approved Nir Soffer: Looks good to me, but someone else must approve Jenkins CI: Passed CI tests Irit Goihman: Verified
vdsm-patches@lists.fedorahosted.org