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
1=== modified file 'charmhelpers/contrib/amulet/utils.py'
2--- charmhelpers/contrib/amulet/utils.py 2014-06-20 13:27:58 +0000
3+++ charmhelpers/contrib/amulet/utils.py 2014-06-30 17:22:58 +0000
4@@ -53,9 +53,10 @@
5 """Verify the specified services are running on the corresponding
6 service units."""
7 for k, v in commands.iteritems():
8- output, code = k.run(v)
9- if code != 0:
10- return "command `{}` returned {}".format(v, str(code))
11+ for cmd in v:
12+ output, code = k.run(cmd)
13+ if code != 0:
14+ return "command `{}` returned {}".format(cmd, str(code))
15 return None
16
17 def _get_config(self, unit, filename):
18@@ -126,21 +127,24 @@
19 """Get last modification time of directory."""
20 return sentry_unit.directory_stat(directory)['mtime']
21
22- def _get_proc_start_time(self, sentry_unit, service):
23+ def _get_proc_start_time(self, sentry_unit, service, pgrep_full=False):
24 """Determine start time of the process based on the last modification
25- time of the /proc/pid directory. The servie string will be matched
26- against any substring in the full command line, choosing the oldest
27- process."""
28- cmd = 'pgrep -f -o {}'.format(service)
29+ time of the /proc/pid directory. If pgrep_full is True, the process
30+ name is matched against the full command line."""
31+ if pgrep_full:
32+ cmd = 'pgrep -o -f {}'.format(service)
33+ else:
34+ cmd = 'pgrep -o {}'.format(service)
35 proc_dir = '/proc/{}'.format(sentry_unit.run(cmd)[0].strip())
36 return self._get_dir_mtime(sentry_unit, proc_dir)
37
38- def service_restarted(self, sentry_unit, service, filename):
39+ def service_restarted(self, sentry_unit, service, filename,
40+ pgrep_full=False):
41 """Compare a service's start time vs a file's last modification time
42 (such as a config file for that service) to determine if the service
43 has been restarted."""
44 sleep(10)
45- if self._get_proc_start_time(sentry_unit, service) >= \
46+ if self._get_proc_start_time(sentry_unit, service, pgrep_full) >= \
47 self._get_file_mtime(sentry_unit, filename):
48 return True
49 else:
50
51=== modified file 'charmhelpers/contrib/openstack/amulet/deployment.py'
52--- charmhelpers/contrib/openstack/amulet/deployment.py 2014-06-20 13:27:21 +0000
53+++ charmhelpers/contrib/openstack/amulet/deployment.py 2014-06-30 17:22:58 +0000
54@@ -7,19 +7,36 @@
55 """This class inherits from AmuletDeployment and has additional support
56 that is specifically for use by OpenStack charms."""
57
58- def __init__(self, series=None, openstack=None):
59+ def __init__(self, series=None, openstack=None, source=None):
60 """Initialize the deployment environment."""
61- self.openstack = None
62 super(OpenStackAmuletDeployment, self).__init__(series)
63-
64- if openstack:
65- self.openstack = openstack
66+ self.openstack = openstack
67+ self.source = source
68+
69+ def _add_services(self, this_service, other_services):
70+ """Add services to the deployment and set openstack-origin."""
71+ super(OpenStackAmuletDeployment, self)._add_services(this_service,
72+ other_services)
73+ name = 0
74+ services = other_services
75+ services.append(this_service)
76+ use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']
77+
78+ if self.openstack:
79+ for svc in services:
80+ if svc[name] not in use_source:
81+ config = {'openstack-origin': self.openstack}
82+ self.d.configure(svc[name], config)
83+
84+ if self.source:
85+ for svc in services:
86+ if svc[name] in use_source:
87+ config = {'source': self.source}
88+ self.d.configure(svc[name], config)
89
90 def _configure_services(self, configs):
91 """Configure all of the services."""
92 for service, config in configs.iteritems():
93- if service == self.this_service:
94- config['openstack-origin'] = self.openstack
95 self.d.configure(service, config)
96
97 def _get_openstack_release(self):
98
99=== modified file 'charmhelpers/contrib/openstack/amulet/utils.py'
100--- charmhelpers/contrib/openstack/amulet/utils.py 2014-06-24 13:57:57 +0000
101+++ charmhelpers/contrib/openstack/amulet/utils.py 2014-06-30 17:22:58 +0000
102@@ -74,7 +74,7 @@
103 if ret:
104 return "unexpected tenant data - {}".format(ret)
105 if not found:
106- return "tenant {} does not exist".format(e.name)
107+ return "tenant {} does not exist".format(e['name'])
108 return ret
109
110 def validate_role_data(self, expected, actual):
111@@ -91,7 +91,7 @@
112 if ret:
113 return "unexpected role data - {}".format(ret)
114 if not found:
115- return "role {} does not exist".format(e.name)
116+ return "role {} does not exist".format(e['name'])
117 return ret
118
119 def validate_user_data(self, expected, actual):
120@@ -110,7 +110,7 @@
121 if ret:
122 return "unexpected user data - {}".format(ret)
123 if not found:
124- return "user {} does not exist".format(e.name)
125+ return "user {} does not exist".format(e['name'])
126 return ret
127
128 def validate_flavor_data(self, expected, actual):
129@@ -192,8 +192,8 @@
130
131 count = 1
132 status = instance.status
133- while status == 'BUILD' and count < 10:
134- time.sleep(5)
135+ while status != 'ACTIVE' and count < 60:
136+ time.sleep(3)
137 instance = nova.servers.get(instance.id)
138 status = instance.status
139 self.log.debug('instance status: {}'.format(status))

Subscribers

People subscribed via source and target branches