Merge lp:~simpoir/landscape-client-charm/1750668_bionic_py3_support into lp:landscape-client-charm

Proposed by Simon Poirier
Status: Merged
Approved by: Simon Poirier
Approved revision: 67
Merged at revision: 66
Proposed branch: lp:~simpoir/landscape-client-charm/1750668_bionic_py3_support
Merge into: lp:landscape-client-charm
Diff against target: 142 lines (+31/-11)
5 files modified
hooks/common.py (+13/-5)
hooks/hooks (+11/-0)
hooks/hooks.py (+4/-5)
hooks/test_hooks.py (+2/-1)
metadata.yaml (+1/-0)
To merge this branch: bzr merge lp:~simpoir/landscape-client-charm/1750668_bionic_py3_support
Reviewer Review Type Date Requested Status
Chad Smith Approve
🤖 Landscape Builder test results Approve
Review via email: mp+339698@code.launchpad.net

Commit message

Wrap hooks hooks to run on version used by landscape-client and correct a couple imports which changed.

Description of the change

Wrap hooks hooks to run on version used by landscape-client and correct a couple imports which changed.

Testing instructions:
juju add-model cli
juju deploy ubuntu --series bionic
juju deploy . --series bionic
juju config landscape-client account-name=CHANGEME
juju config landscape-client origin=ppa:landscape/trunk
juju config landscape-client url=https://landscape.canonical.com/message-system
juju config landscape-client ping-url=http://landscape.canonical.com/ping
juju config landscape-client registration-key=CHANGEME

juju relate landscape-client ubuntu

To post a comment you must log in.
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :
review: Approve (test results)
Revision history for this message
Chad Smith (chad.smith) wrote :

LGTM, minor comment request

review: Approve
Revision history for this message
Simon Poirier (simpoir) :
67. By Simon Poirier

