1. 程式人生 > >OpenStack horizon開發環境搭建

OpenStack horizon開發環境搭建

此文件是在本來安裝了計算節點的機器上實驗的。

cd /home/github

1.取得原始碼:

備份一份

mkdir /home/src

pwd

/home

cp -r /github/horizon   /src

cd /home/src/horizon

2.install the prerequisite packages
    apt-get install nodejs
   

3. create a virtual environment:
     python tools/install_venv.py          時間很長
     注意,1.執行前先修改一下tools/install_venv.py,在def create_virtualenv函式裡,指定安裝pip的版本為1.1,
               if not run_command([WITH_VENV, 'easy_install', 'pip==1.1

']).strip():
              

                2.安裝virtual environment時經常出現timeout錯誤,因此可以修改tools/install_venv.py檔案中的def pip_install函式,增加default-timeout引數,run_command(['tools/with_venv.sh', 'pip','--default-timeout=1800', 'install', '--upgrade'] + list(args),redirect_output=False) 。
       另外,儘量執行python tools/install_venv.py安裝虛擬環境,如果失敗,下次安裝會接著失敗處繼續安裝

安裝成功會提示:

Horizon development environment setup is complete.

To activate the virtualenv for the extent of your current shell session you
can run:

$ source .venv/bin/activate

官方文件: 

Note

If you would like to run commands without the prefix of tools/with_venv.sh you may source your environment directly. This will remain active as long as your shell session stays open:

> source .venv/bin/activate

 例如使用:

> tools/with_venv.sh ./manage.py runserver

Alternately specify the listen IP and port:

> tools/with_venv.sh ./manage.py runserver 0.0.0.0:8080
如果加入


source .venv/bin/activate
就可以直接輸入命令了

python manage.py runserver 0.0.0.0:8080

注意:0.0.0.0需要修改為ip地址

4. unit tests:
    ./run_tests.sh                    時間很長

最後提示:

Horizon development environment setup is complete.

To activate the virtualenv for the extent of your current shell session you
can run:

$ source .venv/bin/activate

Running Horizon application tests
nosetests --verbosity 1 horizon --nocapture --nologcapture --exclude-dir=horizon/conf/ --cover-package=horizon --cover-inclusive --all-modules
Creating test database for alias 'default'...
...........................................................S
----------------------------------------------------------------------
Ran 60 tests in 64.473s

OK (SKIP=1)
Destroying test database for alias 'default'...
Running openstack_dashboard tests
nosetests --verbosity 1 openstack_dashboard --nocapture --nologcapture --cover-package=openstack_dashboard --cover-inclusive --all-modules
Failed to load keyring modules.
WARNING:root:No local_settings file found.
Creating test database for alias 'default'...
..........................................................................................................................................................................................................................................................................................................................................................SS..S
----------------------------------------------------------------------
Ran 351 tests in 149.702s

OK (SKIP=3)
Destroying test database for alias 'default'...
Tests completed successfully.

5.   cp openstack_dashboard/local/local_settings.py.example  openstack_dashboard/local/local_settings.py



6.執行

python manage.py runserver 192.168.240.101:8080   

 輸入使用者名稱admin  密碼openstack 提示認證失敗  An error occurred authenticating. Please try again later.

在執行runserver 服務後,在伺服器的後臺就運行了一個服務。
在本地就可以通過瀏覽器中輸入192.168.1.125:8080
使用者名稱admin
密碼openstack登入

瀏覽器一定要使用支援html5的瀏覽器,推薦使用最新firefox和chrome ,IE9相容性還是很不好。

參考文件:

tools/with_venv.sh <your command>

http://docs.openstack.org/developer/nova/devref/development.environment.html
) s5 `2 X- e# W5 x/ l8 s

http://docs.openstack.org/developer/nova/devref/unit_tests.html! y" O