create server with python api
I followed the link below to create a server by calling python nova client..
Here is my code:
nic_d = [{'net-id': int_net_id_1[0]}, {'net-id': int_net_id_2[0]}]
instance = nc.servers.create(name="vm2", image=img, flavor=my_flavor, nics=nic_d)`enter code here`
However when I specified the nics, it sent me the following error:
Traceback (most recent call last):
File "/home/tsi/openstack/orch-os/src/launchvm.py", line 45, in <module>
instance = nc.servers.create(name="vm2", image=img, flavor=my_flavor, nics=nic_d)
File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/servers.py", line 456, in create
**boot_kwargs)
File "/usr/lib/python2.7/dist-packages/novaclient/v1_1/base.py", line 147, in _boot
if nic_info['v4-fixed-ip']:
KeyError: 'v4-fixed-ip'
I had no issue with this code before using the old version client.. but somehow the newer version added new checkpoint.. My problem is that I don't want to use fixed ip, instead I would like to use dhcp to get ip address. I'm thinking to use port-id to replace the net-id but I'm not sure how to code it with servers.create() function.
Any suggestions on how to workaround it?