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
b86d78c9
Commit
b86d78c9
authored
May 19, 2016
by
Francesc Guasch
Browse files
search domain by id
parent
e0c45443
Changes
5
Hide whitespace changes
Inline
Side-by-side
lib/Ravada.pm
View file @
b86d78c9
...
@@ -151,6 +151,23 @@ sub search_domain {
...
@@ -151,6 +151,23 @@ sub search_domain {
}
}
}
}
=head2 search_domain_by_id
my $domain = $ravada->search_domain_by_id($id);
=cut
sub
search_domain_by_id
{
my
$self
=
shift
;
my
$id
=
shift
;
for
my
$vm
(
@
{
$self
->
vm
})
{
my
$domain
=
$vm
->
search_domain_by_id
(
$id
);
return
$domain
if
$domain
;
}
}
=head2 list_domains
=head2 list_domains
List all created domains
List all created domains
...
...
lib/Ravada/VM.pm
View file @
b86d78c9
...
@@ -15,6 +15,7 @@ requires 'connect';
...
@@ -15,6 +15,7 @@ requires 'connect';
# domain
# domain
requires
'
create_domain
';
requires
'
create_domain
';
requires
'
search_domain
';
requires
'
search_domain
';
requires
'
search_domain_by_id
';
requires
'
list_domains
';
requires
'
list_domains
';
...
...
lib/Ravada/VM/KVM.pm
View file @
b86d78c9
...
@@ -151,6 +151,27 @@ sub search_domain {
...
@@ -151,6 +151,27 @@ sub search_domain {
}
}
}
}
=head2 search_domain_by_id
Returns a domain searching by its id
$domain = $vm->search_domain_by_id($id);
=cut
sub
search_domain_by_id
{
my
$self
=
shift
;
my
$id
=
shift
;
my
$sth
=
$self
->
connector
->
dbh
->
prepare
("
SELECT name FROM domains
"
.
"
WHERE id=?
");
$sth
->
execute
(
$id
);
my
(
$name
)
=
$sth
->
fetchrow
;
return
if
!
$name
;
return
$self
->
search_domain
(
$name
);
}
=head2 list_domains
=head2 list_domains
Returns a list of the created domains
Returns a list of the created domains
...
...
t/20_domain_kvm.t
View file @
b86d78c9
...
@@ -83,6 +83,11 @@ sub test_new_domain {
...
@@ -83,6 +83,11 @@ sub test_new_domain {
my
$row
=
search_domain_db
(
$domain
->
name
);
my
$row
=
search_domain_db
(
$domain
->
name
);
ok
(
$row
->
{
name
}
&&
$row
->
{
name
}
eq
$domain
->
name
,"
I can't find the domain at the db
");
ok
(
$row
->
{
name
}
&&
$row
->
{
name
}
eq
$domain
->
name
,"
I can't find the domain at the db
");
my
$domain2
=
$ravada
->
search_domain_by_id
(
$domain
->
id
);
ok
(
$domain2
->
id
eq
$domain
->
id
,"
Expecting id =
"
.
$domain
->
id
.
"
, got
"
.
$domain2
->
id
);
ok
(
$domain2
->
name
eq
$domain
->
name
,"
Expecting name =
"
.
$domain
->
name
.
"
, got
"
.
$domain2
->
name
);
return
$domain
;
return
$domain
;
}
}
...
...
t/40_auth_sql.t
0 → 100644
View file @
b86d78c9
use
warnings
;
use
strict
;
use
Test::
More
;
use
Test::SQL::
Data
;
my
$test
=
Test::SQL::
Data
->
new
(
config
=>
'
t/etc/ravada.conf
');
use_ok
('
Ravada
');
use_ok
('
Ravada::Auth::SQL
');
ok
(
$
Ravada::Auth::SQL::
CON
,"
Undefined DB connection
");
my
$RAVADA
=
Ravada
->
new
(
connector
=>
$test
->
connector
);
Ravada::Auth::SQL::
add_user
('
test
',
$$
);
my
$sth
=
$$
Ravada::Auth::SQL::
CON
->
dbh
->
prepare
("
SELECT * FROM users WHERE name=?
");
$sth
->
execute
('
test
');
ok
(
$sth
->
fetchrow
,"
I can't find test user in the database
")
or
exit
;
ok
(
Ravada::Auth::SQL::
login
('
test
',
$$
,"
I can't login test/$$
"));
done_testing
();
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