Using SlapOS in the Windows

Jondy Zhao

Revision History
Revision 0.12013-01-06Jondy Zhao - jondy.zhao@gmail.com
Create the document.

Table of Contents

1. Introduction
2. Registering in the slapos.org
3. Installing SlapOS slave node
3.1. Installing by MSI Package
3.2. Installing by sources
3.2.1. Install Cygwin
3.2.2. Buildout SlapOS
3.2.3. IPv6 Support
3.2.4. Run slapformat
4. Creating an instancee of Wordpress in the SlapOS
A. Cygwin Required Packages List

Chapter 1. Introduction

SlapOS can be described as a cloud operating system in which "everything is a process" unlike Unix in which "everything is a file". If one has to manage thousands of servers with thousands of processes, hundred different applications in multiple different releases or versions, SlapOS can help you a lot by making the whole management process well specified, automated and under control.

The goal of this tutorial is to teach how to use SlapOS in the windows.

Chapter 2. Registering in the slapos.org

Before we start, we need to register in VIFIB community Cloud. By doing so, we will obtain X509 certificate and key, make sure you store both of them to your local files. Take also note of the computer id, for example "COMP-161", store it somewhere. All of these are later needed for the installing process.

Refer to http://www.slapos.org/wiki/slapos-Wiki.Home/osoe-Lecture.SlapOS.Extended/developer-Installing.SlapOS.Slave.Node.Source in the section VIFIB Registration.

Chapter 3. Installing SlapOS slave node

There are 2 ways to install SlapOS slave node in the winodws. One is by MSI package, the other is by sources.

3.1. Installing by MSI Package

Download slapos windows installer: http://www.slapos.org/slapos-0.135-cygwin.exe

Run this MSI installer, click Next and type the information: the destination path, startup menu name, etc.

In the SlapOS Node Information wizard page, type the information got at above chapter.

  • Computer ID

  • Key

  • Certificate

At the final wizard page, click Install.

Waiting for everything done.

3.2. Installing by sources

We need Cygwin environment in order to install SlapOS slave node from sources in the Windows.

3.2.1. Install Cygwin

Go to "http://cygwin.com/" and click on "Install Cygwin Now!". This will download a GUI installer called setup.exe which can be run to download a complete cygwin installation via the internet. Follow the instructions on each screen to install Cygwin.

The Root Directory for Cygwin (default C:\cygwin) will become / within your Cygwin installation. You must have write access to the parent directory, and any ACLs on the parent directory will determine access to installed files.

By default, setup.exe will install only the packages in the Base category and their dependencies, resulting in a minimal Cygwin installation. We need choose the packages required by SlapOS, see Appendix A, Cygwin Required Packages List. Since setup.exe automatically selects dependencies, be careful not to unselect any required packages.

You can install cygwin in the command console either:

  • Click startup menu

  • Click Run, type command: 'cmd', click OK to enter windows console

  • Type the following commands:

        C:\Documents and Settings\Administrator>D:
        D:\>MD slapos
        D:\>cd slapos
    
  • Download setup.exe to D:\slapos from cygwin.com

  • In the windows console, run:

        D:\slapos>setup.exe -X -n --site http://mirrors.163.com/cygwin --root D:/slapos/cygwin --quite-mode -P cygrunsrv -P binutils -P gcc4 -P libtool -P make -P autobuild -P autoconf -P automake -P libiconv -P zlib-devel -P patch -P python -P wget -P vim
    

3.2.2. Buildout SlapOS

Double click the desktop icon "Cygwin" or C:\cygwin\Cygwin.bat (Assume the cygwin root directory is C:\cygwin). A cygwin box will open, the following commands are typed in this box.

$ echo "export CYGWIN=server" >> ~/.bash_profile
$ cygrunsrv --install cygslapos --path /usr/sbin/cygserver
$ sed -i -e "s/4\.3\.4/4.5.3/g" /usr/bin/libtool

$ mkdir -p /opt/slapos
$ mkdir -p /opt/download-cache
$ cd /opt/slapos
$ echo "[buildout]
extends = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/cygwin:/component/slapos/buildout.cfg
download-cache = /opt/download-cache
prefix = ${buildout:directory}
" > buildout.cfg 
$ python -S -c 'import urllib2;print urllib2.urlopen("http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/bootstrap.py").read()' > bootstrap.py
$ python -S bootstrap.py
$ bin/buildout

