Find the single smallest IP network with the given IP addresses
You don't have to look at all the IPs to catch 'em all. Just looking at the lowest and highest does the trick. This realisation comes in handy when you consider that ipaddr does have a (private) function that gives you the common prefix length between two IP addresses. The code can then be simplified to:

#with many thanks to gfalcon
def _GetOneNetmaskForAllTheseIPs(ips):
  """Get the one IP network that covers all IPs in input.

  ipaddr.collapse_address_list is a little bit TOO smart and gives you the LIST
  of networks that describe a number of IP addreses. Ceph just wants one
  netmask. This function tries to get that one netmask.

  &gt;&gt;&gt; _GetOneNetmaskForAllTheseIPs(("10.0.0.1", "10.0.0.2",
  ...   "10.0.0.251","10.0.0.255"))
  10.0.0.0/24
  """

  #Look at larger and smaller IP addresses
  ips = [ipaddr.IPAddress(ip) for ip in ips]
  lowest_ip, highest_ip = min(ips), max(ips)

  mask_length = ipaddr._get_prefix_length(
    int(lowest_ip), int(highest_ip), lowest_ip.max_prefixlen)

  #Return the network
  network_ip = ipaddr.IPNetwork("%s/%d" % (lowest_ip, mask_length)).network
  network = ipaddr.IPNetwork("%s/%d" % (network_ip, mask_length), strict = True)
  return str(network)


You still can't use public functions like ipaddr.summarize_address_range, because the library will still painstakingly try to avoid any IP address ever so slightly off range.

&gt;&gt;&gt; ipaddr.summarize_address_range(IPv4Address('10.0.0.1'), IPv4Address('10.0.0.255'))
[IPv4Network('10.0.0.1/32'),
 IPv4Network('10.0.0.2/31'),
 IPv4Network('10.0.0.4/30'),
 IPv4Network('10.0.0.8/29'),
 IPv4Network('10.0.0.16/28'),
 IPv4Network('10.0.0.32/27'),
 IPv4Network('10.0.0.64/26'),
 IPv4Network('10.0.0.128/25')]