Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OK - it looks like the secret is that you can create a port in advance, then you can provide it via the (non-documented) networks attribute :

     newvm = self.osclient.compute.create_server(name=name,
                                                image_id=image.id,
                                                flavor_id=fl.id,
                                                networks=[{"port": port.id}],
                                                key_name=key_name,
                                                availability_zone=availability_zone)

The other gotcha in this is that in creating the port, you need to be careful how you specify the list of security group IDs.

port = conn.network.create_port(network_id=network.id, security_group_ids=[mysecgroup.id])

will not work, however

port = conn.network.create_port(network_id=network.id, security_groups=[str(mysecgroup.id)])

does - so note security_groups NOT security_group_ids as documented, and the explicit str() which is required.