Skip to content

Instantly share code, notes, and snippets.

@robinsmidsrod
Last active December 10, 2015 10:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinsmidsrod/4419556 to your computer and use it in GitHub Desktop.
Save robinsmidsrod/4419556 to your computer and use it in GitHub Desktop.
Some Enterprise-grade HP servers seems to identify with the wrong UUID to iPXE.
#!perl
use strict;
use warnings;
use Test::More;
my $actual_uuid = '1F00B3E0-00C6-0800-2C4A-BCAEC5280EAD';
my $ipxe_uuid = 'e0b3001f-c600-0008-2c4a-bcaec5280ead';
is( convert_ipxe_uuid($ipxe_uuid), $actual_uuid, "iPXE UUID converted successfully" );
done_testing();
exit;
sub convert_ipxe_uuid {
my ($ipxe_uuid) = @_;
my @parts = split /-/, uc $ipxe_uuid;
$parts[0] = reverse_hex($parts[0]);
$parts[1] = reverse_hex($parts[1]);
$parts[2] = reverse_hex($parts[2]);
return uc join("-", @parts);
}
sub reverse_hex {
my ($hex_str) = @_;
return unpack("H*",
join("",
reverse
split("",
pack("H*", $hex_str)
)
)
);
}
@robinsmidsrod
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment