Merge lp:~pedronis/adt-continuous-deployer/list-floating-ips into lp:adt-continuous-deployer

Proposed by Samuele Pedroni
Status: Merged
Approved by: Celso Providelo
Approved revision: 65
Merged at revision: 65
Proposed branch: lp:~pedronis/adt-continuous-deployer/list-floating-ips
Merge into: lp:adt-continuous-deployer
Diff against target: 94 lines (+33/-6)
4 files modified
.bzrignore (+1/-0)
ci_automation/nova.py (+8/-1)
ci_automation/tests/test_nova.py (+18/-3)
list.py (+6/-2)
To merge this branch: bzr merge lp:~pedronis/adt-continuous-deployer/list-floating-ips
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Review via email: mp+262430@code.launchpad.net

Commit message

list.py: list deployments floating ips

Description of the change

list deployments floating ips

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) wrote :

Samuele,

Nice and useful feature. There is only one remark inline about environments with multiple FIPs, but not a blocker, just for your consideration. [pre-approved]

[]

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2015-04-05 02:23:27 +0000
3+++ .bzrignore 2015-06-19 09:41:23 +0000
4@@ -1,1 +1,2 @@
5 adt_continuous_integration.egg-info
6+__pycache__
7
8=== modified file 'ci_automation/nova.py'
9--- ci_automation/nova.py 2015-05-28 00:21:30 +0000
10+++ ci_automation/nova.py 2015-06-19 09:41:23 +0000
11@@ -27,7 +27,7 @@
12 args = [
13 'nova',
14 'list',
15- '--minimal',
16+ '--fields', 'name,networks',
17 ]
18
19 output = subprocess.check_output(
20@@ -92,6 +92,13 @@
21 'epoch': os.stat(path)[stat.ST_MTIME],
22 })
23
24+ deployment.setdefault('floating_ips', [])
25+ networks = line.split('|')[3].strip()
26+ if networks:
27+ ips = networks.split('=')[1].strip()
28+ floating_ips = [ip.strip() for ip in ips.split(',')][1:]
29+ deployment['floating_ips'].extend(floating_ips)
30+
31 return services
32
33
34
35=== modified file 'ci_automation/tests/test_nova.py'
36--- ci_automation/tests/test_nova.py 2015-04-24 03:27:46 +0000
37+++ ci_automation/tests/test_nova.py 2015-06-19 09:41:23 +0000
38@@ -60,12 +60,17 @@
39 def create_output(self):
40 """Return some fake 'nova list' output."""
41 count = 0
42+ ip = 0
43 output = ""
44 for ident in self.identifiers:
45 count += 1
46 for name in self.service_names:
47- output += '| id-{} | juju-{}-{}-machine-0 |\n'.format(
48- count, name, ident)
49+ ip += 1
50+ networks = "net=10.0.0.{}".format(ip)
51+ if 'publisher' in name and ident.startswith('a'):
52+ networks += ', 162.0.100.200'
53+ output += ('| id-{} | juju-{}-{}-machine-0 | {} |\n'.format(
54+ count, name, ident, networks))
55 return output
56
57 def test_service_map_ignores_missing_identifiers(self):
58@@ -95,7 +100,17 @@
59 # including the bootstrap node).
60 deployment_contents = service_contents['abcdef']
61 self.assertEqual(
62- ['epoch', 'path', 'units'], sorted(deployment_contents.keys()))
63+ ['epoch', 'floating_ips', 'path', 'units'],
64+ sorted(deployment_contents.keys()))
65+
66+ def test_service_map_floating_ips(self):
67+ self.generate_identifiers()
68+ service_map = get_services_map(
69+ self.base_dir, nova_output=self.create_output())
70+ self.assertEqual(service_map['mojo-ue-core-image-watcher']
71+ ['abcdef']['floating_ips'], [])
72+ self.assertEqual(service_map['mojo-ue-core-image-publisher']
73+ ['abcdef']['floating_ips'], ['162.0.100.200'])
74
75
76 if __name__ == '__main__':
77
78=== modified file 'list.py'
79--- list.py 2015-04-27 18:16:33 +0000
80+++ list.py 2015-06-19 09:41:23 +0000
81@@ -46,8 +46,12 @@
82 for ident, contents in sorted_deployments:
83 date_created = datetime.datetime.utcfromtimestamp(
84 contents['epoch']).ctime()
85- print('\t{}: {} ({} units)'.format(
86- ident, date_created, len(contents['units'])))
87+ float_ips = ""
88+ if contents['floating_ips']:
89+ float_ips = "=> {}".format(', '.join(
90+ contents['floating_ips']))
91+ print('\t{}: {} ({} units) {}'.format(
92+ ident, date_created, len(contents['units']), float_ips))
93
94 return 0
95

Subscribers

People subscribed via source and target branches

to all changes: