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

Proposed by Corey Bryant
Status: Merged
Merged at revision: 111
Proposed branch: lp:~corey.bryant/charms/trusty/ceilometer/git-1531612
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceilometer/next
Diff against target: 233 lines (+55/-33)
5 files modified
charmhelpers/contrib/openstack/context.py (+12/-2)
charmhelpers/contrib/openstack/templates/haproxy.cfg (+3/-2)
charmhelpers/contrib/openstack/utils.py (+6/-9)
charmhelpers/core/host.py (+34/-17)
charmhelpers/fetch/giturl.py (+0/-3)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/ceilometer/git-1531612
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+281954@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #16804 ceilometer-next for corey.bryant mp281954
    LINT OK: passed

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

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

charm_unit_test #15700 ceilometer-next for corey.bryant mp281954
    UNIT OK: passed

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

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

charm_amulet_test #8585 ceilometer-next for corey.bryant mp281954
    AMULET OK: passed

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

Revision history for this message
Liam Young (gnuoy) wrote :

Approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/openstack/context.py'
--- charmhelpers/contrib/openstack/context.py 2016-01-04 21:24:42 +0000
+++ charmhelpers/contrib/openstack/context.py 2016-01-08 03:09:55 +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 'charmhelpers/contrib/openstack/templates/haproxy.cfg'
--- charmhelpers/contrib/openstack/templates/haproxy.cfg 2015-12-07 23:08:12 +0000
+++ charmhelpers/contrib/openstack/templates/haproxy.cfg 2016-01-08 03:09:55 +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 'charmhelpers/contrib/openstack/utils.py'
--- charmhelpers/contrib/openstack/utils.py 2016-01-05 11:48:08 +0000
+++ charmhelpers/contrib/openstack/utils.py 2016-01-08 03:09:55 +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 'charmhelpers/core/host.py'
--- charmhelpers/core/host.py 2016-01-04 21:24:42 +0000
+++ charmhelpers/core/host.py 2016-01-08 03:09:55 +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 'charmhelpers/fetch/giturl.py'
--- charmhelpers/fetch/giturl.py 2016-01-04 21:24:42 +0000
+++ charmhelpers/fetch/giturl.py 2016-01-08 03:09:55 +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:

Subscribers

People subscribed via source and target branches