2013年12月31日 星期二

Robot Framework

http://robotframework.org/
A keyword base test automation framework.

Setup on Windows:
1. Install Python 2.7
http://www.python.org/getit/

2. Install wxPython 2.8.12.1 (for RIDE)
http://sourceforge.net/projects/wxpython/files/wxPython/

3. Install robot framework (may use pip or easy_setup)
https://pypi.python.org/pypi/robotframework

4. Install RIDE
https://pypi.python.org/pypi/robotframework-ride
https://github.com/robotframework/RIDE/wiki/Installation-Instructions

5. Add PATH C:\Python27\Scripts

2013年12月12日 星期四

How to PAUSE and CONTINUE a Linux process

Use kill command to send -STOP signal to pause a process and -CONT signal to continue it.

Example on CentOS6 Desktop:
1. Open a Terminal (name as T1) on Desktop and send "ps -aux | grep bash" to see how much bash in there.

2. Open another Terminal (name as T2) on Desktop and on T1 send "ps -aux | grep bash" to see process id of new created bash (T2)

3. On T1, send "kill -STOP " to pause T2
>T2 is hang

4. On T1, send "kill -CONT " to continue T2
>T2 is back to work
This is useful if a script is running on T2 and you want to pause it and continue it later

Reference:
http://tombuntu.com/index.php/2007/11/23/how-to-pause-a-linux-process/

2013年11月28日 星期四

dhcpd6.conf & radvd.conf & ip6tables

1. On CentOS 6.4 or RHEL 6.4. install dhcp and radvd
>yum install dhcp radvd

2. Edit NIC config to add IPv6 address. /etc/sysconfig/network-scripts/ifcfg-eth0
IPV6INIT=yes
IPV6ADDR=3ffe:501:ffff:1::1/64

3. edit /etc/dhcp/dhcpd6.conf to assign address pool
subnet6 3ffe:501:ffff:1::/64 {
    range6 3ffe:501:ffff:1::2 3ffe:501:ffff:1::1000
}

4. edit /etc/radvd.conf
interface eth0
{
    AdvSendAdvert on;
    MinRtrAdvInterval 30;
    MaxRtrAdvInterval 100;
    AdvHomeAgentFlag off;
    AdvManagedFlag off; #M bit = 0
    AdvOtherConfigFlag on; #O bit = 1
    prefix fc00:1234:5678:9abc::/64
    {
        AdvOnLink on;
        AdvAutonomous on;
        AdvRouterAddr off;
    };
};

5. add rule in /etc/sysconfig/ip6tables (before -j REJECT line)
-A INPUT -p udp -m udp -m multiport --ports 546 -j ACCEPT
-A INPUT -p udp -m udp -m multiport --ports 547 -j ACCEPT

6. set dhcpd6 radvd start when system up
>chkconfig radvd on
>chkconfig dhcpd6 on

Reference:
http://www.lijyyh.com/2012/05/dhcpv6ip-ciscolinux-isc-dhcpwindows.html
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-dhcp_for_ipv6_dhcpv6.html

2013年11月10日 星期日

Docker on Windows

Docker
目前只支援在Ubuntu下跑,若要在Windows下,可用VirtualBox搭配Vagrant使用
官方Install Document

1.首先把VirtualBox和Vagrant安裝起來

2. git clone docker and vagrant up
git clone https://github.com/dotcloud/docker.git
cd docker
vagrant up
vagrant up之後會有一台ubuntu vm被開啟來,docker daemon就在上面執行

3. 用putty登入127.0.0.1:2222
(ubuntu vm的port 22被vagrant自動bind到host的port 2222)
default user/password 是 vagrant/vagrant


4. 登入後 基本使用教學
sudo su
docker run -t -i ubuntu /bin/bash
跑ubuntu這個image,產生一個container,執行/bin/bash並進入interactive shell

5. 之後就是在container的環境了,用apt-get可以安裝軟體,Alt+P & Alt+Q sequence可以跳回host(ubuntu vm)而不會結束container,跳host之後可用docker attach 回去。

