Make safe int cast

In the case some specs of nodes are missing, we consider them
as 0. This fixes error 500 when spec is missing.

Change-Id: Iadb19447cf7da58b400e9b0ccb4c3a3360d7aeb6