Revision 1be508e9
b/api/actions.py | ||
---|---|---|
68 | 68 |
raise ServiceUnavailable() |
69 | 69 |
|
70 | 70 |
# Let vncauthproxy decide on the source port. |
71 |
# FIXME
|
|
72 |
# sport = 0
|
|
73 |
sport = console_data['port'] - 1000
|
|
71 |
# The alternative: static allocation, e.g.
|
|
72 |
# sport = console_data['port'] - 1000]
|
|
73 |
sport = 0 |
|
74 | 74 |
daddr = console_data['host'] |
75 | 75 |
dport = console_data['port'] |
76 | 76 |
passwd = random_password() |
77 | 77 |
|
78 |
if not request_vnc_forwarding(sport, daddr, dport, passwd): |
|
79 |
raise ServiceUnavailable("Could not allocate VNC console port") |
|
80 |
vnc = { 'host': getfqdn(), 'port': sport, 'password': passwd } |
|
78 |
try: |
|
79 |
fwd = request_vnc_forwarding(sport, daddr, dport, passwd) |
|
80 |
if fwd['status'] != "OK": |
|
81 |
raise ServiceUnavailable("Could not allocate VNC console port") |
|
82 |
vnc = { 'host': getfqdn(), 'port': fwd['source_port'], 'password': passwd } |
|
83 |
except Exception: |
|
84 |
#raise ServiceUnavailable("Could not allocate VNC console port") |
|
85 |
raise |
|
81 | 86 |
|
82 | 87 |
# Format to be reviewed by [verigak], FIXME |
83 | 88 |
if request.serialization == 'xml': |
b/util/vapclient.py | ||
---|---|---|
21 | 21 |
import sys |
22 | 22 |
import socket |
23 | 23 |
|
24 |
try: |
|
25 |
import simplejson as json |
|
26 |
except ImportError: |
|
27 |
import json |
|
28 |
|
|
24 | 29 |
CTRL_SOCKET = "/tmp/vncproxy.sock" |
25 | 30 |
|
26 | 31 |
def request_forwarding(sport, daddr, dport, password): |
27 |
sport = str(int(sport)) |
|
28 |
dport = str(int(dport)) |
|
29 | 32 |
assert(len(password) > 0) |
30 |
|
|
31 |
request = ":".join([sport, daddr, dport, password]) |
|
33 |
req = { |
|
34 |
"source_port": int(sport), |
|
35 |
"destination_address": daddr, |
|
36 |
"destination_port": int(dport), |
|
37 |
"password": password |
|
38 |
} |
|
32 | 39 |
|
33 | 40 |
ctrl = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) |
34 |
|
|
35 | 41 |
ctrl.connect(CTRL_SOCKET) |
36 |
ctrl.send(request) |
|
42 |
ctrl.send(json.dumps(req)) |
|
43 |
|
|
37 | 44 |
response = ctrl.recv(1024) |
38 |
if response == "OK\n": |
|
39 |
return True |
|
40 |
else: |
|
41 |
return False |
|
45 |
res = json.loads(response) |
|
46 |
return res |
|
42 | 47 |
|
43 | 48 |
if __name__ == '__main__': |
44 |
if not request_forwarding(*sys.argv[1:]): |
|
45 |
sys.exit(1) |
|
49 |
res = request_forwarding(*sys.argv[1:]) |
|
50 |
if res['status'] == "OK": |
|
51 |
sys.exit(0) |
|
52 |
else: |
|
53 |
sys.exit(1) |
Also available in: Unified diff