components/openstack/neutron/files/agent/evs_l3_agent.py
branchs11-update
changeset 3196 4c06db2d9388
parent 3178 77584387a894
child 3200 16d08ab96b7f
equal deleted inserted replaced
3195:cf6a5a756b74 3196:4c06db2d9388
   239                             "with the external network, and it is required "
   239                             "with the external network, and it is required "
   240                             "to create external gateway port: %s") % err)
   240                             "to create external gateway port: %s") % err)
   241                 return
   241                 return
   242             vid = stdout.splitlines()[0].strip()
   242             vid = stdout.splitlines()[0].strip()
   243             if vid == "":
   243             if vid == "":
   244                 LOG.error(_("External Network does not has a VLAN ID "
   244                 LOG.error(_("External Network does not have a VLAN ID "
   245                             "associated with it, and it is required to "
   245                             "associated with it, and it is required to "
   246                             "create external gateway port"))
   246                             "create external gateway port"))
   247                 return
   247                 return
   248             mac_address = ex_gw_port['mac_address']
   248             mac_address = ex_gw_port['mac_address']
   249             dl.create_vnic(self.conf.external_network_datalink,
   249             dl.create_vnic(self.conf.external_network_datalink,
   304         ri.ipfilters_manager.add_ippool(new_ippool_name, other_subnet_cidrs)
   304         ri.ipfilters_manager.add_ippool(new_ippool_name, other_subnet_cidrs)
   305 
   305 
   306         # now setup the IPF rule
   306         # now setup the IPF rule
   307         rules = ['block in quick on %s from %s to pool/%d' %
   307         rules = ['block in quick on %s from %s to pool/%d' %
   308                  (internal_dlname, subnet_cidr, new_ippool_name)]
   308                  (internal_dlname, subnet_cidr, new_ippool_name)]
   309         ri.ipfilters_manager.add_ipf_rules(rules)
   309         ipversion = netaddr.IPNetwork(subnet_cidr).version
       
   310         ri.ipfilters_manager.add_ipf_rules(rules, ipversion)
   310 
   311 
   311     def internal_network_removed(self, ri, port):
   312     def internal_network_removed(self, ri, port):
   312         internal_dlname = self.get_internal_device_name(port['id'])
   313         internal_dlname = self.get_internal_device_name(port['id'])
   313         if net_lib.Datalink.datalink_exists(internal_dlname):
   314         if net_lib.Datalink.datalink_exists(internal_dlname):
   314             self.driver.fini_l3(internal_dlname)
   315             self.driver.fini_l3(internal_dlname)
   316 
   317 
   317         # remove all the IP filter rules that we added during addition.
   318         # remove all the IP filter rules that we added during addition.
   318         ippool_name = self._get_ippool_name(port['mac_address'])
   319         ippool_name = self._get_ippool_name(port['mac_address'])
   319         rules = ['block in quick on %s from %s to pool/%d' %
   320         rules = ['block in quick on %s from %s to pool/%d' %
   320                  (internal_dlname, port['subnet']['cidr'], ippool_name)]
   321                  (internal_dlname, port['subnet']['cidr'], ippool_name)]
   321         ri.ipfilters_manager.remove_ipf_rules(rules)
   322         ipversion = netaddr.IPNetwork(port['subnet']['cidr']).version
       
   323         ri.ipfilters_manager.remove_ipf_rules(rules, ipversion)
   322         # remove the ippool
   324         # remove the ippool
   323         ri.ipfilters_manager.remove_ippool(ippool_name, None)
   325         ri.ipfilters_manager.remove_ippool(ippool_name, None)
   324         for internal_port in ri.internal_ports:
   326         for internal_port in ri.internal_ports:
   325             if (self.conf.allow_forwarding_between_networks and
   327             if (self.conf.allow_forwarding_between_networks and
   326                     internal_port['tenant_id'] == port['tenant_id']):
   328                     internal_port['tenant_id'] == port['tenant_id']):