Merge pull request #8 from GNU-tech/master
Support for SSL access to FreeNAS API
This commit is contained in:
		
						commit
						cde040aeca
					
				|  | @ -22,6 +22,8 @@ Please be aware that this enhancment uses the FreeNAS APIs and NOT the ssh/scp l | ||||||
| 1. Execute the following at a console command prompt to active the above | 1. Execute the following at a console command prompt to active the above | ||||||
|     ```bash |     ```bash | ||||||
|     systemctl restart pvedaemon |     systemctl restart pvedaemon | ||||||
|  |     systemctl restart pveproxy | ||||||
|  |     systemctl restart pvestatd | ||||||
|     ``` |     ``` | ||||||
| 
 | 
 | ||||||
| 1. Refresh the Proxmox GUI in your browser to load the new Javascript code.  | 1. Refresh the Proxmox GUI in your browser to load the new Javascript code.  | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ use strict; | ||||||
| use warnings; | use warnings; | ||||||
| use Data::Dumper; | use Data::Dumper; | ||||||
| use PVE::SafeSyslog; | use PVE::SafeSyslog; | ||||||
|  | use IO::Socket::SSL; | ||||||
| 
 | 
 | ||||||
| use REST::Client; | use REST::Client; | ||||||
| use MIME::Base64; | use MIME::Base64; | ||||||
|  | @ -204,11 +205,18 @@ 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'; | ||||||
| 
 | 
 | ||||||
|     $client = REST::Client->new(); |     $client = REST::Client->new(); | ||||||
|     $client->setHost('http://'.  $scfg->{portal}); |     if ($scfg->{freenas_use_ssl}) { | ||||||
|  |         $scheme = 'https'; | ||||||
|  |     } | ||||||
|  |     $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 | ||||||
|  |     $client->getUseragent()->ssl_opts(verify_hostname => 0); | ||||||
|  |     $client->getUseragent()->ssl_opts(SSL_verify_mode => SSL_VERIFY_NONE ); | ||||||
| 
 | 
 | ||||||
|     if ($method eq 'GET') { |     if ($method eq 'GET') { | ||||||
|         $client->GET($path); |         $client->GET($path); | ||||||
|  |  | ||||||
|  | @ -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,14 @@
 | @@ -173,6 +178,18 @@
 | ||||||
|  	    description => "iscsi provider", |  	    description => "iscsi provider", | ||||||
|  	    type => 'string', |  	    type => 'string', | ||||||
|  	}, |  	}, | ||||||
|  | @ -46,16 +46,21 @@ | ||||||
| +	freenas_password => {
 | +	freenas_password => {
 | ||||||
| +	    description => "FreeNAS API Password",
 | +	    description => "FreeNAS API Password",
 | ||||||
| +	    type => 'string',
 | +	    type => 'string',
 | ||||||
|  | +	},
 | ||||||
|  | +	freenas_use_ssl => {
 | ||||||
|  | +	    description => "FreeNAS API access via SSL",
 | ||||||
|  | +	    type => 'boolean',
 | ||||||
| +	},
 | +	},
 | ||||||
|  	# 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 +217,8 @@
 | @@ -204,6 +221,9 @@
 | ||||||
|  	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 },
 | ||||||
|  	content => { optional => 1 }, |  	content => { optional => 1 }, | ||||||
|  	bwlimit => { optional => 1 }, |  	bwlimit => { optional => 1 }, | ||||||
|      }; |      }; | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| --- /usr/share/pve-docs/api-viewer/apidoc.js.orig	2018-06-04 12:08:17.416780601 +0800
 | --- /usr/share/pve-docs/api-viewer/apidoc.js.orig	2018-06-04 12:08:17.416780601 +0800
 | ||||||
| +++ /usr/share/pve-docs/api-viewer/apidoc.js	2018-06-04 12:07:28.073832212 +0800
 | +++ /usr/share/pve-docs/api-viewer/apidoc.js	2018-06-04 12:07:28.073832212 +0800
 | ||||||
| @@ -27549,6 +27549,18 @@
 | @@ -27549,6 +27549,24 @@
 | ||||||
|                             "type" : "string", |                             "type" : "string", | ||||||
|                             "typetext" : "<string>" |                             "typetext" : "<string>" | ||||||
|                          }, |                          }, | ||||||
|  | @ -15,15 +15,20 @@ | ||||||
| +                           "optional" : 1,
 | +                           "optional" : 1,
 | ||||||
| +                           "type" : "string",
 | +                           "type" : "string",
 | ||||||
| +                           "typetext" : "<string>"
 | +                           "typetext" : "<string>"
 | ||||||
|  | +                        },
 | ||||||
|  | +                        "freenas_use_ssl" : {
 | ||||||
|  | +                           "description" : "FreeNAS API access via SSL",
 | ||||||
|  | +                           "optional" : 1,
 | ||||||
|  | +                           "type" : "boolean",
 | ||||||
|  | +                           "typetext" : "<boolean>"
 | ||||||
| +                        },
 | +                        },
 | ||||||
