diff --git a/cli/add_device.php b/cli/add_device.php index ac1e79e964..0c4e8eb93f 100644 --- a/cli/add_device.php +++ b/cli/add_device.php @@ -50,7 +50,7 @@ $ip = ''; $poller_id = $config['poller_id']; $site_id = read_config_option('default_site'); - $template_id = read_config_option('default_template'); + $template_id = (int) read_config_option('default_template'); $community = read_config_option('snmp_community'); $snmp_ver = read_config_option('snmp_version'); $disable = 0; diff --git a/cli/change_device.php b/cli/change_device.php index 80b10cae40..6fe7ca4eca 100644 --- a/cli/change_device.php +++ b/cli/change_device.php @@ -84,7 +84,7 @@ break; case '--template': - $overrides['template_id'] = $value; + $overrides['host_template_id'] = $value; break; case '--community': @@ -321,6 +321,11 @@ /* merge overridden parameters onto host */ $host = array_merge($host, $overrides); +/* exception for IP */ +if (isset($overrides['ip'])) { + $host['hostname'] = $overrides['ip']; +} + /* process the various lists into validation arrays */ $host_templates = getHostTemplates(); $hosts = getHostsByDescription(); @@ -399,7 +404,7 @@ print "Changing device-id: $device_id to {$host['description']} ({$host['hostname']}) as \"{$host_templates[$host['host_template_id']]}\" using SNMP v{$host['snmp_version']} with community \"{$host['snmp_community']}\"\n"; } -$host_id = api_device_save($device_id, $host['host_template_id'], $host['description'], $host['ip'], +$host_id = api_device_save($device_id, $host['host_template_id'], $host['description'], $host['hostname'], $host['snmp_community'], $host['snmp_version'], $host['snmp_username'], $host['snmp_password'], $host['snmp_port'], $host['snmp_timeout'], $host['disabled'], $host['availability_method'], $host['ping_method'], $host['ping_port'], $host['ping_timeout'], $host['ping_retries'], $host['notes'],