Commit 218e7f14 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'develop'

parents a9eabc64 01ff026c
......@@ -6,6 +6,7 @@ blib
pm_to_blib
t/.db
t/etc/ravada_ldap*.conf
t/etc/remote_vm*.conf
t/etc/front_ldap*.conf
hypnotoad.pid
log
......
......@@ -3,56 +3,7 @@
**Implemented enhancements:**
- Add a minimun disk size for each KVM template [\#447]
- Add Fedora Workstation [\#499]
- Remove non-kvm machines fails [\#533]
- Grant remove all clones [\#606]
- Add Refresh button to machines page [\#617]
- New volatile clones option [\#628]
- Volatile VM files not deleted at shutdown [\#629]
- Grant create machine [\#635]
- Confirmation when click on create/remove base image [\#637]
- Manage RAW disk volumes [\#656]
- Enable volatile clones option [\#678]
- Check (and label) if a user is connected to a running desktop [\#682]
- Allow change virtual machine memory [\#692]
- User permissions [\#698]
- Change jp.po to ja.po [\#704]
- Grant shutdown all [#710]
- Add more than one USB devices in xml templates [\#733]
- Grant shutdown clones [\#739]
- Reserve memory for OS [\#746]
- Grant change settings all [\#748]
- Grant change settings clones [\#749]
- Improve start clone [\#751]
- Redirect after view machine [\#753]
- Grant create machine [\#761]
- Bases and clones storage pools [\#841]
- Force click on machine start to show directly in full screen [\#812]
- Review French translation [\#827]
- USB Hardware controllers [\#813]
- Create an empty virtual machine [\#918]
**Fixed bugs:**
- Swap volume is set to 1GB if unspecified [\#480]
- Fix machine remove page [\#485]
- Don't prepare base if already prepared [\#501]
- Web connection is not secure [\#600]
- Sort ISOs by name at new machine [\#611]
- Refresh virtual machine status [\#626]
- Hardcoded footer in start.html.ep [\#630]
- Deny access to no admin users if not allowed [\#639]
- Inconsistencies between en.po and the rest of the language files [\#646]
- Add more than one USB devices in xml templates [\#733]
- Duplicated new clone crashes [\#740]
- Submit without box selected in the user menu [\#744]
- Hibernated machines appear down [\#787]
- Delete machines from database already deleted [\#793]
- Request to open_iptables fails when machine down [\#795]
- Machines won't start while preparing or removing base [\#797]
- Get drivers from frontend fail [\#809]
- iptables jump gets added many times [\#802]
- Kiosk mode fails [\#832]
- Machine with many clone requests won't clone [\#790]
- Allow admins to run more than one machine [#840]
- Verify pre-defined ISO downloads [\#856]
......@@ -13,7 +13,18 @@ to see if someone else in the community has already created a ticket.
You can also ask in our [telegram public group](https://t.me/ravadavdi).
If it is not, go ahead and [create a new issue](https://github.com/UPC/ravada/issues/new)!
## 2. Fork & create a branch
## 2. Source code
We manage the code with Git. If you already know it, skip this point. If this is the
first time you work with it, beware it has a learning curve. First of all read some
introduction. Then please ask questions if you need it, we are more than willing to
mentor first timers.
* Join the [Ravada Google group](https://groups.google.com/forum/#!forum/ravada).
* Meet us in our [Telegram public group](http://t.me/ravadavdi).
## 3. Fork & create a branch
If this is something you think you can fix, then
[fork Ravada](https://help.github.com/articles/fork-a-repo)
......@@ -23,10 +34,10 @@ the branch so it is easier to follow.
A good branch name would be (where issue #77 is the one you're working on):
```sh
git checkout -b 77_start_machine
git checkout -b fix/77_start_machine
```
## 3. Code Style
## 4. Code Style
See our
[editor configuration](http://ravada.readthedocs.io/en/latest/devel-docs/editor-rules.html)
......@@ -36,7 +47,7 @@ spaces or spaces converted to tabs.
Please make sure you don't do that. Run ``git diff`` before commit to see what you are
exactly contributing.
## 4. Commit Format
## 5. Commit Format
If you contribute code, *thank you* ! Plase, follow this guide.
......@@ -57,7 +68,7 @@ footer #issue
Example:
```
fix: active virtual machines can not be started
fix(backend): active virtual machines can not be started
check the machine status before start
returns if machine active
......@@ -66,7 +77,7 @@ before it crashed trying to start the machine
fixes #77
```
### 4.1 Header: Type
### 5.1 Header: Type
Commits must be prefixed with a type, which consists of a verb, feat, fix, build, followed by a colon and space.
......@@ -82,7 +93,7 @@ Your options:
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc).
- test: Adding missing tests or correcting existing tests.
### 4.2 Header: Optional Scope
### 5.2 Header: Optional Scope
Refers to the extent, subject matter or contextual information about your changes. A scope is a phrase describing the file modified or a section of the codebase, it is always enclosed in parenthesis.
......@@ -90,7 +101,7 @@ Example for a (optional scope):
feat(parser): add ability to parse arrays
### 4.3 Header: Description
### 5.3 Header: Description
A description must immediately follow the type(optional scope): The description is a short description of the commit.
......@@ -102,11 +113,11 @@ Important:
- Don't capitalize the first letter.
- Do not use a dot (.) at the end.
### 4.4 Header Lenghth
### 5.4 Header Lenghth
The header cannot be longer than 100 characters. This allows the message to be easier to read on GitHub as well as in various git tools.
### 4.5 Writing the optional body
### 5.5 Writing the optional body
The body should include the motivation for the change and contrast this with previous behavior.
......@@ -118,7 +129,7 @@ remove out of date paragraph
fix broken links
```
### 4.5 Writing the optional footer
### 5.6 Writing the optional footer
The <optional footer> should contain a closing reference to an issue if any.
......@@ -127,11 +138,11 @@ pull request description or commit message. Once the branch is merged into the d
the issue will close.
## 5. Get the tests running
## 6. Get the tests running
See this documentation about [testing](http://ravada.readthedocs.io/en/latest/devel-docs/commit-rules.html#testing) the project.
## 6. Did you find a bug?
## 7. Did you find a bug?
* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/UPC/ravada/issues).
......@@ -139,7 +150,7 @@ See this documentation about [testing](http://ravada.readthedocs.io/en/latest/de
Be sure to include a **title and clear description**, as much relevant information as possible,
and a **code sample**, an **executable test case** or a step by step guide demonstrating the expected behavior that is not occurring.
## 7. Implement your fix or feature
## 8. Implement your fix or feature
At this point, you're ready to make your changes! Feel free to ask for help;
everyone is a beginner at first :smile_cat:
......@@ -148,7 +159,7 @@ Follow this guide about running [Ravada in development mode](http://ravada.readt
If you change a translation or language file make sure you follow this small [guide](http://ravada.readthedocs.io/en/latest/devel-docs/translations.html?highlight=translate) and don't forget to add the issue number when committing.
## 8. Push your changes
## 9. Push your changes
Pushing refers to sending your committed changes to a remote repository, such as a repository
hosted on GitHub. Before that all the changes where local in the computer you are working in.
......@@ -157,7 +168,7 @@ After working on your changes you need to Push it (upload) your newly created br
git push
## 9. Create a Pull Request
## 10. Create a Pull Request
Pull requests or PR are proposed changes to a repository submitted by a user and accepted or rejected by a repository's collaborators.
......@@ -181,7 +192,7 @@ git push --set-upstream origin 325_boost_performance
Finally, go to our GitHub repository and
[create a Pull Request](https://github.com/UPC/ravada/pulls)
### 9.1 How to Write a Title for a Pull Request
### 10.1 How to Write a Title for a Pull Request
Pull Request should be named in reference to the main fix or feature you provide; minor information can be added to the description. Please be specific and don't use generic terms.
Keep it concise and don't write more than 50 characters in the title.
......@@ -189,7 +200,7 @@ Keep it concise and don't write more than 50 characters in the title.
Read [more information about PR](https://help.github.com/articles/creating-a-pull-request)
### 9.2 Keeping your Pull Request updated
### 10.2 Keeping your Pull Request updated
If a maintainer asks you to "rebase" your PR, they're saying that a lot of code
has changed, and that you need to update your branch so it's easier to merge.
......@@ -205,7 +216,7 @@ git pull --rebase origin master
git push --force-with-lease origin 325_boost_performance
```
### 9.3 Merging a PR (maintainers only)
### 10.3 Merging a PR (maintainers only)
A PR can only be merged into master by a maintainer if:
......
......@@ -27,12 +27,14 @@ WriteMakefile(
,'DBD::SQLite' => 0
,'IPTables::ChainMgr' => 0
,'Net::DNS' => 0
,'Net::SSH2' => 0
,'File::Rsync' => 0
},
BUILD_REQUIRES => {
'Test::Perl::Critic' => 0
},
test => {TESTS => 't/*.t t/*/*.t'},
clean => {FILES => 't/.db' }
clean => {FILES => ['t/.db', '/var/tmp/rvd_void'] }
);
......@@ -12,6 +12,11 @@
Ravada is a software that allows the user to connect to a
remote virtual desktop.
Ravada is meant for sysadmins who have some background in GNU/Linux, and want to deploy a VDI project.
Its back-end has been designed and implemented in order to allow future hypervisors to be added to the framework. Currently, it supports KVM and LXC is in the works.
The client only requirements are: a web-browser and a remote viewer supporting the spice protocol.
In the current release we use the
KVM Hypervisors: [KVM](http://www.linux-kvm.org/) as the backend for the Virtual Machines.
......
......@@ -7,6 +7,7 @@ use lib './lib';
use Data::Dumper;
use Getopt::Long;
use POSIX ":sys_wait_h";
use Proc::PID::File;
use Ravada;
......@@ -45,14 +46,18 @@ my $LIST;
my $HIBERNATE_DOMAIN;
my $START_DOMAIN;
my $SHUTDOWN_DOMAIN;
my $REBASE;
my $IMPORT_DOMAIN_OWNER;
my $ADD_LOCALE_REPOSITORY;
my $USAGE = "$0 "
." [--debug] [--config=$FILE_CONFIG_DEFAULT] [--add-user=name] [--add-user-ldap=name]"
." [--change-password] [--make-admin=username] [--import-vbox=image_file.vdi]"
." [--test-ldap] "
." [-X] [start|stop|status]"
." [--rebase MACHINE]"
."\n"
." --add-user : adds a new db user\n"
." --add-user-ldap : adds a new LDAP user\n"
......@@ -61,9 +66,10 @@ my $USAGE = "$0 "
." --import-domain-owner : owner of the domain to import\n"
." --make-admin : make user admin\n"
." --config : config file, defaults to $FILE_CONFIG_DEFAULT"
." -X : start in foreground\n"
." --no-fork : start in foreground\n"
." --url-isos=(URL|default)\n"
." --import-vbox : import a VirtualBox image\n"
.' --add-locale-repository LOCALE : adds ISO repositories for this locale'
."\n"
."Operations on Virtual Machines:\n"
." --list\n"
......@@ -86,6 +92,7 @@ GetOptions ( help => \$help
,list => \$LIST
,debug => \$DEBUG
,verbose => \$VERBOSE
,rebase => \$REBASE
,'no-fork'=> \$NOFORK
,'start=s' => \$START_DOMAIN
,'config=s'=> \$FILE_CONFIG
......@@ -103,6 +110,8 @@ GetOptions ( help => \$help
,'import-domain=s' => \$IMPORT_DOMAIN
,'import-vbox=s' => \$IMPORT_VBOX
,'import-domain-owner=s' => \$IMPORT_DOMAIN_OWNER
,'add-locale-repository=s' => \$ADD_LOCALE_REPOSITORY
) or exit;
$START = 1 if $DEBUG || $FILE_CONFIG || $NOFORK;
......@@ -128,6 +137,9 @@ die "ERROR: Shutdown requires a domain name, or --all , --hibernated , --disconn
die "ERROR: Hibernate requires a domain name, or --all , --disconnected\n"
if defined $HIBERNATE_DOMAIN && !$HIBERNATE_DOMAIN && !$ALL && !$DISCONNECTED;
die "ERROR: Missing the machine name or id\n$USAGE"
if $REBASE && !@ARGV;
my %CONFIG;
%CONFIG = ( config => $FILE_CONFIG ) if $FILE_CONFIG;
......@@ -137,7 +149,6 @@ $Ravada::CAN_FORK=0 if $NOFORK;
###################################################################
my $PID_LONGS;
###################################################################
#
......@@ -146,47 +157,32 @@ sub do_start {
my $old_error = ($@ or '');
my $cnt_error = 0;
clean_killed_requests();
start_process_longs() if !$NOFORK;
my $t_refresh = 0;
my $ravada = Ravada->new( %CONFIG );
Ravada::Request->enforce_limits();
# Ravada::Request->enforce_limits();
#Ravada::Request->refresh_vms();
for (;;) {
my $t0 = time;
$ravada->process_priority_requests();
$ravada->process_long_requests();
$ravada->process_requests();
$ravada->process_long_requests(0,$NOFORK) if $NOFORK;
if ( time - $t_refresh > 60 ) {
Ravada::Request->cleanup();
Ravada::Request->refresh_vms() if rand(5)<3;
Ravada::Request->enforce_limits() if rand(5)<2;
$t_refresh = time;
}
sleep 1 if time - $t0 <1;
}
}
sub start_process_longs {
my $pid = fork();
die "I can't fork" if !defined $pid;
if ( $pid ) {
$PID_LONGS = $pid;
return;
}
warn "Processing long requests in pid $$\n" if $DEBUG;
my $ravada = Ravada->new( %CONFIG );
for (;;) {
my $t0 = time;
$ravada->process_long_requests();
sleep 1 if time - $t0 <1;
}
}
sub clean_killed_requests {
sub clean_old_requests {
my $ravada = Ravada->new( %CONFIG );
$ravada->clean_killed_requests();
$ravada->clean_old_requests();
}
sub start {
......@@ -196,18 +192,13 @@ sub start {
$ravada->_install();
for my $vm (@{$ravada->vm}) {
$vm->id;
$vm->vm;
}
$ravada->_wait_pids();
}
clean_old_requests();
for (;;) {
my $pid = fork();
die "I can't fork $!" if !defined $pid;
if ($pid == 0 ) {
do_start();
exit;
}
warn "Waiting for pid $pid\n";
waitpid($pid,0);
eval { do_start() };
warn $@ if $@;
}
}
......@@ -454,7 +445,8 @@ sub shutdown_domain {
my $down = 0;
my $found = 0;
DOMAIN:
for my $domain ($rvd_back->list_domains) {
for my $domain_data ($rvd_back->list_domains_data) {
my $domain = Ravada::Front::Domain->open($domain_data->{id});
if ((defined $domain_name && $domain->name eq $domain_name)
|| ($hibernated && $domain->is_hibernated)
|| ($DISCONNECTED
......@@ -480,10 +472,11 @@ sub shutdown_domain {
next DOMAIN if _verify_connection($domain);
}
print "Shutting down ".$domain->name.".\n";
eval {
$domain->shutdown(user => Ravada::Utils::user_daemon(), timeout => 300);
$down++;
};
Ravada::Request->shutdown_domain(uid => Ravada::Utils::user_daemon()->id
,id_domain => $domain->id
, timeout => 300
);
$down++;
warn $@ if $@;
}
}
......@@ -531,15 +524,32 @@ sub test_ldap {
exit;
}
sub DESTROY {
return if !$PID_LONGS;
warn "Killing pid: $PID_LONGS";
sub add_locale_repository {
my $locale = shift;
for my $lang ( split /,/, $locale ) {
print "Adding locales for $lang.\n";
my $found = Ravada::Repository::ISO::insert_iso_locale($lang, 'verbose');
print "$found found.\n";
}
}
my $cnt = kill 15 , $PID_LONGS;
return if !$cnt;
sub rebase {
my ($domain_name) = $ARGV[0];
my $rvd_back = Ravada->new(%CONFIG);
my $domain;
if ($domain_name =~ /^\d+$/) {
$domain = Ravada::Domain->open($domain_name);
} else {
$domain = $rvd_back->search_domain($domain_name);
}
die "Error: Unknown domain $domain_name\n" if !$domain;
die "Error: ".$domain->name." is not a clone\n" if !$domain->id_base;
kill 9 , $PID_LONGS;
my $base = Ravada::Domain->open($domain->id_base);
$base->rebase(Ravada::Utils::user_daemon, $domain);
}
sub DESTROY {
}
#################################################################
......@@ -557,6 +567,7 @@ make_admin($MAKE_ADMIN_USER) if $MAKE_ADMIN_USER;
remove_admin($REMOVE_ADMIN_USER) if $REMOVE_ADMIN_USER;
set_url_isos($URL_ISOS) if $URL_ISOS;
test_ldap if $TEST_LDAP;
rebase() if $REBASE;
list($ALL) if $LIST;
hibernate($HIBERNATE_DOMAIN , $ALL) if defined $HIBERNATE_DOMAIN;
......@@ -565,6 +576,7 @@ start_domain($START_DOMAIN) if $START_DOMAIN;
shutdown_domain($SHUTDOWN_DOMAIN, $ALL, $HIBERNATED)
if defined $SHUTDOWN_DOMAIN;
add_locale_repository($ADD_LOCALE_REPOSITORY) if $ADD_LOCALE_REPOSITORY;
}
......
This diff is collapsed.
......@@ -3,6 +3,7 @@
use warnings;
use strict;
use Carp qw(confess);
use Cwd qw(getcwd);
use File::Path qw(remove_tree make_path);
use IPC::Run3;
......@@ -11,7 +12,8 @@ use Ravada;
use File::Copy;
my $VERSION = Ravada::version();
my $DIR_DST = getcwd."/../ravada-$VERSION";
my $DIR_SRC = getcwd;
my $DIR_DST;
my $DEBIAN = "DEBIAN";
my %DIR = (
......@@ -80,8 +82,8 @@ sub copy_files {
sub remove_not_needed {
for my $file (@REMOVE) {
$file = "$DIR_DST/$file";
unlink $file or die "$! $file";
my $file2 = "$DIR_DST/$file";
unlink $file2 or die "$! $file2";
}
for my $dir ('usr/share/doc/ravada/sql/sqlite') {
my $path = "$DIR_DST/$dir";
......@@ -114,7 +116,10 @@ sub create_md5sums {
}
sub create_deb {
my $deb = "ravada_${VERSION}_all.deb";
my $dist = shift or confess "Missing dist";
mkdir "ravada_release" if !-e "ravada_release";
my $deb = "ravada_release/ravada_${VERSION}_${dist}_all.deb";
my @cmd = ('dpkg','-b',"$DIR_DST/",$deb);
my ($in, $out, $err);
run3(\@cmd, \$in, \$out, \$err);
......@@ -218,7 +223,7 @@ sub chown_pms {
sub chmod_control_files {
for (qw(control conffiles)) {
my $path = "$DIR_DST/$DEBIAN/$_";
warn "Missing $path" if ! -e $path;
confess "Missing $path" if ! -e $path;
chmod 0644 , $path or die "$! $path" if -e $path;
}
......@@ -229,19 +234,22 @@ sub chmod_control_files {
}
sub chmod_ravada_conf {
chmod 0644,"$DIR_DST/etc/ravada.conf" or die $!;
chmod 0600,"$DIR_DST/etc/ravada.conf" or die $!;
}
sub tar {
my $dist = shift;
my @cmd = ('tar','czvf',"ravada_$VERSION.orig.tar.gz"
,"ravada-$VERSION"
,"ravada-$VERSION-$dist"
);
warn "@cmd";
my ($in, $out, $err);
run3(\@cmd, \$in, \$out, \$err);
die $err if $err;
confess $err if $err;
}
sub make_pl {
chdir $DIR_SRC or die "$! $DIR_SRC";
my @cmd = ('perl','Makefile.PL');
my ($in, $out, $err);
run3(\@cmd, \$in, \$out, \$err);
......@@ -257,7 +265,7 @@ sub set_version {
my $file_in = "$DIR_DST/DEBIAN/control";
my $file_out = "$file_in.version";
open my $in ,'<',$file_in or die "$! $file_in";
open my $in ,'<',$file_in or confess "$! $file_in";
open my $out,'>',$file_out or die "$! $file_out";
my $version = $VERSION;
......@@ -281,12 +289,49 @@ sub set_version {
unlink $file_out;
}
sub list_dists {
opendir my $dir,'debian' or die "$! debian";
my @dists;
while ( my $file = readdir $dir ) {
my ($dist) = $file =~ /control-(.*)/;
push @dists,($dist) if $dist;
}
closedir $dir;
die "Error: no dists control files found in 'debian' dir"
if !@dists;
return @dists;
}
sub set_control_file {
my $dist = shift;
my $dst = "$DIR_DST/DEBIAN/control";
my $src = "$dst-$dist";
die "Error: no $src" if ! -e $src;
copy($src, $dst) or die "$! $src -> $dst";
opendir my $dir,"$DIR_DST/DEBIAN" or die $!;
while ( my $file = readdir $dir ) {
unlink "$DIR_DST/DEBIAN/$file" or die "$! $file"
if $file =~ /^control-/;
}
closedir $dir;
}
#########################################################################
for my $dist (list_dists) {
$DIR_DST = "$DIR_SRC/../ravada-$VERSION-$dist";
clean();
make_pl();
copy_dirs();
copy_files();
set_control_file($dist);
set_version();
remove_not_needed();
remove_use_lib();
......@@ -306,13 +351,15 @@ chown_files('usr/sbin',0755,0755);
#chown_files('usr/share/ravada/public');
#chown_files('usr/share/ravada/templates');
chown_files('etc');
chmod_ravada_conf();
chown_files('lib');
#chown_files('lib/systemd');
chown_files('var/lib/ravada');
chown_files('usr/share/perl5');
#chown_files('usr/share/man');
create_md5sums();
tar();
tar($dist);
#chown_pms();
create_md5sums();
create_deb();
create_deb($dist);
}