<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_relation_ip(interface, cidr_network=None):
 """Return this unit's IP for the given interface. Allow for an arbitrary interface to use with network-get to select an IP. Handle all address selection options including passed cidr network and IPv6. Usage: get_relation_ip('amqp', cidr_network='10.0.0.0/8') @param interface: string name of the relation. @param cidr_network: string CIDR Network to select an address from. @raises Exception if prefer-ipv6 is configured but IPv6 unsupported. @returns IPv6 or IPv4 address """

    # Select the interface address first
    # For possible use as a fallback bellow with get_address_in_network
    try:
        # Get the interface specific IP
        address = network_get_primary_address(interface)
    except NotImplementedError:
        # If network-get is not available
        address = get_host_ip(unit_get('private-address'))
    except NoNetworkBinding:
        log("No network binding for {}".format(interface), WARNING)
        address = get_host_ip(unit_get('private-address'))

    if config('prefer-ipv6'):
        # Currently IPv6 has priority, eventually we want IPv6 to just be
        # another network space.
        assert_charm_supports_ipv6()
        return get_ipv6_addr()[0]
    elif cidr_network:
        # If a specific CIDR network is passed get the address from that
        # network.
        return get_address_in_network(cidr_network, address)

    # Return the interface address
    return address