MAAS Deploy(1)

This deploy series will record every steps that I deploy OpenStack on Ubuntu based server.

Network Configuration

I want to deploy the MAAS environment in a seperated network, thus I have to create the new network in virt-manager via following steps:
First, double-click localhost(QEMU), this will pop-up the configuration of the virt-manager.
Second, in the Virtual Networks, click “+”, name it, change its ip range addresses to 10.17.17.0/24, de-select Enable DHCPv4, In the last window, select “Forwarding to phsical network”, select the bridge interface that you have in your physical machine.
By this two steps you will have the isolated NAT networks.

Possible problems, I met in my ArchLinux:

First :
Cannot start Virtual Network: "out of memory"

Solved via:    
$ sudo pacman -S ebtables
$ sudo systemctl restart libvirtd

Error creating virtual network: Cannot check dnsmasq binary /sbin/dnsmasq: No such file or directory
$ sudo pacman -S dnsmasq

Mass Controller Machine Installation

In virt-manager, create a new virtual machine, which takes around 1.5G Memory and 2 Cores, 40G memory. The network we used is the one we created in last step, this will create the maas controller in this isolated network, thus every newly-created nodes will start-up from this controller.

Start install this machine, you won’t have the auto-configured ip address, so you should manually specify the IP Address for this controller machine, mine use 10.17.17.202.

Mass Controller Configuration

First add maas testing repository to the existing apt configuration files, Make sure you have added following 2 lines at the end of the file:

$ sudo add-apt-repository  ppa:maas-maintainers/maas-test
$ sudo vim /etc/apt/sources.list
deb http://ppa.launchpad.net/maas-maintainers/testing/ubuntu trusty main 
deb-src http://ppa.launchpad.net/maas-maintainers/testing/ubuntu trusty main 
$ sudo apt-get update

The maas-test is located at:
https://launchpad.net/~maas-maintainers/+archive/ubuntu/maas-test?field.series_filter=trusty

Now install following packages:

$ sudo apt-get install ssh nano iptraf htop wget lynx dnsutils maas maas-dhcp maas-dns git build-essential

Met hashsum missing, solved via following:

