salt.modules.openvswitch

Support for Open vSwitch - module with basic Open vSwitch commands.

Suitable for setting up Openstack Neutron.

codeauthor:

Jiri Kotlin <jiri.kotlin@ultimum.io>

salt.modules.openvswitch.bridge_create(br, may_exist=True, parent=None, vlan=None)

Creates a new bridge.

Parameters:
  • br -- string bridge name

  • may_exist -- bool if False - attempting to create a bridge that exists returns False.

  • parent -- string name of the parent bridge (if the bridge shall be created as a fake bridge). If specified, vlan must also be specified.

  • versionadded: (..) -- 3006.0:

  • vlan -- int VLAN ID of the bridge (if the bridge shall be created as a fake bridge). If specified, parent must also be specified.

  • versionadded: -- 3006.0:

Returns:

True on success, else False.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.bridge_create br0
salt.modules.openvswitch.bridge_delete(br, if_exists=True)

Deletes bridge and all of its ports.

Parameters:
  • br -- A string - bridge name

  • if_exists -- Bool, if False - attempting to delete a bridge that does not exist returns False.

Returns:

True on success, else False.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.bridge_delete br0
salt.modules.openvswitch.bridge_exists(br)

Tests whether bridge exists as a real or fake bridge.

Returns:

True if Bridge exists, else False.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.bridge_exists br0
salt.modules.openvswitch.bridge_list()

Lists all existing real and fake bridges.

Returns:

List of bridges (or empty list), False on failure.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.bridge_list
salt.modules.openvswitch.bridge_to_parent(br)

New in version 3006.0.

Returns the parent bridge of a bridge.

Parameters:

br -- string bridge name

Returns:

Name of the parent bridge. This is the same as the bridge name if the bridge is not a fake bridge. If the bridge does not exist, False is returned.

CLI Example:

salt '*' openvswitch.bridge_to_parent br0
salt.modules.openvswitch.bridge_to_vlan(br)

New in version 3006.0.

Returns the VLAN ID of a bridge.

Parameters:

br -- string bridge name

Returns:

VLAN ID of the bridge. The VLAN ID is 0 if the bridge is not a fake bridge. If the bridge does not exist, False is returned.

CLI Example:

salt '*' openvswitch.bridge_to_parent br0
salt.modules.openvswitch.db_get(table, record, column, if_exists=False)

New in version 3006.0.

Gets a column's value for a specific record.

Parameters:
  • table -- string name of the database table

  • record -- string identifier of the record

  • column -- string name of the column

  • if_exists -- boolean if True, it is not an error if the record does not exist.

Returns:

The column's value.

CLI Example:

salt '*' openvswitch.db_get Port br0 vlan_mode
salt.modules.openvswitch.db_set(table, record, column, value, if_exists=False)

New in version 3006.0.

Sets a column's value for a specific record.

Parameters:
  • table -- string name of the database table

  • record -- string identifier of the record

  • column -- string name of the column

  • value -- string the value to be set

  • if_exists -- boolean if True, it is not an error if the record does not exist.

Returns:

None on success and an error message on failure.

CLI Example:

salt '*' openvswitch.db_set Interface br0 mac 02:03:04:05:06:07
salt.modules.openvswitch.interface_get_options(port)

Port's interface's optional parameters.

Parameters:

port -- A string - port name.

Returns:

String containing optional parameters of port's interface, False on failure.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.interface_get_options tap0
salt.modules.openvswitch.interface_get_type(port)

Type of port's interface.

Parameters:

port -- A string - port name.

Returns:

String - type of interface or empty string, False on failure.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.interface_get_type tap0
salt.modules.openvswitch.port_add(br, port, may_exist=False, internal=False)

Creates on bridge a new port named port.

Returns:

True on success, else False.

Parameters:
  • br -- A string - bridge name

  • port -- A string - port name

  • may_exist -- Bool, if False - attempting to create a port that exists returns False.

  • internal -- A boolean to create an internal interface if one does not exist.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.port_add br0 8080
salt.modules.openvswitch.port_create_gre(br, port, id, remote)

Generic Routing Encapsulation - creates GRE tunnel between endpoints.

Parameters:
  • br -- A string - bridge name.

  • port -- A string - port name.

  • id -- An integer - unsigned 32-bit number, tunnel's key.

  • remote -- A string - remote endpoint's IP address.

Returns:

True on success, else False.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.port_create_gre br0 gre1 5001 192.168.1.10
salt.modules.openvswitch.port_create_vlan(br, port, id, internal=False)

Isolate VM traffic using VLANs.

Parameters:
  • br -- A string - bridge name.

  • port -- A string - port name.

  • id -- An integer in the valid range 0 to 4095 (inclusive), name of VLAN.

  • internal -- A boolean to create an internal interface if one does not exist.

Returns:

True on success, else False.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.port_create_vlan br0 tap0 100
salt.modules.openvswitch.port_create_vxlan(br, port, id, remote, dst_port=None)

Virtual eXtensible Local Area Network - creates VXLAN tunnel between endpoints.

Parameters:
  • br -- A string - bridge name.

  • port -- A string - port name.

  • id -- An integer - unsigned 64-bit number, tunnel's key.

  • remote -- A string - remote endpoint's IP address.

  • dst_port -- An integer - port to use when creating tunnelport in the switch.

Returns:

True on success, else False.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.port_create_vxlan br0 vx1 5001 192.168.1.10 8472
salt.modules.openvswitch.port_get_tag(port)

Lists tags of the port.

Parameters:

port -- A string - port name.

Returns:

List of tags (or empty list), False on failure.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.port_get_tag tap0
salt.modules.openvswitch.port_list(br)

Lists all of the ports within bridge.

Parameters:

br -- A string - bridge name.

Returns:

List of bridges (or empty list), False on failure.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.port_list br0
salt.modules.openvswitch.port_remove(br, port, if_exists=True)

Deletes port.

Parameters:
  • br -- A string - bridge name (If bridge is None, port is removed from whatever bridge contains it)

  • port -- A string - port name.

  • if_exists -- Bool, if False - attempting to delete a por that does not exist returns False. (Default True)

Returns:

True on success, else False.

New in version 2016.3.0.

CLI Example:

salt '*' openvswitch.port_remove br0 8080