Example #1
0
    def _set_network_bridge(self, params):
        params['forward'] = {'mode': 'bridge'}

        # Bridges cannot be the trunk device of a VLAN
        iface = params['interfaces'][0]
        if 'vlan_id' in params and netinfo.is_bridge(iface):
            raise InvalidParameter('KCHNET0019E', {'name': iface})

        # User specified bridge interface, simply use it
        self._ensure_iface_up(iface)
        params['ovs'] = False
        if netinfo.is_bridge(iface):
            params['bridge'] = iface

            if netinfo.is_ovs_bridge(iface):
                params['ovs'] = True

        # connection == macvtap and iface is not bridge
        elif netinfo.is_bare_nic(iface) or netinfo.is_bonding(iface):
            # libvirt bridge creation will fail with NetworkManager enabled
            if self.caps.nm_running:
                raise InvalidParameter('KCHNET0027E')

            if 'vlan_id' in params:
                params['bridge'] = \
                    self._create_vlan_tagged_bridge(str(iface),
                                                    str(params['vlan_id']))
            else:
                # create Linux bridge interface and use it as actual iface
                iface = self._create_linux_bridge(iface)
                params['bridge'] = iface

        # unrecognized interface type: fail
        else:
            raise InvalidParameter("KCHNET0007E")
Example #2
0
    def _set_network_bridge(self, params):
        params['forward'] = {'mode': 'bridge'}

        # Bridges cannot be the trunk device of a VLAN
        iface = params['interfaces'][0]
        if 'vlan_id' in params and netinfo.is_bridge(iface):
            raise InvalidParameter('KCHNET0019E', {'name': iface})

        # User specified bridge interface, simply use it
        self._ensure_iface_up(iface)
        params['ovs'] = False
        if netinfo.is_bridge(iface):
            params['bridge'] = iface

            if netinfo.is_ovs_bridge(iface):
                params['ovs'] = True

        # connection == macvtap and iface is not bridge
        elif netinfo.is_bare_nic(iface) or netinfo.is_bonding(iface):
            # libvirt bridge creation will fail with NetworkManager enabled
            if self.caps.nm_running:
                raise InvalidParameter('KCHNET0027E')

            if 'vlan_id' in params:
                params['bridge'] = \
                    self._create_vlan_tagged_bridge(str(iface),
                                                    str(params['vlan_id']))
            else:
                # create Linux bridge interface and use it as actual iface
                iface = self._create_linux_bridge(iface)
                params['bridge'] = iface

        # unrecognized interface type: fail
        else:
            raise InvalidParameter("KCHNET0007E")
Example #3
0
    def _set_network_bridge(self, params):
        try:
            # fails if host interface is already in use by a libvirt network
            iface = params["interface"]
            if iface in self.get_all_networks_interfaces():
                msg_args = {"iface": iface, "network": params["name"]}
                raise InvalidParameter("KCHNET0006E", msg_args)
        except KeyError:
            raise MissingParameter("KCHNET0004E", {"name": params["name"]})

        # Linux bridges cannot be the trunk device of a VLAN
        if "vlan_id" in params and (netinfo.is_bridge(iface) or params["connection"] == "bridge"):
            raise InvalidParameter("KCHNET0019E", {"name": iface})

        # User specified bridge interface, simply use it
        self._ensure_iface_up(iface)
        params["ovs"] = False
        if netinfo.is_bridge(iface):
            params["bridge"] = iface

            if netinfo.is_ovs_bridge(iface):
                params["ovs"] = True

                # OVS bridges don't work with macvtap
                if params["connection"] != "bridge":
                    raise InvalidParameter("KCHNET0026E")

        # User wants Linux bridge network, but didn't specify bridge interface
        elif params["connection"] == "bridge":

            # libvirt will fail to create bridge if NetworkManager is enabled
            if self.caps.nm_running:
                raise InvalidParameter("KCHNET0027E")

            # create Linux bridge interface first and use it as actual iface
            iface = self._create_linux_bridge(iface)
            params["bridge"] = iface

        # connection == macvtap and iface is not bridge
        elif netinfo.is_bare_nic(iface) or netinfo.is_bonding(iface):
            if params.get("vlan_id") is None:
                params["forward"]["dev"] = iface
            else:
                params["bridge"] = self._create_vlan_tagged_bridge(str(iface), str(params["vlan_id"]))
        else:
            raise InvalidParameter("KCHNET0007E")
Example #4
0
    def _set_network_bridge(self, params):
        try:
            # fails if host interface is already in use by a libvirt network
            iface = params['interface']
            if iface in self.get_all_networks_interfaces():
                msg_args = {'iface': iface, 'network': params['name']}
                raise InvalidParameter("KCHNET0006E", msg_args)
        except KeyError:
            raise MissingParameter("KCHNET0004E", {'name': params['name']})

        # Linux bridges cannot be the trunk device of a VLAN
        if 'vlan_id' in params and \
           (netinfo.is_bridge(iface) or params['connection'] == "bridge"):
            raise InvalidParameter('KCHNET0019E', {'name': iface})

        # User specified bridge interface, simply use it
        self._ensure_iface_up(iface)
        params['ovs'] = False
        if netinfo.is_bridge(iface):
            params['bridge'] = iface

            if netinfo.is_ovs_bridge(iface):
                params['ovs'] = True

                # OVS bridges don't work with macvtap
                if params['connection'] != "bridge":
                    raise InvalidParameter('KCHNET0026E')

        # User wants Linux bridge network, but didn't specify bridge interface
        elif params['connection'] == "bridge":
            # create Linux bridge interface first and use it as actual iface
            iface = self._create_linux_bridge(iface)
            params['bridge'] = iface

        # connection == macvtap and iface is not bridge
        elif netinfo.is_bare_nic(iface) or netinfo.is_bonding(iface):
            if params.get('vlan_id') is None:
                params['forward']['dev'] = iface
            else:
                params['bridge'] = \
                    self._create_vlan_tagged_bridge(str(iface),
                                                    str(params['vlan_id']))
        else:
            raise InvalidParameter("KCHNET0007E")
Example #5
0
    def _set_network_bridge(self, params):
        try:
            # fails if host interface is already in use by a libvirt network
            iface = params['interface']
            if iface in self.get_all_networks_interfaces():
                msg_args = {'iface': iface, 'network': params['name']}
                raise InvalidParameter("KCHNET0006E", msg_args)
        except KeyError:
            raise MissingParameter("KCHNET0004E", {'name': params['name']})

        # Linux bridges cannot be the trunk device of a VLAN
        if 'vlan_id' in params and \
           (netinfo.is_bridge(iface) or params['connection'] == "bridge"):
            raise InvalidParameter('KCHNET0019E', {'name': iface})

        # User specified bridge interface, simply use it
        self._ensure_iface_up(iface)
        params['ovs'] = False
        if netinfo.is_bridge(iface):
            params['bridge'] = iface

            if netinfo.is_ovs_bridge(iface):
                params['ovs'] = True

                # OVS bridges don't work with macvtap
                if params['connection'] != "bridge":
                    raise InvalidParameter('KCHNET0026E')

        # User wants Linux bridge network, but didn't specify bridge interface
        elif params['connection'] == "bridge":
            # create Linux bridge interface first and use it as actual iface
            iface = self._create_linux_bridge(iface)
            params['bridge'] = iface

        # connection == macvtap and iface is not bridge
        elif netinfo.is_bare_nic(iface) or netinfo.is_bonding(iface):
            if params.get('vlan_id') is None:
                params['forward']['dev'] = iface
            else:
                params['bridge'] = \
                    self._create_vlan_tagged_bridge(str(iface),
                                                    str(params['vlan_id']))
        else:
            raise InvalidParameter("KCHNET0007E")