Browse Source

Merge "Fix errors preventing novajoin to start on Python 3"

Zuul 4 months ago
parent
commit
6a1f2e1a87
6 changed files with 17 additions and 14 deletions
  1. 1
    0
      .gitignore
  2. 1
    1
      novajoin/configure_ipa.py
  3. 6
    6
      novajoin/ipa.py
  4. 1
    0
      requirements.txt
  5. 4
    4
      scripts/novajoin-install
  6. 4
    3
      setup.cfg

+ 1
- 0
.gitignore View File

@@ -3,6 +3,7 @@ files/join.conf
3 3
 tools/lintstack.head.py
4 4
 *.pyc
5 5
 *.egg-info/
6
+.eggs/
6 7
 .tox
7 8
 .testrepository
8 9
 .stestr

+ 1
- 1
novajoin/configure_ipa.py View File

@@ -56,7 +56,7 @@ import nss.nss as nss
56 56
 
57 57
 logger = logging.getLogger()
58 58
 
59
-allowed_chars = string.letters + string.digits
59
+allowed_chars = string.ascii_letters + string.digits
60 60
 
61 61
 KRB5_CONF_TMPL = """
62 62
 includedir /var/lib/sss/pubconf/krb5.include.d/

+ 6
- 6
novajoin/ipa.py View File

@@ -105,7 +105,7 @@ class IPANovaJoinBase(object):
105 105
     def split_hostname(self, hostname):
106 106
         """Split a hostname into its host and domain parts"""
107 107
         parts = hostname.split('.')
108
-        domain = ('.'.join(parts[1:]) + '.').decode('UTF-8')
108
+        domain = six.text_type('.'.join(parts[1:]) + '.')
109 109
         return (parts[0], domain)
110 110
 
111 111
     def get_host_and_realm(self):
@@ -282,7 +282,7 @@ class IPAClient(IPANovaJoinBase):
282 282
         # 'description': 'IPA host for %s' % inst.display_description,
283 283
         hostargs = {
284 284
             'description': u'IPA host for OpenStack',
285
-            'userpassword': ipaotp.decode('UTF-8'),
285
+            'userpassword': six.text_type(ipaotp),
286 286
             'force': True  # we don't have an ip addr yet so
287 287
                            # use force to add anyway
288 288
         }
@@ -295,23 +295,23 @@ class IPAClient(IPANovaJoinBase):
295 295
             hostargs['nshostlocation'] = location
296 296
 
297 297
         modargs = {
298
-            'userpassword': ipaotp.decode('UTF-8'),
298
+            'userpassword': six.text_type(ipaotp),
299 299
         }
300 300
 
301 301
         try:
302 302
             self._call_ipa('host_mod', *params, **modargs)
303
-            self.host_cache[hostname] = ipaotp.decode('UTF-8')
303
+            self.host_cache[hostname] = six.text_type(ipaotp)
304 304
         except errors.NotFound:
305 305
             try:
306 306
                 self._call_ipa('host_add', *params, **hostargs)
307
-                self.host_cache[hostname] = ipaotp.decode('UTF-8')
307
+                self.host_cache[hostname] = six.text_type(ipaotp)
308 308
             except errors.DuplicateEntry:
309 309
                 # We have no idea what the OTP is for the existing host.
310 310
                 return False
311 311
             except (errors.ValidationError, errors.DNSNotARecordError):
312 312
                 # Assumes despite these exceptions the host was created
313 313
                 # and the OTP was set.
314
-                self.host_cache[hostname] = ipaotp.decode('UTF-8')
314
+                self.host_cache[hostname] = six.text_type(ipaotp)
315 315
         except errors.ValidationError:
316 316
             # Updating the OTP on an enrolled-host is not allowed
317 317
             # in IPA and really a no-op.

+ 1
- 0
requirements.txt View File

@@ -9,6 +9,7 @@ six>=1.10.0 # MIT
9 9
 python-keystoneclient>=3.8.0 # Apache-2.0
10 10
 keystoneauth1>=3.3.0 # Apache-2.0
11 11
 oslo.concurrency>=3.25.0 # Apache-2.0
12
+oslo.config>=6.1.0 # Apache-2.0
12 13
 oslo.messaging>=5.29.0 # Apache-2.0
13 14
 oslo.policy>=1.30.0 # Apache-2.0
14 15
 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0

+ 4
- 4
scripts/novajoin-install View File

@@ -1,4 +1,4 @@
1
-#!/usr/bin/python
1
+#!/usr/bin/env python
2 2
 # Copyright 2016 Red Hat, Inc.
3 3
 #
4 4
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -79,8 +79,7 @@ def install(opts):
79 79
         os.environ['OS_USERNAME']
80 80
         os.environ['OS_AUTH_URL']
81 81
     except KeyError as e:
82
-        raise ConfigurationError('%s environment variable not set.'
83
-                                 % e.message)
82
+        raise ConfigurationError('%s environment variable not set.' % e)
84 83
 
85 84
     try:
86 85
         pwd.getpwnam(opts.user)
@@ -89,12 +88,13 @@ def install(opts):
89 88
                                  opts.user)
90 89
 
91 90
     api.bootstrap(context='novajoin')
92
-    api.finalize()
93 91
 
94 92
     novajoin = configure_ipa.NovajoinRole(user=opts.user)
95 93
     if not opts.no_kinit:
96 94
         novajoin.kinit(opts.principal, api.env.realm, opts.password)
97 95
 
96
+    api.finalize()
97
+
98 98
     try:
99 99
         api.Backend.rpcclient.connect()
100 100
     except errors.CCacheError:

+ 4
- 3
setup.cfg View File

@@ -32,9 +32,6 @@ data_files =
32 32
     /etc/novajoin =
33 33
         files/join-api-paste.ini
34 34
         files/cloud-config-novajoin.json
35
-    /usr/sbin =
36
-        scripts/novajoin-install
37
-    /usr/libexec = scripts/novajoin-ipa-setup
38 35
     /usr/share/man/man1 =
39 36
         man/novajoin-install.1
40 37
         man/novajoin-notify.1
@@ -43,6 +40,10 @@ data_files =
43 40
 packages =
44 41
     novajoin
45 42
 
43
+scripts =
44
+    scripts/novajoin-install
45
+    scripts/novajoin-ipa-setup
46
+
46 47
 [build_sphinx]
47 48
 source-dir = doc/source
48 49
 build-dir = doc/build

Loading…
Cancel
Save