'Setup the physical network bridges.
Creates physical network bridges and links them to the
integration bridge using veths or patch ports.
:param bridge_mappings: map physical network names to bridge names.'

def setup_physical_bridges(self, bridge_mappings):

    self.phys_brs = {}
    self.int_ofports = {}
    self.phys_ofports = {}
    ip_wrapper = ip_lib.IPWrapper()
    ovs = ovs_lib.BaseOVS()
    ovs_bridges = ovs.get_bridges()
    for (physical_network, bridge) in bridge_mappings.items():
        LOG.info(_LI('Mapping    physical    network    %(physical_network)s    to    bridge    %(bridge)s'), {'physical_network': physical_network, 'bridge': bridge})
        if (bridge not in ovs_bridges):
            LOG.error(_LE('Bridge    %(bridge)s    for    physical    network    %(physical_network)s    does    not    exist.    Agent    terminated!'), {'physical_network': physical_network, 'bridge': bridge})
            sys.exit(1)
        br = self.br_phys_cls(bridge)
        br.create()
        br.set_secure_mode()
        br.setup_controllers(self.conf)
        if cfg.CONF.AGENT.drop_flows_on_start:
            br.uninstall_flows(cookie=ovs_lib.COOKIE_ANY)
        br.setup_default_table()
        self.phys_brs[physical_network] = br
        int_if_name = p_utils.get_interface_name(bridge, prefix=constants.PEER_INTEGRATION_PREFIX)
        phys_if_name = p_utils.get_interface_name(bridge, prefix=constants.PEER_PHYSICAL_PREFIX)
        int_type = self.int_br.db_get_val('Interface', int_if_name, 'type', log_errors=False)
        if self.use_veth_interconnection:
            if (int_type == 'patch'):
                self.int_br.delete_port(int_if_name)
                br.delete_port(phys_if_name)
            device = ip_lib.IPDevice(int_if_name)
            if device.exists():
                device.link.delete()
                utils.execute(['udevadm', 'settle', '--timeout=10'])
            (int_veth, phys_veth) = ip_wrapper.add_veth(int_if_name, phys_if_name)
            int_ofport = self.int_br.add_port(int_if_name)
            phys_ofport = br.add_port(phys_if_name)
        else:
            if (int_type == 'veth'):
                self.int_br.delete_port(int_if_name)
                br.delete_port(phys_if_name)
            if self.int_br.port_exists(int_if_name):
                int_ofport = self.int_br.get_port_ofport(int_if_name)
            else:
                int_ofport = self.int_br.add_patch_port(int_if_name, constants.NONEXISTENT_PEER)
            if br.port_exists(phys_if_name):
                phys_ofport = br.get_port_ofport(phys_if_name)
            else:
                phys_ofport = br.add_patch_port(phys_if_name, constants.NONEXISTENT_PEER)
        self.int_ofports[physical_network] = int_ofport
        self.phys_ofports[physical_network] = phys_ofport
        self.int_br.drop_port(in_port=int_ofport)
        br.drop_port(in_port=phys_ofport)
        if self.use_veth_interconnection:
            int_veth.link.set_up()
            phys_veth.link.set_up()
            if self.veth_mtu:
                int_veth.link.set_mtu(self.veth_mtu)
                phys_veth.link.set_mtu(self.veth_mtu)
        else:
            self.int_br.set_db_attribute('Interface', int_if_name, 'options', {'peer': phys_if_name})
            br.set_db_attribute('Interface', phys_if_name, 'options', {'peer': int_if_name})
