mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-09 04:00:31 -07:00
[PR #645/c3ef9bf6 backport][stable-1] cobbler: Add Python 3 support (#1499)
* cobbler: Add Python 3 support (#645) (cherry picked from commitc3ef9bf668
) * Fix changelog fragment. (cherry picked from commitd495d3969b
) Co-authored-by: Dag Wieers <dag@wieers.com> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
7f92aa0854
commit
a04912dec0
2 changed files with 7 additions and 2 deletions
2
changelogs/fragments/638_cobbler_py3.yml
Normal file
2
changelogs/fragments/638_cobbler_py3.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- cobbler inventory script - add Python 3 support (https://github.com/ansible-collections/community.general/issues/638).
|
|
@ -52,7 +52,10 @@ import argparse
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from time import time
|
from time import time
|
||||||
import xmlrpclib
|
try: # Python 3
|
||||||
|
from xmlrpc.client import Server
|
||||||
|
except ImportError: # Python 2
|
||||||
|
from xmlrpclib import Server
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
@ -106,7 +109,7 @@ class CobblerInventory(object):
|
||||||
|
|
||||||
def _connect(self):
|
def _connect(self):
|
||||||
if not self.conn:
|
if not self.conn:
|
||||||
self.conn = xmlrpclib.Server(self.cobbler_host, allow_none=True)
|
self.conn = Server(self.cobbler_host, allow_none=True)
|
||||||
self.token = None
|
self.token = None
|
||||||
if self.cobbler_username is not None:
|
if self.cobbler_username is not None:
|
||||||
self.token = self.conn.login(self.cobbler_username, self.cobbler_password)
|
self.token = self.conn.login(self.cobbler_username, self.cobbler_password)
|
||||||
|
|
Loading…
Add table
Reference in a new issue