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

Proposed by James Page
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 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.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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.

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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
=== modified file 'charmhelpers/contrib/openstack/utils.py'
--- charmhelpers/contrib/openstack/utils.py 2016-01-04 21:31:57 +0000
+++ charmhelpers/contrib/openstack/utils.py 2016-01-07 09:19:54 +0000
@@ -131,40 +131,40 @@
131# >= Liberty version->codename mapping131# >= Liberty version->codename mapping
132PACKAGE_CODENAMES = {132PACKAGE_CODENAMES = {
133 'nova-common': OrderedDict([133 'nova-common': OrderedDict([
134 ('12.0.0', 'liberty'),134 ('12.0', 'liberty'),
135 ('13.0.0', 'mitaka'),135 ('13.0', 'mitaka'),
136 ]),136 ]),
137 'neutron-common': OrderedDict([137 'neutron-common': OrderedDict([
138 ('7.0.0', 'liberty'),138 ('7.0', 'liberty'),
139 ('8.0.0', 'mitaka'),139 ('8.0', 'mitaka'),
140 ]),140 ]),
141 'cinder-common': OrderedDict([141 'cinder-common': OrderedDict([
142 ('7.0.0', 'liberty'),142 ('7.0', 'liberty'),
143 ('8.0.0', 'mitaka'),143 ('8.0', 'mitaka'),
144 ]),144 ]),
145 'keystone': OrderedDict([145 'keystone': OrderedDict([
146 ('8.0.0', 'liberty'),146 ('8.0', 'liberty'),
147 ('9.0.0', 'mitaka'),147 ('9.0', 'mitaka'),
148 ]),148 ]),
149 'horizon-common': OrderedDict([149 'horizon-common': OrderedDict([
150 ('8.0.0', 'liberty'),150 ('8.0', 'liberty'),
151 ('9.0.0', 'mitaka'),151 ('9.0', 'mitaka'),
152 ]),152 ]),
153 'ceilometer-common': OrderedDict([153 'ceilometer-common': OrderedDict([
154 ('5.0.0', 'liberty'),154 ('5.0', 'liberty'),
155 ('6.0.0', 'mitaka'),155 ('6.0', 'mitaka'),
156 ]),156 ]),
157 'heat-common': OrderedDict([157 'heat-common': OrderedDict([
158 ('5.0.0', 'liberty'),158 ('5.0', 'liberty'),
159 ('6.0.0', 'mitaka'),159 ('6.0', 'mitaka'),
160 ]),160 ]),
161 'glance-common': OrderedDict([161 'glance-common': OrderedDict([
162 ('11.0.0', 'liberty'),162 ('11.0', 'liberty'),
163 ('12.0.0', 'mitaka'),163 ('12.0', 'mitaka'),
164 ]),164 ]),
165 'openstack-dashboard': OrderedDict([165 'openstack-dashboard': OrderedDict([
166 ('8.0.0', 'liberty'),166 ('8.0', 'liberty'),
167 ('9.0.0', 'mitaka'),167 ('9.0', 'mitaka'),
168 ]),168 ]),
169}169}
170170
@@ -251,7 +251,14 @@
251 error_out(e)251 error_out(e)
252252
253 vers = apt.upstream_version(pkg.current_ver.ver_str)253 vers = apt.upstream_version(pkg.current_ver.ver_str)
254 match = re.match('^(\d+)\.(\d+)\.(\d+)', vers)254 if 'swift' in pkg.name:
255 # Fully x.y.z match for swift versions
256 match = re.match('^(\d+)\.(\d+)\.(\d+)', vers)
257 else:
258 # x.y match only for 20XX.X
259 # and ignore patch level for other packages
260 match = re.match('^(\d+)\.(\d+)', vers)
261
255 if match:262 if match:
256 vers = match.group(0)263 vers = match.group(0)
257264
@@ -263,13 +270,8 @@
263 # < Liberty co-ordinated project versions270 # < Liberty co-ordinated project versions
264 try:271 try:
265 if 'swift' in pkg.name:272 if 'swift' in pkg.name:
266 swift_vers = vers[:5]273 return SWIFT_CODENAMES[vers]
267 if swift_vers not in SWIFT_CODENAMES:
268 # Deal with 1.10.0 upward
269 swift_vers = vers[:6]
270 return SWIFT_CODENAMES[swift_vers]
271 else:274 else:
272 vers = vers[:6]
273 return OPENSTACK_CODENAMES[vers]275 return OPENSTACK_CODENAMES[vers]
274 except KeyError:276 except KeyError:
275 if not fatal:277 if not fatal:
276278
=== modified file 'charmhelpers/core/host.py'
--- charmhelpers/core/host.py 2016-01-04 21:31:57 +0000
+++ charmhelpers/core/host.py 2016-01-07 09:19:54 +0000
@@ -72,7 +72,9 @@
72 stopped = service_stop(service_name)72 stopped = service_stop(service_name)
73 upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))73 upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))
74 sysv_file = os.path.join(initd_dir, service_name)74 sysv_file = os.path.join(initd_dir, service_name)
75 if os.path.exists(upstart_file):75 if init_is_systemd():
76 service('disable', service_name)
77 elif os.path.exists(upstart_file):
76 override_path = os.path.join(78 override_path = os.path.join(
77 init_dir, '{}.override'.format(service_name))79 init_dir, '{}.override'.format(service_name))
78 with open(override_path, 'w') as fh:80 with open(override_path, 'w') as fh:
@@ -80,9 +82,9 @@
80 elif os.path.exists(sysv_file):82 elif os.path.exists(sysv_file):
81 subprocess.check_call(["update-rc.d", service_name, "disable"])83 subprocess.check_call(["update-rc.d", service_name, "disable"])
82 else:84 else:
83 # XXX: Support SystemD too
84 raise ValueError(85 raise ValueError(
85 "Unable to detect {0} as either Upstart {1} or SysV {2}".format(86 "Unable to detect {0} as SystemD, Upstart {1} or"
87 " SysV {2}".format(
86 service_name, upstart_file, sysv_file))88 service_name, upstart_file, sysv_file))
87 return stopped89 return stopped
8890
@@ -94,7 +96,9 @@
94 Reenable starting again at boot. Start the service"""96 Reenable starting again at boot. Start the service"""
95 upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))97 upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))
96 sysv_file = os.path.join(initd_dir, service_name)98 sysv_file = os.path.join(initd_dir, service_name)
97 if os.path.exists(upstart_file):99 if init_is_systemd():
100 service('enable', service_name)
101 elif os.path.exists(upstart_file):
98 override_path = os.path.join(102 override_path = os.path.join(
99 init_dir, '{}.override'.format(service_name))103 init_dir, '{}.override'.format(service_name))
100 if os.path.exists(override_path):104 if os.path.exists(override_path):
@@ -102,9 +106,9 @@
102 elif os.path.exists(sysv_file):106 elif os.path.exists(sysv_file):
103 subprocess.check_call(["update-rc.d", service_name, "enable"])107 subprocess.check_call(["update-rc.d", service_name, "enable"])
104 else:108 else:
105 # XXX: Support SystemD too
106 raise ValueError(109 raise ValueError(
107 "Unable to detect {0} as either Upstart {1} or SysV {2}".format(110 "Unable to detect {0} as SystemD, Upstart {1} or"
111 " SysV {2}".format(
108 service_name, upstart_file, sysv_file))112 service_name, upstart_file, sysv_file))
109113
110 started = service_running(service_name)114 started = service_running(service_name)
@@ -115,23 +119,29 @@
115119
116def service(action, service_name):120def service(action, service_name):
117 """Control a system service"""121 """Control a system service"""
118 cmd = ['service', service_name, action]122 if init_is_systemd():
123 cmd = ['systemctl', action, service_name]
124 else:
125 cmd = ['service', service_name, action]
119 return subprocess.call(cmd) == 0126 return subprocess.call(cmd) == 0
120127
121128
122def service_running(service):129def service_running(service_name):
123 """Determine whether a system service is running"""130 """Determine whether a system service is running"""
124 try:131 if init_is_systemd():
125 output = subprocess.check_output(132 return service('is-active', service_name)
126 ['service', service, 'status'],
127 stderr=subprocess.STDOUT).decode('UTF-8')
128 except subprocess.CalledProcessError:
129 return False
130 else:133 else:
131 if ("start/running" in output or "is running" in output):134 try:
132 return True135 output = subprocess.check_output(
133 else:136 ['service', service_name, 'status'],
137 stderr=subprocess.STDOUT).decode('UTF-8')
138 except subprocess.CalledProcessError:
134 return False139 return False
140 else:
141 if ("start/running" in output or "is running" in output):
142 return True
143 else:
144 return False
135145
136146
137def service_available(service_name):147def service_available(service_name):
@@ -146,6 +156,13 @@
146 return True156 return True
147157
148158
159SYSTEMD_SYSTEM = '/run/systemd/system'
160
161
162def init_is_systemd():
163 return os.path.isdir(SYSTEMD_SYSTEM)
164
165
149def adduser(username, password=None, shell='/bin/bash', system_user=False,166def adduser(username, password=None, shell='/bin/bash', system_user=False,
150 primary_group=None, secondary_groups=None):167 primary_group=None, secondary_groups=None):
151 """168 """

Subscribers

People subscribed via source and target branches