Image with no hostname

174 views
Skip to first unread message

Andrea Gabellini

unread,
Jun 21, 2016, 6:23:28 AM6/21/16
to OpenWISP
Hello Federico,

I'm new to OpenWisp and I'm trying it.

Usually I use the Image Generator to build my OpenWRT firmware. I add and remove packeges and my own configuration. I also added the openwisp-config agent.

The image generated has no hostname. So the command "uci get system.@system[0].hostname" returns an empty string and the agent returns the error:

Tue Jun 21 11:56:32 2016 daemon.info openwisp: Registering new device
Tue Jun 21 11:56:32 2016 daemon.err openwisp: Registration failed! error: missing required parameter "name"

Adding  the default hostname (OpenWrt) in the configuration solves the problem and now the AP registers itself to the controller. But I get the error:

Tue Jun 21 12:06:15 2016 daemon.err openwisp: Failed to retrieve checksum: HTTP/1.1 500 Internal Server Error

In the nginx logs I can't find any useful info. But I don't know nginx. I use Apache ;-). If you tell me how to debug server side I can do it.

Thanks,
Andrea

Federico Capoano

unread,
Jun 21, 2016, 6:38:49 AM6/21/16
to OpenWISP
Hi Andrea,

I did not know there could be a case in which there is no hostname. I will address it right now as I'm working on it and will release a new version soon.

Regarding the 500 Internal Server Error, it's most probably an application error which is not related to nginx, so you will have to check the application log which should be located in <path-to-app>/log/error.log.

Let me know what you find so if it's a bug I can fix it asap.

Federico

Andrea Gabellini

unread,
Jun 21, 2016, 8:09:36 AM6/21/16
to OpenWISP
Hi Federico,

the empty hostname is strange, but I notice it few month ago. I remember that the version that you can download from the main site contains "OpenWrt" as the hostname. But there is no default in the Image builder.

This is the app log:

[ERROR 2016-06-21 12:03:18,893] module: base, process: 18863, thread: 140639168608000
Internal Server Error: /controller/checksum/fc3a06bf-0b88-44c1-aade-e8e93758bac4/
Traceback (most recent call last):
  File "/opt/openwisp2/env/lib/python3.4/site-packages/netjsonconfig/backends/openwrt/openwrt.py", line 133, in validate
    validate(self.config, self.schema, format_checker=FormatChecker())
  File "/opt/openwisp2/env/lib/python3.4/site-packages/jsonschema/validators.py", line 478, in validate
    cls(schema, *args, **kwargs).validate(instance)
  File "/opt/openwisp2/env/lib/python3.4/site-packages/jsonschema/validators.py", line 123, in validate
    raise error
jsonschema.exceptions.ValidationError: '5E:48:00:60:E0:5E' is not a 'hostname'

Failed validating 'format' in schema['properties']['general']['properties']['hostname']:
    {'format': 'hostname',
     'maxLength': 63,
     'minLength': 1,
     'propertyOrder': 1,
     'type': 'string'}

On instance['general']['hostname']:
    '5E:48:00:60:E0:5E'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/openwisp2/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/opt/openwisp2/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/openwisp2/env/lib/python3.4/site-packages/django/views/decorators/http.py", line 42, in inner
    return func(request, *args, **kwargs)
  File "/opt/openwisp2/env/lib/python3.4/site-packages/django_netjsonconfig/controller/views.py", line 20, in checksum
    return ControllerResponse(config.checksum, content_type='text/plain')
  File "/opt/openwisp2/env/lib/python3.4/site-packages/django_netjsonconfig/models/config.py", line 147, in checksum
    config = self.generate().getvalue()
  File "/opt/openwisp2/env/lib/python3.4/site-packages/django_netjsonconfig/models/config.py", line 142, in generate
    return self.backend_instance.generate()
  File "/opt/openwisp2/env/lib/python3.4/site-packages/netjsonconfig/backends/openwrt/openwrt.py", line 170, in generate
    self._generate_contents(tar)
  File "/opt/openwisp2/env/lib/python3.4/site-packages/netjsonconfig/backends/openwrt/openwrt.py", line 192, in _generate_contents
    uci = self.render(files=False)
  File "/opt/openwisp2/env/lib/python3.4/site-packages/netjsonconfig/backends/openwrt/openwrt.py", line 94, in render
    self.validate()
  File "/opt/openwisp2/env/lib/python3.4/site-packages/netjsonconfig/backends/openwrt/openwrt.py", line 135, in validate
    raise ValidationError(e)
netjsonconfig.exceptions.ValidationError: '5E:48:00:60:E0:5E' is not a 'hostname'

Failed validating 'format' in schema['properties']['general']['properties']['hostname']:
    {'format': 'hostname',
     'maxLength': 63,
     'minLength': 1,
     'propertyOrder': 1,
     'type': 'string'}

On instance['general']['hostname']:
    '5E:48:00:60:E0:5E'

Federico Capoano

unread,
Jun 21, 2016, 9:04:39 AM6/21/16
to OpenWISP
Oh right, I see. I fixed that issue with this commit:

