예제 #1
0
파일: networks.py 프로젝트: ShinJR/kimchi
    def _set_network_vepa(self, params):
        for iface in params['interfaces']:
            if ('vlan_id' in params or not (netinfo.is_bare_nic(iface) or
               netinfo.is_bonding(iface))):
                raise InvalidParameter('KCHNET0028E', {'name': iface})

        params['forward'] = {'mode': 'vepa', 'devs': params['interfaces']}
예제 #2
0
파일: networks.py 프로젝트: ShinJR/kimchi
    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")
예제 #3
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")
예제 #4
0
    def _set_network_vepa(self, params):
        for iface in params['interfaces']:
            if ('vlan_id' in params or not (netinfo.is_bare_nic(iface) or
               netinfo.is_bonding(iface))):
                raise InvalidParameter('KCHNET0028E', {'name': iface})

        params['forward'] = {'mode': 'vepa', 'devs': params['interfaces']}
예제 #5
0
파일: networks.py 프로젝트: ShinJR/kimchi
    def _set_network_macvtap(self, params):
        iface = params['interfaces'][0]
        if ('vlan_id' in params or not (netinfo.is_bare_nic(iface) or
           netinfo.is_bonding(iface))):
            raise InvalidParameter('KCHNET0028E', {'name': iface})

        # set macvtap network
        params['forward'] = {'mode': 'bridge', 'dev': iface}
예제 #6
0
    def _set_network_macvtap(self, params):
        iface = params['interfaces'][0]
        if ('vlan_id' in params or not (netinfo.is_bare_nic(iface) or
           netinfo.is_bonding(iface))):
            raise InvalidParameter('KCHNET0028E', {'name': iface})

        # set macvtap network
        params['forward'] = {'mode': 'bridge', 'dev': iface}
예제 #7
0
파일: networks.py 프로젝트: bingger/kimchi
    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")
예제 #8
0
파일: networks.py 프로젝트: popbjc/kimchi
    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")
예제 #9
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")
예제 #10
0
    def _set_network_bridge(self, params):
        try:
            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']})

        self._ensure_iface_up(iface)
        if netinfo.is_bridge(iface):
            if 'vlan_id' in params:
                raise InvalidParameter('KCHNET0019E', {'name': iface})
            params['bridge'] = iface
        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")