comment on import fallback

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified symlink 'hooks/ceph-client-relation-broken'
2=== target changed u'hooks.py' => u'hooks'
3=== modified symlink 'hooks/ceph-client-relation-changed'
4=== target changed u'hooks.py' => u'hooks'
5=== modified symlink 'hooks/ceph-client-relation-departed'
6=== target changed u'hooks.py' => u'hooks'
7=== modified symlink 'hooks/ceph-client-relation-joined'
8=== target changed u'hooks.py' => u'hooks'
9=== modified file 'hooks/common.py'
10--- hooks/common.py 2016-12-14 16:08:39 +0000
11+++ hooks/common.py 2018-02-27 14:37:21 +0000
12@@ -8,11 +8,19 @@
13 from charmhelpers.core.hookenv import (
14 log, local_unit, status_set)
15
16-from landscape.configuration import (
17- setup, register, LandscapeSetupConfiguration, ConfigurationError,
18- stop_client_and_disable_init_script)
19-from landscape.deployment import Configuration
20-from landscape.sysvconfig import SysVConfig
21+try:
22+ from landscape.client.configuration import (
23+ setup, register, LandscapeSetupConfiguration, ConfigurationError,
24+ stop_client_and_disable_init_script)
25+ from landscape.client.deployment import Configuration
26+ from landscape.client.sysvconfig import SysVConfig
27+except ImportError:
28+ # Compatibility with landscape-clients older than 18.01 (pre bionic)
29+ from landscape.configuration import (
30+ setup, register, LandscapeSetupConfiguration, ConfigurationError,
31+ stop_client_and_disable_init_script)
32+ from landscape.deployment import Configuration
33+ from landscape.sysvconfig import SysVConfig
34
35
36 class JujuBroker(object):
37
38=== modified symlink 'hooks/config-changed'
39=== target changed u'hooks.py' => u'hooks'
40=== modified symlink 'hooks/container-relation-departed'
41=== target changed u'hooks.py' => u'hooks'
42=== modified symlink 'hooks/container-relation-joined'
43=== target changed u'hooks.py' => u'hooks'
44=== added file 'hooks/hooks'
45--- hooks/hooks 1970-01-01 00:00:00 +0000
46+++ hooks/hooks 2018-02-27 14:37:21 +0000
47@@ -0,0 +1,11 @@
48+#!/bin/sh
49+
50+hooks_py="`dirname $0`/hooks.py"
51+interpreter="/usr/bin/python"
52+
53+if [ `lsb_release -rs` \> "18.00" ]; then
54+ # landscape-client has py3 libs from bionic forward
55+ interpreter="/usr/bin/python3"
56+fi
57+
58+exec ${interpreter} ${hooks_py} $0 $@
59
60=== modified file 'hooks/hooks.py'
61--- hooks/hooks.py 2017-10-19 09:44:44 +0000
62+++ hooks/hooks.py 2018-02-27 14:37:21 +0000
63@@ -1,11 +1,10 @@
64-#!/usr/bin/python
65-
66 import apt_pkg
67 import sys
68 import socket
69 import os
70 import base64
71
72+import six
73 from charmhelpers.core.hookenv import (
74 Hooks, UnregisteredHookError, log)
75 from shutil import rmtree
76@@ -54,7 +53,7 @@
77 install_landscape_client(service_config["origin"], fetch=fetch)
78 # Only update client config with service configs that have been set
79 set_config = {}
80- for key, value in service_config.iteritems():
81+ for key, value in six.iteritems(service_config):
82 if value is not None:
83 if type(value) == str:
84 set_config[key] = value.strip()
85@@ -188,7 +187,7 @@
86 "juju-private-address": None}
87 juju_info = dict.fromkeys(key for key in juju_key_map.values() if key)
88 files_to_delete = []
89- for filename, info_key in juju_key_map.iteritems():
90+ for filename, info_key in six.iteritems(juju_key_map):
91 file_path = os.path.join(meta_data_dir, filename)
92 if not os.path.exists(file_path):
93 continue
94@@ -221,6 +220,6 @@
95
96 if __name__ == '__main__':
97 try:
98- sys.exit(hooks.execute(sys.argv))
99+ sys.exit(hooks.execute(sys.argv[1:]))
100 except UnregisteredHookError as e:
101 log('Unknown hook {} - skipping.'.format(e))
102
103=== modified symlink 'hooks/registration-relation-changed'
104=== target changed u'hooks.py' => u'hooks'
105=== modified symlink 'hooks/registration-relation-departed'
106=== target changed u'hooks.py' => u'hooks'
107=== modified symlink 'hooks/registration-relation-joined'
108=== target changed u'hooks.py' => u'hooks'
109=== modified file 'hooks/test_hooks.py'
110--- hooks/test_hooks.py 2017-03-03 10:16:05 +0000
111+++ hooks/test_hooks.py 2018-02-27 14:37:21 +0000
112@@ -6,6 +6,7 @@
113 from unittest import TestCase
114 from uuid import uuid4
115
116+import six
117 from landscape.deployment import Configuration
118 from landscape.lib.fs import read_file
119 import hooks
120@@ -105,7 +106,7 @@
121 super(MigrateOldJujuInfoTest, self).setUp()
122
123 def setup_old_juju_info(self, juju_info):
124- for filename, contents in juju_info.iteritems():
125+ for filename, contents in six.iteritems(juju_info):
126 juju_path = os.path.join(self.config.meta_data_path, filename)
127 with open(juju_path, "w") as juju_file:
128 juju_file.write(contents)
129
130=== modified symlink 'hooks/upgrade-charm'
131=== target changed u'hooks.py' => u'hooks'
132=== modified file 'metadata.yaml'
133--- metadata.yaml 2016-12-14 16:04:54 +0000
134+++ metadata.yaml 2018-02-27 14:37:21 +0000
135@@ -10,6 +10,7 @@
136 series:
137 - trusty
138 - xenial
139+ - bionic
140 tags: [ ops, monitoring ]
141 requires:
142 container:

Subscribers

People subscribed via source and target branches

to all changes: