'Get target id from image name. Only works for emulated iscsi device'

def get_target_id(self):

    cmd = 'tgtadm    --lld    iscsi    --mode    target    --op    show'
    target_info = utils.system_output(cmd)
    target_id = ''
    for line in re.split('\n', target_info):
        if re.findall('Target\\s+(\\d+)', line):
            target_id = re.findall('Target\\s+(\\d+)', line)[0]
        if re.findall('Backing    store    path:\\s+(/+.+)', line):
            if (self.emulated_image in line):
                break
    else:
        target_id = ''
    return target_id
