Merge lp:~james-page/charms/trusty/swift-storage/lp1531102 into lp:~openstack-charmers-archive/charms/trusty/swift-storage/next

Proposed by James Page on 2016-01-05
Status: Merged
Merged at revision: 98
Proposed branch: lp:~james-page/charms/trusty/swift-storage/lp1531102
Merge into: lp:~openstack-charmers-archive/charms/trusty/swift-storage/next
Diff against target: 198 lines (+61/-42)
2 files modified
charmhelpers/contrib/openstack/utils.py (+27/-25)
charmhelpers/core/host.py (+34/-17)
To merge this branch: bzr merge lp:~james-page/charms/trusty/swift-storage/lp1531102
Reviewer Review Type Date Requested Status
OpenStack Charmers 2016-01-05 Pending
Review via email: mp+281619@code.launchpad.net

Commit message

Resync helpers

Description of the change

Resync helpers

To post a comment you must log in.

charm_lint_check #16591 swift-storage-next for james-page mp281619
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/16591/

charm_unit_test #15497 swift-storage-next for james-page mp281619
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/15497/

charm_amulet_test #8514 swift-storage-next for james-page mp281619
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/14411354/
Build: http://10.245.162.77:8080/job/charm_amulet_test/8514/

charm_amulet_test #8522 swift-storage-next for james-page mp281619
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/14413236/
Build: http://10.245.162.77:8080/job/charm_amulet_test/8522/

99. By James Page on 2016-01-07

Resync charm helpers to resolve systemd related amulet test failures.

charm_lint_check #16725 swift-storage-next for james-page mp281619
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/16725/

charm_unit_test #15618 swift-storage-next for james-page mp281619
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/15618/

