Auto Scaling
Create an API Key and access token:
For create a API Key and Access Token to refer this link :-
https://www.e2enetworks.com/help/knowledge-base/how-to-create-an-api-access-token/
List of Auto Scaling
To get the list of auto scaling send a GET request:-
https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}&location=Delhi
PYTHON
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
conn.request("GET", "/myaccount/api/v1/scaler/scalegroups?apikey={{api}}&location=Delhi", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}&location=Delhi"
payload = ''
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
Headers
Request Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-
content-type: application/json; charset=utf-8
status: 202 Accepted
Body
Response Body
{
"code": 200,
"data": [
{
"id": "1518",
"name": "image1-disk-0-301",
"policy": "CPU>60",
"policy_measure": "CPU",
"policy_op": ">",
"upscale_policy_value": 60,
"downscale_policy_value": 30,
"running": 2,
"desired": 2,
"provision_status": "Deploying",
"tags": "",
"min_nodes": 2,
"max_nodes": 5,
"plan_name": "C2.12GB",
"vm_image_name": "image1-disk-0",
"wait_for_period": 3,
"wait_period": 10,
"cooldown": 150
},
],
"errors": {},
"message": "Success"
}
Create Auto scaling
Create Auto scaling
with Elastic Policy
To create an auto scale service with elstic policy set send a POST request:-
https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}
PYTHON
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"name": "elastic_scale",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"policy": [
{
"type": "CHANGE",
"adjust": 1,
"expression": "CPU>60",
"period_number": "3",
"period": "10",
"cooldown": "150"
},
{
"type": "CHANGE",
"adjust": -1,
"expression": "CPU<30",
"period_number": "3",
"period": "10",
"cooldown": "150"
}
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'api_token'
}
conn.request("POST", "/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}"
payload = json.dumps({
"name": "elastic_scale",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"policy": [
{
"type": "CHANGE",
"adjust": 1,
"expression": "CPU>60",
"period_number": "3",
"period": "10",
"cooldown": "150"
},
{
"type": "CHANGE",
"adjust": -1,
"expression": "CPU<30",
"period_number": "3",
"period": "10",
"cooldown": "150"
}
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'api_token'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Headers
Request Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-
content-type: application/json; charset=utf-8
status: 202 Accepted
Body
Request Body-
{
"name": "elastic_scale",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"policy": [
{
"type": "CHANGE",
"adjust": 1,
"expression": "CPU>60",
"period_number": "3",
"period": "10",
"cooldown": "150"
},
{
"type": "CHANGE",
"adjust": -1,
"expression": "CPU<30",
"period_number": "3",
"period": "10",
"cooldown": "150"
}
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
}
Response Body
{
"code": 200,
"data": {
"id": "6187",
"name": "elastic_scale",
"plane_name": null,
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"provision_status": "Deploying",
"running": 0,
"desired": 2,
"tags": "",
"min_nodes": 2,
"max_nodes": 5,
"customer_id": 18956,
"plan_id": 188,
"image_id": 14523,
"nodes": [],
"elastic_policy": {
"type": "CHANGE",
"policy": "CPU>60",
"policy_measure": "CPU",
"policy_op": ">",
"upscale_policy_value": 60.0,
"downscale_policy_value": 30.0,
"wait_for_period": 3,
"wait_period": 10,
"cooldown": 150
}
},
"errors": {},
"message": "Success"
}
with Schedule Policy
To create an auto scale with schedule policy set send a POST request:-
https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}
PYTHON
`1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"name": "schedule_policy",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"scheduled_policy": [
{
"type": "CARDINALITY",
"adjust": 4,
"recurrence": "0 0 1 * *"
},
{
"type": "CARDINALITY",
"adjust": "2",
"recurrence": "0 0 12 1 1"
}
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'api_token',
}
conn.request("POST", "/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}"
payload = json.dumps({
"name": "schedule_policy",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"scheduled_policy": [
{
"type": "CARDINALITY",
"adjust": 4,
"recurrence": "0 0 1 * *"
},
{
"type": "CARDINALITY",
"adjust": "2",
"recurrence": "0 0 12 1 1"
}
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'api_token',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Headers
Request Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-
content-type: application/json; charset=utf-8
status: 202 Accepted
Body
Request Body-
{
"name": "schedule_policy",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"scheduled_policy": [
{
"type": "CARDINALITY",
"adjust": 3,
"recurrence": "0 0 1 * *"
},
{
"type": "CARDINALITY",
"adjust": "2",
"recurrence": "0 0 12 1 1"
}
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
}
Response Body
{
"code": 200,
"data": {
"id": "6199",
"name": "schedule_policy",
"plane_name": null,
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"provision_status": "Deploying",
"running": 0,
"desired": 2,
"tags": "",
"min_nodes": 2,
"max_nodes": 5,
"customer_id": 18956,
"plan_id": 188,
"image_id": 14523,
"nodes": [],
"scheduled_policy": {
"type": "CARDINALITY",
"scheduled_policy_ip": "scheduled_action",
"upscale_recurrence": "0 0 1 * *",
"upscale_adjust": 3,
"downscale_recurrence": "0 0 12 1 1",
"downscale_adjust": 2
}
},
"errors": {},
"message": "Success"
}
with Elastic and Schedule Policy
To create an scale service which has both elastic and schedule policy set send a POST request:-
https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}
PYTHON
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = json.dumps({
"name": "elastic_with_schedule",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"policy": [
{
"type": "CHANGE",
"adjust": 1,
"expression": "CPU>60",
"period_number": "3",
"period": "10",
"cooldown": "150"
},
{
"type": "CHANGE",
"adjust": -1,
"expression": "CPU<30",
"period_number": "3",
"period": "10",
"cooldown": "150"
}
],
"scheduled_policy": [
{
"type": "CARDINALITY",
"adjust": 3,
"recurrence": "0 0 1 * *"
},
{
"type": "CARDINALITY",
"adjust": "2",
"recurrence": "0 0 12 1 1"
}
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'api_token',
}
conn.request("POST", "/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}"
payload = json.dumps({
"name": "elastic_with_schedule",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"policy": [
{
"type": "CHANGE",
"adjust": 1,
"expression": "CPU>60",
"period_number": "3",
"period": "10",
"cooldown": "150"
},
{
"type": "CHANGE",
"adjust": -1,
"expression": "CPU<30",
"period_number": "3",
"period": "10",
"cooldown": "150"
}
],
"scheduled_policy": [
{
"type": "CARDINALITY",
"adjust": 3,
"recurrence": "0 0 1 * *"
},
{
"type": "CARDINALITY",
"adjust": "2",
"recurrence": "0 0 12 1 1"
}
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'api_token',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Headers
Request Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-
content-type: application/json; charset=utf-8
status: 202 Accepted
Body
Request Body-
{
"name": "elastic_with_schedule",
"min_nodes": "2",
"desired": "2",
"max_nodes": "5",
"plan_id": "188",
"plan_name": "C2.40GB",
"sku_id": "188",
"policy": [
{
"type": "CHANGE",
"adjust": 1,
"expression": "CPU>60",
"period_number": "3",
"period": "10",
"cooldown": "150"
},
{
"type": "CHANGE",
"adjust": -1,
"expression": "CPU<30",
"period_number": "3",
"period": "10",
"cooldown": "150"
}
],
"scheduled_policy": [
{
"type": "CARDINALITY",
"adjust": 3,
"recurrence": "0 0 1 * *"
},
{
"type": "CARDINALITY",
"adjust": "2",
"recurrence": "0 0 12 1 1"
}
],
"vm_image_id": "14523",
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"vm_template_id": 19755,
"my_account_sg_id": 30767
}
Response Body
{
"code": 200,
"data": {
"id": "6201",
"name": "elastic_with_schedule",
"plane_name": null,
"vm_image_name": "C2-40GB-cu-4-image-disk-0",
"provision_status": "Deploying",
"running": 0,
"desired": 2,
"tags": "",
"min_nodes": 2,
"max_nodes": 5,
"customer_id": 18956,
"plan_id": 188,
"image_id": 14523,
"nodes": [],
"elastic_policy": {
"type": "CHANGE",
"policy": "CPU>60",
"policy_measure": "CPU",
"policy_op": ">",
"upscale_policy_value": 60.0,
"downscale_policy_value": 30.0,
"wait_for_period": 3,
"wait_period": 10,
"cooldown": 150
},
"scheduled_policy": {
"type": "CARDINALITY",
"scheduled_policy_ip": "scheduled_action",
"upscale_recurrence": "0 0 1 * *",
"upscale_adjust": 3,
"downscale_recurrence": "0 0 12 1 1",
"downscale_adjust": 2
}
},
"errors": {},
"message": "Success"
}
Delete Auto scaling
To Delete auto scaling to send a DELETE request:-
https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/1516?apikey={{api_key}}
PYTHON
1. Python - http.client Example
import http.client
import json
conn = http.client.HTTPSConnection("api.e2enetworks.com")
payload = ''
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
conn.request("DELETE", "/myaccount/api/v1/scaler/scalegroups/1516?apikey={{api_key}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2. Python - Requests Example
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/1516?apikey={{api_key}}"
payload = ''
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
response = requests.request("DELETE", url, headers=headers, data=payload)
print(response.text)
Headers
Request Headers
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
Response Headers:-
content-type: application/json; charset=utf-8
status: 202 Accepted
Body
Response Body
{
"code": 204,
"data": {},
"errors": {},
"message": "Success"
}