Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
106
Merge Requests
106
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
1653d29c
Commit
1653d29c
authored
Dec 30, 2019
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kvm: add support for Python 3
parent
99356261
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
26 deletions
+23
-26
software/kvm/buildout.hash.cfg
software/kvm/buildout.hash.cfg
+2
-2
software/kvm/template/kvm-controller-run.in
software/kvm/template/kvm-controller-run.in
+1
-1
software/kvm/template/template-kvm-run.in
software/kvm/template/template-kvm-run.in
+16
-19
software/kvm/test/test.py
software/kvm/test/test.py
+4
-4
No files found.
software/kvm/buildout.hash.cfg
View file @
1653d29c
...
...
@@ -55,11 +55,11 @@ md5sum = 2036bf145f472f62ef8dee5e729328fd
[template-kvm-run]
filename = template/template-kvm-run.in
md5sum =
08af4ed0e2a53e76c844e3d7325aac0
9
md5sum =
c319ca536b6bac5425245fae1684ca4
9
[template-kvm-controller]
filename = template/kvm-controller-run.in
md5sum =
b96cba47c97f277c857176d69e086a12
md5sum =
3827b4f7624de190cf5f5d37e3b72e86
[template-apache-conf]
filename = template/apache.conf.in
...
...
software/kvm/template/kvm-controller-run.in
View file @
1653d29c
...
...
@@ -57,7 +57,7 @@ def update():
'nslot': 128,
'canreboot': 1
})
except Exception
,
e:
except Exception
as
e:
write(str(e))
raise
...
...
software/kvm/template/template-kvm-run.in
View file @
1653d29c
...
...
@@ -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:
...
...
@@ -112,22 +115,16 @@ def md5Checksum(file_path):
def getSocketStatus(host, port):
s = None
for res in socket.getaddrinfo(host, port,
socket.AF_UNSPEC, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
for af, socktype, proto, canonname, sa in socket.getaddrinfo(
host, port, socket.AF_UNSPEC, socket.SOCK_STREAM):
try:
s = socket.socket(af, socktype, proto)
except socket.error, msg:
s = None
continue
try:
s.connect(sa)
except socket.error, msg:
s.close()
s = None
continue
break
return s
return s
except socket.error:
if s:
s.close()
s = None
def getMapStorageList(disk_storage_dict, external_disk_number):
map_disk_file = os.path.join(etc_directory, '.data-disk-ids')
...
...
@@ -319,7 +316,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 +358,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 +372,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)
software/kvm/test/test.py
View file @
1653d29c
...
...
@@ -25,14 +25,14 @@
#
##############################################################################
import
httplib
import
six.moves.http_client
as
httplib
import
json
import
os
import
requests
import
six
import
slapos.util
import
sqlite3
import
urlparse
from
six.moves.urllib.parse
import
parse_qs
,
urlparse
import
unittest
from
slapos.recipe.librecipe
import
generateHashFromFiles
...
...
@@ -120,7 +120,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
...
...
@@ -130,7 +130,7 @@ class MonitorAccessMixin(object):
if
not
connection_xml
:
continue
connection_dict
=
slapos
.
util
.
xml2dict
(
partition_information
[
'connection_xml'
]
.
encode
(
'utf-8'
))
connection_xml
if
six
.
PY3
else
connection_xml
.
encode
(
'utf-8'
))
monitor_base_url
=
connection_dict
.
get
(
'monitor-base-url'
)
if
not
monitor_base_url
:
continue
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment