Merge lp:~freyes/ubuntu/precise/serverstack-dns/index-out-of-range into lp:~openstack-charmers/ubuntu/precise/serverstack-dns/trunk

Proposed by Felipe Reyes on 2016-09-13
Status: Needs review
Proposed branch: lp:~freyes/ubuntu/precise/serverstack-dns/index-out-of-range
Merge into: lp:~openstack-charmers/ubuntu/precise/serverstack-dns/trunk
Diff against target: 14 lines (+4/-0)
1 file modified
serverstack-tenant-dns (+4/-0)
To merge this branch: bzr merge lp:~freyes/ubuntu/precise/serverstack-dns/index-out-of-range
Reviewer Review Type Date Requested Status
OpenStack Charmers 2016-09-13 Pending
Review via email: mp+305631@code.launchpad.net

Description of the Change

Skip empty lines when iterating hosts file

If the hosts file contains empty lines a list index out of range exception
is raised

    Traceback (most recent call last):
      File "/usr/bin/serverstack-tenant-dns", line 256, in <module>
        add_current_instances()
      File "/usr/bin/serverstack-tenant-dns", line 144, in add_current_instances
        add_host_entry(hostname, ip_addr, "")
      File "/usr/bin/serverstack-tenant-dns", line 81, in add_host_entry
        hn = _hostname[1]
    IndexError: list index out of range

To post a comment you must log in.

Unmerged revisions

17. By Felipe Reyes on 2016-09-13

Skip empty lines when iterating hosts file

If the hosts file contains empty lines a list index out of range exception
is raised

Traceback (most recent call last):
  File "/usr/bin/serverstack-tenant-dns", line 256, in <module>
    add_current_instances()
  File "/usr/bin/serverstack-tenant-dns", line 144, in add_current_instances
    add_host_entry(hostname, ip_addr, "")
  File "/usr/bin/serverstack-tenant-dns", line 81, in add_host_entry
    hn = _hostname[1]
IndexError: list index out of range

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'serverstack-tenant-dns'
2--- serverstack-tenant-dns 2016-03-07 18:06:43 +0000
3+++ serverstack-tenant-dns 2016-09-13 17:11:01 +0000
4@@ -76,6 +76,10 @@
5 out = []
6 # remove stale entries
7 for hostname in hostnames:
8+
9+ if not hostname.strip(): # skip empty lines
10+ continue
11+
12 _hostname = hostname.split(' ')
13 ip = _hostname[0]
14 hn = _hostname[1]

Subscribers

People subscribed via source and target branches