6. docker ps查看還在跑的container資訊,包括ID和port(docker run時用-p參數),docker ps -a可看全部

7. docker commit 可存下container成image,例如新安裝的軟體,方便下次直接run成新的container

8. 編寫Dockerfile可build新的image

9. docker images查看現在有的images

10. 若要讓vagrant bind ubuntu vm的port給host,在vagrant up之前要先set FORWARD_DOCKER_PORTS=True
(好像沒辦法正常up起來)

Best Practice

2013年11月4日 星期一

2013年10月24日 星期四

Python Google Chart

安裝pygooglechart時出現找不到module setuptools:

Note if you catch an error:"ImportError: No module named setuptools" please download http://peak.telecommunity.com/dist/ez_setup.py and install the setuptools.



參考資料:
http://pygooglechart.slowchop.com/
http://trac.edgewall.org/wiki/TracOnWindows/Python2.5

Subversion, TortoiseSVN 介紹

Subversion(svn)是個很有名的revision control system,在許多open source專案都有被使用到,在協同工作的環境中(個人使用也可以),幫助管理檔案的版本,也可回復到之前的版本,方便追蹤軟體或文件的開發過程。Subversion是個集中式的管理機制,大部分的動作都需要與repository連線來完成,所以若是repository不正常或其他原因無法access到就不能做svn的操作了(Git可以),算是svn的缺點。

TortoiseSVN是一隻Subversion的GUI Client程式,可以方便使用者操作svn而不需要透過command line的方式,但前提是使用者還是必須對svn的各個操作有所認識才行。TortoiseSVN也整合了Office的文件,可以做版本差異的比對,方便解決conflict。

一般svn的convention(慣例)是在project的repository下建立三個directory分別是/trunk, /branches, /tags。/trunk裡面放main line of development,後續可merge進其他的branch進來。/branches裡面放各個branch,一個branch取一個directory名子,通常是從/trunk branch(svn copy)進來這裡。/tags裡面放各版的release版本,和branches directory類似,只是通常就是定版了,不會再commit或merge新的東西進來。

一般操作流程
1. Check Out一個project
2. 編輯內容(新增一個功能或是修正bug)
3. Update
4. Commit

若是要先branch,完成後再merge進trunk
1. Branch: svn copy path/trunk path/branches/feature01
2. 在path/branches/feature01做修改
3. Update & Commit
4. Merge: 先cd到path/trunk在svn merge path/branches/feature01

Reference:

2013年10月18日 星期五

setup git daemon on centos

1. install git, git-daemon, xinetd
>yum install git git-daemon xientd

2. edit /etc/xinetd.d/git file
disabled = no

3. open port 9418 in firewall

4. the git repositories in /var/lib/git directory

5. create a repository in /var/lib/git
>mkdir test
>cd test
>git init --bare --shared

5. restart xinetd
>service xinetd restart

6. try to clone test repository from remote
>git clone git://[server_ip]/test
or with ssh ( can push ):
>git clone root@[server_ip]:/var/lib/git/test

Reference:
http://blog.longwin.com.tw/2011/03/build-git-env-share-over-ssh-2011/

2013年9月23日 星期一

jenkins monitoring external jobs

1. On Jenkins web GUI, add a new job and select "Monitor an external job", name it as "job01"

2. execute from other machine:
$ export JENKINS_HOME=http://jenkins_server:8080
$ java -jar /var/cache/jenkins/war/WEB-INF/lib/jenkins-core-1.530.jar "job01" find /

("find /" is the target command)

reference:
https://wiki.jenkins-ci.org/display/JENKINS/Monitoring+external+jobs

2013年9月6日 星期五

Install fio and required packages

1. Download fio from http://freecode.com/projects/fio
2. yum install zlib-devel libaio-devel libibverbs-devel librdmacm-devel
3. unzip fio file
# tar jxvf fio-2.1.2.tar.bz2

4. configuration
# cd fio-2.1.2
# ./configure

5. make && make install
# make && make install

6.some sample jobsfile in ./t/jobs
# cd ./t/jobs
# fio t0001-52c58027.fio

