enable to select a specific subnet in a net when creating a vm

Registered by Joseph P

when a net has multiple subnets for some purposes,
this function can give selecting a specific subnet that user wants to create VMs on that subnet.

Blueprint information

Status:
Complete
Approver:
None
Priority:
Undefined
Drafter:
Joseph P
Direction:
Needs approval
Assignee:
Joseph P
Definition:
Obsolete
Series goal:
Accepted for icehouse
Implementation:
Unknown
Milestone target:
None
Completed by
Mark McClain

Whiteboard

Brief code investigation shows that Neutron implementation is ready for such
functionality. When Nova invokes a new instance, it links it to specific
network by creating a new port. Port creation involves Neutron API described
at: https://wiki.openstack.org/wiki/Neutron/APIv2-specification#Create_Port
Here we can see that API users may specify specific 'Fixed IPs'. There are two
options mentioned there: specifying both subnet and IP address, which results
in binding port to specific address, or specifying subnet id only, which will
result in non-predeterminate IP address chosen for the instance from the subnet
specified.

Speaking of neutron client, we may pass the preferred subnet as an argument as
follows:

# neutron port-create --fixed-ip subnet_id=subnet1 public

The only problem here is that help message does not suggest there's such
possibility:

# neutron port-create
usage: neutron port-create [-h] [-f {shell,table}] [-c COLUMN]
                           [--variable VARIABLE] [--prefix PREFIX]
                           [--request-format {json,xml}]
                           [--tenant-id TENANT_ID] [--name NAME]
                           [--admin-state-down] [--mac-address MAC_ADDRESS]
                           [--device-id DEVICE_ID]
                           [--fixed-ip ip_address=IP_ADDR]
                           [--security-group SECURITY_GROUP | --no-security-groups [--extra-dhcp-opt EXTRA_DHCP_OPTS]
                           NETWORK
neutron port-create: error: too few arguments

Client part will be handled as:
https://review.openstack.org/#/c/65690/

Now proceeding to Nova part. The code used to invoke new instance and assign it
to network can be found in: nova/network/neutronv2/api.py. Specifically, the
following function is used to create a port for an instance:
API._create_port(). It's passed the following argument, among other things:
":param fixed_ip: Optional fixed IP to use from the given network." It's a
simple string representation of the desired IP address.

Assuming this works the same way as passing both subnet id and ip address.

What we miss is passing specific subnet_id instead of fixed_ip to the function,
and properly setting it for Neutron port POST request.

Conclusion: this is not really a Neutron BP, as it does not require any code changes
in this project. Changes to horizon and novaclient utilities will probably also be
needed.

nova blueprint: https://blueprints.launchpad.net/nova/+spec/selecting-subnet-when-creating-vm

horizon blueprint: https://blueprints.launchpad.net/horizon/+spec/selecting-subnet-when-creating-vm

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.