|
|
1070a0 |
From bad2b8a68909f7fba0252b2d61bbd98489fc4996 Mon Sep 17 00:00:00 2001
|
|
|
1070a0 |
From: Tomas Kasparek <tkasparek@redhat.com>
|
|
|
1070a0 |
Date: Mon, 5 Mar 2018 11:10:46 +0100
|
|
|
1070a0 |
Subject: [PATCH 03/17] fixing xmlrpclib, urllib2 and local imports in Python 3
|
|
|
1070a0 |
|
|
|
1070a0 |
---
|
|
|
1070a0 |
koan/app.py | 23 +++++++++++++----------
|
|
|
1070a0 |
koan/imagecreate.py | 4 ++--
|
|
|
1070a0 |
koan/qcreate.py | 4 ++--
|
|
|
1070a0 |
koan/register.py | 7 +++++--
|
|
|
1070a0 |
koan/utils.py | 8 ++++++--
|
|
|
1070a0 |
koan/virtinstall.py | 4 ++--
|
|
|
1070a0 |
koan/vmwcreate.py | 1 -
|
|
|
1070a0 |
koan/xencreate.py | 4 ++--
|
|
|
1070a0 |
8 files changed, 32 insertions(+), 23 deletions(-)
|
|
|
1070a0 |
|
|
|
1070a0 |
diff --git a/koan/app.py b/koan/app.py
|
|
|
1070a0 |
index 801fedd..e4e8a6d 100755
|
|
|
1070a0 |
--- a/koan/app.py
|
|
|
1070a0 |
+++ b/koan/app.py
|
|
|
1070a0 |
@@ -36,10 +36,13 @@ import time
|
|
|
1070a0 |
import shutil
|
|
|
1070a0 |
import errno
|
|
|
1070a0 |
import sys
|
|
|
1070a0 |
-import xmlrpclib
|
|
|
1070a0 |
+try: #python2
|
|
|
1070a0 |
+ import xmlrpclib
|
|
|
1070a0 |
+except ImportError: #python3
|
|
|
1070a0 |
+ import xmlrpc.client as xmlrpclib
|
|
|
1070a0 |
import string
|
|
|
1070a0 |
import re
|
|
|
1070a0 |
-import utils
|
|
|
1070a0 |
+from . import utils
|
|
|
1070a0 |
|
|
|
1070a0 |
COBBLER_REQUIRED = 1.300
|
|
|
1070a0 |
|
|
|
1070a0 |
@@ -1124,9 +1127,9 @@ class Koan:
|
|
|
1070a0 |
"""
|
|
|
1070a0 |
pd = profile_data
|
|
|
1070a0 |
# importing can't throw exceptions any more, don't put it in a sub-method
|
|
|
1070a0 |
- import xencreate
|
|
|
1070a0 |
- import qcreate
|
|
|
1070a0 |
- import imagecreate
|
|
|
1070a0 |
+ from . import xencreate
|
|
|
1070a0 |
+ from . import qcreate
|
|
|
1070a0 |
+ from . import imagecreate
|
|
|
1070a0 |
|
|
|
1070a0 |
arch = self.safe_load(pd,'arch','x86')
|
|
|
1070a0 |
kextra = self.calc_kernel_args(pd)
|
|
|
1070a0 |
@@ -1211,11 +1214,11 @@ class Koan:
|
|
|
1070a0 |
if (self.image is not None) and (pd["image_type"] == "virt-clone"):
|
|
|
1070a0 |
fullvirt = True
|
|
|
1070a0 |
uuid = None
|
|
|
1070a0 |
- import imagecreate
|
|
|
1070a0 |
+ from . import imagecreate
|
|
|
1070a0 |
creator = imagecreate.start_install
|
|
|
1070a0 |
elif self.virt_type in [ "xenpv", "xenfv" ]:
|
|
|
1070a0 |
uuid = self.get_uuid(self.calc_virt_uuid(pd))
|
|
|
1070a0 |
- import xencreate
|
|
|
1070a0 |
+ from . import xencreate
|
|
|
1070a0 |
creator = xencreate.start_install
|
|
|
1070a0 |
if self.virt_type == "xenfv":
|
|
|
1070a0 |
fullvirt = True
|
|
|
1070a0 |
@@ -1223,15 +1226,15 @@ class Koan:
|
|
|
1070a0 |
elif self.virt_type == "qemu":
|
|
|
1070a0 |
fullvirt = True
|
|
|
1070a0 |
uuid = None
|
|
|
1070a0 |
- import qcreate
|
|
|
1070a0 |
+ from . import qcreate
|
|
|
1070a0 |
creator = qcreate.start_install
|
|
|
1070a0 |
can_poll = "qemu"
|
|
|
1070a0 |
elif self.virt_type == "vmware":
|
|
|
1070a0 |
- import vmwcreate
|
|
|
1070a0 |
+ from . import vmwcreate
|
|
|
1070a0 |
uuid = None
|
|
|
1070a0 |
creator = vmwcreate.start_install
|
|
|
1070a0 |
elif self.virt_type == "vmwarew":
|
|
|
1070a0 |
- import vmwwcreate
|
|
|
1070a0 |
+ from . import vmwwcreate
|
|
|
1070a0 |
uuid = None
|
|
|
1070a0 |
creator = vmwwcreate.start_install
|
|
|
1070a0 |
else:
|
|
|
1070a0 |
diff --git a/koan/imagecreate.py b/koan/imagecreate.py
|
|
|
1070a0 |
index 6bd9d9b..d70d519 100644
|
|
|
1070a0 |
--- a/koan/imagecreate.py
|
|
|
1070a0 |
+++ b/koan/imagecreate.py
|
|
|
1070a0 |
@@ -23,8 +23,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
1070a0 |
02110-1301 USA
|
|
|
1070a0 |
"""
|
|
|
1070a0 |
|
|
|
1070a0 |
-import utils
|
|
|
1070a0 |
-import virtinstall
|
|
|
1070a0 |
+from . import utils
|
|
|
1070a0 |
+from . import virtinstall
|
|
|
1070a0 |
|
|
|
1070a0 |
def start_install(*args, **kwargs):
|
|
|
1070a0 |
cmd = virtinstall.build_commandline("import", *args, **kwargs)
|
|
|
1070a0 |
diff --git a/koan/qcreate.py b/koan/qcreate.py
|
|
|
1070a0 |
index 019a266..1db3d97 100755
|
|
|
1070a0 |
--- a/koan/qcreate.py
|
|
|
1070a0 |
+++ b/koan/qcreate.py
|
|
|
1070a0 |
@@ -23,8 +23,8 @@ module for creating fullvirt guests via KVM/kqemu/qemu
|
|
|
1070a0 |
requires python-virtinst-0.200 (or virt-install in later distros).
|
|
|
1070a0 |
"""
|
|
|
1070a0 |
|
|
|
1070a0 |
-import utils
|
|
|
1070a0 |
-import virtinstall
|
|
|
1070a0 |
+from . import utils
|
|
|
1070a0 |
+from . import virtinstall
|
|
|
1070a0 |
from xml.dom.minidom import parseString
|
|
|
1070a0 |
|
|
|
1070a0 |
def start_install(*args, **kwargs):
|
|
|
1070a0 |
diff --git a/koan/register.py b/koan/register.py
|
|
|
1070a0 |
index 871b8ac..cabd4a6 100755
|
|
|
1070a0 |
--- a/koan/register.py
|
|
|
1070a0 |
+++ b/koan/register.py
|
|
|
1070a0 |
@@ -25,9 +25,12 @@ import traceback
|
|
|
1070a0 |
from optparse import OptionParser
|
|
|
1070a0 |
import time
|
|
|
1070a0 |
import sys
|
|
|
1070a0 |
-import xmlrpclib
|
|
|
1070a0 |
+try: #python2
|
|
|
1070a0 |
+ import xmlrpclib
|
|
|
1070a0 |
+except ImportError: #python3
|
|
|
1070a0 |
+ import xmlrpc.client as xmlrpclib
|
|
|
1070a0 |
import socket
|
|
|
1070a0 |
-import utils
|
|
|
1070a0 |
+from . import utils
|
|
|
1070a0 |
import string
|
|
|
1070a0 |
|
|
|
1070a0 |
# usage: cobbler-register [--server=server] [--hostname=hostname] --profile=foo
|
|
|
1070a0 |
diff --git a/koan/utils.py b/koan/utils.py
|
|
|
1070a0 |
index 4a3f547..b8247e2 100644
|
|
|
1070a0 |
--- a/koan/utils.py
|
|
|
1070a0 |
+++ b/koan/utils.py
|
|
|
1070a0 |
@@ -25,8 +25,12 @@ import os
|
|
|
1070a0 |
import traceback
|
|
|
1070a0 |
import sys
|
|
|
1070a0 |
import subprocess as sub_process
|
|
|
1070a0 |
-import urllib2
|
|
|
1070a0 |
-import xmlrpclib
|
|
|
1070a0 |
+try: #python2
|
|
|
1070a0 |
+ import urllib2
|
|
|
1070a0 |
+ import xmlrpclib
|
|
|
1070a0 |
+except ImportError: #python3
|
|
|
1070a0 |
+ import urllib.request as urllib2
|
|
|
1070a0 |
+ import xmlrpc.client as xmlrpclib
|
|
|
1070a0 |
import string
|
|
|
1070a0 |
import shutil
|
|
|
1070a0 |
import tempfile
|
|
|
1070a0 |
diff --git a/koan/virtinstall.py b/koan/virtinstall.py
|
|
|
1070a0 |
index 4ef7874..ca11e04 100644
|
|
|
1070a0 |
--- a/koan/virtinstall.py
|
|
|
1070a0 |
+++ b/koan/virtinstall.py
|
|
|
1070a0 |
@@ -30,8 +30,8 @@ import os
|
|
|
1070a0 |
import re
|
|
|
1070a0 |
import shlex
|
|
|
1070a0 |
|
|
|
1070a0 |
-import app as koan
|
|
|
1070a0 |
-import utils
|
|
|
1070a0 |
+from . import app as koan
|
|
|
1070a0 |
+from . import utils
|
|
|
1070a0 |
|
|
|
1070a0 |
# The virtinst module will no longer be availabe to import in some
|
|
|
1070a0 |
# distros. We need to get all the info we need from the virt-install
|
|
|
1070a0 |
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
|
|
|
1070a0 |
index 3fda926..372173a 100755
|
|
|
1070a0 |
--- a/koan/vmwcreate.py
|
|
|
1070a0 |
+++ b/koan/vmwcreate.py
|
|
|
1070a0 |
@@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
1070a0 |
|
|
|
1070a0 |
import os
|
|
|
1070a0 |
import random
|
|
|
1070a0 |
-import virtinst
|
|
|
1070a0 |
|
|
|
1070a0 |
IMAGE_DIR = "/var/lib/vmware/images"
|
|
|
1070a0 |
VMX_DIR = "/var/lib/vmware/vmx"
|
|
|
1070a0 |
diff --git a/koan/xencreate.py b/koan/xencreate.py
|
|
|
1070a0 |
index c3492ed..7eda3e6 100755
|
|
|
1070a0 |
--- a/koan/xencreate.py
|
|
|
1070a0 |
+++ b/koan/xencreate.py
|
|
|
1070a0 |
@@ -26,8 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
1070a0 |
02110-1301 USA
|
|
|
1070a0 |
"""
|
|
|
1070a0 |
|
|
|
1070a0 |
-import utils
|
|
|
1070a0 |
-import virtinstall
|
|
|
1070a0 |
+from . import utils
|
|
|
1070a0 |
+from . import virtinstall
|
|
|
1070a0 |
|
|
|
1070a0 |
def start_install(*args, **kwargs):
|
|
|
1070a0 |
cmd = virtinstall.build_commandline("xen:///", *args, **kwargs)
|
|
|
1070a0 |
--
|
|
|
1070a0 |
2.5.5
|
|
|
1070a0 |
|