Tutorial: How to Launch a Node from Saved Image via API

Introduction:

Deploying applications on production gets easier when we can use API to programmatically manage to compute nodes and resources on E2E Cloud, In this guide, we will use API and show you how to Launch a node with the Saved Image using CURL command for Nodes

prerequisite

  • Image of Your Virtual Compute Node. If you have not yet saved the Image, Please refer to this article to Save your Image.

  • Create an API token necessary to interact with E2E Networks API, If you have not yet created the API, Please refer to this article

Step 1: Get Your Template Image ID

After You save Image on Your Myaccount Portal, You need to get the template ID of your Saved Image. This detail can be Fetched by using below API curl command

curl -X GET 'https://api.e2enetworks.com/myaccount/api/v1/images/saved-images/?apikey=75c48498-0c44-4c1b-995d-4ba835fc601d9' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJjejBXYVVKVF9wWmE5MXNpRl9QRXVxUUpqdm5VODhsMXdsVmNla1ZiUXBRIn0.eyJqdGkiOiIwYWIwMWYyNC02N2Q2LTRjMmEtYThmYS03M2IxNTc1ZGFhYTAiLCJleHAiOjE2MzY2MTY4OTMsIm5iZiI6MCwiaWF0IjoxNjA1MDgwODkzLCJpc3MiOiJodHRwOi8vZ2F0ZXdheS5lMmVuZXR3b3Jrcy5jb20vYXV0aC9yZWFsbXMvYXBpbWFuIiwiYXVkIjoiYXBpbWFudWkiLCJzdWIiOiIyY2NjODI0YS04YWFhLTRlNjktYWU3MC1jNjM4YmY0ZGNkYTEiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJhcGltYW51aSIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjczMzQzNzhmLTUxM2UtNGFiZS1iMjY1LTcxYWY2YjVjMjY2ZSIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOltdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsidW1hX2F1dGhvcml6YXRpb24iLCJhcGl1c2VyIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwibmFtZSI6Ik1vaGFtbWVkIEZ1cnFhYW4iLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJtb2hhbW1lZC5mdXJxYWFuQGUyZW5ldHdvcmtzLmNvbSIsImdpdmVuX25hbWUiOiJNb2hhbW1lZCIsImZhbWlseV9uYW1lIjoiRnVycWFhbiIsImVtYWlsIjoibW9oYW1tZWQuZnVycWFhbkBlMmVuZXR3b3Jrcy5jb20ifQ.PT9Lvw9yVkQTJaczYyJecJkbpZS7HMiaPXHXMC9VIbWYP59OnkNN082gVJkaSPUx9Gx3GJSg8987SN0ZcVj4PM4_8Yug3F1V8vFhI8FYeDNLbTT6XYuzS3LjePCmo6j20bPAvsr-TpeY7emff3778AG-xqKBd6J7vPWUD-oNIZtl8JprlRezzlkjhe4MaZqAR5JP52uDxIWBpOmEEJrcsgII-98cS2jX2tZK2GtNEU2D-kzr3veAEfnFkWZf34BiCgbqp4SnH86s2ReboeXkx1b2blSsdXVbShh9cQekWna_4OaljCmPlsgR-FHtvKpLTnVHUQZpgjlgc9JkOAajUQ'

Note

Replace the Actual API key and Authentication Token of yours on the Above command.

Once you have run the above command, You will get outputs similar to as below

{"code":200,"data":[{**"template_id":6157**,"vm_info":[],"os_distribution":"web2-18",**"name":"web2-18-disk-0"**,"image_id":"3536","distro":"CentOS-7.5","sku_type":"C2VPS","image_state":"Ready","running_vms":"0","image_size":"95.367 GB","creation_time":"12-10-2020 12:26:57","auto_scale_template":true},{"template_id":5066,"vm_info":[],"os_distribution":"CP-I360-C2.15GB-Upgraded","name":"cpanel_centos7_golden_04062020_new-disk-0","image_id":"3035","distro":"CentOS-7.5-cpanel","sku_type":"C2_CP_Imunify","image_state":"Ready","running_vms":"0","image_size":"8.192 GB","creation_time":"04-06-2020 22:15:28","auto_scale_template":true}],"errors":{},"message":"Success"}

In the above output, We can Identify the Template ID of our Image. Here its 6157 for the image web2-18-disk-0

Step 2: Identify Image Name and Plan Name associated with your Saved Image

For creating a node using the Image, You need to have details of the Image Name and Plan name that is associated with your Image. Only then you would be able to Launch a node for your Image with an Appropriate Plan. For Example, if you have saved Centos 7 Server, You need to get the details of the centos 7 Plan name and its Image Name. You can get the Image and Plan name for your saved Image using below curl command.

Make Sure to replace the Template ID in the below command with your actual ID. In this case, our Template ID was 6157

curl -X GET  'https://api.e2enetworks.com/myaccount/api/v1/images/upgradeimage/6157/?apikey=bc62dab6-0b60-4237-8754-43ffd6e803c0'  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJjejBXYVVKVF9wWmE5MXNpRl9QRXVxUUpqdm5VODhsMXdsVmNla1ZiUXBRIn0.eyJqdGkiOiJkYjljMTM1OC1lZWJkLTQzYmEtODQyZi0yYzE4ODgxMmQ0MmYiLCJleHAiOjE2MzY2MTY0MDAsIm5iZiI6MCwiaWF0IjoxNjA1MDgwNDAwLCJpc3MiOiJodHRwOi8vZ2F0ZXdheS5lMmVuZXR3b3Jrcy5jb20vYXV0aC9yZWFsbXMvYXBpbWFuIiwiYXVkIjoiYXBpbWFudWkiLCJzdWIiOiIyY2NjODI0YS04YWFhLTRlNjktYWU3MC1jNjM4YmY0ZGNkYTEiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJhcGltYW51aSIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6ImZiZGViZDA3LWMwN2ItNDdjOS05ZDNiLTRkMWQ5M2ZmOGFiYSIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOltdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsidW1hX2F1dGhvcml6YXRpb24iLCJhcGl1c2VyIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwibmFtZSI6Ik1vaGFtbWVkIEZ1cnFhYW4iLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJtb2hhbW1lZC5mdXJxYWFuQGUyZW5ldHdvcmtzLmNvbSIsImdpdmVuX25hbWUiOiJNb2hhbW1lZCIsImZhbWlseV9uYW1lIjoiRnVycWFhbiIsImVtYWlsIjoibW9oYW1tZWQuZnVycWFhbkBlMmVuZXR3b3Jrcy5jb20ifQ.QWwf-HuDH3RjVCB6TWaBEGRz-AbS1ycoAkpkHTlgEZifY54bKQUeQK6U0PXRJWOk4dSjHdLI2lwkvXPUfjOCzMzSjiojUi1AmaiHHIyLg57w4Eh_v6nf006Y_73-y6149fFpB3ntXLCXGPQ4wzE2JJAmIhfS7zvclTsEjZk0LHzNZQUWnJCVWtmCyHDdmX-U6bNs4RtpMuly7Tq4JODSNRGjTPqWb7_Y71H61mRgcur2UQkBO4wNfiqcmVSkLzhaOktBoXYY0nNzu83MhX98CmgJrsET0PlDNfQCVcpinv4wp_gLwwtHtLcPlWx4d0AorCM0WQ9SnZDBSmqhcm-A' -H 'Content-Type: application/json'

Note

Replace the Actual API key, Authentication Token, and Template ID of yours on the Above command.

You will get outputs similar to as below

{"code":200,"data":[{"name":"C2.12GB-CentOS-7.5",**"plan":"C-4vCPU-12RAM-100DISK-C2.12GB-CentOS-7.5"**,**"image":"CentOS-7.5-Distro"**,"os":{"name":"CentOS","version":"7.5","image":"CentOS-7.5-Distro","category":"CentOS"},"location":"Delhi","specs":{"id":"184","sku_name":"C2.12GB","ram":"12.00","cpu":4,"disk_space":100,"price_per_month":"1642.50","price_per_hour":"2.25","series":"C","minimum_billing_amount":"0","committed_sku":[{"committed_sku_id":229,"committed_sku_name":"365 Days Committed , Rs 17739","committed_node_message":"This committed node will be reserved for next 365 days ( till 13-November-2021 18:39). The cost Rs. 17739 of this node  will be added in next invoice.","committed_sku_price":"17739","committed_upto_date":"13-November-2021 18:39","committed_days":365}],"family":"CPU Intensive","available_inventry":-1},"cpu_type":"vCPU","gpu_card_details":{},"node_description":"","installed_application_version":{},"can_support_bitninja":{"show_bitninja":true,"bitninja_cost":"760.00"}},{"name":"C2.15GB-CentOS-7.5",**"plan":"C-6vCPU-15RAM-150DISK-C2.15GB-CentOS-7.5"**,"image":"CentOS-7.5-Distro","os":{"name":"CentOS","version":"7.5","image":"CentOS-7.5-Distro","category":"CentOS"},"location":"Delhi","specs":{"id":"176","sku_name":"C2.15GB","ram":"15.00","cpu":6,"disk_space":150,"price_per_month":"2555.00","price_per_hour":"3.50","series":"C","minimum_billing_amount":"0","committed_sku":[{"committed_sku_id":512,"committed_sku_name":"365 Days Committed , Rs 27594","committed_node_message":"This committed node will be reserved for next 365 days ( till 13-November-2021 18:39). The cost Rs. 27594 of this node  will be added in next invoice.","committed_sku_price":"27594","committed_upto_date":"13-November-2021 18:39","committed_days":365}],"family":"CPU Intensive","available_inventry":-1},"cpu_type":"vCPU","gpu_card_details":{},"node_description":"","installed_application_version":{},"can_support_bitninja":{"show_bitninja":true,"bitninja_cost":"760.00"}},{"name":"C2.20GB-CentOS-7.5",**"plan":"C-8vCPU-20RAM-300DISK-C2.20GB-CentOS-7.5"**,"image":"CentOS-7.5-Distro","os":{"name":"CentOS","version":"7.5","image":"CentOS-7.5-Distro","category":"CentOS"},"location":"Delhi","specs":{"id":"186","sku_name":"C2.20GB","ram":"20.00","cpu":8,"disk_space":

As shown in the above output, You can get the Image and Plan details for your Nodes. You can Select any of the above Plans from the output to create a node. In this case, we are selecting

Image Name = CentOS-7.5-Distro
Plan Name = C-4vCPU-12RAM-100DISK-C2.12GB-CentOS-7.5

Step 3: Launching the Node from Saved Image.

You have now got the details of Template ID, Image Name, Plan Name, You can Now the Launch the Node with the below API curl command and replace the data accordingly in the below command

curl -X POST \
   'https://api.e2enetworks.com/myaccount/api/v1/nodes/?apikey=bc62dab6-56020-4237-84a8-43ffd6e803c0' \
   -H 'Authorization: Bearer     eyJhbGciOiJSUzI1Ni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XPUfjOCzMzSjiojUi1AmaiHHIyLg57w4Eh_v6nf006Y_73-y6149fFpB3ntXLCXGPQ4wzE2JJAmIhfS7zvclTsEjOXZk0LHzNZQUWnJCVWtmCyHDdmX-U6bNs4RtpMuly7Tq4JODSNRGjTPqWb7_Y71H61mRgcur2UQkBO4wNfiqcmVSkLzhaOktBoXYY0nNzu83MhX98CmgJrsET0PlDNfQCVcpinv4wp_gLwwtHtLcPlWx4d0AorCM0WQ9SnZDBSmqhcm-A' \
   -H 'Content-Type: application/json' \
   -H 'Postman-Token: 5a201495-93c9-437d-ae64-ca50e4082bb1' \
   -H 'cache-control: no-cache' \
   -d '{"name":"C2-12GB-CentOS-7-5",
 "region":"ncr",
 "plan":"C-4vCPU-12RAM-100DISK-C2.12GB-CentOS-7.5**",
 "image":"CentOS-7.5-Distro**",
 "ssh_keys":[],
 "backups":false,
 "enable_bitninja":false,
 "disable_password":false,
 "is_saved_image":true,
 "saved_image_template_id":"6157"**,
 "reserve_ip":""}'

Note

Replace the Actual API key, Authentication Token, Template ID, Plan, and Image Name of yours on the Above command

You will get outputs similar to as below and Message at the end as a success, Which means your Node has been launched successfully.

{"code":200,"data":{"id":55366,"name":"C2-12GB-CentOS-7-5","created_at":"2020-11-11T08:37:24.897236Z","public_ip_address":"164.52.194.3","private_ip_address":"172.16.122.245","backup":false,"disk":"100 GB","status":"Creating","vcpus":"4","memory":"12 GB","plan":"C2.12GB","region":null,"is_locked":false,"zabbix_host_id":null,"gpu":"","price":"Rs 2.25/Hour or Rs 1642.50 Monthly","additional_ip":[],"label":"Default","ssh_keys":[],"is_active":true,"scaler_id":null,"os_info":{"name":"CentOS","version":"7.5","category":"Linux Virtual Node"},"is_monitored":false,"backup_status":"not_enabled","location":"Delhi","monitor_status":{"status":"not_activated","reason":""},"enable_bitninja_details":{"show_bitninja":true,"bitninja_cost":"760.00"},"is_bitninja_license_active":false,"any_license_attached":{"is_license_attached":false,"license_deletion_message":""},"is_committed":false},"errors":{},"message":"Success"

Conclusion:

You will now be able to Launch the Node from your Image, every time when you run the Launch node curl command. If you face any issue while performing the above-mentioned action. Contact us at cloud-platform@e2enetworks.com to get assistance on it.