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
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
index 46cb9c8..1ff8fae 100644
--- a/cloudinit/net/__init__.py
+++ b/cloudinit/net/__init__.py
@@ -511,21 +511,7 @@ def get_interfaces_by_mac():
511511
512 Bridges and any devices that have a 'stolen' mac are excluded."""512 Bridges and any devices that have a 'stolen' mac are excluded."""
513 ret = {}513 ret = {}
514 devs = get_devicelist()514 for name, mac, _driver, _devid in get_interfaces():
515 empty_mac = '00:00:00:00:00:00'
516 for name in devs:
517 if not interface_has_own_mac(name):
518 continue
519 if is_bridge(name):
520 continue
521 if is_vlan(name):
522 continue
523 mac = get_interface_mac(name)
524 # some devices may not have a mac (tun0)
525 if not mac:
526 continue
527 if mac == empty_mac and name != 'lo':
528 continue
529 if mac in ret:515 if mac in ret:
530 raise RuntimeError(516 raise RuntimeError(
531 "duplicate mac found! both '%s' and '%s' have mac '%s'" %517 "duplicate mac found! both '%s' and '%s' have mac '%s'" %

Subscribers

People subscribed via source and target branches