Merge "Remove dependency on bridge-utils"

This commit is contained in:
Zuul 2018-11-08 15:45:13 +00:00 committed by Gerrit Code Review
commit 8d0435c2cd
4 changed files with 48 additions and 24 deletions

View File

@ -15,9 +15,7 @@ This role manages a veth pair. Actions:
Requirements
------------
The host should have the `ip` and `ovs-vsctl` commands accessible. If
`veth_pair_plug_into_source` is enabled, the command `brctl` must also be
accessible.
The host should have the `ip` and `ovs-vsctl` commands accessible.
Role Variables
--------------

View File

@ -1,16 +1,17 @@
---
- name: Unplug veth from source bridge
command: >-
brctl delif {{ veth_pair_source_bridge }}
{{ veth_pair_source_link_name }}
register: res
failed_when:
- res.rc != 0
# Case where veth is already unplugged.
- not (res.rc == 1 and 'does not exist' in res.stderr)
changed_when: res.rc == 0
- block:
- include_tasks: is-attached.yml
vars:
bridge: "{{ veth_pair_source_bridge }}"
interface: "{{ veth_pair_source_link_name }}"
- name: Unplug veth from source bridge
command: >-
ip link set {{ veth_pair_source_link_name }} nomaster
when:
- veth_pair_is_attached
become: true
when: veth_pair_plug_into_source | bool
become: true
- name: Delete veth pair
command: >-

View File

@ -0,0 +1,22 @@
---
# This will determine if interface is attached to bridge and set a fact called
# veth_pair_is_attached containing the result
- name: Set a default value for veth_pair_is_attached
set_fact:
veth_pair_is_attached: false
- name: Speculatively check {{ interface }}'s master
command: >-
realpath /sys/class/net/{{ interface }}/master
register: master_result
failed_when: false
changed_when: false
- name: Determine if {{ interface }} is attached to {{ bridge }}
vars:
master: "{{ master_result.stdout | basename }}"
set_fact:
veth_pair_is_attached: "{{ master == bridge }}"
when: master_result.rc == 0

View File

@ -23,14 +23,17 @@
port: "{{ veth_pair_ovs_link_name }}"
become: true
- name: Plug veth into source bridge
command: >-
brctl addif {{ veth_pair_source_bridge }}
{{ veth_pair_source_link_name }}
register: res
failed_when:
- res.rc != 0
- "'already a member of a bridge' not in res.stderr"
changed_when: "'already a member of a bridge' not in res.stderr"
- block:
- include_tasks: is-attached.yml
vars:
bridge: "{{ veth_pair_source_bridge }}"
interface: "{{ veth_pair_source_link_name }}"
- name: Plug veth into source bridge
command: >-
ip link set {{ veth_pair_source_link_name }} master
{{ veth_pair_source_bridge }}
when:
- not veth_pair_is_attached
become: true
when: veth_pair_plug_into_source | bool
become: true