示例#1
0
    def create_br_vnic(self, instance_id, vif):
        iface_id = self.get_ovs_interfaceid(vif)
        qbr_veth, br_int_veth = self.get_veth_pair_names(vif.get('id'))

        # veth for br-int creation
        if not hu.device_exists(qbr_veth):
            hu.create_veth_pair(br_int_veth, qbr_veth)

        # add in br-int the veth
        hu.create_ovs_vif_port(self.get_bridge_name(vif),
                               br_int_veth, iface_id,
                               vif['address'], instance_id)

        if cfg.CONF.hyperagent.ip_tables:
            br_name = self.get_br_name(vif.get('id'))

            tap_veth, vnic_veth = self.get_veth_pair_names2(vif.get('id'))
            # veth for virtual nic creation
            if not hu.device_exists(vnic_veth):
                hu.create_veth_pair(tap_veth, vnic_veth)

            hu.set_device_mtu(tap_veth, True)

            # linux bridge creation
            hu.create_linux_bridge(br_name, [qbr_veth, tap_veth])
        else:
            vnic_veth = qbr_veth

        return vnic_veth
示例#2
0
    def plug(self, instance_id, hyper_vif):
        LOG.debug("hyper_vif=%s" % hyper_vif)
        vnic_veth = self.create_br_vnic(instance_id, hyper_vif)
        if cfg.CONF.hyperagent.ip_tables:
            tap1 = "lvo%s" % vnic_veth[3:]
            tap2 = "lvb%s" % vnic_veth[3:]
            br = "obr%s" % vnic_veth[3:]
            if not hu.device_exists(tap1):
                hu.create_veth_pair(tap1, tap2)
            hu.create_linux_bridge(br, [vnic_veth, tap1])
            vnic_veth = tap2

            # set MTU
            hu.set_device_mtu(br, True)
            hu.set_device_mtu(tap1, True)

        # set mac address on device
        hu.execute('ip', 'link', 'set', vnic_veth,
                   'address', hyper_vif['address'],
                   run_as_root=True)
        # set MTU
        hu.set_device_mtu(vnic_veth, True)

        container_nic_name = self._container_device_name(hyper_vif)
        eth_vif_config = {
            'devices': {
                container_nic_name: {
                    'type': 'nic',
                    'nictype': 'physical',
                    'parent': vnic_veth
                }
            }
        }

        self.lxd.container_update(self.container_name, eth_vif_config)