vm in py3
This commit is contained in:
parent
e711e7dbe5
commit
48434f4393
2 changed files with 22 additions and 31 deletions
|
|
@ -26,8 +26,6 @@
|
|||
# kojiwind --install
|
||||
# in a cygwin shell.
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import base64
|
||||
import glob
|
||||
import hashlib
|
||||
|
|
@ -43,12 +41,11 @@ import traceback
|
|||
import zipfile
|
||||
from optparse import OptionParser
|
||||
|
||||
import six
|
||||
import six.moves.xmlrpc_client
|
||||
import xmlrpc.client
|
||||
# urllib is required by the SCM class which is substituted into this file
|
||||
# do not remove the import below
|
||||
from six.moves import urllib # noqa: F401
|
||||
from six.moves.configparser import RawConfigParser
|
||||
import urllib # noqa: F401
|
||||
from configparser import RawConfigParser
|
||||
|
||||
MANAGER_PORT = 7000
|
||||
|
||||
|
|
@ -630,14 +627,12 @@ def get_mgmt_server():
|
|||
macaddr, gateway = find_net_info()
|
||||
logger.debug('found MAC address %s, connecting to %s:%s',
|
||||
macaddr, gateway, MANAGER_PORT)
|
||||
server = six.moves.xmlrpc_client.ServerProxy('http://%s:%s/' %
|
||||
(gateway, MANAGER_PORT), allow_none=True)
|
||||
server = xmlrpc.client.ServerProxy('http://%s:%s/' % (gateway, MANAGER_PORT), allow_none=True)
|
||||
# we would set a timeout on the socket here, but that is apparently not
|
||||
# supported by python/cygwin/Windows
|
||||
task_port = server.getPort(macaddr)
|
||||
logger.debug('found task-specific port %s', task_port)
|
||||
return six.moves.xmlrpc_client.ServerProxy('http://%s:%s/' % (gateway, task_port),
|
||||
allow_none=True)
|
||||
return xmlrpc.client.ServerProxy('http://%s:%s/' % (gateway, task_port), allow_none=True)
|
||||
|
||||
|
||||
def get_options():
|
||||
|
|
@ -690,7 +685,7 @@ def stream_logs(server, handler, builds):
|
|||
logpath = os.path.join(build.source_dir, relpath)
|
||||
if logpath not in logs:
|
||||
logs[logpath] = (relpath, None)
|
||||
for log, (relpath, fd) in six.iteritems(logs):
|
||||
for log, (relpath, fd) in logs.items():
|
||||
if not fd:
|
||||
if os.path.isfile(log):
|
||||
try:
|
||||
|
|
|
|||
36
vm/kojivmd
36
vm/kojivmd
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python2
|
||||
#!/usr/bin/python3
|
||||
|
||||
# Koji virtual machine management daemon
|
||||
# Copyright (c) 2010-2014 Red Hat, Inc.
|
||||
|
|
@ -35,14 +35,13 @@ import subprocess
|
|||
import sys
|
||||
import threading
|
||||
import time
|
||||
import xmlrpc
|
||||
from contextlib import closing
|
||||
from optparse import OptionParser
|
||||
|
||||
import libvirt
|
||||
import libxml2
|
||||
import requests
|
||||
import six.moves.xmlrpc_client
|
||||
import six.moves.xmlrpc_server
|
||||
|
||||
import koji
|
||||
import koji.util
|
||||
|
|
@ -254,24 +253,24 @@ def main(options, session):
|
|||
# Tasks for handling VM lifecycle
|
||||
####################
|
||||
|
||||
class DaemonXMLRPCServer(six.moves.xmlrpc_server.SimpleXMLRPCServer):
|
||||
class DaemonXMLRPCServer(xmlrpc.server.SimpleXMLRPCServer):
|
||||
allow_reuse_address = True
|
||||
|
||||
def __init__(self, addr, port):
|
||||
if sys.version_info[:2] <= (2, 4):
|
||||
six.moves.xmlrpc_server.SimpleXMLRPCServer.__init__(self, (addr, port),
|
||||
logRequests=False)
|
||||
xmlrpc.server.SimpleXMLRPCServer.__init__(self, (addr, port),
|
||||
logRequests=False)
|
||||
else:
|
||||
six.moves.xmlrpc_server.SimpleXMLRPCServer.__init__(self, (addr, port),
|
||||
logRequests=False,
|
||||
allow_none=True)
|
||||
xmlrpc.server.SimpleXMLRPCServer.__init__(self, (addr, port),
|
||||
logRequests=False,
|
||||
allow_none=True)
|
||||
self.logger = logging.getLogger('koji.vm.DaemonXMLRPCServer')
|
||||
self.socket.settimeout(5)
|
||||
self.active = True
|
||||
|
||||
def server_close(self):
|
||||
self.active = False
|
||||
six.moves.xmlrpc_server.SimpleXMLRPCServer.server_close(self)
|
||||
xmlrpc.server.SimpleXMLRPCServer.server_close(self)
|
||||
|
||||
def handle_while_active(self):
|
||||
while self.active:
|
||||
|
|
@ -292,23 +291,20 @@ class DaemonXMLRPCServer(six.moves.xmlrpc_server.SimpleXMLRPCServer):
|
|||
# Copy and paste from SimpleXMLRPCServer, with the addition of passing
|
||||
# allow_none=True to xmlrpclib.dumps()
|
||||
def _marshaled_dispatch(self, data, dispatch_method=None):
|
||||
params, method = six.moves.xmlrpc_client.loads(data)
|
||||
params, method = xmlrpc.client.loads(data)
|
||||
try:
|
||||
if dispatch_method is not None:
|
||||
response = dispatch_method(method, params)
|
||||
else:
|
||||
response = self._dispatch(method, params)
|
||||
response = (response,)
|
||||
response = six.moves.xmlrpc_client.dumps(response,
|
||||
methodresponse=1, allow_none=True)
|
||||
except six.moves.xmlrpc_client.Fault as fault:
|
||||
response = six.moves.xmlrpc_client.dumps(fault)
|
||||
response = xmlrpc.client.dumps(response, methodresponse=1, allow_none=True)
|
||||
except xmlrpc.client.Fault as fault:
|
||||
response = xmlrpc.client.dumps(fault)
|
||||
except Exception:
|
||||
# report exception back to server
|
||||
response = six.moves.xmlrpc_client.dumps(
|
||||
six.moves.xmlrpc_client.Fault(
|
||||
1, "%s:%s" %
|
||||
(sys.exc_info()[0], sys.exc_info()[1]))
|
||||
response = xmlrpc.client.dumps(
|
||||
xmlrpc.client.Fault(1, "%s:%s" % (sys.exc_info()[0], sys.exc_info()[1]))
|
||||
)
|
||||
return response
|
||||
|
||||
|
|
@ -434,7 +430,7 @@ class VMExecTask(BaseTaskHandler):
|
|||
|
||||
def __init__(self, *args, **kw):
|
||||
super(VMExecTask, self).__init__(*args, **kw)
|
||||
self.task_manager = six.moves.xmlrpc_client.ServerProxy(
|
||||
self.task_manager = xmlrpc.client.ServerProxy(
|
||||
'http://%s:%s/' % (self.options.privaddr, self.options.portbase), allow_none=True)
|
||||
self.port = None
|
||||
self.server = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue