Fixed pull request to support FreeNAS, TrueNAS-CORE and TrueNAS-SCALE.

- Adjusted Regex to parse the current TrueNAS-SCALE product and
versioning. Also changed the FreeNAS and TrueNAS so releases will be a
variable (e.g. - U, BETA, RC, MASTER)
- Used the $product_name to change use either a slash (/) for
FreeNAS/TrueNAS-CORE and a dash (-) for FreeNAS-SCALE.
This commit is contained in:
Kevin Scott Adams 2020-09-24 12:32:19 -04:00
parent 9aa40c7d7d
commit 084faf9903
1 changed files with 4 additions and 5 deletions

View File

@ -399,11 +399,11 @@ sub freenas_api_check {
$result->{'fullversion'} =~ s/^"//g;
}
syslog("info", (caller(0))[3] . " : successful : Server version: " . $result->{'fullversion'});
$result->{'fullversion'} =~ /^(\w+(?:-\w+)?)\-(\d+)\.(\d+)/;
my $freenas_version = sprintf("%02d%02d", $2, $3 || 0);
$result->{'fullversion'} =~ s/^((?!\-\d).*)\-(\d+)\.(\d+)\-([A-Za-z]*)(?(?=\-)\-(\d*)\-(\d*)|(\d?)\.?(\d?))//;
$product_name = $1;
my $freenas_version = sprintf("%02d%02d%02d%02d", $2, $3 || 0, $7 || 0, $8 || 0);
syslog("info", (caller(0))[3] . " : ". $product_name . " Unformatted Version: " . $freenas_version);
if ($freenas_version >= 1103) {
if ($freenas_version >= 11030100) {
$freenas_api_version = "v2.0";
$dev_prefix = "/dev/";
}
@ -510,8 +510,7 @@ sub freenas_iscsi_create_extent {
my $name = $lun_path;
$name =~ s/^.*\///; # all from last /
$name = $scfg->{'pool'} . '/' . $name;
$name =~ s/\//-/; # replace / to -
$name = $scfg->{'pool'} . ($product_name eq "TrueNAS-SCALE" ? '-' : '/') . $name;
my $device = $lun_path;
$device =~ s/^\/dev\///; # strip /dev/