os_server: Adding support to accept 'n' nic args as a string containing list

pull/18777/head
Abitha Palaniappan 9 years ago committed by Matt Clay
parent dd76088019
commit 5047561036

@ -84,7 +84,10 @@ options:
nics: nics:
description: description:
- A list of networks to which the instance's interface should - A list of networks to which the instance's interface should
be attached. Networks may be referenced by net-id or net-name. be attached. Networks may be referenced by net-id/net-name/port-id
or port-name.
Also this accepts a string containing a list of net-id/port-id.
Eg: nics: "net-id=uuid-1,net-id=uuid-2"
required: false required: false
default: None default: None
public_ip: public_ip:
@ -241,6 +244,25 @@ EXAMPLES = '''
image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM) image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
flavor_ram: 4096 flavor_ram: 4096
flavor_include: Performance flavor_include: Performance
# Creates a new instance and attaches to multiple network
- name: launch a compute instance
hosts: localhost
tasks:
- name: launch an instance with a string
os_server:
name: vm1
auth:
auth_url: https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/
username: admin
password: admin
project_name: admin
name: vm1
image: 4f905f38-e52a-43d2-b6ec-754a13ffb529
key_name: ansible_key
timeout: 200
flavor: 4
nics: "net-id=4cb08b20-62fe-11e5-9d70-feff819cdc9f,net-id=542f0430-62fe-11e5-9d70-feff819cdc9f..."
''' '''
@ -252,6 +274,14 @@ def _exit_hostvars(module, cloud, server, changed=True):
def _network_args(module, cloud): def _network_args(module, cloud):
args = [] args = []
nics = module.params['nics']
if type(nics) == str :
for kv_str in nics.split(","):
nic = {}
k, v = kv_str.split("=")
nic[k] = v
args.append(nic)
else:
for net in module.params['nics']: for net in module.params['nics']:
if net.get('net-id'): if net.get('net-id'):
args.append(net) args.append(net)

Loading…
Cancel
Save