charm_amulet_test #8548 swift-storage-next for james-page mp281619
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/8548/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/utils.py'
2--- charmhelpers/contrib/openstack/utils.py 2016-01-04 21:31:57 +0000
3+++ charmhelpers/contrib/openstack/utils.py 2016-01-07 09:19:54 +0000
4@@ -131,40 +131,40 @@
5 # >= Liberty version->codename mapping
6 PACKAGE_CODENAMES = {
7 'nova-common': OrderedDict([
8- ('12.0.0', 'liberty'),
9- ('13.0.0', 'mitaka'),
10+ ('12.0', 'liberty'),
11+ ('13.0', 'mitaka'),
12 ]),
13 'neutron-common': OrderedDict([
14- ('7.0.0', 'liberty'),
15- ('8.0.0', 'mitaka'),
16+ ('7.0', 'liberty'),
17+ ('8.0', 'mitaka'),
18 ]),
19 'cinder-common': OrderedDict([
20- ('7.0.0', 'liberty'),
21- ('8.0.0', 'mitaka'),
22+ ('7.0', 'liberty'),
23+ ('8.0', 'mitaka'),
24 ]),
25 'keystone': OrderedDict([
26- ('8.0.0', 'liberty'),
27- ('9.0.0', 'mitaka'),
28+ ('8.0', 'liberty'),
29+ ('9.0', 'mitaka'),
30 ]),
31 'horizon-common': OrderedDict([
32- ('8.0.0', 'liberty'),
33- ('9.0.0', 'mitaka'),
34+ ('8.0', 'liberty'),
35+ ('9.0', 'mitaka'),
36 ]),
37 'ceilometer-common': OrderedDict([
38- ('5.0.0', 'liberty'),
39- ('6.0.0', 'mitaka'),
40+ ('5.0', 'liberty'),
41+ ('6.0', 'mitaka'),
42 ]),
43 'heat-common': OrderedDict([
44- ('5.0.0', 'liberty'),
45- ('6.0.0', 'mitaka'),
46+ ('5.0', 'liberty'),
47+ ('6.0', 'mitaka'),
48 ]),
49 'glance-common': OrderedDict([
50- ('11.0.0', 'liberty'),
51- ('12.0.0', 'mitaka'),
52+ ('11.0', 'liberty'),
53+ ('12.0', 'mitaka'),
54 ]),
55 'openstack-dashboard': OrderedDict([
56- ('8.0.0', 'liberty'),
57- ('9.0.0', 'mitaka'),
58+ ('8.0', 'liberty'),
59+ ('9.0', 'mitaka'),
60 ]),
61 }
62
63@@ -251,7 +251,14 @@
64 error_out(e)
65
66 vers = apt.upstream_version(pkg.current_ver.ver_str)
67- match = re.match('^(\d+)\.(\d+)\.(\d+)', vers)
68+ if 'swift' in pkg.name:
69+ # Fully x.y.z match for swift versions
70+ match = re.match('^(\d+)\.(\d+)\.(\d+)', vers)
71+ else:
72+ # x.y match only for 20XX.X
73+ # and ignore patch level for other packages
74+ match = re.match('^(\d+)\.(\d+)', vers)
75+
76 if match:
77 vers = match.group(0)
78
79@@ -263,13 +270,8 @@
80 # < Liberty co-ordinated project versions
81 try:
82 if 'swift' in pkg.name:
83- swift_vers = vers[:5]
84- if swift_vers not in SWIFT_CODENAMES:
85- # Deal with 1.10.0 upward
86- swift_vers = vers[:6]
87- return SWIFT_CODENAMES[swift_vers]
88+ return SWIFT_CODENAMES[vers]
89 else:
90- vers = vers[:6]
91 return OPENSTACK_CODENAMES[vers]
92 except KeyError:
93 if not fatal:
94
95=== modified file 'charmhelpers/core/host.py'
96--- charmhelpers/core/host.py 2016-01-04 21:31:57 +0000
97+++ charmhelpers/core/host.py 2016-01-07 09:19:54 +0000
98@@ -72,7 +72,9 @@
99 stopped = service_stop(service_name)
100 upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))
101 sysv_file = os.path.join(initd_dir, service_name)
102- if os.path.exists(upstart_file):
103+ if init_is_systemd():
104+ service('disable', service_name)
105+ elif os.path.exists(upstart_file):
106 override_path = os.path.join(
107 init_dir, '{}.override'.format(service_name))
108 with open(override_path, 'w') as fh:
109@@ -80,9 +82,9 @@
110 elif os.path.exists(sysv_file):
111 subprocess.check_call(["update-rc.d", service_name, "disable"])
112 else:
113- # XXX: Support SystemD too
114 raise ValueError(
115- "Unable to detect {0} as either Upstart {1} or SysV {2}".format(
116+ "Unable to detect {0} as SystemD, Upstart {1} or"
117+ " SysV {2}".format(
118 service_name, upstart_file, sysv_file))
119 return stopped
120
121@@ -94,7 +96,9 @@
122 Reenable starting again at boot. Start the service"""
123 upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))
124 sysv_file = os.path.join(initd_dir, service_name)
125- if os.path.exists(upstart_file):
126+ if init_is_systemd():
127+ service('enable', service_name)
128+ elif os.path.exists(upstart_file):
129 override_path = os.path.join(
130 init_dir, '{}.override'.format(service_name))
131 if os.path.exists(override_path):
132@@ -102,9 +106,9 @@
133 elif os.path.exists(sysv_file):
134 subprocess.check_call(["update-rc.d", service_name, "enable"])
135 else:
136- # XXX: Support SystemD too
137 raise ValueError(
138- "Unable to detect {0} as either Upstart {1} or SysV {2}".format(
139+ "Unable to detect {0} as SystemD, Upstart {1} or"
140+ " SysV {2}".format(
141 service_name, upstart_file, sysv_file))
142
143 started = service_running(service_name)
144@@ -115,23 +119,29 @@
145
146 def service(action, service_name):
147 """Control a system service"""
148- cmd = ['service', service_name, action]
149+ if init_is_systemd():
150+ cmd = ['systemctl', action, service_name]
151+ else:
152+ cmd = ['service', service_name, action]
153 return subprocess.call(cmd) == 0
154
155
156-def service_running(service):
157+def service_running(service_name):
158 """Determine whether a system service is running"""
159- try:
160- output = subprocess.check_output(
161- ['service', service, 'status'],
162- stderr=subprocess.STDOUT).decode('UTF-8')
163- except subprocess.CalledProcessError:
164- return False
165+ if init_is_systemd():
166+ return service('is-active', service_name)
167 else:
168- if ("start/running" in output or "is running" in output):
169- return True
170- else:
171+ try:
172+ output = subprocess.check_output(
173+ ['service', service_name, 'status'],
174+ stderr=subprocess.STDOUT).decode('UTF-8')
175+ except subprocess.CalledProcessError:
176 return False
177+ else:
178+ if ("start/running" in output or "is running" in output):
179+ return True
180+ else:
181+ return False
182
183
184 def service_available(service_name):
185@@ -146,6 +156,13 @@
186 return True
187
188
189+SYSTEMD_SYSTEM = '/run/systemd/system'
190+
191+
192+def init_is_systemd():
193+ return os.path.isdir(SYSTEMD_SYSTEM)
194+
195+
196 def adduser(username, password=None, shell='/bin/bash', system_user=False,
197 primary_group=None, secondary_groups=None):
198 """

Subscribers

People subscribed via source and target branches