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
bfcb8f0a
Unverified
Commit
bfcb8f0a
authored
May 03, 2021
by
Francesc Guasch
Committed by
GitHub
May 03, 2021
Browse files
feat(frontend): show network interfaces hw address (#1539)
issue #1534
parent
90348489
Changes
5
Hide whitespace changes
Inline
Side-by-side
lib/Ravada.pm
View file @
bfcb8f0a
...
...
@@ -1587,7 +1587,7 @@ sub _upgrade_tables {
$self
->
_upgrade_table
('
domains
','
status
','
varchar(32) DEFAULT "shutdown"
');
$self
->
_upgrade_table
('
domains
','
display
','
text
');
$self
->
_upgrade_table
('
domains
','
display_file
','
text DEFAULT NULL
');
$self
->
_upgrade_table
('
domains
','
info
','
varchar(255)
DEFAULT NULL
');
$self
->
_upgrade_table
('
domains
','
info
','
TEXT
DEFAULT NULL
');
$self
->
_upgrade_table
('
domains
','
internal_id
','
varchar(64) DEFAULT NULL
');
$self
->
_upgrade_table
('
domains
','
id_vm
','
int default null
');
$self
->
_upgrade_table
('
domains
','
volatile_clones
','
int NOT NULL default 0
');
...
...
lib/Ravada/Domain/KVM.pm
View file @
bfcb8f0a
...
...
@@ -1413,7 +1413,16 @@ sub get_info {
$info
->
{
cpu_time
}
=
$info
->
{
cpuTime
};
$info
->
{
n_virt_cpu
}
=
$info
->
{
nrVirtCpu
};
confess
Dumper
(
$info
)
if
!
$info
->
{
n_virt_cpu
};
$info
->
{
ip
}
=
$self
->
ip
()
if
$self
->
is_active
();
if
(
$self
->
is_active
()
)
{
$info
->
{
ip
}
=
$self
->
ip
();
my
@interfaces
;
eval
{
@interfaces
=
$self
->
domain
->
get_interface_addresses
(
Sys::Virt::Domain::
INTERFACE_ADDRESSES_SRC_LEASE
)
};
my
@interfaces2
;
eval
{
@interfaces2
=
$self
->
domain
->
get_interface_addresses
(
Sys::Virt::Domain::
INTERFACE_ADDRESSES_SRC_AGENT
)
};
@interfaces
=
@interfaces2
if
!
scalar
(
@interfaces
);
$info
->
{
interfaces
}
=
\
@interfaces
;
}
lock_keys
(
%$info
);
return
$info
;
...
...
lib/Ravada/Domain/Void.pm
View file @
bfcb8f0a
...
...
@@ -524,6 +524,13 @@ sub get_info {
return
$info
;
}
sub
_new_mac
($mac='ff:54:00:a7:49:71') {
my
$num
=
sprintf
"
%02X
",
rand
(
0xff
);
my
@macparts
=
split
/:/
,
$mac
;
$macparts
[
5
]
=
$num
;
return
join
("
:
",
@macparts
);
}
sub
_set_default_info
($self, $listen_ip=undef) {
my
$info
=
{
max_mem
=>
512
*
1024
...
...
@@ -532,6 +539,7 @@ sub _set_default_info($self, $listen_ip=undef) {
,
n_virt_cpu
=>
1
,
state
=>
'
UNKNOWN
'
,
ip
=>
'
1.1.1.
'
.
int
(
rand
(
254
)
+
1
)
,
mac
=>
_new_mac
()
,
time
=>
time
};
$self
->
_store
(
info
=>
$info
);
...
...
@@ -541,6 +549,10 @@ sub _set_default_info($self, $listen_ip=undef) {
next
if
$name
eq
'
disk
';
$self
->
set_controller
(
$name
,
2
);
}
$info
->
{
interfaces
}
->
[
0
]
=
{
hwaddress
=>
$info
->
{
mac
}
,
address
=>
$info
->
{
ip
}
};
return
$info
;
}
...
...
t/vm/92_ports.t
View file @
bfcb8f0a
...
...
@@ -704,6 +704,32 @@ sub _iptables_save($vm,$table=undef,$chain=undef) {
return
@out
;
}
sub
test_interfaces
($vm) {
my
$domain
=
$BASE
->
clone
(
name
=>
new_domain_name
,
user
=>
user_admin
);
$domain
->
start
(
remote_ip
=>
'
10.1.1.2
',
user
=>
user_admin
);
_wait_ip2
(
$vm
,
$domain
);
my
$info
=
$domain
->
info
(
user_admin
);
my
$domain_f
=
Ravada::Front::
Domain
->
open
(
$domain
->
id
);
my
$info_f
=
$domain_f
->
info
(
user_admin
);
ok
(
exists
$info_f
->
{
ip
},"
Expecting ip in front domain info
");
is
(
$info_f
->
{
ip
},
$domain
->
ip
);
ok
(
$info_f
->
{
interfaces
},"
Expecting interfaces on
"
.
$domain
->
_vm
->
type
)
and
isa_ok
(
$info_f
->
{
interfaces
},"
ARRAY
","
Expecting mac address is a list
")
and
do
{
my
$found
=
0
;
for
my
$if
(
@
{
$info_f
->
{
interfaces
}})
{
$found
++
;
like
(
$if
->
{
hwaddr
},
qr/^[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]/
);
}
ok
(
$found
,"
Expecting some interfaces, found=
$found
")
or
exit
;
};
$domain
->
remove
(
user_admin
);
}
sub
test_redirect_ip_duplicated
($vm) {
diag
("
Test redirect ip duplicated
"
.
$vm
->
type
);
my
$internal_port
=
22
;
...
...
@@ -905,6 +931,7 @@ sub test_clone_exports_add_ports($vm) {
}
sub
_wait_ip2
($vm_name, $domain) {
$domain
->
start
(
user
=>
user_admin
,
remote_ip
=>
'
1.2.3.5
')
unless
$domain
->
is_active
();
for
(
1
..
22
)
{
return
$domain
->
ip
if
$domain
->
ip
;
diag
("
Waiting for
"
.
$domain
->
name
.
"
ip
")
if
!
(
time
%
10
);
...
...
@@ -1316,6 +1343,8 @@ for my $vm_name ( 'KVM', 'Void' ) {
flush_rules
()
if
!
$<
;
import_base
(
$vm
);
test_interfaces
(
$vm
);
test_redirect_ip_duplicated
(
$vm
);
test_open_port_duplicated
(
$vm
);
test_close_port
(
$vm
);
...
...
templates/main/run_request.html.ep
View file @
bfcb8f0a
...
...
@@ -56,6 +56,7 @@
<li><b>
Internal IP:
</b><span
ng-show=
"domain.ip"
>
{{domain.ip}}
</span>
<span
ng-hide=
"domain.ip"
><i>
waiting for network to come up
</i></span>
</li>
<li
ng-show=
"domain.interfaces"
><b>
Hardware address
</b>
{{domain.interfaces[0].hwaddr}}
</li>
<li><b>
Max Memory:
</b>
{{domain.max_mem}}
</li>
<li><b>
Memory:
</b>
{{domain.memory}}
</li>
<li><b>
CPUs:
</b>
{{domain.nrVirtCpu}}
</li>
...
...
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