Skip to content

Commit

Permalink
Set port security for all allocated ips
Browse files Browse the repository at this point in the history
Fixes LP929018

Change-Id: Iab56cb815381eb4832358053bde8ddc70f9c4ef6
  • Loading branch information
jkoelker committed Feb 8, 2012
1 parent 27ac9d5 commit d7b032b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions nova/network/quantum/manager.py
Expand Up @@ -341,13 +341,13 @@ def allocate_for_instance(self, context, **kwargs):
rxtx_factor = instance_type['rxtx_factor']
nova_id = self._get_nova_id(instance)
# Tell the ipam library to allocate an IP
ip = self.ipam.allocate_fixed_ip(context, project_id,
ips = self.ipam.allocate_fixed_ips(context, project_id,
quantum_net_id, net_tenant_id, vif_rec)
pairs = []
# Set up port security if enabled
if FLAGS.quantum_use_port_security:
pairs = [{'mac_address': vif_rec['address'],
'ip_address': ip}]
'ip_address': ip} for ip in ips]
self.q_conn.create_and_attach_port(net_tenant_id, quantum_net_id,
vif_rec['uuid'],
vm_id=instance['uuid'],
Expand Down
12 changes: 6 additions & 6 deletions nova/network/quantum/melange_ipam_lib.py
Expand Up @@ -79,13 +79,13 @@ def create_subnet(self, context, label, project_id,
admin_context = context.elevated()
network = db.network_create_safe(admin_context, net)

def allocate_fixed_ip(self, context, project_id, quantum_net_id,
network_tenant_id, vif_ref):
def allocate_fixed_ips(self, context, project_id, quantum_net_id,
network_tenant_id, vif_ref):
"""Pass call to allocate fixed IP on to Melange"""
ip = self.m_conn.allocate_ip(quantum_net_id, network_tenant_id,
vif_ref['uuid'], project_id,
vif_ref['address'])
return ip[0]['address']
ips = self.m_conn.allocate_ip(quantum_net_id, network_tenant_id,
vif_ref['uuid'], project_id,
vif_ref['address'])
return [ip['address'] for ip in ips]

def get_network_id_by_cidr(self, context, cidr, project_id):
"""Find the Quantum UUID associated with a IPv4 CIDR
Expand Down
6 changes: 3 additions & 3 deletions nova/network/quantum/nova_ipam_lib.py
Expand Up @@ -129,8 +129,8 @@ def get_project_and_global_net_ids(self, context, project_id):
id_priority_map[net_id] = n['priority']
return sorted(net_list, key=lambda x: id_priority_map[x[0]])

def allocate_fixed_ip(self, context, tenant_id, quantum_net_id,
network_tenant_id, vif_rec):
def allocate_fixed_ips(self, context, tenant_id, quantum_net_id,
network_tenant_id, vif_rec):
"""Allocates a single fixed IPv4 address for a virtual interface."""
admin_context = context.elevated()
network = db.network_get_by_uuid(admin_context, quantum_net_id)
Expand All @@ -142,7 +142,7 @@ def allocate_fixed_ip(self, context, tenant_id, quantum_net_id,
values = {'allocated': True,
'virtual_interface_id': vif_rec['id']}
db.fixed_ip_update(admin_context, address, values)
return address
return [address]

def get_tenant_id_by_net_id(self, context, net_id, vif_id, project_id):
"""Returns tenant_id for this network. This is only necessary
Expand Down

0 comments on commit d7b032b

Please sign in to comment.