2013年3月31日 星期日
pif-plug vs pif-unplug
pif-plug
Attempt to bring up the specified physical interface
pif-unplug
Attempt to bring down the specified physical interface
2013年3月30日 星期六
虛擬網卡 TUN/TAP
http://www.ibm.com/developerworks/cn/linux/l-tuntap/
http://wangcong.org/blog/archives/1679
http://wangcong.org/blog/archives/1679
2013年3月29日 星期五
2013年3月28日 星期四
decorator pattern
http://en.wikipedia.org/wiki/Decorator_pattern
In object-oriented programming, the decorator pattern is a design pattern that allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.
In object-oriented programming, the decorator pattern is a design pattern that allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.
Citrix Xenserver - network
network-create
network-create name-label=<name_for_network> [name-description=<descriptive_text>]
Creates a new network.
network-destroy
network-destroy uuid=<network_uuid>
Destroys an existing network.
network-create name-label=<name_for_network> [name-description=<descriptive_text>]
Creates a new network.
network-destroy
network-destroy uuid=<network_uuid>
Destroys an existing network.
Host Internal Management Network
Host Internal Management Network
此主機內部管理網路是用來銜接dom0與domU之間溝通用的網路。在主機加入Resource Pool時就會由Citrix Xenserver自行產生,此網路是只用來內部溝通用,不會連結到外部網路,所以不會連接到pif。
uuid ( RO) : 85926476-fa05-2071-22e9-1900a21e6161
name-label ( RW): Host internal management network
name-description ( RW): Network on which guests will get assigned a private link-local IP address
VIF-uuids (SRO):
PIF-uuids (SRO):
MTU ( RW): 1500
bridge ( RO): xapi2
other-config (MRW): is_guest_installer_network: true; is_host_internal_management_network: true; ip_begin: 169.254.0.1; ip_end: 169.254.255.254; netmask: 255.255.0.0
blobs ( RO):
tags (SRW):
2013年3月26日 星期二
sed vs find
http://liwecan.pixnet.net/blog/post/29606145-%5Blinux%5D-%E6%90%9C%E5%B0%8B%E4%B8%A6%E5%8F%96%E4%BB%A3-%E6%9F%90%E4%BA%9B%E6%96%87%E4%BB%B6%E8%A3%A1%E9%9D%A2%E7%9A%84-%E6%9F%90%E5%80%8B%E5%AD%97%E4%B8%B2
# grep的使用技巧
http://ottoshare.blogspot.tw/2012/06/linux.html
2013年3月25日 星期一
2013年3月21日 星期四
利用OpenSSL rand產生亂數
openssl rand -hex num-of-digits(位數)
-base64
http://www.tech-recipes.com/rx/1264/generate-passwords-with-openssl/
Xenserver上設定Guest Installer Network
xe network-param-set uuid=<Network-UUID> other-config: is_guest_installer_network=true
2013年3月20日 星期三
script的執行方式
./ 要看第一行的 #! 說用什麼intepreter執行
sh 的話就真的是用 sh 執行; 若用python就代表用python執行 ; 若用bash就代表用bash執行。
顯示XenServer host上的volume group
[Command]
vgdisplay -s | awk '{print $1}' | sed 's/"//g'
[Result]
VG_XenStorage-f1685e12-35d8-8ddb-3567-0651944ac264
2013年3月19日 星期二
vhd-util
vhd-util scan -f -m "VHD-*" -l "VG_XenStorage-f1685e12-35d8-8ddb-3567-0651944ac264"
-f : fast
-m: match-filter
-l: lovume
2013年3月18日 星期一
2013年3月16日 星期六
Citrix Xenserver Networking
http://support.citrix.com/servlet/KbServlet/download/17424-102-671540/Xen_Networking_in_Linux_final.pdf
- In this setup, the bridge is also seen as an interface. If it‟s joining members of an external network together, its name will begin with “xenbr”, the “br” meaning bridge.
- If it‟s joining members of an internal network together, its name will being with “xapi”.
vim的進階用法
http://www.openfoundry.org/en/tech-column/2383-vim--buffers-and-windows
http://c9s.blogspot.tw/2007/07/vim-tips-split-window.html
XenServer Disk Space Reclaiming
coalescing
When snapshots or clones are deleted on LVM-based, Local EXT and NFS SRs, XenServer automatically reclaims disk space by freeing unused data, a process known as coalescing.XenServer coalesces the disk space while Virtual Machines (VMs) remain running (online coalescing).
[指令]
coalesce-leaf <VM-UUID>
參考網址
http://support.citrix.com/article/CTX123400
2013年3月15日 星期五
2013年3月14日 星期四
pull requests
https://help.github.com/articles/using-pull-requests
pull requests
pull有"招致"、"吸引"的意思
pull requests就是讓你告訴參與該專案的其他人你將會改變那些部分然後push回GitHub repo.一旦pull request送出,有興趣的人就可以檢閱有哪些部分有改變過,然後討論是否要進行更進一步的修改。
Pull requests let you tell others about changes you've pushed to a GitHub repository. Once a pull request is sent, interested parties can review the set of changes, discuss potential modifications, and even push follow-up commits if necessary.
Reference
http://edwardinaction.blogspot.tw/2012/05/github-pull-requests.html
http://www.worldhello.net/gotgithub/04-work-with-others/010-fork-and-pull.html
http://tw.polydice.com/2012/05/08/github-pull-requests/
Pull requests let you tell others about changes you've pushed to a GitHub repository. Once a pull request is sent, interested parties can review the set of changes, discuss potential modifications, and even push follow-up commits if necessary.
一般的協同開發模式( Collaborative Development Models )可以分成兩種:
1. Fork & Pull
-- lets anyone fork an existing repository and push changes to their personal fork without requiring access be granted to the source repository.
-- The changes must then be pulled into the source repository by the project maintainer.
-- This model reduces the amount of friction for new contributors and is popular with open source projects because it allows people to work independently without upfront coordination.
2. Shared Repository Model
-- more prevalent with small teams and organizations collaborating on private projects
-- Everyone is granted push access to a single shared repository and topic branches are used to isolate changes.
-- Everyone is granted push access to a single shared repository and topic branches are used to isolate changes.
Reference
http://edwardinaction.blogspot.tw/2012/05/github-pull-requests.html
http://www.worldhello.net/gotgithub/04-work-with-others/010-fork-and-pull.html
http://tw.polydice.com/2012/05/08/github-pull-requests/
2013年3月11日 星期一
2013年3月10日 星期日
2013年3月9日 星期六
exec
- http://imxfox.appspot.com/?p=118002
- exec家族比較, http://man7.org/linux/man-pages/man3/execl.3.html
- http://tc.itkee.com/os/detail-1bae.html
- http://linux.about.com/od/commands/l/blcmdln_exec.htm
#include <unistd.h>
extern char **environ;
int execl(const char *path, const char *arg, ...);
int execlp(const char *file, const char *arg, ...);
int execle(const char *path, const char *arg,..., char * const envp[]);
int execv(const char *path, char *const argv[]);
int execvp(const char *file, char *const argv[]);
int execvpe(const char *file, char *const argv[], char *const envp[]);
getent - get entries from Name Service Switch libraries
getent - get entries from Name Service Switch libraries
getent database [key ...]
The getent command displays entries from databases supported by the Name Service Switch libraries, which are configured in /etc/nsswitch.conf. If one or more key arguments are provided, then only the entries that match the supplied keys will be displayed.Otherwise, if no key is provided, all entries will be displayed (unless the database does not support enumeration).
2013年3月8日 星期五
2013年3月7日 星期四
main和_tmain的差別
main是c程式的起始函數
_tmain是main為了支援unicode所使用的main的變形(別名)
_tmain的定義在tchar.h可以找到,如
#define _tmain main
所以要加#include <tchar.h>才能用
不過visual studio的程式會自動加
#include “stdafx.h"
而stdafx.h中會自動加#include <tchar.h>
所以沒問題因此_tmain compile後仍為main
所以都可以執行
另外,wmain也是main的另一個變形,是為了支援二個bytes的語系
———————–
int main( int argc[ , char *argv[ ] [, char *envp[ ] ] ] );
wmain( int argc, wchar_t *argv[ ], wchar_t *envp[ ] )
int _tmain(int argc, _TCHAR* argv[])
———————–
int main( int argc[ , char *argv[ ] [, char *envp[ ] ] ] );
wmain( int argc, wchar_t *argv[ ], wchar_t *envp[ ] )
int _tmain(int argc, _TCHAR* argv[])
http://lex0912.wordpress.com/2006/03/08/_tmain%E8%88%87main%E7%9A%84%E5%8D%80%E5%88%A5/
init
http://caoruntao.iteye.com/blog/666780
http://fanqiang.chinaunix.net/a1/b1/20010828/0900001195_b.html
2013年3月6日 星期三
bash script return value
http://www.linuxjournal.com/content/return-values-bash-functions
1. return a value from a bash function is to just set a global variable to the result.
// the simplest way since all variables in bash are global by default
function myfunc() { myresult='some value' } myfunc echo $myresult
2. command substitution
function myfunc() { local myresult='some value' echo "$myresult" } result=$(myfunc) # or result=`myfunc` echo $result
bash script 預設變數
- $# :代表後接的參數『個數』,
- $@ :代表『 "$1" "$2" "$3" "$4" 』之意,每個變數是獨立的(用雙引號括起來);
- $* :代表『 "$1c$2c$3c$4" 』,其中 c 為分隔字元,預設為空白鍵, 所以本例中代表『 "$1 $2 $3 $4" 』之意。
Citrix vlan指令
vlan-create
vlan-create pif-uuid=<uuid_of_pif> vlan=<vlan_number> network-uuid=<uuid_of_network>
Create a new VLAN on a XenServer host.
pool-vlan-create
vlan-create pif-uuid=<uuid_of_pif> vlan=<vlan_number> network-uuid=<uuid_of_network>
Create a new VLAN on all hosts on a pool, by determining which interface (for example, eth0) the specified
network is on (on each host) and creating and plugging a new PIF object one each host accordingly.
vlan-destroy
vlan-destroy uuid=<uuid_of_pif_mapped_to_vlan>
Destroy a VLAN. Requires the UUID of the PIF that represents the VLAN.
tr -- translate or delete characters
http://linux.about.com/library/cmd/blcmdl1_tr.htm
NAME
tr - translate or delete charactersSYNOPSIS
tr [OPTION]... SET1 [SET2]DESCRIPTION
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
- -c, --complement
- first complement SET1
- -d, --delete
- delete characters in SET1, do not translate
Debian Intaller Preseeding
Debian-like OS auto installation
http://lackof.org/taggart/hacking/d-i_preseed/
2013年3月5日 星期二
python的super()深入研究
http://gcoder.blogbus.com/logs/42444130.html
http://blog.csdn.net/johnsonguo/article/details/585193
http://simba-wjxy.iteye.com/blog/669517
getopt vs getopts
http://blog.onetechnical.com/2012/07/16/bash-getopt-versus-getopts/
http://linuxwell.com/2011/07/14/getopt-in-bash/
getopts基礎使用
[Note that]
getopts is not able to parse GNU-style long options (--myoption) or
XF86-style long options (-myoption)
How it works
- In general you need to call
getopts
several times. - Each time it will use "the next" positional parameter (and a possible argument), if parsable, and provide it to you.
getopts
will not change the positional parameter set — if you want to shift it, you have to do it manually after processing:
shift $((OPTIND-1)) # now do something with $@
Since
getopts
will set an exit status of FALSE when there's nothing left to parse, it's easy to use it in a while-loop:while getopts ...; do ... done
getopts
will parse options and their possible arguments. It will stop parsing on the first non-option argument (a string that doesn't begin with a hyphen (-
) that isn't an argument for any option infront of it). It will also stop parsing when it sees the --
(double-hyphen), which means end of options.[getopts Base Syntax]
The base-syntax for
getopts
is:getopts OPTSTRING VARNAME [ARGS...]where:
OPTSTRING | tells getopts which options to expect and where to expect arguments (see below) |
---|---|
VARNAME | tells getopts which shell-variable to use for option reporting |
ARGS | tells getopts to parse these optional words instead of the positional parameters |
The option-string
- The option-string tells
getopts
which options to expect and which of them must have an argument. - The syntax is very simple — every option character is simply named as is, this example-string would tell
getopts
to look for-f
,-A
and-x
:
getopts fAx VARNAME
- When you want
getopts
to expect an argument for an option, just place a:
(colon) after the proper option flag. - If you want
-A
to expect an argument (i.e. to become-A SOMETHING
) just do:
getopts fA:x VARNAME
- If the very first character of the option-string is a
:
(colon), which normally would be nonsense because there's no option letter preceeding it,getopts
switches to the mode "silent error reporting". In productive scripts, this is usually what you want (handle errors yourself and don't get disturbed by annoying messages).
[Used Variable]
OPTIND
option index, Holds the index to the next argument to be processed.
- This is how
getopts
"remembers" its own status between invocations. Also usefull to shift the positional parameters after processing withgetopts
OPTIND
is initially set to 1, and needs to be re-set to 1 if you want to parse anything again with getopts
OPTARG
option argument, This variable is set to any argument for an option found by
getopts
.- It also contains the option flag of an unknown option.
OPTERR
option error, (Values 0 or 1) Indicates if Bash should display error messages generated by the
getopts
builtin- The value is initialized to 1 on every shell startup - so be sure to always set it to 0 if you don't want to see annoying messages!
http://wiki.bash-hackers.org/howto/getopts_tutorial
MapReduce DistributedCache
How to use MapReduce DistributedCache v0.20.2
首先要先
import org.apache.hadoop.filecache.* ==> 給 DistributedCache用
import java.net.RUI
import org.apache.hadoop.fs.Path
2013年3月4日 星期一
Python的"方法(method)": 方法是物件(Method Object)
方法也是物件
在Python中,"類別方法(class method)"能經由"實例(instance)"或是"類別(class)"來存取操作。
基本上會有兩種的操作模式:
(1)
(2)
在Python中,"類別方法(class method)"能經由"實例(instance)"或是"類別(class)"來存取操作。
基本上會有兩種的操作模式:
(1)
(2)
2013年3月3日 星期日
git的物件型態
在物件儲存中,git僅使用了四種型態的物件:
1. BLOBs, Binary Large OBjects (二進位的大型物件):
檔案的每個版本都是由Blob所組成的。而這個詞彙被廣泛使用在資訊界,泛指可以儲存任何型態資料的檔案或變數,而且使用BLOBs的程式是並不會在意其內部結構的,因為BLOB型態的資料不易理解,因為它並沒有包含任何關於檔案的資訊,甚至檔案名稱都沒有。
2. Tree:
樹狀物件代表一個階層的目錄資訊。它記錄著
I. BLOB辨識碼
II. BLOB的路徑名稱
III. 以及在這個目錄中所有檔案的一些資訊。
樹狀物件本身也可以遞迴的參考其他子樹物件,然後建立出完整的檔案以及子目錄的階層架構。
3. Commits(送交):
--- 送交物件擁有每次容器更動時的所有資訊,包含了作者、送交者、送交的時間以及歷史紀錄訊息等。
--- 每次的送交都會指向一個樹狀物件,這個物件紀錄了送交當下該容器的狀態。(除了最一開始的送交沒有"父送交物件",而大多數的送交都會有一個"父送交物件")
4. Tags(標籤):
標籤物件將人類易讀的名字賦予給特定物件(通常是Commits送交物件)
1. BLOBs, Binary Large OBjects (二進位的大型物件):
檔案的每個版本都是由Blob所組成的。而這個詞彙被廣泛使用在資訊界,泛指可以儲存任何型態資料的檔案或變數,而且使用BLOBs的程式是並不會在意其內部結構的,因為BLOB型態的資料不易理解,因為它並沒有包含任何關於檔案的資訊,甚至檔案名稱都沒有。
2. Tree:
樹狀物件代表一個階層的目錄資訊。它記錄著
I. BLOB辨識碼
II. BLOB的路徑名稱
III. 以及在這個目錄中所有檔案的一些資訊。
樹狀物件本身也可以遞迴的參考其他子樹物件,然後建立出完整的檔案以及子目錄的階層架構。
3. Commits(送交):
--- 送交物件擁有每次容器更動時的所有資訊,包含了作者、送交者、送交的時間以及歷史紀錄訊息等。
--- 每次的送交都會指向一個樹狀物件,這個物件紀錄了送交當下該容器的狀態。(除了最一開始的送交沒有"父送交物件",而大多數的送交都會有一個"父送交物件")
4. Tags(標籤):
標籤物件將人類易讀的名字賦予給特定物件(通常是Commits送交物件)
git的tag(標籤)
git tag的基礎概念
git目前僅有實作一種標籤物件,但它卻有兩種型態:
1. Lightweight Tag(輕量標籤):
輕量標籤參照至一個"送交物件",且通常是該容器所私有的標籤(?!),這種標籤不會在物件儲存上建立永久物件。
2. Annotated Tag(標示標籤):
標示標籤則會真實的建立一個物件,而該物件裡面會包含你所提供的訊息,則該訊息可以根據RFC-4880使用GnuPG金鑰來簽屬"數位簽章"。
Git將Lightweight Tag以及Annotated
git tag的使用
http://blog.wu-boy.com/2010/11/git-%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E6%A8%99%E7%B1%A4tag/
http://gitbook.liuhui998.com/3_7.html
git所維護的特殊符號參照
- git當中所有的符號參照都可以使用 git symbolic-ref 指令來管理
- git因為某些特殊目的所以維護了一些特別的符號參照,它們可以被用在任何可以使用"送交(commit)"的地方:
1. HEAD
HEAD永遠指向目前分支上最新的commit(送交)。當你修改分支時,HEAD就會被更新,指向該分支最新的commit(送交)。
2. ORIG_HEAD
在執行某些動作例如"merge(合併)"或是"reset(重設)"時,在執行之前,會將前一個版本的HEAD紀錄在ORIG_HEAD。
可以使用ORIG_HEAD來回復至前一個版本或者是進行比較。
3. FETCH_HEAD
當使用"遠端容器(Remote Repo)"時,git fetch指令會記錄從 .git/FETCH_HEAD檔案中所有分支的HEAD。
FETCH_HEAD就是你抓取的上一個分支的HEAD,並且僅在抓取的指令之後有效。使用這個符號參照,你可以找到你使用 git fetch指令所抓取的HEAD,並且不用指定分支名稱。
4. MERGE_HEAD
當合併在執行時,另一個分支的HEAD會被暫時的紀錄在MERGE_HEAD之中。
換句話說: MERGE_HEAD會指向要被合併到目前HEAD的送交物件。
[Note]
雖然可以使用上述的符號參照來建立自己的分支,但不建議這麼做!!
git中的檔案分類
Git將"檔案"分成三大類:
- 被追蹤(tracked):
被追蹤的檔案代表它已經在容器或是已經在索引中準備好了。
EX: 要新增一個檔名叫做somefile的檔案此管理容器中,執行git add somefile即可。 - 被忽略(ignored):
被忽略的檔案必須設定為"隱藏的"或是"被忽略的",就算檔案本身在你所管理的容器中。
Git會維護一張被忽略的檔案清單(.gitignore),可以在你管理的容器內自行配置要忽略的檔案。 - 不被追蹤(untracked):
不屬於前述兩個類別的檔案就稱之為"不被追蹤"的檔案。
訂閱:
文章 (Atom)