Need help on making my own Plugin work in FreeNAS

Status
Not open for further replies.
P

Patrick_Q

Guest
I just started to work on making my own plugin and gave the first shot on existing btsync and plexmediaserver.

I can successfully compiled pbi files on those and they can be uploaded and installed onto FreeNAS 9.3 but the thing is once I clicked the status switch button both of the two plugins didn't work with "No JSON object could be decoded" error message shown in system log:

upload_2015-4-17_21-32-29.png


Can anyone help me with it?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,996
There is a posting somewhere around here from about 2 weeks ago stating that plugins will be changing and for the better so it will be easier to create them. I don't know when that will occur, possibly with FreeNAS 10 but you may be better off waiting for that time. I've tried to build plugins before and failed.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I just started to work on making my own plugin and gave the first shot on existing btsync and plexmediaserver.

I can successfully compiled pbi files on those and they can be uploaded and installed onto FreeNAS 9.3 but the thing is once I clicked the status switch button both of the two plugins didn't work with "No JSON object could be decoded" error message shown in system log:

View attachment 7455

Can anyone help me with it?
sounds like the Python api has an error or isn't running. try browsing to the path in the error, sometimes a useful error is shown.

I don't know if the current plugin code works with current django, so you'd either need to update the code or build off an older ports tree like I do. (from 9/21/2014 with specific ports upgraded as needed)
 
P

Patrick_Q

Guest
sounds like the Python api has an error or isn't running. try browsing to the path in the error, sometimes a useful error is shown.

I don't know if the current plugin code works with current django, so you'd either need to update the code or build off an older ports tree like I do. (from 9/21/2014 with specific ports upgraded as needed)

Thank you for your response and yes there is something wrong with python REST API like this:

Code:
Request Method:     GET
Request URL:     http://10.2.1.207/plugins/plexmediaserver/1/_s/status
Software Version:     FreeNAS-9.3-STABLE-201503270027
Exception Type:     error
Exception Value:    

[Errno 61] Connection refused

Exception Location:     /usr/local/lib/python2.7/socket.py in create_connection, line 571
Server time:     Fri, 17 Apr 2015 15:12:40 -0700
Traceback
Environment: Software Version: FreeNAS-9.3-STABLE-201503270027 Request Method: GET Request URL: http://10.2.1.207/plugins/plexmediaserver/1/_s/status Traceback: File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 112. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/www/freenasUI/../freenasUI/plugins/views.py" in plugin_fcgi_client 581. status, headers, body, raw = app(env, args=args) File "/usr/local/www/freenasUI/../freenasUI/plugins/utils/fcgi_client.py" in __call__ 222. sock = self._getConnection() File "/usr/local/www/freenasUI/../freenasUI/plugins/utils/fcgi_client.py" in _getConnection 340. sock = socket.create_connection(self._connect) File "/usr/local/lib/python2.7/socket.py" in create_connection 571. raise err Exception Type: error at /plugins/plexmediaserver/1/_s/status Exception Value: [Errno 61] Connection refused

Request information
GET

No GET data
POST

No POST data
FILES

