Commit f9e0f65d authored by Francesc Guasch's avatar Francesc Guasch Committed by Francesc Guasch
Browse files

[#575] new field internal id

parent 341f25c8
......@@ -803,6 +803,7 @@ sub _upgrade_tables {
$self->_upgrade_table('domains','status','varchar(32) DEFAULT "shutdown"');
$self->_upgrade_table('domains','display','varchar(128) DEFAULT NULL');
$self->_upgrade_table('domains','info','varchar(255) DEFAULT NULL');
$self->_upgrade_table('domains','internal_id','varchar(64) DEFAULT NULL');
$self->_upgrade_table('domains_network','allowed','int not null default 1');
......
......@@ -726,6 +726,12 @@ sub _insert_db {
}
$sth->finish;
$sth = $$CONNECTOR->dbh->prepare(
"UPDATE domains set internal_id=? "
." WHERE id=?"
);
$sth->execute($self->internal_id, $self->id);
$sth->finish;
}
=head2 pre_remove
......@@ -1812,4 +1818,25 @@ sub _pre_clone($self,%args) {
confess "ERROR: Unknown arguments ".join(",",sort keys %args) if keys %args;
}
=head2 file_screenshot
Returns the name of the file where the virtual machine screenshot is stored
=cut
sub file_screenshot($self){
return $self->_data('file_screenshot');
}
=head2 internal_id
Returns the internal id of this domain as found in its Virtual Manager connection
=cut
sub internal_id {
my $self = shift;
return $self->id;
}
1;
......@@ -1614,4 +1614,8 @@ sub is_removed($self) {
return 0;
}
sub internal_id($self) {
return $self->domain->get_id();
}
1;
......@@ -18,6 +18,7 @@ CREATE TABLE `domains` (
`status` varchar(32) default 'shutdown',
`display` varchar(128) default NULL,
`info` varchar(255) default NULL,
`internal_id` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_base` (`id_base`,`name`),
UNIQUE KEY `name` (`name`)
......
......@@ -18,6 +18,7 @@ CREATE TABLE `domains` (
, `status` varchar(32) default 'shutdown'
, `display` varchar(128) default NULL
, `info` varchar(255) default NULL
, `internal_id` varchar(64) DEFAULT NULL
, UNIQUE (`id_base`,`name`)
, UNIQUE (`name`)
);
......@@ -77,6 +77,12 @@ sub test_create_domain {
." for VM $vm_name"
);
if ($vm_name eq 'KVM') {
is($domain->internal_id, $domain->domain->get_id);
} else {
ok($domain->internal_id);
}
for my $dom2 ( $vm->list_domains ) {
is(ref($dom2),ref($domain)) if $vm_name ne 'Void';
}
......
Supports Markdown
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