def _get_subnetpool_id(self, context, subnet):
        use_default_subnetpool = subnet.get('use_default_subnetpool')
        if use_default_subnetpool == constants.ATTR_NOT_SPECIFIED:
            use_default_subnetpool = False
        subnetpool_id = subnet.get('subnetpool_id')
        if subnetpool_id == constants.ATTR_NOT_SPECIFIED:
            subnetpool_id = None

        if use_default_subnetpool and subnetpool_id:
            msg = _('subnetpool_id and use_default_subnetpool cannot both be '
                    'specified')
            raise exc.BadRequest(resource='subnets', msg=msg)

        if subnetpool_id:
            return subnetpool_id

        if not use_default_subnetpool:
            return

        cidr = subnet.get('cidr')
        if validators.is_attr_set(cidr):
            ip_version = netaddr.IPNetwork(cidr).version
        else:
            ip_version = subnet.get('ip_version')
            if not validators.is_attr_set(ip_version):
                msg = _('ip_version must be specified in the absence of '
                        'cidr and subnetpool_id')
                raise exc.BadRequest(resource='subnets', msg=msg)

        if ip_version == 6 and cfg.CONF.ipv6_pd_enabled:
            return constants.IPV6_PD_POOL_ID

        subnetpool = self.get_default_subnetpool(context, ip_version)
        if subnetpool:
            return subnetpool['id']

        # Until the default_subnet_pool config options are removed in the N
        # release, check for them after get_default_subnetpool returns None.
        # TODO(john-davidge): Remove after Mitaka release.
        if ip_version == 4 and cfg.CONF.default_ipv4_subnet_pool:
            return cfg.CONF.default_ipv4_subnet_pool
        if ip_version == 6 and cfg.CONF.default_ipv6_subnet_pool:
            return cfg.CONF.default_ipv6_subnet_pool

        msg = _('No default subnetpool found for IPv%s') % ip_version
        raise exc.BadRequest(resource='subnets', msg=msg)
Send configuration commands down the SSH channel from a file.
dataset/ETHPy150Open openstack/neutron/neutron/db/db_base_plugin_v2.py/NeutronDbPluginV2._get_subnetpool_id--crossover with--dataset/ETHPy150Open ktbyers/netmiko/netmiko/base_connection.py/BaseSSHConnection.send_config_from_file