ibus-pinyin 使用 OpenCC 地區用字轉換

ibus-pinyin 對於臺灣使用者有個很麻煩的地方是它在輸入繁體模式的時候會出現很奇怪的用字,譬如「羣」和「衆」這兩個字在臺灣習慣的寫法是「群眾」。

trace ibus-pinyin 好久老是找不到它到底是怎麼做繁簡轉換的……

最後發現是利用 libpyzy ,libpyzy 本身看起來有一些基本的轉換功能,但在 Ubuntu 的套件裡面看來是會直接呼叫 OpenCC (套件名稱是 libopencc1)。

OpenCC 其實有支援地區習慣用字的轉換,從簡體字可以轉到臺灣或是香港的習慣用字。但是從原始碼macro 的定義看起來不會做地區用字轉換。

opencc_open 函數接受轉換設定檔的檔名,轉換設定檔的檔名在 Ubuntu 下可以去 /usr/lib/x86_64-linux-gnu/opencc/ 找到(附檔名 ini)。




m_od = opencc_open ("zhs2zhtw_vp.ini");



Multiple Neutron external network on one node

In order to achieve multiple external networks in Neutron, where each external network has different subnet and default gateway, we need multiple L3 agents. Note: this is only for Havana and below, since Change Id260a239 (developed in Icehouse cycle) multiple external networks can be handled by single l3-agent.

Official documentation has cover on this, I will cover much detail in this article.

Besides br-ex you originally have, we need to create a new OVS bridge br-ex-2, then add the physical interface connected to that external network to br-ex-2.

If there is IP address already associated with that physical interface (eth3), you need to clear it with:

# ip addr del x.y.z.w dev eth3

Create the bridge and add the port:

# ovs-vsctl add-br br-ex-2
# ovs-vsctl add-port br-ex-2 eth3

Same as when you configured br-ex , configure /etc/network/interfaces like this:

# We need the section below or eth3 will not be up on boot
auto eth3
        iface eth3 inet manual
        up ifconfig $IFACE up
        up ip link set $IFACE promisc on
        down ip link set $IFACE promisc off
        down ifconfig $IFACE down
# br-ex-2 should have a IP belongs to that external subnet, default gateway should not be needed, since you already have br-ex
auto br-ex-2
iface br-ex-2 inet static
        address x.y.z.w
        network x.y.z.0
        broadcast x.y.z.255

Each l3-agent has respective l3_agent.ini:

# l3_agent.ini
host = network
external_network_bridge = br-ex
metadata_port = 8775
gateway_external_network_id = 9de13fee-fdcf-4343-9a8b-9f04deaf0d41 # Your external network id obtained via neutron net-list
router_id = 046c79ed-64f3-40ce-9328-f8b6329e81f4 # Your external router ID obtained via neutron router-list
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
# l3_agent-2.ini
#debug = True
host = network-psuedo2
external_network_bridge = br-ex-2
metadata_port = 8775
handle_internal_only_routers = False
gateway_external_network_id = cc4ad4e0-e86e-43cf-bcd8-36de71be8b01
router_id = 6e9cc927-73ba-40e4-8d2e-e2a8fca24280
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver

The host directive distinguishes multiple l3-agents, or they’ll be recognized as the same agent in Neutron.
Also add network-psuedo2 to /etc/hosts , point to the IP address you set on br-ex-2:

x.y.z.w      network-psuedo2

Now just start the agent in commandline:

# /usr/bin/python /usr/bin/neutron-l3-agent --config-file=/etc/neutron/neutron.conf --config-file=/etc/neutron/l3_agent-2.ini --log-file=/var/log/neutron/-agent-2.log

Note: I’m not sure if there’s any risk running l3-agent as root, but I have yet to figure out a way to run it as the neutron user. You can also combine nohup tool.