Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
3817e5a4
Commit
3817e5a4
authored
Sep 26, 2016
by
Francesc Guasch
Browse files
removed duplicated code for new machine
parent
15f010b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
rvd_front.pl
View file @
3817e5a4
...
...
@@ -268,33 +268,7 @@ sub domains {
my
@error
=
();
my
$ram
=
(
$c
->
param
('
ddram
')
or
2
);
my
$disk
=
(
$c
->
param
('
dddisk
')
or
8
);
my
$backend
=
$c
->
param
('
backend
');
my
$id_iso
=
$c
->
param
('
id_iso
');
my
$id_template
=
$c
->
param
('
id_template
');
if
(
$c
->
param
('
submit
'))
{
push
@error
,("
Name is mandatory
")
if
!
$c
->
param
('
name
');
if
(
!
@error
)
{
my
$domain
=
req_new_domain
(
$c
);
if
(
$domain
)
{
return
show_link
(
$c
,
$domain
);
}
else
{
return
show_failure
(
$c
,
$c
->
param
('
name
'));
}
}
}
warn
join
("
\n
",
@error
)
if
@error
;
$c
->
render
(
template
=>
'
bootstrap/machines
'
,
name
=>
$c
->
param
('
name
')
,
ram
=>
$ram
,
disk
=>
$disk
,
error
=>
\
@error
);
$c
->
render
(
template
=>
'
bootstrap/machines
');
}
...
...
@@ -320,15 +294,21 @@ sub new_machine {
if
(
$c
->
param
('
submit
'))
{
push
@error
,("
Name is mandatory
")
if
!
$c
->
param
('
name
');
if
(
!
@error
)
{
my
$domain
=
req_new_domain
(
$c
);
if
(
$domain
)
{
return
show_link
(
$c
,
$domain
);
my
$request
=
req_new_domain
(
$c
);
if
(
$request
)
{
if
(
$request
->
status
eq
'
done
')
{
my
$domain
=
$RAVADA
->
search_domain
(
$c
->
param
('
name
'));
return
show_link
(
$c
,
$domain
)
if
$domain
;
return
show_failure
(
$c
,
$c
->
param
('
name
'))
if
!
$domain
;
return
_show_request
(
$c
,
$request
);
}
}
else
{
return
show_failure
(
$c
,
$c
->
param
('
name
'));
}
}
}
warn
join
("
\n
",
@error
)
if
@error
;
$c
->
render
(
template
=>
'
bootstrap/new_machine
'
...
...
@@ -342,7 +322,6 @@ sub new_machine {
sub
req_new_domain
{
my
$c
=
shift
;
my
$name
=
$c
->
param
('
name
');
warn
$USER
->
id
;
my
$req
=
$RAVADA
->
create_domain
(
name
=>
$name
,
id_iso
=>
$c
->
param
('
id_iso
')
...
...
@@ -351,19 +330,7 @@ sub req_new_domain {
,
id_owner
=>
$USER
->
id
);
$RAVADA
->
wait_request
(
$req
);
if
(
$req
->
error
)
{
$c
->
stash
(
error
=>
$req
->
error
)
;
return
;
}
my
$domain
=
$RAVADA
->
search_domain
(
$name
);
if
(
!
$domain
)
{
return
_show_request
(
$c
,
$req
);
}
return
$domain
;
return
$req
;
}
sub
_show_request
{
...
...
@@ -436,6 +403,7 @@ sub show_link {
my
$c
=
shift
;
my
$domain
=
shift
;
# or confess "Missing domain";
confess
"
Domain is not a ref
$domain
"
if
!
ref
$domain
;
my
$uri
=
$RAVADA
->
domdisplay
(
$domain
->
{
name
},
$USER
)
if
$domain
;
if
(
!
$uri
)
{
...
...
templates/bootstrap/machines.html.ep
View file @
3817e5a4
...
...
@@ -32,8 +32,6 @@
</div>
</div>
<
%=
join
("<
br
/>
",@$error ) %>
</div>
</div>
%= include 'bootstrap/scripts'
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment