-
Book Overview & Buying
-
Table Of Contents
OpenStack Networking Cookbook
By :
The previous recipe showed you how to create a Port using CLI. The next recipe shows you how we can use an existing Port as part of the instance creation command.
For this recipe, you will have to identify the Port that you want to associate with an instance. For the instance creation itself, the software image needs to be identified.
The next set of steps will show you how to use the Nova and Neutron CLI commands to create an instance that uses an existing Port:
neutron port-list command and identify the ID of the Port that you want to use to create an instance. Make a note of the MAC and IP addresses assigned to the Port:
nova boot. This command supports an argument called --nic that allows us to specify a Port ID that we want to associate with the instance:openstack@controller:~$ nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic port-id=ee6f30a1-6851-435a-89cd-a8e7390325a4 CLIPortVM
CLIPortVM. If we execute the nova show command now, we can see the details about the instance:

At the shell prompt of the instance, type ifconfig eth0. This command will show the virtual interface for this instance. The command output shows the MAC and IP addresses that are assigned to the virtual interface:

This recipe demonstrated how to associate a Port to an instance. At the end of the recipe, we can see that the MAC and IP addresses for this virtual interface (eth0) match those of the Port that we used in the nova boot command.
We have seen that Neutron assigns an IP address and MAC address to a Port during their creation. When users execute the nova boot command with the --nic option, then Nova takes the IP and MAC addresses of the Port and uses this information to configure the virtual interface of the instance.
This technique of creating a Port prior to the instance creation is helpful if a specific IP address needs to be assigned to an instance or virtual machine. While we will cover this in another recipe later in the book, it is important to note that this capability is not available using the Horizon dashboard.
Change the font size
Change margin width
Change background colour