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