Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added query parameters documentation

Table of Contents

Related Documentation 

Nodes API 

We can also manage nodes using the API. 

OperationMethodURLResponseExample
Get NodesGEThttp://host/en/omk/admin/api/v2/nodes.json

http://

uburnto

athena.opmantek.net/en/omk/admin/api/v2/nodes.json?

requestData=undefined&

page=1&per_page=

25

5&sort_by=name&order=asc

See Query Parameters

Get NodeGEThttp://host/en/omk/admin/api/v2/nodes/{node_uuid}.json
http://uburnto.opmantek.net/en/omk/admin/api/v2/nodes/86a82b4c-6ef6-4691-8c8c-1fc8da334d6f.json
Create NodePOST

http://host/en/omk/admin/api/v2/nodes.json

To create a remote node in an opHA cluster see below.

The node in json from the recently created node
created
, including the UUID
configuration
activated":
{
"
netType
NMIS": "
default
1",
"
polling_policy
opConfig": "
default
0",
"
port
opEvents": "
161
1"
},
"
collect
configuration":
1,"threshold

{
"active":
1
 null, "
roleType
authkey": "
default
", "
ping
authpassword":
1
 "", "
group
authprotocol": null, "
NMIS9
businessService": null,
"
host":"asgard.opmantek.net","location":null,
collect": 1, "community": "", "context": "", "customer": null, "
businessService
group":
null
 "NMIS9",
"
notes
host": "asgard.opmantek.net", "host_backup": "", "
active
location": null,
"
community
netType": "default", "
wmiusername
nettype":
""
 null, "
wmipassword
node_context_name": "", "
username
node_context_url": "", "
context
notes": "",
"
authpassword
ping":
""
 1, "
authkey
polling_policy": "default", "
authprotocol
port":
null
 "161", "
privpassword
privkey": "", "
privkey
privpassword": "",
"privprotocol": null, "
serviceStatus
remote_connection_name":
null,
 "
nettype
"
:null,"roletype":null,"node_context_name":
, "remote_connection_url": "", "
node_context_url
roleType": "default",
"
remote_connection_name
roletype":
""
 null, "
remote_connection_url
serviceStatus":
""}
 null, "
activated
threshold":
{"opEvents
 1, "username": "
1
", "
opConfig
wmipassword": "
0
", "
NMIS
wmiusername": "
1
"
},
"uuid":null,"

"current_user_privileges":
{
"
update
delete": true,
"
delete
update": true
},
"
name
friendly_addresses": "
test
",
"friendly_
addresses
aliases": "",
"
friendly_aliases
name": "test",
"uuid": null
}


Update NodePUT

http://host/en/omk/admin/api/v2/nodes/{node_uuid}.json

http:

To update a remote node in an opHA cluster see below.


configuration
activated":
    {
"netType

        "NMIS": "
default
1",
"polling_policy

        "opConfig": "
1_minute","port":"161","collect":1,"threshold":1,"roleType":"access","ping":1,"group":"EXSI","active":1,"addresses":[
0",
        "opEvents": "1"
    },
    "addresses":
    [],
    "aliases":
    [],
    "cluster_id": "a515c63a-0d11-4bcb-a402-39a4600aebb9",
    "configuration":
    {
        "active": 1, "addresses": [ "192.168.88.13" ], "aliases": [],
        "authkey": "", "authpassword": "", "authprotocol": "md5", "businessService": null, "cbqos": "none",
        "collect": 1, "community": "OMKRead", "context": "", "customer": "Opmantek", "depend": [],
        "display_name": "", "group": "EXSI", "host": "castor.opmantek.net", "host_backup": "", "ip_protocol": "IPv4",
"location":

        "location": "Cloud", "max_msg_size": 1472, "max_repetitions": 0, "model": "automatic",
        "netType": "default", "nettype": null, "node_context_name": "Node Context",
        "node_context_url": "https://somelink.com/map/thing/", "notes": "", "
privkey
ping":
"","
 1,
        "polling_policy": "1_minute", "port": "161", "privkey": "", "privpassword": "",
        "privprotocol": "des", "remote_connection_name": "SSH to Node", "remote_connection_url": "ssh://$host",
"serviceStatus":"

        "roleType": "access", "roletype": null, "serviceStatus": "Testing", "services": [],
        "sysDescr": "VMware ESXi 6.7.0 build-17167734 VMware, Inc. x86_64", "threshold": 1, "timezone": 0,
        "username": "", "version": "snmpv2c", "webserver": 0, "wmipassword": "", "wmiusername": ""
    },
"nettype":null,"roletype":null},"activated":{"opEvents":"1","opConfig":"0","NMIS":"1"},"uuid":"b56ba595-69e7-4702-9fe5-49512e1340b0","current_user_privileges":{"update":0,"delete":0},"addresses":[],"aliases":[],"cluster_id":"a515c63a-0d11-4bcb-a402-39a4600aebb9","friendly_addresses":"192.168.88.13","friendly_aliases":"","name":"Castor","node_local":"Remote","overrides":{},"server_name":"fulla","unknown":{}}

    "current_user_privileges":
    {
        "delete": 0,
        "update": 0
    },
    "friendly_addresses": "192.168.88.13",
    "friendly_aliases": "",
    "name": "Castor",
    "node_local": "Remote",
    "overrides":
    {},
    "server_name": "fulla",
    "unknown":
    {},
    "uuid": "b56ba595-69e7-4702-9fe5-49512e1340b0"
}


Delete NodeDELETEhttp://host/en/omk/admin/api/v2/nodes/{node_uuid}.json
http://
Delete NodeDELETEhttp://host/en/omk/admin/api/v2/nodes/{node_uuid}.jsonhttp://
uburnto.opmantek.net/en/omk/admin/api/v2/nodes/b56ba595-69e7-4702-9fe5-49512e1340b0

Important: All this methods are authenticated. 

...


Request Modifiers (query parameters)

Not all requests will use all request modifiers.

Query Parameter

Possible Values

fields_hash

Array of property names. If provided only the properties specified will be returned (instead of the whole document).

eg:   fields_hash={"name":1,"uuid":1} returns only the node name and the node uuid.

By default all properties if no fields_hash is specified.

page

Which page of the requested document to be returned, from 1 .. n, defaults to no pagination.

per_page

How many results are returned per page, defaults to 25

search

List of key=value pairs. Search filter applied to the list of results.
eg: search={"name":"athena","configuration.group":"SydneyDC"} (which is "Name"="athena" AND "Group"="SydneyDC")

For a string, if it starts with regex: or iregex: then a case-sensitive or case-insensitive regular expression match is used.
eg: filter={"name":"iregex:Switch"} to find all the nodes with switch or SWITCH in their name.

sort_by

Property to sort by. eg: sort_by=name to sort by node name

order

Sort order. asc | desc : sort the response by sort_by ascending or descending.

By example, the queries will look something like this: 

http://athena.opmantek.net/omk/admin/api/v2/nodes.json?fields_hash={"name":1,"uuid":1}&search={"name":"Switch-1"}

Authentication

Important: All these methods are authenticated. 

OperationMethodURLResponseExample
AuthenticatePOSThttp://host/en/omk/admin/login

http://uburnto.opmantek.net/en/omk/admin/login


Code Block
{"username": "username",
"password": "password"}


We should receive a 200 response and a cookie, that we can reuse for next API calls. 

Create a remote Node

If we want to create a node in a remote cluster, we should indicate the remote cluster id in configuration.pollers: cluster_id

cluster_id is the uuid of which opHA server the node belongs to.

E.x.

Create RemotePOSThttp://host/en/omk/admin/api/v2/nodes.jsonIt will return the json node, the same structure that the CREATE. 

http://uburnto.opmantek.net/en/omk/opHA/login

Code Block
{"username": "username",
"password": "password"}

We should receive a 200 response and a cookie, that we can reuse for next API calls. 

Create a remote Node

If we want to create a node in a remote cluster, we should indicate the remote cluster id in configuration.pollers: Cluster_id. 

E.x.

Create RemotePOSThttp://host/en/omk/admin/api/v2/nodes.json

http://uburnto.opmantek.net/en/omk/admin/api/v2/nodes.json

Code Block{"configuration":{"pollers": "a515c63a-0d11-4bcb-a402-39a4600aebb9", "netType":"default","polling_policy":"default","port":"161","collect":1,"threshold":1,"roleType":"default","ping":1,"group":"NMIS9","host":"asgard.opmantek.net","location":null,"customer":null,"businessService":null,"notes":"","host_backup":"","active":null,"community":"","wmiusername":"","wmipassword":"","username":"","context":"","authpassword":"","authkey":"","authprotocol":null,"privpassword":"","privkey":"","privprotocol":null,"serviceStatus":null,"nettype":null,"roletype":null,"node_context_name":"","node_context_url":"","remote_connection_name":"","remote_connection_url":""},"activated":{"opEvents":"1","opConfig":"0","NMIS":"1"},"uuid":null,"current_user_privileges":{"update":true,"delete":true},"name":"test","friendly_addresses":"","friendly_aliases":""}

It will return the same output as for a local node: 

Code Block
{
    "activated": {
        "NMIS": 1,
        "opConfig": "0",
        "opEvents": "1"
    },
    "cluster_id": "a515c63a-0d11-4bcb-a402-39a4600aebb9",
    "configuration": {
        "active": 1,
        "aliases": [],
        "authkey": "",
        "authpassword": "",
        "authprotocol": null,
        "businessService": null,
        "collect": 1,
        "community": "",
        "context": "",
        "customer": null,
        "group": "NMIS9",
        "host": "asgard.opmantek.net",
        "host_backup": "",
        "location": null,
        "max_msg_size": 65535,
        "max_repetitions": 0,
        "netType": "default",
        "nettype": null,
        "node_context_name": "",
        "node_context_url": "",
        "notes": "",
        "ping": 1,
        "pollers": "a515c63a-0d11-4bcb-a402-39a4600aebb9",
        "polling_policy": "default",
        "port": "161",
        "privkey": "",
        "privpassword": "",
        "privprotocol": null,
        "remote_connection_name": "",
        "remote_connection_url": "",
        "roleType": "default",
        "roletype": null,
        "serviceStatus": null,
        "threshold": 1,
        "username": "",
        "wmipassword": "",
        "wmiusername": ""
    },
    "friendly_addresses": "",
    "friendly_aliases": "",
    "name": "test",
    "uuid": "6ce5fd5c-d703-4d03-b36c-b8e01439a9f2"
}



Update a remote Node

If we want to create update a node in a remote cluster, we just need to should indicate the remote cluster id in configuration.pollers: cluster_id:

cluster_id is the uuid of which opHA server the node belongs to.

E.x.

Create
Update RemotePUThttp://host/en/omk/admin/api/v2/nodes/node_uuid
.json
.jsonIt will return the json node, the same structure that the CREATE. 

http://volla.opmantek.net:6042/en/omk/admin/api/v2/nodes/6ce5fd5c-d703-4d03-b36c-b8e01439a9f2.json


Code Block
{
    "cluster_id": "a515c63a-0d11-4bcb-a402-39a4600aebb9",
    "configuration": {
        "netType": "default",
        "polling_policy": "default",
        "port": "161",
        "collect":
1,
 1,
        "threshold": 1,
        "roleType": "default",
        "ping": 1,
        "group": "NMIS9",
        "host": "asgard.opmantek.net",
        "location": null,
        "customer": null,
        "businessService": null,
        "notes": "",
        "host_backup": "",
        "active": null,
        "community": ""
,
,
        "wmiusername": "",
        "wmipassword": "",
        "username": "",
        "context": "",
        "authpassword": "",
        "authkey": "",
        "authprotocol": null,
        "privpassword": "",
        "privkey": "",
        "privprotocol": null,
        "serviceStatus": null,
        "nettype": null,
        "roletype": null,
        "node_context_name": "",
        "node_context_url": "",
        "remote_connection_name": "",
        "remote_connection_url": ""
    },
    "activated"
:{
: {
        "opEvents": "1",
        "opConfig": "0",
        "NMIS": "1"
    },
    "uuid": null,
    "current_user_privileges": {
        "update":
true,
 true,
        "delete": true
    },
    "name": "test",
    "friendly_addresses": "",
    "friendly_aliases": ""
}

It will return the json node, the same structure that the CREATE. 



Remote Nodes Error

If any operation has a remote cluster id, the API will try to edit in the remote server. If this operation is not possible, it will fail. 

...

  • opHA needs to be pulling that peer. This is because the peer sends the API url to update the remote in the registry data. And this information should be updated at least once a day. 
  • The peer has to be online. 

If we should want to edit the remote node locally for some reason, we should use opnodenode_admin cli tool. 

Related Documentation 

...