Merge lp:~corey.bryant/charms/trusty/cinder/git-1531612 into lp:~openstack-charmers-archive/charms/trusty/cinder/next

Proposed by Corey Bryant
Status: Merged
Merged at revision: 141
Proposed branch: lp:~corey.bryant/charms/trusty/cinder/git-1531612
Merge into: lp:~openstack-charmers-archive/charms/trusty/cinder/next
Diff against target: 324 lines (+129/-34)
7 files modified
charm-helpers-hooks.yaml (+1/-1)
hooks/charmhelpers/contrib/openstack/context.py (+12/-2)
hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg (+3/-2)
hooks/charmhelpers/contrib/openstack/utils.py (+6/-9)
hooks/charmhelpers/core/host.py (+34/-17)
hooks/charmhelpers/fetch/giturl.py (+0/-3)
hooks/charmhelpers/payload/archive.py (+73/-0)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/cinder/git-1531612
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+281955@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #15693 cinder-next for corey.bryant mp281955
    UNIT OK: passed

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

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

charm_lint_check #16811 cinder-next for corey.bryant mp281955
    LINT OK: passed

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

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

charm_amulet_test #8576 cinder-next for corey.bryant mp281955
    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/14435305/
Build: http://10.245.162.77:8080/job/charm_amulet_test/8576/

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

charm_lint_check #16839 cinder-next for corey.bryant mp281955
    LINT OK: passed

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

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

charm_unit_test #15725 cinder-next for corey.bryant mp281955
    UNIT OK: passed

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

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

charm_amulet_test #8608 cinder-next for corey.bryant mp281955
    AMULET OK: passed

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

143. By Corey Bryant

[corey.bryant,r=osci] Add hooks/charmhelpers/payload/archive.py

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

charm_unit_test #15954 cinder-next for corey.bryant mp281955
    UNIT OK: passed

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

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

charm_lint_check #17086 cinder-next for corey.bryant mp281955
    LINT OK: passed

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

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

