opennetadmin / ona

OpenNetAdmin IP Address Management (IPAM) system
opennetadmin.com
GNU General Public License v2.0
136 stars 35 forks source link

Add DHCP Option silently fails. #128

Closed Gankarloo closed 6 years ago

Gankarloo commented 6 years ago

No error in GUI ona.log:

[DEFAULT] ERROR => dhcp_option_edit add ws_save()  SQL Query failed : ERROR => SQL INSERT failed: Field` 'sys_default' doesn't have a default value 

Simple solution: run this SQL statement:

ALTER TABLE dhcp_options MODIFY COLUMN sys_default INT(1) UNSIGNED NOT NULL DEFAULT '1';

I'm guessing a simple add statement marked by ** to ona-table_schema.xml will do the trick.


  <table name="dhcp_options">
   <opt platform="mysql">ENGINE=INNODB DEFAULT CHARSET=utf8 DEFAULT COLLATE=utf8_general_ci</opt>
    <field name="id" type="I" size="10">
      <KEY/>
      <UNSIGNED/>
    </field>
    <field name="name" type="C" size="31">
      <NOTNULL/>
    </field>
    <field name="number" type="I" size="3">
      <NOTNULL/>
      <UNSIGNED/>
    </field>
    <field name="type" type="C" size="1">
      <NOTNULL/>
    </field>
    <field name="display_name" type="C" size="31">
      <NOTNULL/>
    </field>
    <field name="sys_default" type="I" size="1">
      <NOTNULL/>
      <UNSIGNED/>
    **<DEFAULT value="1"/>**
    </field>
  </table>
mattpascoe commented 6 years ago

While your suggestion would be a typical fix, the use case here is actually one that would not be updated a the table level like this.

The intent of the 'sys_default' column was to mark the row as a system provided record that 'locked' it so it could not be edited or deleted by the user. Any new records created by the user should automatically be getting a value of 0.

This is actually fixed in the develop branch as shown here https://github.com/opennetadmin/ona/blob/develop/www/winc/app_dhcp_option_edit.inc.php#L256

I'll try and get that merged back in to master shortly.

Thanks