2013年8月16日 星期五

Serail Port Redirection and VNC setting on Linux

Serail Port Redirection and VNC setting on Linux

How to setup serial port redirection on Linux?

    The purpose of this session is to teach you setting up serial port redirection on RHEL 6 and SLES 11. After setup, you can login linux system in text mode through serial port.

BIOS setup

    Enter BIOS setup menu and open console redirect. This setting can redirect POST screen to serial port.

RHEL 6

Please refer below link to setup after RHEL 6 is installed.
Note. Pysical serial port is COM1 (ttyS0) and serial port of SOL is COM2 (ttyS1)

SLES 11

Please refer below link to setup after SLES 11 is installed


How to establish SOL session?

Using opensource ipmitool to activate SOL session
>ipmitool -I lanplus -H [bmc_ip] -U [bmc_username] -P [bmc_pasword] -C 3 sol activate


press ~. to deactivate session


How to enable remote desktop on Linux?

    The purpose of this session is to each you setting up remote desktop on Linux system, after setup, you can connect to this Linux system by using a vnc client.

RHEL 6

1. Install tigervnc-server
# yum install tigervnc-server


2. edit /etc/sysconfig/vncserver
VNCSERVERS=”2:root”
VNCSERVERARGS[2]=”-geometry 1024x768”


3. Open port 5902 on firewall


4. create /root/.vnc/passwd
# vncpasswd


5. Restart the System


6. Use remote vnc client to open remote desktop


SLES 11

Please refer to below link to setup

2013年6月14日 星期五

開啟NetworkManager可自動註冊hostname進公司windows domain

CentOS 6預設安裝桌面時才會安裝Network Manger,只安裝純文字介面預設不會安裝NetworkManager但可在手動安裝。
用Webmin改hostname之後重開機hostname就可ping的到了

2013年6月6日 星期四

httpd 403 Forbidden

1. set Alias in httpd.conf
Alias /download /opt/download

2. add directory in httpd.conf

    AllowOverride All
    AcceptPathInfo On
    Options Indexes SymLinksIfOwnerMatch FollowSymLinks


http://server/download may return 403 cause selinux

3. set selinux setting
# chcon -tR httpd_sys_content_t /opt/download


Reference:
http://www.mikehomme.com/node/16

2013年5月14日 星期二

Linux SUID, SGID, Sticky bit

當SUID (set user id):chmod u+s file
  • 被設定在檔案上時,檔案的執行者會以檔案的擁有者的身分來執行
當SGID (set group id):chmod g+s file 或是 chmod g+s directory
  • 被設定在檔案上時,檔案的執行者會以檔案的擁有群組的身分來執行
  • 當設定在目錄上時,在此目錄下新建的檔案群組會被自動套用此目錄的群組 
Sticky bit:chmod +t directory
  • 當設定在目錄上時,以下的檔案只有該擁有者才能刪除或更名( /tmp )
http://en.wikipedia.org/wiki/Setuid
http://en.wikipedia.org/wiki/Sticky_bit

2013年5月13日 星期一

compile ipmitool 1.8.13

  1. remove freeipmi first
    # make uninstall (from freeipmi-1.4.9) don't know why
    # make clean 
  2. yum install ncurses-* readline-* openssl-*
  3. tar xvjf ipmitool-1.8.13.tar.bz2; cd ipmitool-1.8.13
  4. ./configure && make
  5. make install
  6. Enter freeipmi source code folder (need install libgcrypt-devel before compiler freeipmi)
    # ./configure
    # make
    # make install
Do build freeipmi
# yum install libgcrypt-devel

2013年5月7日 星期二

cntlm

讓Linux可透過Windows Server的Proxy (NTLM) 連到外面去
Cntlm
設定檔
/etc/cntlm.conf

restart the system and cntlm will run automatically
執行檔
/usr/sbin/cntlm

set http_proxy variable
# export http_proxy=http://127.0.0.1:3128

iptables 開通port 80

# iptables -I INPUT -p tcp ––dport 80 -j ACCEPT