|                          "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", | ||||||
| @@ -27895,6 +27907,18 @@
 | @@ -27896,6 +27914,24 @@
 | ||||||
|                       "optional" : 1, |  | ||||||
|                       "type" : "string", |                       "type" : "string", | ||||||
|                       "typetext" : "<string>" |                       "typetext" : "<string>" | ||||||
| +                  },
 |                    }, | ||||||
| +                  "freenas_user" : {
 | +                  "freenas_user" : {
 | ||||||
| +                     "description" : "FreeNAS user for API calls",
 | +                     "description" : "FreeNAS user for API calls",
 | ||||||
| +                     "optional" : 1,
 | +                     "optional" : 1,
 | ||||||
|  | @ -35,6 +40,13 @@ | ||||||
| +                     "optional" : 1,
 | +                     "optional" : 1,
 | ||||||
| +                     "type" : "string",
 | +                     "type" : "string",
 | ||||||
| +                     "typetext" : "<string>"
 | +                     "typetext" : "<string>"
 | ||||||
|                    }, | +                  },
 | ||||||
|  | +                  "freenas_use_ssl" : {
 | ||||||
|  | +                     "description" : "FreeNAS API access via SSL",
 | ||||||
|  | +                     "optional" : 1,
 | ||||||
|  | +                     "type" : "boolean",
 | ||||||
|  | +                     "typetext" : "<boolean>"
 | ||||||
|  | +                  },
 | ||||||
|                    "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,6 +1,6 @@ | ||||||
| --- /usr/share/pve-manager/js/pvemanagerlib.js.orig	2018-06-04 11:21:26.419121310 +0800
 | --- /usr/share/pve-manager/js/pvemanagerlib.js.orig	2018-06-04 11:21:26.419121310 +0800
 | ||||||
| +++ /usr/share/pve-manager/js/pvemanagerlib.js	2018-06-04 11:52:58.628592707 +0800
 | +++ /usr/share/pve-manager/js/pvemanagerlib.js	2018-06-04 11:52:58.628592707 +0800
 | ||||||
| @@ -5303,6 +5303,7 @@
 | @@ -5356,6 +5356,7 @@
 | ||||||
|      alias: ['widget.pveiScsiProviderSelector'], |      alias: ['widget.pveiScsiProviderSelector'], | ||||||
|      comboItems: [ |      comboItems: [ | ||||||
|  	['comstar', 'Comstar'], |  	['comstar', 'Comstar'], | ||||||
|  | @ -8,7 +8,7 @@ | ||||||
|  	[ 'istgt', 'istgt'], |  	[ 'istgt', 'istgt'], | ||||||
|  	[ 'iet', 'IET'] |  	[ 'iet', 'IET'] | ||||||
|      ] |      ] | ||||||
| @@ -27145,6 +27146,13 @@
 | @@ -27343,6 +27344,27 @@
 | ||||||
|  		value: '', |  		value: '', | ||||||
|  		fieldLabel: gettext('Target group'), |  		fieldLabel: gettext('Target group'), | ||||||
|  		allowBlank: true |  		allowBlank: true | ||||||
|  | @ -19,13 +19,6 @@ | ||||||
| +		value: '',
 | +		value: '',
 | ||||||
| +		fieldLabel: gettext('FreeNAS User'),
 | +		fieldLabel: gettext('FreeNAS User'),
 | ||||||
| +		allowBlank: true
 | +		allowBlank: true
 | ||||||
|  	    } |  | ||||||
|  	]; |  | ||||||
|   |  | ||||||
| @@ -27176,6 +27184,13 @@
 |  | ||||||
|  		value: '', |  | ||||||
|  		fieldLabel: gettext('Host group'), |  | ||||||
|  		allowBlank: true |  | ||||||
| +	    },
 | +	    },
 | ||||||
| +	    {
 | +	    {
 | ||||||
| +		xtype: me.isCreate ? 'textfield' : 'displayfield',
 | +		xtype: me.isCreate ? 'textfield' : 'displayfield',
 | ||||||
|  | @ -33,6 +26,13 @@ | ||||||
| +		value: '',
 | +		value: '',
 | ||||||
| +		fieldLabel: gettext('FreeNAS Password'),
 | +		fieldLabel: gettext('FreeNAS Password'),
 | ||||||
| +		allowBlank: true
 | +		allowBlank: true
 | ||||||
|  | +	    },
 | ||||||
|  | +	    {
 | ||||||
|  | +		xtype: 'proxmoxcheckbox',
 | ||||||
|  | +		name: 'freenas_use_ssl',
 | ||||||
|  | +		checked: false,
 | ||||||
|  | +		uncheckedValue: 0,
 | ||||||
|  | +		fieldLabel: gettext('FreeNAS API use SSL')
 | ||||||
|  	    } |  	    } | ||||||
|  	]; |  	]; | ||||||
|   |   | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue