With the new NOS release comes a new exciting option: Acropolis. The PRISM UI looks awesome slick like always and allows you to create networks and virtual machines with a few clicks. With this Acropolis Hypervisor Management you have the power to use your Nutanix solution to automate your Test/Dev environment or run your Build automation for example.
Okay… But where´s the automation magic?
Within the PRISM UI there´s the well known REST API and with Acropolis there´s a new one: the Management API based on REST. With this API it´s just easy to create a network, create a virtual machine, test some stuff, delete the virtual machine, delete the network and validate the results.
I just wanted to show you how to automate the network creation with a short python snippet:
import json import requests import config import time def main(): requests.packages.urllib3.disable_warnings() base_url = "https://10.20.26.9:9440/api/nutanix/v0.8/" s = requests.Session() s.auth = (config.kvm_cred["username"], config.kvm_cred["password"]) s.headers.update({'Content-Type': 'application/json; charset=utf-8'}) data = s.get(base_url + 'networks', verify=False).json() print data net = {'vlanId': '100', 'uuid': '1aa07ddb-d887-4aaf-8a74-2fb8b3044d55', 'ipConfig': {'dhcpServerAddress': '10.10.10.10', 'networkAddress': '10.10.10.0', 'prefixLength': 24}} r = s.post(base_url + 'networks', data=json.dumps(net)) result = r.json() print "Network was created... One minute sleep before network gets deleted." time.sleep(60) remove = s.delete(base_url + 'networks/' + result["networkUuid"]) print remove if __name__ == "__main__": main()
As you can see this short script create a network, sets the config (only a few parameters, all others can be found in the REST Explorer) and deletes the network, with the VLAN ID 100, after 60 seconds.
Imagine how easy it is to build an integration in your Build system like Jenkins, Maven, Ant etc. to deploy the tests directly on Nutanix without complex infrastructure administration or layered automation.
I will post some more automation magic in the next days 🙂
One Comment
Nice tutorial! I am experimenting the REST API for Nutanix CE. It seems like there is no API for deleting a vm. But since they claim that everything you can do through the web console you can do it with REST API, do you know if ‘Delete VM’ API actually exists?