Commit edcf7bfe authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

kvm: add support for Python 3

parent 5abbb45e
......@@ -55,11 +55,11 @@ md5sum = 2036bf145f472f62ef8dee5e729328fd
[template-kvm-run]
filename = template/template-kvm-run.in
md5sum = 08af4ed0e2a53e76c844e3d7325aac09
md5sum = ccaae3912dc85ecccc4974d875dd70e3
[template-kvm-controller]
filename = template/kvm-controller-run.in
md5sum = b96cba47c97f277c857176d69e086a12
md5sum = 3827b4f7624de190cf5f5d37e3b72e86
[template-apache-conf]
filename = template/apache.conf.in
......
......@@ -57,7 +57,7 @@ def update():
'nslot': 128,
'canreboot': 1
})
except Exception, e:
except Exception as e:
write(str(e))
raise
......
......@@ -6,7 +6,10 @@ import hashlib
import os
import socket
import subprocess
import urllib
try:
from urllib.request import FancyURLopener
except ImportError:
from urllib import FancyURLopener
import gzip
import shutil
from random import shuffle
......@@ -96,9 +99,9 @@ enable_device_hotplug = '{{ parameter_dict.get("enable-device-hotplug") }}'.lowe
logfile = '{{ parameter_dict.get("log-file") }}'
if hasattr(ssl, '_create_unverified_context') and url_check_certificate == 'false':
opener = urllib.FancyURLopener(context=ssl._create_unverified_context())
opener = FancyURLopener(context=ssl._create_unverified_context())
else:
opener = urllib.FancyURLopener({})
opener = FancyURLopener({})
def md5Checksum(file_path):
with open(file_path, 'rb') as fh:
......@@ -117,12 +120,12 @@ def getSocketStatus(host, port):
af, socktype, proto, canonname, sa = res
try:
s = socket.socket(af, socktype, proto)
except socket.error, msg:
except socket.error as msg:
s = None
continue
try:
s.connect(sa)
except socket.error, msg:
except socket.error as msg:
s.close()
s = None
continue
......@@ -319,7 +322,7 @@ for numa in numa_list:
kvm_argument_list += numa_parameter
if tap_network_parameter == [] and nat_network_parameter == []:
print 'Warning : No network interface defined.'
print('Warning : No network interface defined.')
else:
kvm_argument_list += nat_network_parameter + tap_network_parameter
if language in language_list:
......@@ -361,7 +364,7 @@ for nbd_ip, nbd_port in nbd_list:
s = getSocketStatus(nbd_ip, nbd_port)
if s is None:
# NBD is not available : launch kvm without it
print 'Warning : Nbd is not available.'
print('Warning : Nbd is not available.')
else:
# NBD is available
# We close the NBD socket else qemu won't be able to use it apparently
......@@ -375,5 +378,5 @@ else:
'-drive', 'file=%s,media=cdrom' % default_cdrom_iso
])
print 'Starting KVM: \n %s' % ' '.join(kvm_argument_list)
print('Starting KVM: \n %s' % ' '.join(kvm_argument_list))
os.execv(qemu_path, kvm_argument_list)
......@@ -25,7 +25,7 @@
#
##############################################################################
import httplib
import six.moves.http_client as httplib
import json
import os
import re
......@@ -34,7 +34,7 @@ import six
import slapos.util
import subprocess
import sqlite3
import urlparse
from six.moves.urllib.parse import parse_qs, urlparse
import unittest
from slapos.recipe.librecipe import generateHashFromFiles
......@@ -49,7 +49,7 @@ def sanityCheck():
output = e.output
else:
state = True
if state is True and re.search(r'kvm.*kvm_intel', output):
if state is True and re.search(br'kvm.*kvm_intel', output):
return True
......@@ -133,7 +133,7 @@ class MonitorAccessMixin(object):
monitor_setup_url = connection_parameter_dict['monitor-setup-url']
monitor_url_with_auth = 'https' + monitor_setup_url.split('https')[2]
auth = urlparse.parse_qs(urlparse.urlparse(monitor_url_with_auth).path)
auth = parse_qs(urlparse(monitor_url_with_auth).path)
# check that monitor-base-url for all partitions in the tree are accessible
# with published username and password
......
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