<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_ip(interface=0):
 """This method return the IP address :param interface: (int) Interface number (e.g. 0 for eth0) :return: (str) IP address or None """

    log = logging.getLogger(mod_logger + '.get_ip')

    log.info('Getting the IP address for this system...')
    ip_address = None
    try:
        log.info('Attempting to get IP address by hostname...')
        ip_address = socket.gethostbyname(socket.gethostname())
    except socket.error:
        log.info('Unable to get IP address for this system using hostname, '
                 'using a bash command...')
        command = 'ip addr show eth%s | grep inet | grep -v inet6 | ' \
                  'awk \'{ print $2 }\' | cut -d/ -f1 ' \
                  '>> /root/ip' % interface
        try:
            log.info('Running command: %s', command)
            subprocess.check_call(command, shell=True)
        except(OSError, subprocess.CalledProcessError):
            _, ex, trace = sys.exc_info()
            msg = 'Unable to get the IP address of this system\n{e}'.format(
                e=str(ex))
            log.error(msg)
            raise CommandError, msg, trace
        else:
            ip_file = '/root/ip'
            log.info('Command executed successfully, pulling IP address from '
                     'file: %s', ip_file)
            if os.path.isfile(ip_file):
                with open(ip_file, 'r') as f:
                    for line in f:
                        ip_address = line.strip()
                        log.info('Found IP address from file: %s', ip_address)
            else:
                msg = 'File not found: {f}'.format(f=ip_file)
                log.error(msg)
                raise CommandError(msg)
    log.info('Returning IP address: %s', ip_address)
    return ip_address