Merge lp:~corey.bryant/charm-helpers/openstack-origin into lp:charm-helpers

Proposed by Corey Bryant
Status: Merged
Merged at revision: 177
Proposed branch: lp:~corey.bryant/charm-helpers/openstack-origin
Merge into: lp:charm-helpers
Diff against target: 139 lines (+43/-22)
3 files modified
charmhelpers/contrib/amulet/utils.py (+14/-10)
charmhelpers/contrib/openstack/amulet/deployment.py (+24/-7)
charmhelpers/contrib/openstack/amulet/utils.py (+5/-5)
To merge this branch: bzr merge lp:~corey.bryant/charm-helpers/openstack-origin
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+224436@code.launchpad.net

Description of the change

The openstack-origin wasn't properly getting set for all services. This fixes that.

To post a comment you must log in.
173. By Marco Ceppi

[tvansteenburgh] Adds basic API documentation for the package, along with make targets for building and publishing it (see HACKING for details).

174. By Stuart Bishop

[stub] Stop configure_sources() from breaking when configuration was not provided

175. By Juan L. Negron

Add a function get_ipv6_addr() to let service charm get an ipv6 address.
And could return a url containing ipv6 address if service charm have set the use-ipv6 config. MP:224793

176. By James Page

Revert last change to charm-helpers as it breaks unit tests

177. By James Page

[coreycb,r=james-page] Ensure openstack-origin is set consistently during testing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/amulet/utils.py'
--- charmhelpers/contrib/amulet/utils.py 2014-06-20 13:27:58 +0000
+++ charmhelpers/contrib/amulet/utils.py 2014-06-30 17:22:58 +0000
@@ -53,9 +53,10 @@
53 """Verify the specified services are running on the corresponding53 """Verify the specified services are running on the corresponding
54 service units."""54 service units."""
55 for k, v in commands.iteritems():55 for k, v in commands.iteritems():
56 output, code = k.run(v)56 for cmd in v:
57 if code != 0:57 output, code = k.run(cmd)
58 return "command `{}` returned {}".format(v, str(code))58 if code != 0:
59 return "command `{}` returned {}".format(cmd, str(code))
59 return None60 return None
6061
61 def _get_config(self, unit, filename):62 def _get_config(self, unit, filename):
@@ -126,21 +127,24 @@
126 """Get last modification time of directory."""127 """Get last modification time of directory."""
127 return sentry_unit.directory_stat(directory)['mtime']128 return sentry_unit.directory_stat(directory)['mtime']
128129
129 def _get_proc_start_time(self, sentry_unit, service):130 def _get_proc_start_time(self, sentry_unit, service, pgrep_full=False):
130 """Determine start time of the process based on the last modification131 """Determine start time of the process based on the last modification
131 time of the /proc/pid directory. The servie string will be matched132 time of the /proc/pid directory. If pgrep_full is True, the process
132 against any substring in the full command line, choosing the oldest133 name is matched against the full command line."""
133 process."""134 if pgrep_full:
134 cmd = 'pgrep -f -o {}'.format(service)135 cmd = 'pgrep -o -f {}'.format(service)
136 else:
137 cmd = 'pgrep -o {}'.format(service)
135 proc_dir = '/proc/{}'.format(sentry_unit.run(cmd)[0].strip())138 proc_dir = '/proc/{}'.format(sentry_unit.run(cmd)[0].strip())
136 return self._get_dir_mtime(sentry_unit, proc_dir)139 return self._get_dir_mtime(sentry_unit, proc_dir)
137140
138 def service_restarted(self, sentry_unit, service, filename):141 def service_restarted(self, sentry_unit, service, filename,
142 pgrep_full=False):
139 """Compare a service's start time vs a file's last modification time143 """Compare a service's start time vs a file's last modification time
140 (such as a config file for that service) to determine if the service144 (such as a config file for that service) to determine if the service
141 has been restarted."""145 has been restarted."""
142 sleep(10)146 sleep(10)
143 if self._get_proc_start_time(sentry_unit, service) >= \147 if self._get_proc_start_time(sentry_unit, service, pgrep_full) >= \
144 self._get_file_mtime(sentry_unit, filename):148 self._get_file_mtime(sentry_unit, filename):
145 return True149 return True
146 else:150 else:
147151
=== modified file 'charmhelpers/contrib/openstack/amulet/deployment.py'
--- charmhelpers/contrib/openstack/amulet/deployment.py 2014-06-20 13:27:21 +0000
+++ charmhelpers/contrib/openstack/amulet/deployment.py 2014-06-30 17:22:58 +0000
@@ -7,19 +7,36 @@
7 """This class inherits from AmuletDeployment and has additional support7 """This class inherits from AmuletDeployment and has additional support
8 that is specifically for use by OpenStack charms."""8 that is specifically for use by OpenStack charms."""
99
10 def __init__(self, series=None, openstack=None):10 def __init__(self, series=None, openstack=None, source=None):
11 """Initialize the deployment environment."""11 """Initialize the deployment environment."""
12 self.openstack = None
13 super(OpenStackAmuletDeployment, self).__init__(series)12 super(OpenStackAmuletDeployment, self).__init__(series)
1413 self.openstack = openstack
15 if openstack:14 self.source = source
16 self.openstack = openstack15
16 def _add_services(self, this_service, other_services):
17 """Add services to the deployment and set openstack-origin."""
18 super(OpenStackAmuletDeployment, self)._add_services(this_service,
19 other_services)
20 name = 0
21 services = other_services
22 services.append(this_service)
23 use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']
24
25 if self.openstack:
26 for svc in services:
27 if svc[name] not in use_source:
28 config = {'openstack-origin': self.openstack}
29 self.d.configure(svc[name], config)
30
31 if self.source:
32 for svc in services:
33 if svc[name] in use_source:
34 config = {'source': self.source}
35 self.d.configure(svc[name], config)
1736
18 def _configure_services(self, configs):37 def _configure_services(self, configs):
19 """Configure all of the services."""38 """Configure all of the services."""
20 for service, config in configs.iteritems():39 for service, config in configs.iteritems():
21 if service == self.this_service:
22 config['openstack-origin'] = self.openstack
23 self.d.configure(service, config)40 self.d.configure(service, config)
2441
25 def _get_openstack_release(self):42 def _get_openstack_release(self):
2643
=== modified file 'charmhelpers/contrib/openstack/amulet/utils.py'
--- charmhelpers/contrib/openstack/amulet/utils.py 2014-06-24 13:57:57 +0000
+++ charmhelpers/contrib/openstack/amulet/utils.py 2014-06-30 17:22:58 +0000
@@ -74,7 +74,7 @@
74 if ret:74 if ret:
75 return "unexpected tenant data - {}".format(ret)75 return "unexpected tenant data - {}".format(ret)
76 if not found:76 if not found:
77 return "tenant {} does not exist".format(e.name)77 return "tenant {} does not exist".format(e['name'])
78 return ret78 return ret
7979
80 def validate_role_data(self, expected, actual):80 def validate_role_data(self, expected, actual):
@@ -91,7 +91,7 @@
91 if ret:91 if ret:
92 return "unexpected role data - {}".format(ret)92 return "unexpected role data - {}".format(ret)
93 if not found:93 if not found:
94 return "role {} does not exist".format(e.name)94 return "role {} does not exist".format(e['name'])
95 return ret95 return ret
9696
97 def validate_user_data(self, expected, actual):97 def validate_user_data(self, expected, actual):
@@ -110,7 +110,7 @@
110 if ret:110 if ret:
111 return "unexpected user data - {}".format(ret)111 return "unexpected user data - {}".format(ret)
112 if not found:112 if not found:
113 return "user {} does not exist".format(e.name)113 return "user {} does not exist".format(e['name'])
114 return ret114 return ret
115115
116 def validate_flavor_data(self, expected, actual):116 def validate_flavor_data(self, expected, actual):
@@ -192,8 +192,8 @@
192192
193 count = 1193 count = 1
194 status = instance.status194 status = instance.status
195 while status == 'BUILD' and count < 10:195 while status != 'ACTIVE' and count < 60:
196 time.sleep(5)196 time.sleep(3)
197 instance = nova.servers.get(instance.id)197 instance = nova.servers.get(instance.id)
198 status = instance.status198 status = instance.status
199 self.log.debug('instance status: {}'.format(status))199 self.log.debug('instance status: {}'.format(status))

Subscribers

People subscribed via source and target branches