But I realized just now I never issued a new stable release containing that change, so I guess you are using the latest stable release.
I will issue a new release of django-netjsonconfig now to fix this.

Federico

Andrea Gabellini

unread,
Jun 21, 2016, 9:26:19 AM6/21/16
to OpenWISP
Hi  Federico,

yes, I use stable release for both the agent and the controller.

Do you suggests to use the devel versions?

Andrea

Federico Capoano

unread,
Jun 21, 2016, 10:22:51 AM6/21/16
to OpenWISP
I just released a new stable version:

I am currently using only the development versions, but I am doing this because things are moving fast.
We need to pay more attention to stable versions.

Federico

Andrea Gabellini

unread,
Jun 22, 2016, 5:06:48 AM6/22/16
to OpenWISP
Hi Federico,

I just updated the django app to 0.3.2 and installed the devel version of the agent.

A new flashed Picostation, with OpenWrt as hostname, register itself succefully and I didn't get errors like those I reported.

But changing the configuration (hostname only) on the controller doesn't apply to the AP.

The log report this:
Wed Jun 22 10:46:54 2016 daemon.info openwisp: Configuration in controller has changed
Wed Jun 22 10:46:55 2016 daemon.info openwisp: Testing configuration
Wed Jun 22 10:46:55 2016 daemon.crit openwisp: Could not update configuration, openwisp-update-config exit code was 1
Wed Jun 22 10:46:56 2016 daemon.info openwisp: Configuration test succeded
Wed Jun 22 10:46:57 2016 daemon.info openwisp: Configuration applied

The agent config:
config controller 'http'
option url 'https://xxxxxx'
option interval '120'
option verify_ssl '0'
option consistent_key '1'
option merge_config '1'
option test_config '1'
list unmanaged 'system.@led'
list unmanaged 'network.loopback'
list unmanaged 'network.@switch'
list unmanaged 'network.@switch_vlan'
option connect_timeout '5'
option max_time '15'
option capath '/etc/ssl/certs'
option uuid 'xxxx'
option key 'xxxx'

How can I debug openwisp-update-config ?

Andrea

Federico Capoano

unread,
Jun 22, 2016, 6:03:18 AM6/22/16
to Andrea Gabellini, OpenWISP
Try to run it by itself:

openwisp-update-config

What error do you get?

Federico


--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrea Gabellini

unread,
Jun 22, 2016, 6:26:41 AM6/22/16
to OpenWISP
lua: /usr/sbin/openwisp-update-config:39: bad argument #2 to 'foreach' (string expected, got nil)
stack traceback:
[C]: in function 'foreach'
/usr/sbin/openwisp-update-config:39: in main chunk
[C]: ?

The /tmp/openwisp/configuration.tar.gz file contains only the file "system":

config system
option hostname 'Pippo'
option timezone 'UTC'

config timeserver 'ntp'
list server '0.openwrt.pool.ntp.org'
list server '1.openwrt.pool.ntp.org'
list server '2.openwrt.pool.ntp.org'
list server '3.openwrt.pool.ntp.org'
option enable_server '0'
option enabled '1'

Federico Capoano

unread,
Jun 22, 2016, 11:39:56 AM6/22/16
to OpenWISP
Not good at all.
Which OpenWRT version are you testing?

Federico

Andrea Gabellini

unread,
Jun 23, 2016, 2:43:45 AM6/23/16
to OpenWISP
I'm using 15.05.01

using the stable versions of two day ago it works

Federico Capoano

unread,
Jun 23, 2016, 3:14:30 AM6/23/16
to Andrea Gabellini, OpenWISP
I completed to introduce an important change just in these last 3 days. But I am testing it on trunk (LEDE master, to be corrext), so today I have to test it on chaos calmer and see. I think there's a difference in the lua bindings for libuci between these two versions.

Will let you know later today, sorry for the inconvenience!

Federico

Federico Capoano

unread,
Jun 23, 2016, 6:17:39 AM6/23/16
to OpenWISP
This commit should fix it:

I have tested the changes on OpenWRT 15.05.01, but I'm waiting for the compilation to complete in order to reflash a router and try from a fresh install.

Federico


On Thursday, June 23, 2016 at 9:14:30 AM UTC+2, Federico Capoano wrote:
I completed to introduce an important change just in these last 3 days. But I am testing it on trunk (LEDE master, to be corrext), so today I have to test it on chaos calmer and see. I think there's a difference in the lua bindings for libuci between these two versions.

Will let you know later today, sorry for the inconvenience!

Federico


To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+unsubscribe@googlegroups.com.

Federico Capoano

unread,
Jun 23, 2016, 8:40:46 AM6/23/16
to OpenWISP
I tested the latest fix on a fresh router and everything is ok.

Federico

Andrea Gabellini

unread,
Jun 24, 2016, 8:59:43 AM6/24/16
to OpenWISP
It also works well here! ;-)
Reply all
Reply to author
Forward
0 new messages