summaryrefslogtreecommitdiff
path: root/python/rvi_get_services.py
blob: 100ecf07a5e3d2a069d26f7976a0c20d9414c9aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python

#
# Copyright (C) 2014, Jaguar Land Rover
#
# This program is licensed under the terms and conditions of the
# Mozilla Public License, version 2.0.  The full text of the 
# Mozilla Public License is at https://www.mozilla.org/MPL/2.0/
#
# 
# Simple RVI service caller
#  

import sys
from rvilib import RVI
import threading
import time

def usage():
    print "Return the name of all available services that can be reached"
    print "through an RVI node."
    print
    print "Usage:", sys.argv[0], " [RVI-node]"
    print "Default RVI node is http://127.0.0.1:9001"
    print
    print "Example: ./callrvi.py http://rvi1.nginfotpdx.net:9001"
    print
    sys.exit(255)


# 
# Check that we have the correct arguments
#
if len(sys.argv) != 1 and len(sys.argv) != 2:
    usage()

progname = sys.argv[0]

if len(sys.argv) == 2:
    rvi_node = sys.argv[1]
else:
    rvi_node = "http://localhost:9001"

#
# Setup an outbound JSON-RPC connection to the backend RVI node
# Service Edge.
#
rvi = RVI(rvi_node)


#
# Retreieve services
#
for i in rvi.get_available_services():
    print i