Now we need patch slapos.core for supporting cygwin, after these code are merged, it don't need.

$ wget http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/cygwin:/component/cygwin/cygwin-slapos-core-format.patch
$ wget http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/cygwin:/component/cygwin/cygwin-slapos-core-env-none.patch
$ cd eggs/slapos.core-0.33.1-py2.7.egg/slapos
$ patch -p1 < /opt/slapos/cygwin-slapos-core-format.patch
$ patch -p1 < /opt/slapos/cygwin-slapos-env-none.patch

3.2.3. IPv6 Support

If native IPv6 is available, skip this section. Otherwise be sure you have installed IPv6 by the command:

$ netsh interface ipv6 install

Download openvpn windows installer, for example, openvpn-2.2.1-install.exe, then install openvpn. By default, it installed at C:\Program Files\OpenVPN

Copy required files of openvpn to /opt/openvpn and edit client.ovpn

$ mkdir -p /opt/openvpn
$ cd /opt/openvpn
$ cp "C:/Program Files/OpenVPN/bin/*" /opt/openvpn
$ cp -a "C:/Program Files/OpenVPN/config" /opt/openvpn
$ chmod 755 *.exe

$ cd config
$ wget http://www.slapos.org/vifib-ca.crt/getData  -O ca.crt
$ http://www.slapos.org/vifib-client.crt/getData -O client-vifib.crt
$ wget http://www.slapos.org/vifib-client.key/getData -O client-vifib.key
$ mv client.ovpn vifib.ovpn
$ vi vifib.ovpn
# Edit the following options
dev tap
proto tcp
remote 176.31.103.87 443
ca ca.crt
cert client-vifib.crt
key client-vifib.key

3.2.4. Run slapformat

Assume we have registered a server which id is 'COMP-161', and saved its key and certificate files in the home directory. So we can use script 'configure.sh' to do all the configuration.

$ mkdir -p /etc/slapos/ssl
$ mkdir -p /etc/slapos/ssl/partition_pki
$ cd /
$ wget http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/cygwin:/component/cygwin/configure.sh 
$ /configure.sh COMP-161 ~/computer.key ~/computer.crt

Finally, run slapformat

$ cd /opt/slapos
$ bin/slapformat -c --now /etc/slapos/slapos.cfg

Chapter 4. Creating an instancee of Wordpress in the SlapOS

The common way to release a software is to login vifib website. But we haven't integrated this software.cfg into vifib, so we verify it in the local machine. It need a patch:

$ cd /opt/slapos
$ wget http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/cygwin:/component/slapos/slapgrid-test-local-software.patch
$ cd /opt/slapos/eggs/slapos.core-0.33.1-py2.7.egg
$ patch -p1 < /opt/slapos/slapgrid-test-local-software.patch

Release Wordpress:

$ mkdir -p /var/slapgrid/instance
$ mkdir -p /var/slapgrid/software
$ bin/slapgrid --only_sr http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/cygwin:/software/wordpress/software.cfg /etc/slapos/slapos.cfg

Some dlls need to rebase in order to avoid fork issue in the Cygwin. Refer to http://cygwin.com/faq.html question 4.44 or search "rebase" in this page. First, exit all Cygwin processes and stop all Cygwin services.

$ net stop cfgslapos
$ ps -ef | grep python2.7
# kill all these process which start by supervisord
$ exit

If you install SlapOS node by MSI package, Click Start menu, select SlapOS program group, click Run rebaseall. Otherwise, download rebase-software.bat and save it in the cygwin root path.

$ cd /
$ wget http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/cygwin:/component/cygwin/rebase-software.bat
$ exit

Double click rebase-software.bat in the windows explorer. The file should be in the directory "C:/cygwin"

Create an instance:

$ net start cygslapos
$ bin/slapgrid --only_sr http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/cygwin:/software/wordpress/software.cfg /etc/slapos/slapos.cfg

Now wordpress should work. Type "http://localhost:8080/index.php" in your browser to check it.

Appendix A. Cygwin Required Packages List

The following packages are required when building SlapOS Node

  • Admin/cygrunsrv

  • Devel/autobuild

  • Devel/autoconf

  • Devel/automake

  • Devel/binutils

  • Devel/gcc4.5.4

  • Devel/libtool

  • Devel/make

  • Devel/libiconv?

  • Devel/zlib-devel?

  • Utils/patch*

  • Python/python2.6*

  • Web/wget*

  • Web/git*

  • Editor/vim*