Added API Host
- This change allows the API traffic to be on a different interface then the iSCSI Provider interface. This allows the selection of the FreeNAS WebGUI address for HTTP/HTTPS to be on a specific interface instead of "ALL" (0.0.0.0) interfaces. If the API Host is not defined then the API traffic will default to the iSCSI Provider interface.
This commit is contained in:
parent
3f6059e75f
commit
94d897f7d1
|
|
@ -230,10 +230,11 @@ sub freenas_api_call {
|
||||||
my ($scfg, $method, $path, $data) = @_;
|
my ($scfg, $method, $path, $data) = @_;
|
||||||
my $client = undef;
|
my $client = undef;
|
||||||
my $scheme = $scfg->{freenas_use_ssl} ? "https" : "http";
|
my $scheme = $scfg->{freenas_use_ssl} ? "https" : "http";
|
||||||
|
my $apihost = defined($scfg->{freenas_apiv4_host}) ? $scfg->{freenas_apiv4_host} : $scfg->{portal};
|
||||||
my $apiping = '/api/v1.0/system/version/';
|
my $apiping = '/api/v1.0/system/version/';
|
||||||
|
|
||||||
$client = REST::Client->new();
|
$client = REST::Client->new();
|
||||||
$client->setHost($scheme . '://' . $scfg->{portal});
|
$client->setHost($scheme . '://' . $apihost);
|
||||||
$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}));
|
||||||
# If using SSL, don't verify SSL certs
|
# If using SSL, don't verify SSL certs
|
||||||
|
|
@ -241,12 +242,13 @@ sub freenas_api_call {
|
||||||
$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);
|
||||||
}
|
}
|
||||||
# Check if the API is working via the selected scheme
|
# Check if the APIs are accessable via the selected host and scheme
|
||||||
my $code = $client->request('GET', $apiping)->responseCode();
|
my $code = $client->request('GET', $apiping)->responseCode();
|
||||||
if ($code != 200) {
|
if ($code != 200) {
|
||||||
freenas_api_log_error($client, "freenas_api_call");
|
freenas_api_log_error($client, "freenas_api_call");
|
||||||
die "Unable to connect to the FreeNAS API service at '" . $scfg->{portal} . "' using '" . $scheme . "' protocol";
|
die "Unable to connect to the FreeNAS API service at '" . $apihost . "' using the '" . $scheme . "' protocol";
|
||||||
}
|
}
|
||||||
|
syslog("info","FreeNAS::api_call : setup : sucessfull");
|
||||||
if ($method eq 'GET') {
|
if ($method eq 'GET') {
|
||||||
$client->GET($path);
|
$client->GET($path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
--- /usr/share/perl5/PVE/Storage/ZFSPlugin.pm.orig 2018-06-04 11:59:59.851426278 +0800
|
--- ZFSPlugin.pm.orig 2018-05-16 04:06:14.000000000 -0400
|
||||||
+++ /usr/share/perl5/PVE/Storage/ZFSPlugin.pm 2018-06-04 12:04:56.781049166 +0800
|
+++ ZFSPlugin.pm 2018-08-19 09:34:25.169349056 -0400
|
||||||
@@ -10,6 +10,7 @@
|
@@ -10,6 +10,7 @@
|
||||||
|
|
||||||
use base qw(PVE::Storage::ZFSPoolPlugin);
|
use base qw(PVE::Storage::ZFSPoolPlugin);
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
} elsif ($scfg->{iscsiprovider} eq 'istgt') {
|
} elsif ($scfg->{iscsiprovider} eq 'istgt') {
|
||||||
$msg = PVE::Storage::LunCmd::Istgt::run_lun_command($scfg, $timeout, $method, @params);
|
$msg = PVE::Storage::LunCmd::Istgt::run_lun_command($scfg, $timeout, $method, @params);
|
||||||
} elsif ($scfg->{iscsiprovider} eq 'iet') {
|
} elsif ($scfg->{iscsiprovider} eq 'iet') {
|
||||||
@@ -173,6 +178,18 @@
|
@@ -173,6 +178,22 @@
|
||||||
description => "iscsi provider",
|
description => "iscsi provider",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
|
|
@ -50,17 +50,22 @@
|
||||||
+ freenas_use_ssl => {
|
+ freenas_use_ssl => {
|
||||||
+ description => "FreeNAS API access via SSL",
|
+ description => "FreeNAS API access via SSL",
|
||||||
+ type => 'boolean',
|
+ type => 'boolean',
|
||||||
|
+ },
|
||||||
|
+ freenas_apiv4_host => {
|
||||||
|
+ description => "FreeNAS API Host",
|
||||||
|
+ type => 'string',
|
||||||
+ },
|
+ },
|
||||||
# this will disable write caching on comstar and istgt.
|
# this will disable write caching on comstar and istgt.
|
||||||
# it is not implemented for iet. iet blockio always operates with
|
# it is not implemented for iet. iet blockio always operates with
|
||||||
# writethrough caching when not in readonly mode
|
# writethrough caching when not in readonly mode
|
||||||
@@ -204,6 +221,9 @@
|
@@ -204,6 +225,10 @@
|
||||||
sparse => { optional => 1 },
|
sparse => { optional => 1 },
|
||||||
comstar_hg => { optional => 1 },
|
comstar_hg => { optional => 1 },
|
||||||
comstar_tg => { optional => 1 },
|
comstar_tg => { optional => 1 },
|
||||||
+ freenas_user => { optional => 1 },
|
+ freenas_user => { optional => 1 },
|
||||||
+ freenas_password => { optional => 1 },
|
+ freenas_password => { optional => 1 },
|
||||||
+ freenas_use_ssl => { optional => 1 },
|
+ freenas_use_ssl => { optional => 1 },
|
||||||
|
+ freenas_apiv4_host => { optional => 1 },
|
||||||
content => { optional => 1 },
|
content => { optional => 1 },
|
||||||
bwlimit => { optional => 1 },
|
bwlimit => { optional => 1 },
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
--- apidoc.js 2018-07-10 06:05:33.000000000 -0400
|
--- apidoc.js.orig 2018-08-19 10:18:11.715767285 -0400
|
||||||
+++ apidoc.js.new 2018-07-30 22:21:11.479045222 -0400
|
+++ apidoc.js.new 2018-08-19 10:17:09.364282178 -0400
|
||||||
@@ -27584,6 +27584,24 @@
|
@@ -27584,6 +27584,31 @@
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
"typetext" : "<string>"
|
"typetext" : "<string>"
|
||||||
},
|
},
|
||||||
|
|
@ -21,14 +21,22 @@
|
||||||
+ "optional" : 1,
|
+ "optional" : 1,
|
||||||
+ "type" : "boolean",
|
+ "type" : "boolean",
|
||||||
+ "typetext" : "<boolean>"
|
+ "typetext" : "<boolean>"
|
||||||
|
+ },
|
||||||
|
+ "freenas_apiv4_host" : {
|
||||||
|
+ "description" : "FreeNAS API Host via IPv4",
|
||||||
|
+ "format" : "address",
|
||||||
|
+ "optional" : 1,
|
||||||
|
+ "type" : "string",
|
||||||
|
+ "typetext" : "<string>"
|
||||||
+ },
|
+ },
|
||||||
"content" : {
|
"content" : {
|
||||||
"description" : "Allowed content types.\n\nNOTE: the value 'rootdir' is used for Containers, and value 'images' for VMs.\n",
|
"description" : "Allowed content types.\n\nNOTE: the value 'rootdir' is used for Containers, and value 'images' for VMs.\n",
|
||||||
"format" : "pve-storage-content-list",
|
"format" : "pve-storage-content-list",
|
||||||
@@ -27949,6 +27967,24 @@
|
@@ -27948,6 +27973,31 @@
|
||||||
|
"optional" : 1,
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
"typetext" : "<string>"
|
"typetext" : "<string>"
|
||||||
},
|
+ },
|
||||||
+ "freenas_user" : {
|
+ "freenas_user" : {
|
||||||
+ "description" : "FreeNAS user for API access",
|
+ "description" : "FreeNAS user for API access",
|
||||||
+ "optional" : 1,
|
+ "optional" : 1,
|
||||||
|
|
@ -47,6 +55,12 @@
|
||||||
+ "type" : "boolean",
|
+ "type" : "boolean",
|
||||||
+ "typetext" : "<boolean>"
|
+ "typetext" : "<boolean>"
|
||||||
+ },
|
+ },
|
||||||
|
+ "freenas_apiv4_host" : {
|
||||||
|
+ "description" : "FreeNAS API Host via IPv4",
|
||||||
|
+ "format" : "address",
|
||||||
|
+ "optional" : 1,
|
||||||
|
+ "type" : "string",
|
||||||
|
+ "typetext" : "<string>"
|
||||||
|
},
|
||||||
"content" : {
|
"content" : {
|
||||||
"description" : "Allowed content types.\n\nNOTE: the value 'rootdir' is used for Containers, and value 'images' for VMs.\n",
|
"description" : "Allowed content types.\n\nNOTE: the value 'rootdir' is used for Containers, and value 'images' for VMs.\n",
|
||||||
"format" : "pve-storage-content-list",
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
--- pvemanagerlib.js 2018-07-10 08:46:32.000000000 -0400
|
--- pvemanagerlib.js.orig 2018-07-30 23:13:28.045035059 -0400
|
||||||
+++ pvemanagerlib.js.new 2018-07-30 22:19:23.207915760 -0400
|
+++ pvemanagerlib.js.new 2018-08-19 10:42:58.494724196 -0400
|
||||||
@@ -5379,6 +5379,7 @@
|
@@ -5379,6 +5379,7 @@
|
||||||
alias: ['widget.pveiScsiProviderSelector'],
|
alias: ['widget.pveiScsiProviderSelector'],
|
||||||
comboItems: [
|
comboItems: [
|
||||||
|
|
@ -8,10 +8,19 @@
|
||||||
[ 'istgt', 'istgt'],
|
[ 'istgt', 'istgt'],
|
||||||
[ 'iet', 'IET']
|
[ 'iet', 'IET']
|
||||||
]
|
]
|
||||||
@@ -27361,6 +27362,30 @@
|
@@ -27361,7 +27362,23 @@
|
||||||
value: '',
|
value: '',
|
||||||
fieldLabel: gettext('Target group'),
|
fieldLabel: gettext('Target group'),
|
||||||
allowBlank: true
|
allowBlank: true
|
||||||
|
- }
|
||||||
|
+ },
|
||||||
|
+ {
|
||||||
|
+ xtype: 'proxmoxcheckbox',
|
||||||
|
+ name: 'freenas_use_ssl',
|
||||||
|
+ checked: false,
|
||||||
|
+ uncheckedValue: 0,
|
||||||
|
+ hidden: me.iscsiprovider !== "freenas",
|
||||||
|
+ fieldLabel: gettext('FreeNAS API use SSL')
|
||||||
+ },
|
+ },
|
||||||
+ {
|
+ {
|
||||||
+ xtype: me.isCreate ? 'textfield' : 'displayfield',
|
+ xtype: me.isCreate ? 'textfield' : 'displayfield',
|
||||||
|
|
@ -21,25 +30,10 @@
|
||||||
+ fieldLabel: gettext('FreeNAS User'),
|
+ fieldLabel: gettext('FreeNAS User'),
|
||||||
+ allowBlank: true
|
+ allowBlank: true
|
||||||
+ },
|
+ },
|
||||||
+ {
|
|
||||||
+ xtype: me.isCreate ? 'textfield' : 'displayfield',
|
|
||||||
+ name: 'freenas_password',
|
|
||||||
+ value: '',
|
|
||||||
+ hidden: me.iscsiprovider !== "freenas",
|
|
||||||
+ fieldLabel: gettext('FreeNAS Password'),
|
|
||||||
+ allowBlank: true
|
|
||||||
+ },
|
|
||||||
+ {
|
|
||||||
+ xtype: 'proxmoxcheckbox',
|
|
||||||
+ name: 'freenas_use_ssl',
|
|
||||||
+ checked: false,
|
|
||||||
+ uncheckedValue: 0,
|
|
||||||
+ hidden: me.iscsiprovider !== "freenas",
|
|
||||||
+ fieldLabel: gettext('FreeNAS API use SSL')
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -27370,7 +27395,23 @@
|
me.column2 = [
|
||||||
|
@@ -27370,7 +27387,26 @@
|
||||||
name: 'iscsiprovider',
|
name: 'iscsiprovider',
|
||||||
value: 'comstar',
|
value: 'comstar',
|
||||||
fieldLabel: gettext('iSCSI Provider'),
|
fieldLabel: gettext('iSCSI Provider'),
|
||||||
|
|
@ -48,19 +42,45 @@
|
||||||
+ listeners: {
|
+ listeners: {
|
||||||
+ change: function(f, value) {
|
+ change: function(f, value) {
|
||||||
+ if (value === "freenas") {
|
+ if (value === "freenas") {
|
||||||
|
+ me.down('field[name=freenas_use_ssl]').setHidden(false);
|
||||||
|
+ me.down('field[name=freenas_apiv4_host]').setHidden(false);
|
||||||
+ me.down('field[name=freenas_user]').setHidden(false);
|
+ me.down('field[name=freenas_user]').setHidden(false);
|
||||||
+ me.down('field[name=freenas_password]').setHidden(false);
|
+ me.down('field[name=freenas_password]').setHidden(false);
|
||||||
+ me.down('field[name=freenas_use_ssl]').setHidden(false);
|
|
||||||
+ } else {
|
+ } else {
|
||||||
|
+ me.down('field[name=freenas_use_ssl]').setHidden(true);
|
||||||
|
+ me.down('field[name=freenas_use_ssl]').setValue(false);
|
||||||
|
+ me.down('field[name=freenas_apiv4_host]').setHidden(true);
|
||||||
|
+ me.down('field[name=freenas_apiv4_host]').setValue(false);
|
||||||
+ me.down('field[name=freenas_user]').setHidden(true);
|
+ me.down('field[name=freenas_user]').setHidden(true);
|
||||||
+ me.down('field[name=freenas_user]').setValue('');
|
+ me.down('field[name=freenas_user]').setValue('');
|
||||||
+ me.down('field[name=freenas_password]').setHidden(true);
|
+ me.down('field[name=freenas_password]').setHidden(true);
|
||||||
+ me.down('field[name=freenas_password]').setValue('');
|
+ me.down('field[name=freenas_password]').setValue('');
|
||||||
+ me.down('field[name=freenas_use_ssl]').setHidden(true);
|
|
||||||
+ me.down('field[name=freenas_use_ssl]').setValue(false);
|
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype: 'proxmoxcheckbox',
|
xtype: 'proxmoxcheckbox',
|
||||||
|
@@ -27392,6 +27428,22 @@
|
||||||
|
value: '',
|
||||||
|
fieldLabel: gettext('Host group'),
|
||||||
|
allowBlank: true
|
||||||
|
+ },
|
||||||
|
+ {
|
||||||
|
+ xtype: me.isCreate ? 'textfield' : 'displayfield',
|
||||||
|
+ name: 'freenas_apiv4_host',
|
||||||
|
+ value: '',
|
||||||
|
+ hidden: me.iscsiprovider !== "freenas",
|
||||||
|
+ fieldLabel: gettext('API IPv4 Host'),
|
||||||
|
+ allowBlank: true
|
||||||
|
+ },
|
||||||
|
+ {
|
||||||
|
+ xtype: me.isCreate ? 'textfield' : 'displayfield',
|
||||||
|
+ name: 'freenas_password',
|
||||||
|
+ value: '',
|
||||||
|
+ hidden: me.iscsiprovider !== "freenas",
|
||||||
|
+ fieldLabel: gettext('FreeNAS Password'),
|
||||||
|
+ allowBlank: true
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue