Project

General

Profile

API Automation

Introduction to API Automation

This wiki page give the necessary information to automate some of the most important task in viapps. This tasks can be automated thanks to Viapps API. 

You can use Viapps API using Curl calls to automate almost all task on Viapps. This page show some examples of this automation.

Common Steps

GET Login Token

First of all you need to get the login token.
You will need this token to use in all operations.

  1. Get the login token:
    • Curl format: curl -k -X POST -d '{"username":"$username","password":"$password"}' https://$MyCMIIP/cmi-api/login
    • Curl example: curl -k -X POST -d '{"username":"admin","password":"viapps"}' https://localhost/cmi-api/login
    • Curl response: {"login":true,"token":"localhost.localdomain59bb7d422b64d6.84110420"

List of installed appliances

*Curl format*: curl -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X GET -d '' https://localhost/cmi-api/appliance
*Curl example*: curl -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59bb7d422b64d6.84110420" -X GET -d '' https://localhost/cmi-api/appliance
*Curl response*: [{"id":"2","node":"VAPP_IX2","name":"lb01.viapps.org","description":"LB","farm":"Test","ip":"1.1.1.1","ipmanagement":"10.10.36.150","flavoursid":"4","statusid":"6","stepstatusid":"1","updatestatusid":0,"message":"VAPP scripts copied to client.","owner":"admin","version":"1.5.0-3.5835","uri":"https:\/\/10.10.36.150\/cmix-api","token":"lb01.viapps.org_59bb7de00d637","mail":"","automode":"0","status":"Running","flavours":"IP Load Balance","enabled_stats":0,"tags":"","logicalClusterId":null,"hasSchedulers":null,"enabled_elasticSearch":0,"created":"2017-09-15T09:14:40+02:00","createdby":0,"modified":"2017-09-15T09:22:55+02:00","modifiedby":0},{"id":"4","node":"VAPP_IX4","name":"lb02.viapps.org","description":"Test Description","farm":"TestFarm","ip":"1.1.1.1","ipmanagement":"10.10.36.151","flavoursid":"4","statusid":"6","stepstatusid":"1","updatestatusid":0,"message":"VAPP scripts copied to client.","owner":"admin","version":"1.5.0-3.5835","uri":"https:\/\/10.10.36.151\/cmix-api","token":"lb02.viapps.org_59bb8554bf9d2","mail":"","automode":"0","status":"Running","flavours":"IP Load Balance","enabled_stats":0,"tags":"","logicalClusterId":null,"hasSchedulers":null,"enabled_elasticSearch":0,"created":"2017-09-15T09:46:28+02:00","createdby":0,"modified":"2017-09-15T10:20:19+02:00","modifiedby":0}]

Deploy of flavour

The parameters you need to execute the curls:
  • user
  • token
  • hostname
  • description
  • service_addr
  • IPADDR
  • Flavour id:
    • firewall -> flavourid=1
    • proxy -> flavourid=2
    • smtpgw -> flavourid=3
    • iplb -> flavourid=4
    • dns|dhcp|ntp|ddn -> flavourid=5
  • farm
  • sshUser
  • sshPwd
  • MyCMIIP

Step 1:

*Curl format*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X POST -d '{ "name": "'${HOSTNAME}'", "description": "'${description}'", "ip": "'${service_addr}'", "ipmanagement": "'${IPADDR}'", "flavoursid": "'${flavourid}'", "farm": "'${farm}'", "sshUser": "root", "sshPwd": "viapps", "mail": "",  "cmd": "", "tags": "", "stepstatusid": 4 }' https://${MyCMIIP}/cmi-api/appliance
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{ "name": "lb02.viapps.org", "description": "Test Description", "ip": "1.1.1.1", "ipmanagement": "10.10.36.151", "flavoursid": "4", "farm": "TestFarm", "sshUser": "root", "sshPwd": "viapps", "mail": "",  "cmd": "", "tags": "", "stepstatusid": 4 }' https://localhost/cmi-api/appliance
*Curl response*: {"id":"4","node":"VAPP_IX4","name":"lb02.viapps.org","description":"Test Description","farm":"TestFarm","ip":"1.1.1.1","ipmanagement":"10.10.36.151","flavoursid":"4","statusid":"2","stepstatusid":"4","updatestatusid":0,"message":"","owner":"admin","version":"","uri":"https:\/\/10.10.36.151\/cmix-api","token":"lb02.viapps.org_59bb8554bf9d2","mail":"","automode":"0","status":"Step 2","flavours":"IP Load Balance","enabled_stats":0,"tags":"","logicalClusterId":null,"hasSchedulers":null,"enabled_elasticSearch":0,"created":"2017-09-15T09:46:28+02:00","createdby":0,"modified":"2017-09-15T03:46:28+02:00","modifiedby":0}

Step 2:

*Curl format* curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token:  ${token}" -X POST -d '{"operation": "next","vappId": '${vappid}',"params": {"step":2}}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token:  localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{"operation": "next","vappId": '4',"params": {"step":2}}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl response*: 201

*Curl format*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token:  ${token}" -X POST -d '{"operation": "try", "vappId": "'${vappid}'", "params": { "step": "2", "sshUser": "'${sshuser}'", "sshPwd": "'${sshpass}'" }}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token:  localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{"operation": "try", "vappId": "4", "params": { "step": "2", "sshUser": "root", "sshPwd": "viapps" }}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl response*: 201

if the result is 201 you can continue.

Step 3:

*Curl format*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token:  ${token}" -X POST -d '{"operation": "next","vappId": '${vappid}',"params": {"step":3}}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token:  localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{"operation": "next","vappId": "4","params": {"step":3}}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl response*: 201

*Curl format*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token:  ${token}" -X POST -d '{ "operation": "try", "vappId": "'${vappid}'", "params": { "step": 3 } }' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token:  localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{ "operation": "try", "vappId": "4", "params": { "step": 3 } }' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl response*: 201

if the result is 201 you can continue.

Step 4:

*Curl format*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token:  ${token}" -X POST -d '{"operation": "next","vappId": '${vappid}',"params": {"step":4}}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token:  localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{"operation": "next","vappId": "4","params": {"step":4}}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl response*: 201

*Curl format*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token:  ${token}" -X POST -d '{ "operation": "try", "vappId": "'${vappid}'", "params": { "step": 4 } }' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token:  localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{ "operation": "try", "vappId": "4", "params": { "step": 4 } }' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl response*: 201

if the result is 201 you can continue.

Step 5:

*Curl format*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token:  ${token}" -X POST -d '{"operation": "next","vappId": '${vappid}',"params": {"step":5}}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token:  localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{"operation": "next","vappId": "4","params": {"step":5}}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl response*: 201

*Curl format*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token:  ${token}" -X POST -d '{ "operation": "status", "vappId": "'${vappid}'", "params": {} }' https://localhost/cmi-api/setup
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token:  ${token}" -X POST -d '{ "operation": "status", "vappId": "'${vappid}'", "params": {} }' https://localhost/cmi-api/setup
*Curl response*: {"id":0,"result":{"status":"INSTALLING"}}

Get the "status" of the last response.

if the status is "INSTALLING" you can continue.

You should continue executing the Curl 9 while the state dont change to "INSTALLED" 

*Curl response when the process finalize*: {"id":0,"result":{"status":"INSTALLED"}}

Step 6:

*Curl format*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token:  ${token}" -X POST -d '{"operation": "quality", "vappId": "'${vappid}'"}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token:  localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{"operation": "quality", "vappId": "4"}' https://localhost/cmi-api/setup --write-out %{http_code} --silent --output /dev/null
*Curl response*: 201

The deploy of the flavour has ended

Cluster operations

Get appliances ID to generate the cluster

*Curl format*: curl -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X GET -d '' https://localhost/cmi-api/appliance
*Curl example*: curl -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59bb7d422b64d6.84110420" -X GET -d '' https://localhost/cmi-api/appliance
*Curl response*: [{"id":"2","node":"VAPP_IX2","name":"lb01.viapps.org","description":"LB","farm":"Test","ip":"1.1.1.1","ipmanagement":"10.10.36.150","flavoursid":"4","statusid":"6","stepstatusid":"1","updatestatusid":0,"message":"VAPP scripts copied to client.","owner":"admin","version":"1.5.0-3.5835","uri":"https:\/\/10.10.36.150\/cmix-api","token":"lb01.viapps.org_59bb7de00d637","mail":"","automode":"0","status":"Running","flavours":"IP Load Balance","enabled_stats":0,"tags":"","logicalClusterId":null,"hasSchedulers":null,"enabled_elasticSearch":0,"created":"2017-09-15T09:14:40+02:00","createdby":0,"modified":"2017-09-15T09:22:55+02:00","modifiedby":0},{"id":"4","node":"VAPP_IX4","name":"lb02.viapps.org","description":"Test Description","farm":"TestFarm","ip":"1.1.1.1","ipmanagement":"10.10.36.151","flavoursid":"4","statusid":"6","stepstatusid":"1","updatestatusid":0,"message":"VAPP scripts copied to client.","owner":"admin","version":"1.5.0-3.5835","uri":"https:\/\/10.10.36.151\/cmix-api","token":"lb02.viapps.org_59bb8554bf9d2","mail":"","automode":"0","status":"Running","flavours":"IP Load Balance","enabled_stats":0,"tags":"","logicalClusterId":null,"hasSchedulers":null,"enabled_elasticSearch":0,"created":"2017-09-15T09:46:28+02:00","createdby":0,"modified":"2017-09-15T10:20:19+02:00","modifiedby":0}]

You can get the appliance id using information like the "ipmanagement" to searh in the response.

Search for all clusters

*Curl format*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X GET -d '' https://localhost/cmi-api/cluster
*Curl example*: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59bb7d422b64d6.84110420" -X GET -d '' https://localhost/cmi-api/cluster
*Curl response*: [{"id":"1","name":"LB Cluster","description":"LB Description","flavoursId":"4","logicalClusterId":"1","masterName":"lb01.viapps.org","slaveName":"lb02.viapps.org","masterServiceIp":"10.10.36.150","slaveServiceIp":"10.10.36.151","masterInterface":"eth0","slaveInterface":"eth0","masterNodeId":"2","slaveNodeId":"4","masterVersion":"1.5.0-3.5835","nodesId":null,"params":"","statusCluster":1,"statusMasterId":6,"statusSlaveId":6,"flavours":"IP Load Balance","vips":"10.10.10.100\/24 eth0","pendingJobs":0,"masterHaStatus":"unknown","slaveHaStatus":"unknown","created":"2017-09-15T11:11:45+02:00","createdby":0,"modified":"2017-09-15T05:11:45+02:00","modifiedby":0}]

Deploy a cluster

You can create a cluster with only one vip. The parameter vip is a json array of vips.

Flavour id:
  • firewall --> cl_flavours=1
  • proxy --> cl_flavours=2
  • smtpgw --> cl_flavours=3
  • iplb --> cl_flavours=4
  • dns|dhcp|ntp|ddn --> cl_flavours=5
Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X POST -d '{"name":"$cl_name","description":"$cl_description","flavours":"$cl_flavours","params":"","autoSync":"$autosync","vips":"$vips","masterNodeId":"$master_id","masterServiceIp":"$master_ip","masterInterface":"$master_interface","slaveNodeId":"$slave_id","slaveServiceIp":"$slave_ip","slaveInterface":"$slave_interface","forceUpdate":"true"}' https://localhost/cmi-api/cluster
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{"name":"LB Cluster","description":"LB Description","flavours":"4","params":"","autoSync":true,"vips":[{"ip":"10.10.10.100","netmask":"24","interface":"eth0"}],"masterNodeId":"2","masterServiceIp":"10.10.36.150","masterInterface":"eth0","slaveNodeId":"4","slaveServiceIp":"10.10.36.151","slaveInterface":"eth0"}' https://localhost/cmi-api/cluster
Curl response: {"id":"1","name":"LB Cluster","description":"LB Description","flavoursId":"4","logicalClusterId":"1","masterName":"lb01.viapps.org","slaveName":"lb02.viapps.org","masterServiceIp":"10.10.36.150","slaveServiceIp":"10.10.36.151","masterInterface":"eth0","slaveInterface":"eth0","masterNodeId":"2","slaveNodeId":"4","masterVersion":"1.5.0-3.5835","nodesId":null,"params":"","statusCluster":1,"statusMasterId":6,"statusSlaveId":6,"flavours":"IP Load Balance","vips":"10.10.10.100\/24 eth0","pendingJobs":0,"masterHaStatus":"unknown","slaveHaStatus":"unknown","created":"2017-09-15T11:11:45+02:00","createdby":0,"modified":"2017-09-15T05:11:45+02:00","modifiedby":0}

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X POST -d '{"what":"heartbeat","params":{"clusterId":"$clusterID", "masterServiceIp":"$clusterMasterServiceIp","slaveServiceIp":"$clusterSlaveServiceIp"}}' https://localhost/cmi-api/cluster-sync
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59bf74470f8892.88023063" -X POST -d '{"what":"heartbeat","params":{"clusterId":"1", "masterServiceIp":"10.10.36.150","slaveServiceIp":"10.10.36.151"}}' https://localhost/cmi-api/cluster-sync
Curl response: Installation log
To insert more vips you need to edit the cluster after the creation:
  • Get the id parameter of the cluster using the response of the last curl or search id of a desired cluster.
  • You should use this id in the URL and as parameter
  • Re-send all information with all vips

Update a cluster

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X POST -d '{"id":"$clusterID","name":"$cl_name","description":"$cl_description","flavours":"$cl_flavours","params":"","autoSync":"$autosync","vips":"$vips","masterNodeId":"$master_id","masterServiceIp":"$master_ip","masterInterface":"$master_interface","slaveNodeId":"$slave_id","slaveServiceIp":"$slave_ip","slaveInterface":"$slave_interface","forceUpdate":"true"}' https://localhost/cmi-api/cluster/$clusterID
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59bb7d422b64d6.84110420" -X POST -d '{"id":"1","name":"LB Cluster","description":"LB Description","flavours":"4","params":"","autoSync":true,"vips":[{"ip":"10.10.10.100","netmask":"24","interface":"eth0"},{"ip":"10.10.10.102","netmask":"24","interface":"eth0"}],"masterNodeId":"2","masterServiceIp":"10.10.36.150","masterInterface":"eth0","slaveNodeId":"4","slaveServiceIp":"10.10.36.151","slaveInterface":"eth0","forceUpdate":true}' https://localhost/cmi-api/cluster/1
Curl response: {"id":"1","name":"LB Cluster","description":"LB Description","flavoursId":"4","logicalClusterId":"1","masterName":"lb01.viapps.org","slaveName":"lb02.viapps.org","masterServiceIp":"10.10.36.150","slaveServiceIp":"10.10.36.151","masterInterface":"eth0","slaveInterface":"eth0","masterNodeId":"2","slaveNodeId":"4","masterVersion":"1.5.0-3.5835","nodesId":null,"params":"","statusCluster":1,"statusMasterId":6,"statusSlaveId":6,"flavours":"IP Load Balance","vips":"10.10.10.100\/24 eth0;10.10.10.102\/24 eth0","pendingJobs":0,"masterHaStatus":"unknown","slaveHaStatus":"unknown","created":"2017-09-15T11:11:45+02:00","createdby":0,"modified":"2017-09-15T05:11:45+02:00","modifiedby":0}

Cluster TakeOver

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X POST -d '{"what":"change_control","params":{"clusterId":"$clusterID"}}' https://localhost/cmi-api/cluster-sync
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59bf74470f8892.88023063" -X POST -d '{"what":"change_control","params":{"clusterId":"1"}}' https://localhost/cmi-api/cluster-sync
Curl response: null

CMDB Operations

Get CMDB SSL Certificates:

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X GET -d '' https://localhost/cmi-api/cmdbcertssl
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59c0c403346c50.28948722" -X GET -d '' https://localhost/cmi-api/cmdbcertssl
Curl response: All SSL Certificate info

Get CMDB Server Certificates:

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X GET -d '' https://localhost/cmi-api/cmdbcertserver
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59c0c403346c50.28948722" -X GET -d '' https://localhost/cmi-api/cmdbcertserver
Curl response: All Server Certificate info

LB Operations

Important Parameters:

  • name -> VIP
  • type -> Ipvs / HAproxy
  • description -> description of vip
  • disabled -> true / false
  • Layer 4 (IPVS):
    • protocol -> tcp / udp
    • port -> Number of port
    • traffic -> NAT / Direct
    • snat -> true / false (Only for NAT)
    • ipToServer -> IP to real server (Only with SNAT)
    • realServerInterface -> Real server interface (ethX)
    • scheduler -> rr (Round Robin) / wrr (Weighted Round Robin) / lc (Least Connection) / wlc (Weighted Least Connection) / lblc (Locality Based Least Connection) / lblcr (Locality Based Least Connection with replication) / dh (Destination Hashing) / sh (Source Hashing) / sed (Shortest Expected Delay) / nq (Never Queue)
    • time -> Time of scheduler
  • Layer 7 (HAProxy):
    • port -> Number of port
    • sslPort -> Number of SSL Port
    • mode -> "http"
    • cName -> Common Name
    • maxConn -> Number of Max. Connections
    • certificateName -> Certificate name
    • certificate -> Certificate content
    • custom -> Custom options

List all vips from one node:

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X GET -d '' https://localhost/cmi-api/appliances/$nodeID/lb/vip
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59bbbe687e1b90.96306414" -X GET -d '' https://localhost/cmi-api/appliances/2/lb/vip
Curl response: [{"name":"10.10.10.120","type":"Ipvs","protocol":"tcp","port":"80","disabled":false,"description":"Test","traffic":"NAT","snat":true,"ipToServer":"10.10.36.150","realServerInterface":"eth0","scheduler":"rr","time":"10","cps":null,"servers":[],"id":"ea34a8011323a8f90832ebb8ae560edd"}]

Insert new vip (Layer 4):

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X POST -d '{"name":"$name","type":"$type","protocol":"$protocol","port":"$port","disabled":$disabled,"description":"$descripcion","traffic":"$traffic","snat":$snat,"ipToServer":"$ipToServer","realServerInterface":"$realServerInterface","scheduler":"$scheduler","time":"$time"}' https://localhost/cmi-api/appliances/$nodeID/lb/vip
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59c108818b3b84.78000841" -X POST -d '{"name":"10.10.10.122","type":"Ipvs","protocol":"tcp","port":"70","disabled":false,"description":"Test Comando","traffic":"NAT","snat":true,"ipToServer":"10.10.36.150","realServerInterface":"eth0","scheduler":"rr","time":"10"}' https://localhost/cmi-api/appliances/2/lb/vip
Curl response: [{"name":"10.10.10.122","type":"Ipvs","protocol":"tcp","port":"70","disabled":null,"description":"Test Comando","traffic":"NAT","snat":true,"ipToServer":"10.10.36.150","realServerInterface":null,"scheduler":"rr","time":"10","cps":null,"servers":[],"id":"fcd2be259f68d5490cb7788f29291307"}]

Insert new vip (Layer 7):

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X POST -d '{"type":"HAproxy","cName":"L7Test","sslPort":"","certificateName":"","certificate":"","custom": "","maxConn":"10","mode":"http","name":"192.168.101.82","description":"Test VIP","port":"80","disabled":$disabled}' https://localhost/cmi-api/appliances/$nodeID/lb/vip
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: cmi150.viapps.org5a9eb60f70b5e7.70840166" -X POST -d '{"type":"HAproxy","cName":"L7Test","sslPort":"","certificateName":"","certificate":"","custom": "","maxConn":"10","mode":"http","name":"192.168.101.82","description":"Test VIP","port":"80"}' https://10.10.36.80/cmi-api/appliances/4/lb/vip
Curl response: [{"cName":"l7test","name":"192.168.101.82","type":"HAproxy","protocol":"tcp","disabled":false,"description":"Test VIP","mode":"http","maxConn":"10","custom":"","certificateName":"","certificate":"","port":"80","sslPort":"","interface":"eth0","cps":null,"sessions":null,"bytesIn":null,"bytesOut":null,"backends":[],"layer":"layer7","id":"b0163d67dca2012360b41e46685e9661"}]

Update a vip (Layer 4):

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X PUT -d '{"name":"$name","type":"$type","protocol":"$protocol","port":"$port","disabled":$disabled,"description":"$descripcion","traffic":"$traffic","snat":$snat,"ipToServer":"$ipToServer","realServerInterface":"$realServerInterface","scheduler":"$scheduler","time":"$time", "id":"$VipID"}' https://localhost/cmi-api/appliances/$nodeID/lb/vip/$vipID
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59c108818b3b84.78000841" -X PUT -d '{"name":"10.10.10.127","type":"Ipvs","protocol":"tcp","port":"70","disabled":false,"description":"Test Comando","traffic":"NAT","snat":true,"ipToServer":"10.10.36.150","realServerInterface":"eth0","scheduler":"rr","time":"10","id":"12f59b31ff9458ef1dfe86c2547562e8"}' https://localhost/cmi-api/appliances/2/lb/vip/12f59b31ff9458ef1dfe86c2547562e8
Curl response: {"name":"10.10.10.127","type":"Ipvs","protocol":"tcp","port":"70","disabled":false,"description":"Test Comando","traffic":"NAT","snat":true,"ipToServer":"10.10.36.150","realServerInterface":"eth0","scheduler":"rr","time":"10","cps":null,"servers":[],"id":"12f59b31ff9458ef1dfe86c2547562e8"}

Update a vip (Layer 7):

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X PUT -d '{"type":"HAproxy","cName":"L7Test","sslPort":"","certificateName":"","certificate":"","custom": "","maxConn":"10","mode":"http","name":"192.168.101.82","description":"Test VIP","port":"80","disabled":$disabled, "id":"$VipID"}' https://localhost/cmi-api/appliances/$nodeID/lb/vip
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: cmi150.viapps.org5a9eb60f70b5e7.70840166" -X PUT -d '{"type":"HAproxy","cName":"L7Test","sslPort":"","certificateName":"","certificate":"","custom": "","maxConn":"10","mode":"http","name":"192.168.101.85","description":"Test VIP","port":"80","id":"b0163d67dca2012360b41e46685e9661"}' https://10.10.36.80/cmi-api/applia
nces/4/lb/vip
Curl response: [{"name":"192.168.101.88","type":"Ipvs","protocol":"udp","port":"53","disabled":false,"description":"DNS Balance","traffic":"NAT","snat":true,"ipToServer":"192.168.101.82","realServerInterface":"eth0","scheduler":"rr","time":"5","cps":"0","servers":[[],[]],"layer":"layer4","id":"d83334a4004d359427e09729d1dcbb73"},{"cName":"stats-frontend","name":"*","type":"HAproxy","protocol":"tcp","disabled":false,"description":null,"mode":"http","maxConn":null,"custom":"stats enable;stats realm Haproxy\\ Statistics;stats refresh 5s;tcp-request content accept if white_list;tcp-request content reject;","certificateName":null,"certificate":null,"port":"2000","sslPort":"","interface":"*","cps":"0","sessions":"0","bytesIn":"125","bytesOut":"21254","backends":[[]],"layer":"layer7","id":"3ce4b0e108b2c029f40051d7ae439f0d"},{"cName":"www1","name":"192.168.101.88","type":"HAproxy","protocol":"tcp","disabled":false,"description":"Web Service","mode":"http","maxConn":null,"custom":"","certificateName":null,"certificate":null,"port":"8000","sslPort":"","interface":null,"cps":"0","sessions":"0","bytesIn":"0","bytesOut":"0","backends":[[]],"layer":"layer7","id":"2b137572bc8060a32d1066ee7023b781"},{"cName":"l7test","name":"192.168.101.85","type":"HAproxy","protocol":"tcp","disabled":false,"description":"Test VIP","mode":"http","maxConn":"10","custom":"","certificateName":null,"certificate":null,"port":"80","sslPort":"","interface":null,"cps":null,"sessions":null,"bytesIn":null,"bytesOut":null,"backends":[],"layer":"layer7","id":"b0163d67dca2012360b41e46685e9661"}]

Delete a vip (Layer 4 and Layer 7):

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X DELETE -d '{"id":"$VipID"}' https://localhost/cmi-api/appliances/$nodeID/lb/vip/$vipID
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59c108818b3b84.78000841" -X DELETE -d '{"id":"12f59b31ff9458ef1dfe86c2547562e8"}' https://localhost/cmi-api/appliances/2/lb/vip/12f59b31ff9458ef1dfe86c2547562e8
Curl response: empty

Enable / Disable a VIP:

Modify VIP curl with $(disabled) = true / false

List all server from one vip:

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}" -X GET -d '' https://localhost/cmi-api/appliances/$nodeID/lb/vip/$VipID/server
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59c108818b3b84.78000841" -X GET -d '' https://localhost/cmi-api/appliances/2/lb/vip/ea34a8011323a8f90832ebb8ae560edd/server
Curl response: [{"type":"Ipvs","address":"10.10.36.56","disabled":false,"port":50,"protocol":"tcp","weight":null,"assignedWeight":"12","monitor":"","testParameters":"","cps":null,"status":null,"autoRecovery":false,"manualRecovery":false,"snmpNotify":false,"traffic":"NAT","id":"130242b5345571cf438b5bf2f8d3bc87"},{"type":"Ipvs","address":"10.10.36.55","disabled":false,"port":25,"protocol":"tcp","weight":null,"assignedWeight":"10","monitor":"","testParameters":"","cps":null,"status":null,"autoRecovery":false,"manualRecovery":true,"snmpNotify":false,"traffic":"NAT","id":"74b2084eefff7ff7d5840fbd58b8c37b"}]

Monitor list with test Parameters

  • dns-query
    • [-t secs_timeout (5)] -n dnshostname
  • dns
    • -zone zone -master master server
  • fping
    • [-r num_retries (3)] [-t milisecs_ping_delay (2000)]
  • ftp
    • [-p port (21)] [-t secs_timeout (30)]
  • http
    • [-p port (80)] [-t secs (30)] [-u url (/)] [-m regex (regex to match)] [-a agent (mon.d/http.monitor)] [-o (omit headers)]
  • imap
    • [-p port (143)] [-t secs_timeout (30)]
  • ldap
    • (anonymous bind) [--port port (389)] [--basedn 'basedn' ('o=Your Org, c=US')] [--filter 'filter'('cn=Directory Admin')] [--attribute attribute ('objectClass')]
  • ldapsearch
    • [-p port (389)] -D 'bindDn' -w 'password' -b 'basesearch' [-s scope (one)] -f 'ldap-filter' [-r attributes(dn)]
  • ntpdate
    • [--maxstratum nn (10)] [--maxoffset n.nn (0.80 secs)]
  • ping
    • (none)
  • pop3
    • [-p port (110)] [-t secs_timeout (30)]
  • process
    • [-c snmp_community (public)]
  • rpc
    • [-t secs_timeout (10)] [-a (all)] [[-p|-t] program (RPC registered)]
  • smtp
    • [-p port (25)] [-t secs_timeout (30)]
  • smtp3
    • [-l /path/to/logfile_YYYYMM.log] [--timeout secs] [--alarmtime time] [--maxfailtime secs] [--mx] [--esmtp] [--requiretls] [--nofail] [--from ] [--to ,] [--size nnnnn] [--port nn]
  • tcp
    • [-p tcp_port (23)] [-t secs_timeout (10)]
  • telnet
    • [-p port (23)] [-t secs (10)] [-l regex ('ogin:/i')

Insert new server:

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}"" -X POST -d '{"type":"$(Type)","address":"$(ServerIP)","disabled":$(disabled),"port":$(port),"weight":"$(weight)","monitor":"$(Monitor)","testParameters":"$(TestParameters)","autoRecovery":$(autoRecovery),"snmpNotify":$(snmpNotify)}' https://localhost/cmi-api/appliances/$nodeID/lb/vip/$VipID/server
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59c108818b3b84.78000841" -X POST -d '{"type":"Ipvs","address":"10.10.36.60","disabled":false,"port":50,"weight":"10","monitor":"","testParameters":"","autoRecovery":false,"snmpNotify":false}' https://localhost/cmi-api/appliances/2/lb/vip/ea34a8011323a8f90832ebb8ae560edd/server
Curl response: [{"type":"Ipvs","address":"10.10.36.60","disabled":false,"port":50,"protocol":"tcp","weight":"10","assignedWeight":"10","monitor":"","testParameters":"","cps":null,"status":null,"autoRecovery":false,"manualRecovery":false,"snmpNotify":false,"traffic":"NAT","id":"f40ce6a0a83d74b4fa5c5d5cea4b7e43"}]