$ sudo rm -fR /var/lib/apt/lists/*  
$ sudo mkdir /var/lib/apt/lists/partial  
$ sudo bash
$ proxychains4 apt-get update

After installation, you will got MAAS installed, so open your browser and visit http://10.17.17.202/MAAS, you will get a hint that you have to run following commands for making MAAS service really avaiable:

$ sudo maas-region-admin createsuperuser

The configuration above should input the username/password, and also your email address, etc. After inputing all of this, visit http://10.17.17.202/MAAS again, now you got the MAAS configuration webpages.

Build SS for WJ

For I have a CentOS host machine on DO, I started to build a SS server which could make use of the freedom network in DO, following is the steps.

Python-pip

Python-pip located in epel repository, so first we have to enable epel repository:

# rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# vim /etc/yum.repos.d/epel.repo
enable=1
# yum -y update

Install python-pip via:

# yum install python-pip

SS

Install ShadowSocks via:

# pip install shadowsocks

Configure the shadowsocks:

# vim /etc/shadowsocks.json
{
    "server":"1xx.xxx.xxx.xxx",
    "server_port":xxxx,
    "local_address": "127.0.0.1",
    "local_port":1080,
    "password":"Pass!Pass!Pass",
    "timeout":300,
    "method":"aes-256-cfb",
    "fast_open": false,
    "workers": 1
}

Use supervisor for managing the ShadowSocks Server:

# yum install -y supervisor
# vim /etc/supervisord.conf
[program:shadowsocks]
command=ssserver -c /etc/shadowsocks.json
autorestart=true
user=nobody

Add the supervisord to startup as a daemon:

# vi /etc/rc.d/init.d/supervisord
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord

# Source init functions
. /etc/rc.d/init.d/functions

prog="supervisord"

prefix="/usr/"
exec_prefix="${prefix}"
prog_bin="${exec_prefix}/bin/supervisord"
PIDFILE="/var/run/$prog.pid"

start()
{
       echo -n $"Starting $prog: "
       daemon $prog_bin --pidfile $PIDFILE
       [ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup"
       echo
}

stop()
{
       echo -n $"Shutting down $prog: "
       [ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown"
       echo
}

case "$1" in

 start)
   start
 ;;

 stop)
   stop
 ;;

 status)
       status $prog
 ;;

 restart)
   stop
   start
 ;;

 *)
   echo "Usage: $0 {start|stop|restart|status}"
 ;;

esac

Now add configuration :

# chmod +x /etc/rc.d/init.d/supervisord
# chkconfig --add supervisord
# chkconfig supervisord on
# chmod a+x  /etc/init.d/supervisord
# service supervisord start

Since we updated so much, better we restart the machine and view if ssserver running or not.

$ ps -ef | grep sss
nobody     678   478  0 09:56 ?        00:00:00 /usr/bin/python /usr/bin/ssserver -c /etc/shadowsocks.json
Trusty      1743  1718  0 09:57 pts/0    00:00:00 grep --color=auto sss

Client

Download the Windows client from:
http://shadowsocks.org/en/download/clients.html
Windows 8 above are different from other clients.

Enable Bluetooth Playing

First scan the bluetooth adapter via lsusb:

$ lsusb
Bus 005 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

Install packages and configure bluetooth:

$ sudo apt-get install bluetooth
$ sudo apt-get install bluez-utils
$ sudo apt-get install blueman

Then setup the bluetooth headset in blueman’s graphical interface.
The more detailed steps are available at:
http://kkkttt.github.io/blog/2013/12/19/bluetooth-headset-on-archlinux/

Establish Ubuntu Virt Node

Just some tips on how to establish an Ubuntu Virt Node from existing installed system.

Re-Partition

2T Disk has been allocated to opensuse, thus I have first umount the mounted /home/ partition and use partition from yast for adjust the partition size, I got 1.9 T size of disk for installing new system.
Umount the mounted /home/ partition is via edit /etc/fstab file.

Install Ubuntu

Download the iso file of ubuntu x86_64 version, then enable kvm via:

$ sudo modprobe kvm
$ sudo modprobe kvm-intel

Install the system via following commands:

$ qemu-system-x86_64 -hda /dev/sda -m 1024 -boot d -cdrom ./install_media.iso

The above command is for installing the system into the real harddisk. It will automatically install the system onto the harddisk and over-write the MBR. Ubuntu will automatically detect the installed opensuse and generate the system description line.
In grub, the default system will be the installed ubuntu.

System Preparation

Install following packages:

$ sudo apt-get install openssh-server vim-gtk bridge-utils virt-manager git subversion sysfsutils virtualbox awesome firefox chromium-browser xinit libreoffice build-essential pidgin konsole meld  fcitx fcitx-googlepinyin git subversion wqy* zsh rox-filer smplayer cmake scrot thunderbird midori gpicview docker.io  qemu qemu-kvm bridge-utils

Configure the network via following command:

$ sudo brctl addif br0 eth0
$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual
# If you want to enable the static, uncomment following
# iface eth0 inet static
#       address 192.168.0.119
#       netmask 255.255.255.0


# Add Bridge Interface
iface br0 inet static
address 192.168.0.119
netmask 255.255.255.0
gateway 192.168.0.236
dns-nameservers 114.114.114.114
bridge_ports eth0
bridge_stp off
auto br0

Restart computer and now you got br0 enabled.

Install QQ:

$ sudo vim /etc/apt/sources.list
deb http://ppa.launchpad.net/lainme/pidgin-lwqq/ubuntu trusty main 
deb-src http://ppa.launchpad.net/lainme/pidgin-lwqq/ubuntu trusty main
$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-get install pidgin-lwqq

Now you could use pidgin for chatting.

Install xlockmore for using xlock locking screen:

$ wget http://packages.ubuntu.com/precise/amd64/xlockmore/download/*xxxx.deb
$ sudo dpkg -i xlockmore_package.deb

Disable UTC time via:

$ sudo vim /etc/default/rcS
# assume that the BIOS clock is set to UTC time (recommended)
UTC=no

Configure ZSH:

$ sudo vim ~/.zshrc
# For setting zsh history
HISTFILE=$HOME/.zsh_history
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
HISTSIZE=5000
SAVEHIST=5000

Now the history file has been created and you could navigate between command history.

Quick setup for capturing picture:

$ cat /usr/bin/mycapscr 
scrot -s '%Y_%m_%d_%H_%M_%S_$wx$h.jpg' -e 'mv $f ~/capscr/'
$ mkdir -p ~/capscr

Now we got the standard development environment ready.

Rebuild Vrouter

In order to dive into Vrouter’s researching, we build the ko by following comands.

$ cp /opt/contrail/contrail_install_repo/contrail-vrouter-source_1.21-74_all.deb ~/Code/
$ cd ~/Code && ar vx contrail-vrouter-source_1.21-74_all.deb 
$ tar xzvf control.tar.gz 
$ tar xzvf data.tar.gz 
$ cd usr/src/modules/contrail-vrouter/
$ tar xzvf contrail-vrouter-1.21.tar.gz 
$ make

After building the ko will be available under the folder