Source
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* Class containing operations for updating/creating a host.
*/
abstract class CControllerHostUpdateGeneral extends CController {
/**
* Common host field validation rules.
*
* @return array
*/
protected static function getValidationFields(): array {
return [
'host' => 'required|db hosts.host|not_empty',
'visiblename' => 'db hosts.name',
'description' => 'db hosts.description',
'status' => 'required|db hosts.status|in '.implode(',', [HOST_STATUS_MONITORED,
HOST_STATUS_NOT_MONITORED
]),
'monitored_by' => 'db hosts.monitored_by|in '.implode(',', [ZBX_MONITORED_BY_SERVER, ZBX_MONITORED_BY_PROXY, ZBX_MONITORED_BY_PROXY_GROUP]),
'proxyid' => 'db hosts.proxyid',
'proxy_groupid' => 'db hosts.proxy_groupid',
'interfaces' => 'array',
'mainInterfaces' => 'array',
'groups' => 'required|array',
'tags' => 'array',
'templates' => 'array_db hosts.hostid',
'add_templates' => 'array_db hosts.hostid',
'clear_templates' => 'array_db hosts.hostid',
'ipmi_authtype' => 'in '.implode(',', [IPMI_AUTHTYPE_DEFAULT, IPMI_AUTHTYPE_NONE, IPMI_AUTHTYPE_MD2,
IPMI_AUTHTYPE_MD5, IPMI_AUTHTYPE_STRAIGHT, IPMI_AUTHTYPE_OEM,
IPMI_AUTHTYPE_RMCP_PLUS
]),
'ipmi_privilege' => 'in '.implode(',', [IPMI_PRIVILEGE_CALLBACK, IPMI_PRIVILEGE_USER,
IPMI_PRIVILEGE_OPERATOR, IPMI_PRIVILEGE_ADMIN, IPMI_PRIVILEGE_OEM
]),
'ipmi_username' => 'db hosts.ipmi_username',
'ipmi_password' => 'db hosts.ipmi_password',
'tls_connect' => 'db hosts.tls_connect|in '.implode(',', [HOST_ENCRYPTION_NONE, HOST_ENCRYPTION_PSK,
HOST_ENCRYPTION_CERTIFICATE
]),
'tls_accept' => 'db hosts.tls_accept|ge 0|le '.
(0 | HOST_ENCRYPTION_NONE | HOST_ENCRYPTION_PSK | HOST_ENCRYPTION_CERTIFICATE),
'tls_subject' => 'db hosts.tls_subject',
'tls_issuer' => 'db hosts.tls_issuer',
'tls_psk_identity' => 'db hosts.tls_psk_identity',
'tls_psk' => 'db hosts.tls_psk',
'inventory_mode' => 'db host_inventory.inventory_mode|in '.implode(',', [HOST_INVENTORY_DISABLED,