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
104
Merge Requests
104
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
...
@@ -55,11 +55,11 @@ md5sum = 2036bf145f472f62ef8dee5e729328fd
[template-kvm-run]
[template-kvm-run]
filename = template/template-kvm-run.in
filename = template/template-kvm-run.in
md5sum =
08af4ed0e2a53e76c844e3d7325aac0
9
md5sum =
c319ca536b6bac5425245fae1684ca4
9
[template-kvm-controller]
[template-kvm-controller]
filename = template/kvm-controller-run.in
filename = template/kvm-controller-run.in
md5sum =
b96cba47c97f277c857176d69e086a12
md5sum =
3827b4f7624de190cf5f5d37e3b72e86
[template-apache-conf]
[template-apache-conf]
filename = template/apache.conf.in
filename = template/apache.conf.in
...
...
software/kvm/template/kvm-controller-run.in
View file @
1653d29c
...
@@ -57,7 +57,7 @@ def update():
...
@@ -57,7 +57,7 @@ def update():
'nslot': 128,
'nslot': 128,
'canreboot': 1
'canreboot': 1
})
})
except Exception
,
e:
except Exception
as
e:
write(str(e))
write(str(e))
raise
raise
...
...
software/kvm/template/template-kvm-run.in
View file @
1653d29c
...
@@ -6,7 +6,10 @@ import hashlib
...
@@ -6,7 +6,10 @@ import hashlib
import os
import os
import socket
import socket
import subprocess
import subprocess
import urllib
try:
from urllib.request import FancyURLopener
except ImportError:
from urllib import FancyURLopener
import gzip
import gzip
import shutil
import shutil
from random import shuffle
from random import shuffle
...
@@ -96,9 +99,9 @@ enable_device_hotplug = '{{ parameter_dict.get("enable-device-hotplug") }}'.lowe
...
@@ -96,9 +99,9 @@ enable_device_hotplug = '{{ parameter_dict.get("enable-device-hotplug") }}'.lowe
logfile = '{{ parameter_dict.get("log-file") }}'
logfile = '{{ parameter_dict.get("log-file") }}'
if hasattr(ssl, '_create_unverified_context') and url_check_certificate == 'false':
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:
else:
opener =
urllib.
FancyURLopener({})
opener = FancyURLopener({})
def md5Checksum(file_path):
def md5Checksum(file_path):
with open(file_path, 'rb') as fh:
with open(file_path, 'rb') as fh:
...
@@ -112,22 +115,16 @@ def md5Checksum(file_path):
...
@@ -112,22 +115,16 @@ def md5Checksum(file_path):
def getSocketStatus(host, port):
def getSocketStatus(host, port):
s = None
s = None
for res in socket.getaddrinfo(host, port,
for af, socktype, proto, canonname, sa in socket.getaddrinfo(
socket.AF_UNSPEC, socket.SOCK_STREAM):
host, port, socket.AF_UNSPEC, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
try:
s = socket.socket(af, socktype, proto)
s = socket.socket(af, socktype, proto)
except socket.error, msg:
s = None
continue
try:
s.connect(sa)
s.connect(sa)
except socket.error, msg:
return s
s.close()
except socket.error:
s = None
if s:
continue
s.close()
break
s = None
return s
def getMapStorageList(disk_storage_dict, external_disk_number):
def getMapStorageList(disk_storage_dict, external_disk_number):
map_disk_file = os.path.join(etc_directory, '.data-disk-ids')
map_disk_file = os.path.join(etc_directory, '.data-disk-ids')
...
@@ -319,7 +316,7 @@ for numa in numa_list:
...
@@ -319,7 +316,7 @@ for numa in numa_list:
kvm_argument_list += numa_parameter
kvm_argument_list += numa_parameter
if tap_network_parameter == [] and nat_network_parameter == []:
if tap_network_parameter == [] and nat_network_parameter == []:
print
'Warning : No network interface defined.'
print
('Warning : No network interface defined.')
else:
else:
kvm_argument_list += nat_network_parameter + tap_network_parameter
kvm_argument_list += nat_network_parameter + tap_network_parameter
if language in language_list:
if language in language_list:
...
@@ -361,7 +358,7 @@ for nbd_ip, nbd_port in nbd_list:
...
@@ -361,7 +358,7 @@ for nbd_ip, nbd_port in nbd_list:
s = getSocketStatus(nbd_ip, nbd_port)
s = getSocketStatus(nbd_ip, nbd_port)
if s is None:
if s is None:
# NBD is not available : launch kvm without it
# NBD is not available : launch kvm without it
print
'Warning : Nbd is not available.'
print
('Warning : Nbd is not available.')
else:
else:
# NBD is available
# NBD is available
# We close the NBD socket else qemu won't be able to use it apparently
# We close the NBD socket else qemu won't be able to use it apparently
...
@@ -375,5 +372,5 @@ else:
...
@@ -375,5 +372,5 @@ else:
'-drive', 'file=%s,media=cdrom' % default_cdrom_iso
'-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)
os.execv(qemu_path, kvm_argument_list)
software/kvm/test/test.py
View file @
1653d29c
...
@@ -25,14 +25,14 @@
...
@@ -25,14 +25,14 @@
#
#
##############################################################################
##############################################################################
import
httplib
import
six.moves.http_client
as
httplib
import
json
import
json
import
os
import
os
import
requests
import
requests
import
six
import
six
import
slapos.util
import
slapos.util
import
sqlite3
import
sqlite3
import
urlparse
from
six.moves.urllib.parse
import
parse_qs
,
urlparse
import
unittest
import
unittest
from
slapos.recipe.librecipe
import
generateHashFromFiles
from
slapos.recipe.librecipe
import
generateHashFromFiles
...
@@ -120,7 +120,7 @@ class MonitorAccessMixin(object):
...
@@ -120,7 +120,7 @@ class MonitorAccessMixin(object):
monitor_setup_url
=
connection_parameter_dict
[
'monitor-setup-url'
]
monitor_setup_url
=
connection_parameter_dict
[
'monitor-setup-url'
]
monitor_url_with_auth
=
'https'
+
monitor_setup_url
.
split
(
'https'
)[
2
]
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
# check that monitor-base-url for all partitions in the tree are accessible
# with published username and password
# with published username and password
...
@@ -130,7 +130,7 @@ class MonitorAccessMixin(object):
...
@@ -130,7 +130,7 @@ class MonitorAccessMixin(object):
if
not
connection_xml
:
if
not
connection_xml
:
continue
continue
connection_dict
=
slapos
.
util
.
xml2dict
(
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'
)
monitor_base_url
=
connection_dict
.
get
(
'monitor-base-url'
)
if
not
monitor_base_url
:
if
not
monitor_base_url
:
continue
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