Add openstack instance second NIC


#1

Anybody has sample code on how to add a second NIC to an Openstack instance at provisioning time?


#2

Posting in case someone has the same question. Found this code that does what we need:

https://github.com/ramrexx/CloudFormsPOC/blob/master/Automate/CloudFormsPOC/Cloud/VM/Provisioning/StateMachines/Methods.class/methods/openstack_preprovision.rb

Check add_networks.


#3

@jhernandez hello

the right place for setting networks should be placement step in state machine. Method is called best_fit_openstack. Doing something like this will set any networks you need.

prov = $evm.root[“miq_provision”]
private_networks = prov.eligible_cloud_networks.select { |x| x.external_facing == false }
prov.set_option(:networks, [{:network_id => private_networks[0].id}, {:network_id => private_networks[1].id}])

I never tried add_networks, it might work too.