No FILES data
COOKIES
Variable     Value
csrftoken     'YIERfio4BDRHmCzKCNXfr6HpImwGSwFB'
fntreeSaveStateCookie     'root%2Croot%2F133'
sessionid     '41480dm6nucq80eyfby9ezgtxxwwy1l4'
META
Variable     Value
wsgi.input     <flup.server.fcgi_base.InputStream object at 0x816345d90>
CSRF_COOKIE     u'YIERfio4BDRHmCzKCNXfr6HpImwGSwFB'
wsgi.version     (1, 0)
SERVER_NAME     'localhost'
wsgi.errors     <flup.server.fcgi_base.TeeOutputStream object at 0x81635cdd0>
REQUEST_METHOD     'GET'
CONTENT_TYPE     ''
QUERY_STRING     ''
SERVER_PORT     '80'
DOCUMENT_ROOT     '/usr/local/etc/nginx/html'
HTTP_ACCEPT     'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
CONTENT_LENGTH     ''
wsgi.multiprocess     False
HTTPS     ''
REMOTE_PORT     '13545'
wsgi.url_scheme     'http'
HTTP_ACCEPT_LANGUAGE     'en-US,en;q=0.5'
REMOTE_ADDR     '10.2.3.110'
HTTP_HOST     '10.2.1.207'
HTTP_COOKIE     'csrftoken=YIERfio4BDRHmCzKCNXfr6HpImwGSwFB; sessionid=41480dm6nucq80eyfby9ezgtxxwwy1l4; fntreeSaveStateCookie=root%2Croot%2F133'
REDIRECT_STATUS     '200'
DOCUMENT_URI     '/plugins/plexmediaserver/1/_s/status'
REQUEST_URI     '/plugins/plexmediaserver/1/_s/status'
SERVER_SOFTWARE     'nginx/1.6.2'
SCRIPT_NAME     u''
GATEWAY_INTERFACE     'CGI/1.1'
PATH_INFO     u'/plugins/plexmediaserver/1/_s/status'
SERVER_ADDR     '10.2.1.207'
wsgi.run_once     False
HTTP_USER_AGENT     'Mozilla/5.0 (X11; FreeBSD amd64; rv:27.0) Gecko/20100101 Firefox/27.0'
wsgi.multithread     True
HTTP_CONNECTION     'keep-alive'
SERVER_PROTOCOL     'HTTP/1.1'
HTTP_ACCEPT_ENCODING     'gzip, deflate'
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Thank you for your response and yes there is something wrong with python REST API like this:

Code:
Request Method:     GET
Request URL:     http://10.2.1.207/plugins/plexmediaserver/1/_s/status
Software Version:     FreeNAS-9.3-STABLE-201503270027
Exception Type:     error
Exception Value:    

[Errno 61] Connection refused

Exception Location:     /usr/local/lib/python2.7/socket.py in create_connection, line 571
Server time:     Fri, 17 Apr 2015 15:12:40 -0700
Traceback
Environment: Software Version: FreeNAS-9.3-STABLE-201503270027 Request Method: GET Request URL: http://10.2.1.207/plugins/plexmediaserver/1/_s/status Traceback: File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 112. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/www/freenasUI/../freenasUI/plugins/views.py" in plugin_fcgi_client 581. status, headers, body, raw = app(env, args=args) File "/usr/local/www/freenasUI/../freenasUI/plugins/utils/fcgi_client.py" in __call__ 222. sock = self._getConnection() File "/usr/local/www/freenasUI/../freenasUI/plugins/utils/fcgi_client.py" in _getConnection 340. sock = socket.create_connection(self._connect) File "/usr/local/lib/python2.7/socket.py" in create_connection 571. raise err Exception Type: error at /plugins/plexmediaserver/1/_s/status Exception Value: [Errno 61] Connection refused

Request information
GET

No GET data
POST

No POST data
FILES

No FILES data
COOKIES
Variable     Value
csrftoken     'YIERfio4BDRHmCzKCNXfr6HpImwGSwFB'
fntreeSaveStateCookie     'root%2Croot%2F133'
sessionid     '41480dm6nucq80eyfby9ezgtxxwwy1l4'
META
Variable     Value
wsgi.input     <flup.server.fcgi_base.InputStream object at 0x816345d90>
CSRF_COOKIE     u'YIERfio4BDRHmCzKCNXfr6HpImwGSwFB'
wsgi.version     (1, 0)
SERVER_NAME     'localhost'
wsgi.errors     <flup.server.fcgi_base.TeeOutputStream object at 0x81635cdd0>
REQUEST_METHOD     'GET'
CONTENT_TYPE     ''
QUERY_STRING     ''
SERVER_PORT     '80'
DOCUMENT_ROOT     '/usr/local/etc/nginx/html'
HTTP_ACCEPT     'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
CONTENT_LENGTH     ''
wsgi.multiprocess     False
HTTPS     ''
REMOTE_PORT     '13545'
wsgi.url_scheme     'http'
HTTP_ACCEPT_LANGUAGE     'en-US,en;q=0.5'
REMOTE_ADDR     '10.2.3.110'
HTTP_HOST     '10.2.1.207'
HTTP_COOKIE     'csrftoken=YIERfio4BDRHmCzKCNXfr6HpImwGSwFB; sessionid=41480dm6nucq80eyfby9ezgtxxwwy1l4; fntreeSaveStateCookie=root%2Croot%2F133'
REDIRECT_STATUS     '200'
DOCUMENT_URI     '/plugins/plexmediaserver/1/_s/status'
REQUEST_URI     '/plugins/plexmediaserver/1/_s/status'
SERVER_SOFTWARE     'nginx/1.6.2'
SCRIPT_NAME     u''
GATEWAY_INTERFACE     'CGI/1.1'
PATH_INFO     u'/plugins/plexmediaserver/1/_s/status'
SERVER_ADDR     '10.2.1.207'
wsgi.run_once     False
HTTP_USER_AGENT     'Mozilla/5.0 (X11; FreeBSD amd64; rv:27.0) Gecko/20100101 Firefox/27.0'
wsgi.multithread     True
HTTP_CONNECTION     'keep-alive'
SERVER_PROTOCOL     'HTTP/1.1'
HTTP_ACCEPT_ENCODING     'gzip, deflate'
that's why I suggested you browse to it
http://10.2.1.207/plugins/plexmediaserver/1/_s/status
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Yep. This is kind of authentication problem due to "connection refused".

