Few housekeeping changes
- Whitespace cleanup - Removed the 'hardcoded' username and password. Will not throw an error if it is not defined or blank in /etc/pve/storage.cfg for each ZFS via ISCSI definition. - Used a Ternary (Elvis - ?:) Operator for the scheme variable.
This commit is contained in:
parent
32d243b872
commit
42edb8614e
|
|
@ -26,10 +26,8 @@ sub get_base {
|
||||||
sub run_lun_command {
|
sub run_lun_command {
|
||||||
my ($scfg, $timeout, $method, @params) = @_;
|
my ($scfg, $timeout, $method, @params) = @_;
|
||||||
|
|
||||||
# TODO : Move configuration of the storage
|
if(!defined($scfg->{'freenas_user'}) || !defined($scfg->{'freenas_password'})) {
|
||||||
if(!defined($scfg->{'freenas_user'})) {
|
die "Undefined freenas_user and/or freenas_password.";
|
||||||
$scfg->{'freenas_user'} = 'root';
|
|
||||||
$scfg->{'freenas_password'} = '*** password ***';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
syslog("info","FreeNAS::lun_command : $method(@params)");
|
syslog("info","FreeNAS::lun_command : $method(@params)");
|
||||||
|
|
@ -231,19 +229,17 @@ sub run_delete_lu {
|
||||||
sub freenas_api_call {
|
sub freenas_api_call {
|
||||||
my ($scfg, $method, $path, $data) = @_;
|
my ($scfg, $method, $path, $data) = @_;
|
||||||
my $client = undef;
|
my $client = undef;
|
||||||
my $scheme = 'http';
|
my $scheme = $scfg->{freenas_use_ssl} ? "https" : "http";
|
||||||
|
|
||||||
$client = REST::Client->new();
|
$client = REST::Client->new();
|
||||||
if ($scfg->{freenas_use_ssl}) {
|
|
||||||
$scheme = 'https';
|
|
||||||
}
|
|
||||||
$client->setHost($scheme . '://' . $scfg->{portal});
|
$client->setHost($scheme . '://' . $scfg->{portal});
|
||||||
$client->addHeader('Content-Type' , 'application/json');
|
$client->addHeader('Content-Type' , 'application/json');
|
||||||
$client->addHeader('Authorization' , 'Basic ' . encode_base64($scfg->{freenas_user} . ':' . $scfg->{freenas_password}));
|
$client->addHeader('Authorization' , 'Basic ' . encode_base64($scfg->{freenas_user} . ':' . $scfg->{freenas_password}));
|
||||||
# don't verify SSL certs
|
# If using SSL, don't verify SSL certs
|
||||||
|
if ($scfg->{freenas_use_ssl}) {
|
||||||
$client->getUseragent()->ssl_opts(verify_hostname => 0);
|
$client->getUseragent()->ssl_opts(verify_hostname => 0);
|
||||||
$client->getUseragent()->ssl_opts(SSL_verify_mode => SSL_VERIFY_NONE);
|
$client->getUseragent()->ssl_opts(SSL_verify_mode => SSL_VERIFY_NONE);
|
||||||
|
}
|
||||||
if ($method eq 'GET') {
|
if ($method eq 'GET') {
|
||||||
$client->GET($path);
|
$client->GET($path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue