code: def egress_subnets(rid=None, unit=None):
      
      def _to_range(addr):
          if re.search(r'^(?:\d{1,3}\.){3}\d{1,3}$', addr) is not None:
              addr += '/32'
          elif ':' in addr and '/' not in addr:  # IPv6
              addr += '/128'
          return addr
  
      settings = relation_get(rid=rid, unit=unit)
      if 'egress-subnets' in settings:
          return [n.strip() for n in settings['egress-subnets'].split(',') if n.strip()]
      if 'ingress-address' in settings:
          return [_to_range(settings['ingress-address'])]
      if 'private-address' in settings:
          return [_to_range(settings['private-address'])]
      return []
docs: Retrieve the egress-subnets from a relation.
  
      This function is to be used on the providing side of the
      relation, and provides the ranges of addresses that client
      connections may come from. The result is uninteresting on
      the consuming side of a relation (unit == local_unit()).
  
      Returns a stable list of subnets in CIDR format.
      eg. ['192.168.1.0/24', '2001::F00F/128']
  
      If egress-subnets is not available, falls back to using the published
      ingress-address, or finally private-address.
  
      :param rid: string relation id
      :param unit: string unit name
      :side effect: calls relation_get
      :return: list of subnets in CIDR format. eg. ['192.168.1.0/24', '2001::F00F/128']