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&project_id={{id}}
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&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}&project_id={{id}}&location=Delhi"
payload = ''
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
content-type: application/json; charset=utf-8
status: 202 Accepted
{
"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
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}}&project_id={{id}}
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}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}&project_id={{id}}"
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)
curl 'https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey=' \
–header ‘Content-Type: application/json’ –header ‘Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJGSjg2R2NGM2pUYk5MT2NvNE52WmtVQ0lVb
“desired”: 2, “max_nodes”: 5, “min_nodes”: 2, “name”: “image1-disk-0-301”, “plan_id”: “184”, “plan_name”: “C2.12GB”, “policy”: [
- {
“adjust”: 1, “cooldown”: 150, “expression”: “CPU>60”, “period”: 10, “period_number”: 3, “type”: “CHANGE”
}, {
“adjust”: -1, “cooldown”: 150, “expression”: “CPU<30”, “period”: 10, “period_number”: 3, “type”: “CHANGE”
}
], “sku_id”: “184”, “vm_image_id”: “8515”, “vm_image_name”: “image1-disk-0”, “vm_template_id”: 11959
}’
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
content-type: application/json; charset=utf-8
status: 202 Accepted
{
"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
}
{
"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}}&project_id={{id}}
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}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups?apikey={{api_key}}&project_id={{id}}"
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)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
content-type: application/json; charset=utf-8
status: 202 Accepted
{
"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
}
{
"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}}&project_id={{id}}
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}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/?apikey={{api_key}}&&project_id={{id}}"
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)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
content-type: application/json; charset=utf-8
status: 202 Accepted
{
"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
}
{
"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}}&project_id={{id}}
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}}&project_id={{id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
import json
url = "https://api.e2enetworks.com/myaccount/api/v1/scaler/scalegroups/1516?apikey={{api_key}}&project_id={{id}}"
payload = ''
headers = {
'Authorization': 'api_token',
'Content-Type': 'application/json',
}
response = requests.request("DELETE", url, headers=headers, data=payload)
print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
content-type: application/json; charset=utf-8
status: 202 Accepted
{
"code": 204,
"data": {},
"errors": {},
"message": "Success"
}