charm_amulet_test #8689 cinder-next for corey.bryant mp281955
    AMULET OK: passed

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charm-helpers-hooks.yaml'
--- charm-helpers-hooks.yaml 2015-07-31 13:11:29 +0000
+++ charm-helpers-hooks.yaml 2016-01-11 14:15:00 +0000
@@ -10,7 +10,7 @@
10 - apache10 - apache
11 - cluster11 - cluster
12 - fetch12 - fetch
13 - payload.execd13 - payload
14 - contrib.network.ip14 - contrib.network.ip
15 - contrib.python.packages15 - contrib.python.packages
16 - contrib.charmsupport16 - contrib.charmsupport
1717
=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
--- hooks/charmhelpers/contrib/openstack/context.py 2016-01-04 21:26:14 +0000
+++ hooks/charmhelpers/contrib/openstack/context.py 2016-01-11 14:15:00 +0000
@@ -57,6 +57,7 @@
57 get_nic_hwaddr,57 get_nic_hwaddr,
58 mkdir,58 mkdir,
59 write_file,59 write_file,
60 pwgen,
60)61)
61from charmhelpers.contrib.hahelpers.cluster import (62from charmhelpers.contrib.hahelpers.cluster import (
62 determine_apache_port,63 determine_apache_port,
@@ -87,6 +88,8 @@
87 is_bridge_member,88 is_bridge_member,
88)89)
89from charmhelpers.contrib.openstack.utils import get_host_ip90from charmhelpers.contrib.openstack.utils import get_host_ip
91from charmhelpers.core.unitdata import kv
92
90CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'93CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
91ADDRESS_TYPES = ['admin', 'internal', 'public']94ADDRESS_TYPES = ['admin', 'internal', 'public']
9295
@@ -636,11 +639,18 @@
636 ctxt['ipv6'] = True639 ctxt['ipv6'] = True
637 ctxt['local_host'] = 'ip6-localhost'640 ctxt['local_host'] = 'ip6-localhost'
638 ctxt['haproxy_host'] = '::'641 ctxt['haproxy_host'] = '::'
639 ctxt['stat_port'] = ':::8888'
640 else:642 else:
641 ctxt['local_host'] = '127.0.0.1'643 ctxt['local_host'] = '127.0.0.1'
642 ctxt['haproxy_host'] = '0.0.0.0'644 ctxt['haproxy_host'] = '0.0.0.0'
643 ctxt['stat_port'] = ':8888'645
646 ctxt['stat_port'] = '8888'
647
648 db = kv()
649 ctxt['stat_password'] = db.get('stat-password')
650 if not ctxt['stat_password']:
651 ctxt['stat_password'] = db.set('stat-password',
652 pwgen(32))
653 db.flush()
644654
645 for frontend in cluster_hosts:655 for frontend in cluster_hosts:
646 if (len(cluster_hosts[frontend]['backends']) > 1 or656 if (len(cluster_hosts[frontend]['backends']) > 1 or
647657
=== modified file 'hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg'
--- hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2015-12-07 23:11:09 +0000
+++ hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2016-01-11 14:15:00 +0000
@@ -33,13 +33,14 @@
33 timeout server 3000033 timeout server 30000
34{%- endif %}34{%- endif %}
3535
36listen stats {{ stat_port }}36listen stats
37 bind {{ local_host }}:{{ stat_port }}
37 mode http38 mode http
38 stats enable39 stats enable
39 stats hide-version40 stats hide-version
40 stats realm Haproxy\ Statistics41 stats realm Haproxy\ Statistics
41 stats uri /42 stats uri /
42 stats auth admin:password43 stats auth admin:{{ stat_password }}
4344
44{% if frontends -%}45{% if frontends -%}
45{% for service, ports in service_ports.items() -%}46{% for service, ports in service_ports.items() -%}
4647
=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
--- hooks/charmhelpers/contrib/openstack/utils.py 2016-01-05 11:01:37 +0000
+++ hooks/charmhelpers/contrib/openstack/utils.py 2016-01-11 14:15:00 +0000
@@ -593,7 +593,7 @@
593 return yaml.load(projects_yaml)593 return yaml.load(projects_yaml)
594594
595595
596def git_clone_and_install(projects_yaml, core_project, depth=1):596def git_clone_and_install(projects_yaml, core_project):
597 """597 """
598 Clone/install all specified OpenStack repositories.598 Clone/install all specified OpenStack repositories.
599599
@@ -643,6 +643,9 @@
643 for p in projects['repositories']:643 for p in projects['repositories']:
644 repo = p['repository']644 repo = p['repository']
645 branch = p['branch']645 branch = p['branch']
646 depth = '1'
647 if 'depth' in p.keys():
648 depth = p['depth']
646 if p['name'] == 'requirements':649 if p['name'] == 'requirements':
647 repo_dir = _git_clone_and_install_single(repo, branch, depth,650 repo_dir = _git_clone_and_install_single(repo, branch, depth,
648 parent_dir, http_proxy,651 parent_dir, http_proxy,
@@ -687,19 +690,13 @@
687 """690 """
688 Clone and install a single git repository.691 Clone and install a single git repository.
689 """692 """
690 dest_dir = os.path.join(parent_dir, os.path.basename(repo))
691
692 if not os.path.exists(parent_dir):693 if not os.path.exists(parent_dir):
693 juju_log('Directory already exists at {}. '694 juju_log('Directory already exists at {}. '
694 'No need to create directory.'.format(parent_dir))695 'No need to create directory.'.format(parent_dir))
695 os.mkdir(parent_dir)696 os.mkdir(parent_dir)
696697
697 if not os.path.exists(dest_dir):698 juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch))
698 juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch))699 repo_dir = install_remote(repo, dest=parent_dir, branch=branch, depth=depth)
699 repo_dir = install_remote(repo, dest=parent_dir, branch=branch,
700 depth=depth)
701 else:
702 repo_dir = dest_dir
703700
704 venv = os.path.join(parent_dir, 'venv')701 venv = os.path.join(parent_dir, 'venv')
705702
706703
=== modified file 'hooks/charmhelpers/core/host.py'
--- hooks/charmhelpers/core/host.py 2016-01-04 21:26:14 +0000
+++ hooks/charmhelpers/core/host.py 2016-01-11 14:15:00 +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 """
152169
=== modified file 'hooks/charmhelpers/fetch/giturl.py'
--- hooks/charmhelpers/fetch/giturl.py 2016-01-04 21:26:14 +0000
+++ hooks/charmhelpers/fetch/giturl.py 2016-01-11 14:15:00 +0000
@@ -22,7 +22,6 @@
22 filter_installed_packages,22 filter_installed_packages,
23 apt_install,23 apt_install,
24)24)
25from charmhelpers.core.host import mkdir
2625
27if filter_installed_packages(['git']) != []:26if filter_installed_packages(['git']) != []:
28 apt_install(['git'])27 apt_install(['git'])
@@ -62,8 +61,6 @@
62 else:61 else:
63 dest_dir = os.path.join(os.environ.get('CHARM_DIR'), "fetched",62 dest_dir = os.path.join(os.environ.get('CHARM_DIR'), "fetched",
64 branch_name)63 branch_name)
65 if not os.path.exists(dest_dir):
66 mkdir(dest_dir, perms=0o755)
67 try:64 try:
68 self.clone(source, dest_dir, branch, depth)65 self.clone(source, dest_dir, branch, depth)
69 except OSError as e:66 except OSError as e:
7067
=== added file 'hooks/charmhelpers/payload/archive.py'
--- hooks/charmhelpers/payload/archive.py 1970-01-01 00:00:00 +0000
+++ hooks/charmhelpers/payload/archive.py 2016-01-11 14:15:00 +0000
@@ -0,0 +1,73 @@
1# Copyright 2014-2015 Canonical Limited.
2#
3# This file is part of charm-helpers.
4#
5# charm-helpers is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# charm-helpers is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
16
17import os
18import tarfile
19import zipfile
20from charmhelpers.core import (
21 host,
22 hookenv,
23)
24
25
26class ArchiveError(Exception):
27 pass
28
29
30def get_archive_handler(archive_name):
31 if os.path.isfile(archive_name):
32 if tarfile.is_tarfile(archive_name):
33 return extract_tarfile
34 elif zipfile.is_zipfile(archive_name):
35 return extract_zipfile
36 else:
37 # look at the file name
38 for ext in ('.tar', '.tar.gz', '.tgz', 'tar.bz2', '.tbz2', '.tbz'):
39 if archive_name.endswith(ext):
40 return extract_tarfile
41 for ext in ('.zip', '.jar'):
42 if archive_name.endswith(ext):
43 return extract_zipfile
44
45
46def archive_dest_default(archive_name):
47 archive_file = os.path.basename(archive_name)
48 return os.path.join(hookenv.charm_dir(), "archives", archive_file)
49
50
51def extract(archive_name, destpath=None):
52 handler = get_archive_handler(archive_name)
53 if handler:
54 if not destpath:
55 destpath = archive_dest_default(archive_name)
56 if not os.path.isdir(destpath):
57 host.mkdir(destpath)
58 handler(archive_name, destpath)
59 return destpath
60 else:
61 raise ArchiveError("No handler for archive")
62
63
64def extract_tarfile(archive_name, destpath):
65 "Unpack a tar archive, optionally compressed"
66 archive = tarfile.open(archive_name)
67 archive.extractall(destpath)
68
69
70def extract_zipfile(archive_name, destpath):
71 "Unpack a zip file"
72 archive = zipfile.ZipFile(archive_name)
73 archive.extractall(destpath)

Subscribers

People subscribed via source and target branches