April 2018
Intermediate to advanced
280 pages
8h 37m
English
One of the most important operations that our application might have to perform is launching a new virtual machine on OpenStack. Launching a VM requires the VM name, Glance image name, the network name to connect this VM to, and the keypair to be used. Once these parameters are available, we can easily launch a virtual machine using the create_server() function call.
The following program creates image, flavor, network, and keypair objects and launches a virtual machine. Note that we are using the create_keypair() function that we wrote in the last section. The wait_for_server() function will ensure that the program waits for the VM to launch and then proceeds:
def create_vm(conn): server_name = "packt-pub-vm" # The name to ...