Modify a server:

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: ${user}" -H "X-cmix-token: ${token}"" -X PUT -d '{"type":"$(Type)","address":"$(ServerIP)","disabled":$(disabled),"port":$(port),"weight":"$(weight)","monitor":"$(Monitor)","testParameters":"$(TestParameters)","autoRecovery":$(autoRecovery),"manualRecovery":$(manualRecovery),"snmpNotify":$(snmpNotify), "id":"$ServerID"}' https://localhost/cmi-api/appliances/$nodeID/lb/vip/$VipID/server/$ServerID
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59c108818b3b84.78000841" -X PUT -d '{"type":"Ipvs","address":"10.10.36.90","disabled":false,"port":50,"wei
ght":"10","monitor":"","testParameters":"","autoRecovery":false,"manualRecovery":false,"snmpNotify":false,"id":"607cf4f9709d5d3ef181d752fa122caa"}' https://localhost/cmi-api/appliances/2/lb/vip/ea34a8011323a8f90832ebb8ae560edd/server/607cf4f
9709d5d3ef181d752fa122caa
Curl response: {"type":"Ipvs","address":"10.10.36.95","disabled":false,"port":50,"protocol":"tcp","weight":null,"assignedWeight":"10","monitor":"","testParameters":"","cps":null,"status":null,"autoRecovery":false,"manualRecovery":false,"snmpNotify":false,"traffic":"NAT","id":"607cf4f9709d5d3ef181d752fa122caa"}

Delete a server:

Curl format: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59c108818b3b84.78000841" -X DELETE -d '{"id":"$ServerID"}' https://localhost/cmi-api/appliances/2/lb/vip/$nodeID/server/$ServerID
Curl example: curl -s -k -H "Content-Type: application/json" -H "X-cmix-username: admin" -H "X-cmix-token: localhost.localdomain59c108818b3b84.78000841" -X DELETE -d '{"id":"607cf4f9709d5d3ef181d752fa122caa"}' https://localhost/cmi-api/appliances/2/lb/vip/ea34a8011323a8f90832ebb8ae560edd/server/607cf4f9709d5d3ef181d752fa122caa
Curl response: empty

Enable / Disable a server:

Modify server curl with $(disabled) = true / false

Add a server to the pool (L4 Server):

Modify server curl with $(manualRecovery) = true