Merge ~smoser/cloud-init:cleanup/get_by_mac_use_get_interfaces into cloud-init:master

Proposed by Scott Moser
Status: Merged
Merged at revision: 9d923c1ab9c4556b980509513ece4a414269b5b9
Proposed branch: ~smoser/cloud-init:cleanup/get_by_mac_use_get_interfaces
Merge into: cloud-init:master
Diff against target: 27 lines (+1/-15)
1 file modified
cloudinit/net/__init__.py (+1/-15)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+328542@code.launchpad.net

Commit message

net: Reduce duplicate code. Have get_interfaces_by_mac use get_interfaces.

get_interfaces_by_mac and get_interfaces just looked much alike.
This makes get_interfaces_by_mac call get_interfaces.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:9d923c1ab9c4556b980509513ece4a414269b5b9
https://jenkins.ubuntu.com/server/job/cloud-init-ci/112/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/112/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

+1 on the drop

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
2index 46cb9c8..1ff8fae 100644
3--- a/cloudinit/net/__init__.py
4+++ b/cloudinit/net/__init__.py
5@@ -511,21 +511,7 @@ def get_interfaces_by_mac():
6
7 Bridges and any devices that have a 'stolen' mac are excluded."""
8 ret = {}
9- devs = get_devicelist()
10- empty_mac = '00:00:00:00:00:00'
11- for name in devs:
12- if not interface_has_own_mac(name):
13- continue
14- if is_bridge(name):
15- continue
16- if is_vlan(name):
17- continue
18- mac = get_interface_mac(name)
19- # some devices may not have a mac (tun0)
20- if not mac:
21- continue
22- if mac == empty_mac and name != 'lo':
23- continue
24+ for name, mac, _driver, _devid in get_interfaces():
25 if mac in ret:
26 raise RuntimeError(
27 "duplicate mac found! both '%s' and '%s' have mac '%s'" %

Subscribers

People subscribed via source and target branches