-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support UUID for lxc containers (#307)
* Support UUID for lxc containers: UUID defined as sha1 sum of string containing /etc/machine-id and /etc/hostname contents
- Loading branch information
Showing
3 changed files
with
99 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package FusionInventory::Agent::Tools::Virtualization; | ||
|
||
use strict; | ||
use warnings; | ||
use base 'Exporter'; | ||
|
||
use UNIVERSAL::require; | ||
|
||
use constant STATUS_RUNNING => 'running'; | ||
use constant STATUS_BLOCKED => 'blocked'; | ||
use constant STATUS_IDLE => 'idle'; | ||
use constant STATUS_PAUSED => 'paused'; | ||
use constant STATUS_SHUTDOWN => 'shutdown'; | ||
use constant STATUS_CRASHED => 'crashed'; | ||
use constant STATUS_DYING => 'dying'; | ||
use constant STATUS_OFF => 'off'; | ||
|
||
our @EXPORT = qw( | ||
STATUS_RUNNING STATUS_BLOCKED STATUS_IDLE STATUS_PAUSED | ||
STATUS_SHUTDOWN STATUS_CRASHED STATUS_DYING STATUS_OFF | ||
getVirtualUUID | ||
); | ||
|
||
sub getVirtualUUID { | ||
my $machineid = shift | ||
or return ''; | ||
|
||
my $name = shift | ||
or return ''; | ||
|
||
return '' unless Digest::SHA->use('sha1_hex'); | ||
|
||
return sha1_hex($machineid . $name); | ||
} | ||
|
||
1; |