Wednesday, September 2, 2015

[Make] Build the Linux Kernel

This document keeps my previous job that is to deal with re-building Linux Kernel for myself reference:

Modules存放位置:  /lib/modules/$(uname -r)/kernel/

核心檔案放置在:  /usr/src/kernels/`uname -r`/arch/x86/boot/bzImage

第一次進行編譯, 保持乾淨原始碼: make mrproper
其餘的時刻,你想要刪除前一次編譯過程的殘留資料: make clean

開始挑選核心功能: make XXconfig
make menuconfig

make help

[root@www linux-]# make vmlinux  <==未經壓縮的核心
[root@www linux-]# make modules  <==僅核心模組
[root@www linux-]# make bzImage  <==經壓縮過的核心(預設)
[root@www linux-]# make all      <==進行上述的三個動作

移動核心到 /boot 且保留舊核心檔案
[root@www ~]# cp /usr/src/kernels/linux- \
> /boot/vmlinuz-  <==實際核心
[root@www ~]# cp /usr/src/kernels/linux- \
> /boot/config-   <==建議設定檔也複製備

建立相對應的 Initial Ram Disk (initrd)
mkinitrd -v /boot/initrd-

vim /boot/grub/menu.lst

[Horizon] The summary of Horizon module

Basically Horizon is based on Django framework to be developed.

Install Horizon

To install the related packages for Horizon in Controller Node:
root@controller:~# apt-get -y install openstack-dashboard apache2 libapache2-mod-wsgi memcached python-memcache

Django setting 

Modify the file: /etc/openstack-dashboard/
Change the LOCATION's ip to controller's ip 
OPENSTACK_HOST = "controller"

# session ( default using memcached as session management )
   'default': {
       'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
       'LOCATION': '',

# Time zone
TIME_ZONE = "Asia/Taipei"

Restart the service

Restart apache & memcached:
root@controller:~# service apache2 restart
root@controller:~# service memcached restart


The following list and items are the the related information when I study Horizon.
Openstack introduction:
Trace python code:
OpenStack APIs and WSGI

Tuesday, September 1, 2015

[Python] Protecting your Python code when doing the deployment

As we know that Python is a scripting language and need interpreter to compile the source code to byte code and execute it. When running python code, the interpreter will read Python file(*.py) and generate compiled Python file(*.pyc) during the first time running or doing the import. Unfortunately, there is no perfect way to protect your Python byte code because there are some tools, like: Python 2.7 decompiler (uncompyle2), can do the reverse engineering.

Here are several tools and approach that can do some kind of protection for your code.

1. Remove the Python source code
> python -m compileall .
or > python -OO -m compileall .
find . -name "*.py" -exec rm -rf {} \;

2. Let Obfuscater help you to obfuscate your code
Python Obfuscater

3. If your python program is stand alone application, I believe PythonInstaller can help you generate an executable file for your Python code.

4. Use Cython