POST /devices

Contents[Hide]

Permite crear dispositivos en el sistema CNM

 

 

POST /devices.json -F "CAMPO1=valor1" -F "CAMPO2=valor2" -F "form[CAMPO3]=valor3" Crea el dispositivo con los campos indicados

 

1. Campos

 

NombreTipoValores posiblesObligatorioDescripción
name Texto Cualquiera Si Nombre del dispositivo
domain Texto Cualquiera Si Dominio del dispositivo
ip Texto Cualquiera Si Dirección IP del dispositivo
type Texto Cualquiera No Tipo del dispositivo (definido por el usuario)
snmpversion Entero 0:sin SNMP | 1:version 1 | 2:version 2 | 3:version 3 No Versión SNMP del dispositivo
snmpcommunity Texto Cualquiera No Comunidad SNMP (solo para snmpversion 1 o 2)
snmpcredential Texto Cualquiera No Credenciales SNMP (solo para snmpversion 3)
geo Texto Cualquiera No Geolocalizacion en formato Google Maps
critic Entero 25: baja | 50: media | 75: alta | 100: máxima No Criticidad
correlated Entero Cualquiera No Id del dispositivo del que depende
status Entero 0:activo | 1:inactivo | 2:mantenimiento No Estado del dispositivo
profile Texto Cualquiera No Perfil al que pertenece el dispositivo
Campos de usuario Texto Cualquiera No Campo de usuario definido por el usuario

 


2. Códigos de respuesta

 

CódigoDescripción
200 Resultado correcto
400 Error en la petición.
401 Error de autenticación.
403 Error por falta de permisos.
500 Error interno del servidor

 

3. Valor devuelto

Devuelve un vector de datos indicando el código de respuesta de la operación y el id del dispositivo creado.

4. Ejemplos

 

root@cnm:/tmp# curl -ki "https://localhost/onm/api/2.0/auth/token.json?u=admin&p=cnm123"
HTTP/1.1 200 OK
Date: Sun, 21 Sep 2014 13:28:55 GMT
Server: Apache/2.2.16 (Debian) PHP/5.3.3-7 with Suhosin-Patch proxy_html/3.0.1 mod_ssl/2.2.16 OpenSSL/0.9.8o mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By: PHP/5.3.3-7
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
:
Vary: Accept-Encoding
Content-Length: 59
Content-Type: text/html; charset=utf-8

{"status":0,"sessionid":"3d30466324b20d9a66be964751e1616a","expires_in":180}

root@cnm:/tmp# curl -ki -H "Authorization: 3d30466324b20d9a66be964751e1616a" -X GET "https://localhost/onm/api/1.0/devices.json"
HTTP/1.1 200 OK
Date: Sun, 21 Sep 2014 13:29:13 GMT
Server: Apache/2.2.16 (Debian) PHP/5.3.3-7 with Suhosin-Patch proxy_html/3.0.1 mod_ssl/2.2.16 OpenSSL/0.9.8o mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By: PHP/5.3.3-7
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
:
Vary: Accept-Encoding
Content-Length: 698
Content-Type: text/html; charset=utf-8

[{"id":"1","profile":"Global","name":"cnm-inet2","snmpsyslocation":"\"CPD (edit \/etc\/snmp\/snmpd.conf)\"","switch":"0","snmpsysclass":".1.3.6.1.4.1.8072.3.2.10","critic":"50","domain":"s30labsi.com","ip":"127.0.0.1","type":"Appliance","xagentversion":"","status":"0","snmpsysoid":".1.3.6.1.4.1.8072.3.2.10","network":"127.0.0.0\/8","snmpsysdesc":"\"Linux cnm-inet2 2.6.32-5-amd64 #1 SMP Wed Jan 12 03:40:32 UTC 2011 x86_64\"","geo":"","correlated":"0","snmpcommunity":"public","snmpversion":"2","entity":"0","sysloc":"\"CPD (edit \/etc\/snmp\/snmpd.conf)\"","mac":"-","macvendor":"","yellowalerts":"0","orangealerts":"0","redalerts":"0","bluealerts":"1","metrics":"31","Version de software":"-"}]

root@cnm:/tmp# curl -ki -H "Authorization: 3d30466324b20d9a66be964751e1616a" -X POST "https://localhost/onm/api/1.0/devices.json" -F "name=proxmox" -F "domain=localdomain.com" -F "ip=192.168.2.100" -F "type=Servidor" -F "snmpversion=2" -F "snmpcommunity=public" -F "critic=100" -F "form[Version de software]=2.3"
HTTP/1.1 100 Continue


HTTP/1.1 200 OK
Date: Sun, 21 Sep 2014 13:29:27 GMT
Server: Apache/2.2.16 (Debian) PHP/5.3.3-7 with Suhosin-Patch proxy_html/3.0.1 mod_ssl/2.2.16 OpenSSL/0.9.8o mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By: PHP/5.3.3-7
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
:
Vary: Accept-Encoding
Content-Length: 28
Content-Type: text/html; charset=utf-8

{"rc":0,"rcstr":"","id":"2"}

root@cnm:/tmp# curl -ki -H "Authorization: 3d30466324b20d9a66be964751e1616a" -X GET "https://localhost/onm/api/1.0/devices.json"
HTTP/1.1 200 OK
Date: Sun, 21 Sep 2014 13:29:59 GMT
Server: Apache/2.2.16 (Debian) PHP/5.3.3-7 with Suhosin-Patch proxy_html/3.0.1 mod_ssl/2.2.16 OpenSSL/0.9.8o mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By: PHP/5.3.3-7
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
:
Vary: Accept-Encoding
Content-Length: 1414
Content-Type: text/html; charset=utf-8

[{"id":"2","profile":"Global","name":"proxmox","snmpsyslocation":"Madrid","switch":"0","snmpsysclass":".1.3.6.1.4.1.8072.3.2.10","critic":"100","domain":"localdomain.com","ip":"192.168.2.100","type":"Servidor","xagentversion":"-","status":"0","snmpsysoid":".1.3.6.1.4.1.8072.3.2.10","network":"192.168.2.0\/24","snmpsysdesc":"\"Linux proxmox 2.6.32-19-pve #1 SMP Wed May 15 07:32:52 CEST 2013 x86_64\"","geo":"","correlated":"0","snmpcommunity":"public","snmpversion":"2","entity":"0","sysloc":"Madrid","mac":"3c:d9:2b:0b:01:75","macvendor":"Hewlett-Packard Company","yellowalerts":"0","orangealerts":"0","redalerts":"0","bluealerts":"0","metrics":"0","Version de software":"2.3"},{"id":"1","profile":"Global","name":"cnm-inet2","snmpsyslocation":"\"CPD (edit \/etc\/snmp\/snmpd.conf)\"","switch":"0","snmpsysclass":".1.3.6.1.4.1.8072.3.2.10","critic":"50","domain":"s30labsi.com","ip":"127.0.0.1","type":"Appliance","xagentversion":"","status":"0","snmpsysoid":".1.3.6.1.4.1.8072.3.2.10","network":"127.0.0.0\/8","snmpsysdesc":"\"Linux cnm-inet2 2.6.32-5-amd64 #1 SMP Wed Jan 12 03:40:32 UTC 2011 x86_64\"","geo":"","correlated":"0","snmpcommunity":"public","snmpversion":"2","entity":"0","sysloc":"\"CPD (edit \/etc\/snmp\/snmpd.conf)\"","mac":"-","macvendor":"","yellowalerts":"0","orangealerts":"0","redalerts":"0","bluealerts":"1","metrics":"31","Version de software":"-"}]

 

 

 

 

 

Más en esta categoría: « PUT /devices POST /users »

Iniciar sesión

Back to Top