再见少年拉满弓,不惧岁月不惧风

用 patch port 连接两个 OVS 网桥

说明 环境根据 [用 Open vSwitch 的内部端口连接两个 Namespace]: http://yhz.me/blog/Connect-Namespace.html 创建br1 ovs-vsctl add-br br1 创建内部端口 ovs-vsctl add-port br1 tap3 -- set Interface tap3 type=internal 设置命令空间 ip link set tap2 netns ns3 配置 ip netns exec ns3 ip addr add 192.168.0.102/24 dev tap3 ip netns exec ns3 ip link set tap3 up ip netns exec ns3 ip link set lo up ip netns exec ns3 ping 192.168.0.102 创建patch port ovs-vsctl add-port br0 patch-ovs-1 -- set Interface patch-ovs-1 type=patch -- set Interface patch-ovs-1 options:peer=patch-ovs-2 ovs-vsctl add-port br1 patch-ovs-2 -- set Interface patch-ovs-2 type=patch -- set Interface patch-ovs-2 options:peer=patch-ovs-1 测试 ip netns exec ns3 ping 192.

在CentOS 6.5 安装 Open vSwitch 及初步使用

更新源 yum install wget wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo yum makecache 安装依赖包 yum -y install wget gcc make automake rpm-build redhat-rpm-config openssl-devel kernel-devel libtool iproute tunctl yum install -y https://repos.fedorapeople.org/repos/openstack/openstack-icehouse/rdo-release-icehouse-4.noarch.rpm yum update --enablerepo=openstack-icehouse -y iproute reboot 源码安装最新的autoconf wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz tar zxvf autoconf-2.69.tar.gz cd autoconf-2.69 ./configure make -j 4 make install 下载最新的Open vSwitch wget http://openvswitch.org/releases/openvswitch-2.3.1.tar.gz mkdir -p ~/rpmbuild/SOURCES cp openvswitch-2.3.1.tar.gz ~/rpmbuild/SOURCES/ 解压 tar zxvf openvswitch-2.3.1.tar.gz cd openvswitch-2.3.1 cp rhel/openvswitch-kmod.files ~/rpmbuild/SOURCES/ 生成rpm rpmbuild -bb rhel/openvswitch.

HTTPie的使用

安装 on Mac : brew install httpie on Linux : yum install httpie 或者 apt-get install httpie use Pip: pip install --upgrade httpie use easy_install: easy_install httpie 使用 模拟提交表单 http -f POST yhz.me username=nate 显示详细的请求 http -v yhz.me 只显示Header http -h yhz.me 只显示Body http -b yhz.me 下载文件 http -d yhz.me 请求删除的方法 http DELETE yhz.me 传递JSON数据请求(默认就是JSON数据请求) http PUT yhz.me name=nate password=nate_password 如果JSON数据存在不是字符串则用:=分隔,例如 http PUT yhz.me name=nate password=nate_password age:=28 a:=true streets:='["a", "b"]' 模拟Form的Post请求, Content-Type: application/x-www-form-urlencoded; charset=utf-8 http --form POST yhz.

Write Custom Twig Extension In ZF2

说明 extension 必须 implements Twig_ExtensionInterface 这个接口,但是这个接口方法太多。 所以 另一个方法是 entends Twig_Extension, 实现部分的方法就行了。 创建 创建 Application/src/Application/Extension/TestExtension.php /** * Class TestExtension * @package Application\Extension */ class TestExtension extends \Twig_Extension { public function getName() { return 'test_extension'; } public function getFunctions() { return array( new \Twig_SimpleFunction('test', array($this, 'test')), ); } public function test($a) { echo 'test for ' . $a; } } 在module.config.php加入配置 'zfctwig' => array( 'extensions' => array( 'test_extension' => 'Application\Extension\TestExtension', ), ),

在 Zend Framework 2 使用 factory service

在Module.php 加入配置方法 闭包方式: public function getServiceConfig() { return array( 'factories'=> array( 'Test\A\B' => function($serviceManager) { return new B(); }, ), ); } 工厂类方式: public function getServiceConfig() { return array( 'factories'=> array( 'Test\A\B' => 'Test\Service\TestFactory', ), ); } 编写Test\Service\TestFactory namespace Test\Service; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; class TestFactory implements FactoryInterface { /** * Create custom_service * * @param ServiceLocatorInterface $serviceLocator * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { return $this; } /** * @return string */ public function test() { return 'test'; } } 在Controller调用 $this->getServiceLocator()->get('Test\A\B');

在 OSX 上使用 Tomcat

查看版本 java -version java version "1.7.0_21" Java(TM) SE Runtime Environment (build 1.7.0_21-b12) Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode) 下载Tomcat http://tomcat.apache.org/download-70.cgi wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.57/bin/apache-tomcat-7.0.57.tar.gz 解压安装 tar zxvf apache-tomcat-7.0.57.tar.gz -C /opt/ rm -rf /Library/Tomcat ln -s /opt/apache-tomcat-7.0.57 /Library/Tomcat chown -R nate /Library/Tomcat chmod +x /Library/Tomcat/bin/*.sh 启动 /Library/Tomcat/bin/startup.sh 停止 /Library/Tomcat/bin/shutdown.sh 编写测试文件 package me.yhz; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; /** * Created by nate on 21/11/14.
0%