See www.zabbix.com for the official Zabbix site.

Docs/specs/ZBXNEXT-1679

From Zabbix.org
Jump to: navigation, search

Value Mapping XML import/export

ZBXNEXT-1679

Status: v1.2

Owner: Ivo

Summary

When exporting hosts or templates, the configured value mappings should also be exported. It should be possible to also import/export value mappings separately and it should be possible to select which value maps to export. When importing value mappings, the rules should provide an option to create new and update existing value mappings from XML.

Specification

Exporting and XML structure

  • Exporting of all value maps is available to all users with read permissions;
  • If there are no value maps to export, the tag <value_maps> is not present in XML;
  • Exported value maps should be in a separate tag <value_maps> and should contain the following structure:
 <value_maps>
   <value_map>
     <name>Host status</name>
     <mappings>
       <mapping>
         <value>0</value>
         <newvalue>Up</newvalue>
       </mapping>
     </mappings>
     <mappings>
       <mapping>
         <value>2</value>
         <newvalue>Unreachable</newvalue>
       </mapping>
     </mappings>
   </value_map>
   <value_map>
     <name>Service state</name>
     <mappings>
       <mapping>
         <value>0</value>
         <newvalue>Down</newvalue>
       </mapping>
     </mappings>
     <mappings>
       <mapping>
         <value>1</value>
         <newvalue>Up</newvalue>
       </mapping>
     </mappings>
   </value_map>
 </value_maps>

Importing and validation

  • Importing value maps is available to all users providing they can pass the API validation. API validates create/update which is available only to super admins. Thus super admins may import value maps. And only super admins are able to see and select the import rules. The import rules for regular admins are not visible;
  • Regular admin cannot separately import value maps, but may import hosts and templates just like before, but has to make sure the value maps already exist otherwise, just like in maps with missing images, there will be an error that corresponding value map cannot be found;
  • If XML contains <value_maps> tag, other sub-tags should be present in order to pass validation. The validation for XML should be handled by XmlValidator;

Front-end changes

  • The interface for value mappings should be made consistent with other lists, providing it with checkboxes on the left side to select value maps and on the bottom there should be two bulk option buttons: Export and Delete, should be possible to sort value maps by name, limit the amount of records displayed and there should be paging option.
  • Add new column Used in items to display if value maps are used in items. If a value map is used in at least one item, show green Yes text in corresponding table cell.
  • At the top right corner there should be Import button which redirects to conf.import.php.
  • Create new value mappings rule should be selected by default when importing Templates, Hosts or Value mappings.
  • Selecting Update existing value mappings, there should be a warning message that says: Value mappings for value maps will be updated!.

API changes

  • configuration.import method should support import rule valueMaps - object should support parameters:
    • createMissing - (boolean) if set to true, new value maps will be created. Default is set to false;
    • updateExisting - (boolean) if set to true, existing value maps will be updated and value mappings will be overwritten. Default is set to false;
  • configuration.export method should support option valueMaps - array of IDs of value maps to export.


Translation strings

Add new translation strings

  • Value maps deleted
  • Cannot delete value maps
  • Value mappings
  • Value mappings for value maps will be updated!
  • Delete selected value maps?
  • Used in items

Database changes

No database changes.

Documentation

ChangeLog

  • 1.1 fixed default selection of the value mapping rules
  • 1.2 added new column Used in items in value map list view