Commit f87aed2a authored by Vassilios Karakoidas's avatar Vassilios Karakoidas
Browse files

Merge branch 'master' into logic-refactoring

parents 296573e9 ac49a70a
......@@ -15,3 +15,7 @@ lib/
.idea
.DS_Store
selenium-server-standalone-2.0b2.jar
.project
.pydevproject
.settings/
DEPLOYMENT notes
=================
Debian
------
\ No newline at end of file
DEVELOP.txt - Information on how to setup a development environment.
Dependencies
------------
Synnefo depends on the following Python modules
- django
- django-piston
- simplejson
- selenium
- pyzmq-static
also, depending on the database engine of choice, on one of the following:
- MySQL-python
- psycopg2
Preparing the development environment
-------------------------------------
1. Prepare the system
The easiest method is to setup a working environment through virtualenv.
Alternatively, you can use your system's package manager to install
the dependencies (e.g. Macports has them all).
*On Snow Leopard, you have to set the following environment variable for
pip to compile the dependencies correctly.
$export ARCHFLAGS="-arch x86_64"
*On Ubuntu, a few more packages must be isntalled before installing the
prerequisite Python libraries
$sudo aptitude install libcurl3-gnutls libcurl3-gnutls-dev uuid-dev
2. Checkout the code and install the Python prerequisites. This assumes
that python is already installed on the host.
$ sudo easy_install virtualenv
$ git clone https://user@code.grnet.gr/git/synnefo synnefo
$ virtualenv --python=python2.6 synnefo --no-site-packages
...
$ cd synnefo
$ ./bin/pip install django django-piston pycurl simplejson selenium pyzmq-static
2. At this point you should have all required dependencies installed. Now you
have to select a database engine. The choices are: postgres, mysql and sqlite.
-SQLite
The python sqlite driver is available by default with Python so no additional
configuration is required. Also, most self-respecting systems have the sqlite
library installed by default.
-MySQL
MySQL must be installed first
*Ubuntu - Debian
$sudo apt-get install libmysqlclient-dev
*MacPorts
$sudo port install mysql5
Install the MySQL python library
$ bin/pip install MySQL-python
Note: On MacOSX with Mysql install from MacPorts the above command will fail
complaining that it cannot find the mysql_config command. Do the following and
restart the installation
$ echo "mysql_config = /opt/local/bin/mysql_config5" >> ./build/MySQL-python/site.cfg
Configure a MySQL db/account for synnefo
$ mysql -u root -p
mysql> create database synnefo;
mysql> show databases;
mysql> GRANT ALL on synnefo.* TO username IDENTIFIED BY 'password';
-Postgres
#Ubuntu - Debian
$ sudo apt-get install postgresql-8.4 libpq-dev
#MacPorts
$ sudo port install postgresql84
Install the postgres Python library
$ bin/pip install psycopg2
Configure a postgres db/account for synnefo
<TODO>
3. At this point you should have a working DB. Now configure Django to access it:
Copy the default configuration file
$ cp settings.py.dist settings.py
and then edit according to the database used:
-SQLite
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
DATABASES = {
'default': {
'ENGINE': 'sqlite3', # ATTENTION: This *must* be the absolute path if using sqlite3.
'NAME': PROJECT_PATH + 'database.sqlite'
}
}
-MySQL
DATABASES = {
'default': {
'ENGINE': 'mysql',
'NAME': 'synnefo',
'USER': 'USERNAME'
'PASSWORD': 'PASSWORD',
'HOST': 'HOST',
'PORT': 'PORT',
'OPTIONS': {
'init_command': 'SET storage_engine=INNODB',
}
}
}
-Postgres
DATABASES = {
'default': {
'ENGINE': 'postgresql_psycopg2',
'NAME': 'DATABASE',
'USER': 'USERNAME',
'PASSWORD': 'PASSWORD',
'HOST': 'HOST',
'PORT': 'PORT',
}
}
4. Try it out. The following command will attempt to connec to the DB and
print out DDL statements. It should not fail.
$ ./bin/python manage.py sql db
5. Create the DB and (optionally) load test data
$ ./bin/python manage.py syncdb
$ ./bin/python manage.py loaddata db/fixtures/flavors.json
$ ./bin/python manage.py loaddata db/fixtures/images.json
$ ./bin/python manage.py loaddata db/fixtures/vms.json
6. Start the system
$ cd db
$ ../bin/python db_controller.py
$ cd ..
$ ./bin/python manage.py runserver
7. Done
UI Testing
----------
The functional ui tests require the Selenium server and the synnefo app to be running.
$ wget http://selenium.googlecode.com/files/selenium-server-standalone-2.0b2.jar
$ java -jar selenium-server-standalone-2.0b2.jar &
$ ./bin/python manage.py runserver &
$ ./bin/python manage.py test ui
Test coverage
-------------
In order to get code coverage reports you need to install django-test-coverage
$ ./bin/pip install django-test-coverage
Then edit your settings.py and configure the test runner:
TEST_RUNNER = 'django-test-coverage.runner.run_tests'
......@@ -532,8 +532,8 @@ div.machine div.actions a.more {
}
div.machine div.actions a:hover{
color: orange !important;
text-decoration: none;
color: black !important;
text-decoration: underline;
display: block;
}
......@@ -821,8 +821,8 @@ div.list div.actions a.enabled {
div.list div.actions a.enabled:hover{
cursor: pointer;
color: orange !important;
text-decoration: none;
color: black !important;
text-decoration: underline;
}
input.machine {
......@@ -1160,4 +1160,4 @@ div.list table thead #name {
.message {
display: none;
}
\ No newline at end of file
}
......@@ -27,6 +27,16 @@ function update_confirmations(){
if (pending_actions.length>1 || $.cookie("list") == '1' && pending_actions.length == 1){ // if more than one pending action show multiple confirm box
$('div.confirm_multiple span.actionLen').text(pending_actions.length);
// set the label of the buttons in list view
if ($.cookie("list") == '1') {
$('div.confirm_multiple button.yes').text('Confirm');
$('div.confirm_multiple button.no').text('Cancel');
}
// set the label of the buttons in standard view
else {
$('div.confirm_multiple button.yes').text('Confirm All');
$('div.confirm_multiple button.no').text('Cancel All');
}
$('div.confirm_multiple').show();
}
}
......
......@@ -97,11 +97,18 @@ var actions = { 'reboot': ['ACTIVE', 'REBOOT', 'multiple'],
};
// on checkbox click, update the actions
$("tbody input[type='checkbox']").live('change', function() { updateActions(); });
$("tbody input[type='checkbox']").live('change', function() {
updateActions();
pending_actions = [];
$(".selected").removeClass('selected');
update_confirmations();
});
// destroy action
$("a.enabled#action-destroy").live('click', function() {
var checked = $("table.list-machines tbody input[type='checkbox']:checked");
$(".selected").removeClass('selected');
$(this).addClass('selected');
pending_actions = []; // reset pending actions
checked.each(function(i,c) {
serverID=c.id;
......@@ -112,9 +119,10 @@ $("a.enabled#action-destroy").live('click', function() {
return false;
});
$("a.enabled#action-reboot").live('click', function() {
var checked = $("table.list-machines tbody input[type='checkbox']:checked");
$(".selected").removeClass('selected');
$(this).addClass('selected');
pending_actions = []; // reset pending actions
checked.each(function(i,c) {
serverID=c.id;
......@@ -125,9 +133,10 @@ $("a.enabled#action-reboot").live('click', function() {
return false;
});
$("a.enabled#action-start").live('click', function() {
var checked = $("table.list-machines tbody input[type='checkbox']:checked");
$(".selected").removeClass('selected');
$(this).addClass('selected');
pending_actions = []; // reset pending actions
checked.each(function(i,c) {
serverID=c.id;
......@@ -138,9 +147,10 @@ $("a.enabled#action-start").live('click', function() {
return false;
});
$("a.enabled#action-shutdown").live('click', function() {
var checked = $("table.list-machines tbody input[type='checkbox']:checked");
$(".selected").removeClass('selected');
$(this).addClass('selected');
pending_actions = []; // reset pending actions
checked.each(function(i,c) {
serverID=c.id;
......@@ -159,7 +169,10 @@ function update_machines_view(data){
tableData = vmTable.fnGetData();
$.each(data.servers, function(i,server){
current = -1;
// check server status to select the appropriate OS icon
osTag = image_tags[server.imageRef]
var osIcon = osTag + ".png";
// check if the server already exists in the datatable
tableData.forEach(function(row,index){
......@@ -178,6 +191,13 @@ function update_machines_view(data){
} else {
// update status
tableData[current][0] = "<input class="+server.status+" id="+server.id+" type=checkbox>";
// check server status to select the appropriate OS icon
if (['ERROR', 'STOPPED'].indexOf(server.status) >= 0) {
osIcon = osTag + "-off.png";
}
tableData[current][1] = "<span class=imagetag>" + osTag +
"</span><img class=list-logo src=static/os_logos/" + osIcon +
" title=" + osTag + " height=16 width=16>";
tableData[current][5] = "<span class=status>" + STATUS_MESSAGES[server.status] + "</span>";
// TODO: update name & ip
vmTable.fnUpdate(tableData[current],current);
......@@ -185,8 +205,6 @@ function update_machines_view(data){
updateActions();
} else if (server.status != "DELETED") { // does not exist, we should create it
// check server status to select the appropriate OS icon
osTag = image_tags[server.imageRef]
var osIcon = osTag + ".png";
if (['ERROR', 'STOPPED'].indexOf(server.status) >= 0) {
osIcon = osTag + "-off.png";
}
......@@ -225,8 +243,6 @@ function display_failure(serverID, status, action) {
ajax_error(status);
}
var vmTable = $("div.list table.list-machines").dataTable({
"bInfo": false,
"bRetrieve": true,
......@@ -242,7 +258,6 @@ var vmTable = $("div.list table.list-machines").dataTable({
]
});
if (images.length == 0) {
// populate image list
update_images();
......
......@@ -225,6 +225,9 @@ function update_machines_view(data){
});
$("#spinner").hide();
// show all separators
$("div.machine div.separator").show();
// hide the last one
$("div.machine:last-child").find("div.separator").hide();
// the separator shows only when running and terminated machines are available
if ($(".terminated a.name").length > 0 && $(".running a.name").length > 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment