def set_host_networking(self):
        """set cluster hosts networking."""
        def get_subnet(ip_str):
            try:
                LOG.info("subnets: %s" % self.subnet_mapping.keys())
                ip = netaddr.IPAddress(ip_str)
                for cidr, subnet_id in self.subnet_mapping.items():
                    subnet = netaddr.IPNetwork(cidr)
                    if ip in subnet:
                        return True, subnet_id

                    LOG.info("ip %s not in %s" % (ip_str, cidr))
                return False, None
            except Exception:
                LOG.exception("ip addr %s is invalid" % ip_str)
                return False, None

        for host_network in CONF.host_networks.split(';'):
            hostname, networks_str = host_network.split(':', 1)
            hostname = hostname.strip()
            networks_str = networks_str.strip()

            assert(hostname in self.host_mapping)

            host_id = self.host_mapping[hostname]
            intf_list = networks_str.split(',')
            for intf_str in intf_list:
                interface, intf_properties = intf_str.split('=', 1)
                intf_properties = intf_properties.strip().split('|')

                assert(intf_properties)
                ip_str = intf_properties[0]

                status, subnet_id = get_subnet(ip_str)
                if not status:
                    raise RuntimeError("ip addr %s is invalid" % ip_str)

                properties = dict([
                    (intf_property, True)
                    for intf_property in intf_properties[1:]
                ])

                LOG.info(
                    'add host %s interface %s ip %s network proprties %s',
                    hostname, interface, ip_str, properties)

                status, response = self.client.add_host_network(
                    host_id, interface, ip=ip_str, subnet_id=subnet_id,
                    **properties
                )

                LOG.info(
                    'add host %s interface %s ip %s network properties %s '
                    'status %s: %s',
                    hostname, interface, ip_str, properties,
                    status, response
                )

                if not self.is_ok(status):
                    raise RuntimeError("add host network failed")

                self.host_ips[hostname].append(ip_str)
dataset/ETHPy150Open openstack/compass-core/bin/client.py/CompassClient.set_host_networking/original