Commit ae88ef45 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

ganeti.rpc: Convert to new HTTP server

Reviewed-by: amishchenko
parent bc2929fc
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
import os import os
import socket import socket
import httplib
import logging import logging
from ganeti import utils from ganeti import utils
...@@ -42,6 +41,8 @@ from ganeti import serializer ...@@ -42,6 +41,8 @@ from ganeti import serializer
from ganeti import constants from ganeti import constants
from ganeti import errors from ganeti import errors
import ganeti.http.client
# Module level variable # Module level variable
_http_manager = None _http_manager = None
...@@ -57,7 +58,7 @@ def Init(): ...@@ -57,7 +58,7 @@ def Init():
assert not _http_manager, "RPC module initialized more than once" assert not _http_manager, "RPC module initialized more than once"
_http_manager = http.HttpClientManager() _http_manager = http.client.HttpClientManager()
def Shutdown(): def Shutdown():
...@@ -156,11 +157,12 @@ class Client: ...@@ -156,11 +157,12 @@ class Client:
if address is None: if address is None:
address = name address = name
self.nc[name] = http.HttpClientRequest(address, self.port, http.HTTP_PUT, self.nc[name] = \
"/%s" % self.procedure, http.client.HttpClientRequest(address, self.port, http.HTTP_PUT,
post_data=self.body, "/%s" % self.procedure,
ssl_params=self._ssl_params, post_data=self.body,
ssl_verify_peer=True) ssl_params=self._ssl_params,
ssl_verify_peer=True)
def GetResults(self): def GetResults(self):
"""Call nodes and return results. """Call nodes and return results.
...@@ -176,7 +178,7 @@ class Client: ...@@ -176,7 +178,7 @@ class Client:
results = {} results = {}
for name, req in self.nc.iteritems(): for name, req in self.nc.iteritems():
if req.success and req.resp_status == http.HTTP_OK: if req.success and req.resp_status_code == http.HTTP_OK:
results[name] = RpcResult(data=serializer.LoadJson(req.resp_body), results[name] = RpcResult(data=serializer.LoadJson(req.resp_body),
node=name, call=self.procedure) node=name, call=self.procedure)
continue continue
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment