Add method to attach several interfaces for one network

Added interfaces_create method that creates the given
count of interfaces for the given network

Change-Id: I01b68d38449dc7bec6868d03159b1c9a803e67a5
Closes-Bug: #1301834
This commit is contained in:
Anastasiia Naboikina 2014-04-04 17:44:50 +03:00
parent 076940706c
commit 6dd926bcd5
1 changed files with 19 additions and 6 deletions

View File

@ -162,15 +162,28 @@ class Manager(object):
return generate_mac()
def interface_create(self, network, node, type='network',
mac_address=None, model='virtio'):
mac_address=None, model='virtio',
interface_map={}):
"""
:rtype : Interface
"""
interface = Interface.objects.create(
network=network, node=node, type=type,
mac_address=mac_address or self._generate_mac(), model=model)
interface.add_address(str(network.next_ip()))
return interface
interfaces = []
def _create(mac_addr=None):
interface = Interface.objects.create(
network=network, node=node, type=type,
mac_address=mac_addr or self._generate_mac(),
model=model)
interface.add_address(str(network.next_ip()))
return interface
if interface_map:
if len(interface_map[network.name]) > 0:
for iface in interface_map[network.name]:
interfaces.append(_create())
return interfaces
else:
return _create(mac_address)
def network_create_address(self, ip_address, interface):
"""