So is this the FreeNAS API problem or other's? Since I have been working on scripts using FreeNAS API from last summer in iX so if it is the API's problem on FreeNAS system I will need to file a bug.
It isn't a problem with freenas but the code built into the plugin. the plugin basically has to create the interface that freenas interacts with, whether that code is in python/php/whatever doesn't matter.

when I compile plugins they work fine. but like I said, I'm using a very bastardized environment with an old version of most ports. I don't remembers exactly what component it was, but I think django 1.7+ doesn't work with the python code you would find in the plugins/*/resources/ folders.

####

also, check 'ps aux' in the jail. you should see the api service running. compare what you have to a working installed plugin.
 
P

Patrick_Q

Guest
It isn't a problem with freenas but the code built into the plugin. the plugin basically has to create the interface that freenas interacts with, whether that code is in python/php/whatever doesn't matter.

when I compile plugins they work fine. but like I said, I'm using a very bastardized environment with an old version of most ports. I don't remembers exactly what component it was, but I think django 1.7+ doesn't work with the python code you would find in the plugins/*/resources/ folders.

####

also, check 'ps aux' in the jail. you should see the api service running. compare what you have to a working installed plugin.


Could you give me more details info of environment like what version of FreeNAS 9.3 and which port tree you are using?
Thanks
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
So you are building plugins using FreeBSD 9.3 and I'm wondering which version of freenas are you using.

Thank you so much.
I'm personally using FreeNAS 9.3, but that's irrelevant to me building plugins
 
P

Patrick_Q

Guest
I'm personally using FreeNAS 9.3, but that's irrelevant to me building plugins
I think it must be the django version problem.

I modified www/django to www/django16 in pbi.conf under "PBI_MAKEPORAFTER" but it says a conflict between www/django and django 1.7.7 when it was on compiling
 
Last edited by a moderator:

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I think it must be the django version problem.

I modified www/django to www/django16 in pbi.conf under "PBI_MAKEPORAFTER" but it says a conflict between www/django and django 1.7.7 when it was on compiling
I'm guessing something else is dependant on django, so it's installing 1.7 first. a fix would be to just replace the django port with the 1.6 version. like I said, the tree needs manual edits or we need someone to update the Python code in the plugins. I'll eventually do the second, when freenas10 is a thing, but I'd be faster if someone else did it. Im not a programmer so I just read docs and try stuff till it works.
 
P

Patrick_Q

Guest
I'm guessing something else is dependant on django, so it's installing 1.7 first. a fix would be to just replace the django port with the 1.6 version. like I said, the tree needs manual edits or we need someone to update the Python code in the plugins. I'll eventually do the second, when freenas10 is a thing, but I'd be faster if someone else did it. Im not a programmer so I just read docs and try stuff till it works.
I can just buid up plexmediaserver plugin and it's working good on FreeNAS 9.3.

But for couchpotato and sabnzbd something is wrong with PBI_PROGVERSION like this

upload_2015-4-28_18-46-29.png


Is it ports problem?
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
I can just buid up plexmediaserver plugin and it's working good on FreeNAS 9.3.

But for couchpotato and sabnzbd something is wrong with PBI_PROGVERSION like this

View attachment 7574

Is it ports problem?
Did you copy the port like mentioned in the README?
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Yes I did.
strange, that's where it should be building the port from.
can you build the couchpotato port on that system normally (not into a PBI)?
 
Status
Not open for further replies.
Top