def add_local_port(self, lport):
        if self.get_datapath() is None:
            LOG.error(_LE("datapath is none"))
            return

        secgroups = lport.get_security_groups()
        if secgroups is None:
            return

        ip = lport.get_ip()
        for secgroup_id in secgroups:
            # update the record of aggregate addresses of ports associated
            # with this security group.
            aggregate_addresses_range = \
                self.secgroup_aggregate_addresses.get(secgroup_id)
            if aggregate_addresses_range is None:
                aggregate_addresses_range = []
            new_cidr_array, added_cidr, removed_cidr = SGApp._add_one_address(
                aggregate_addresses_range,
                SGApp._get_integer_value_from_address(ip)
            )
            self.secgroup_aggregate_addresses[secgroup_id] = new_cidr_array

            # update the flows representing those rules each of which specifies
            #  this security group as its parameter
            # of remote group.
            secrules = self.remote_secgroup_ref.get(secgroup_id)
            if secrules is not None:
                for rule_info in secrules.values():
                    self._update_security_group_rule_flows_by_addresses(
                        rule_info.security_group_id,
                        rule_info,
                        added_cidr,
                        removed_cidr)

            # update the record of ports associated with this security group.
            associate_ports = \
                self.secgroup_associate_local_ports.get(secgroup_id)
            if associate_ports is None:
                self.secgroup_associate_local_ports[secgroup_id] = \
                    [lport.get_id()]
                self._allocate_security_group_id(secgroup_id)
                self._install_security_group_flows(secgroup_id)
            elif lport.get_id() not in associate_ports:
                associate_ports.append(lport.get_id())

            # install associating flow
            self._install_associating_flows(secgroup_id, lport)

        # install ct table
        self._install_connection_track_flows(lport)
dataset/ETHPy150Open openstack/dragonflow/dragonflow/controller/sg_app.py/SGApp.add_local_port/original