'Subscribe to requested yum repositories using \'rhn-channel\' command'

def _subscribe(self, channels=[]):

    rhn_channel_cmd = ("rhn-channel    --user='%s'    --password='%s'" % (self.username, self.password))
    (rc, stdout, stderr) = self.module.run_command((rhn_channel_cmd + '    --available-channels'), check_rc=True)
    for wanted_channel in channels:
        for available_channel in stdout.rstrip().split('\n'):
            if re.search(wanted_repo, available_channel):
                (rc, stdout, stderr) = self.module.run_command((rhn_channel_cmd + ('    --add    --channel=%s' % available_channel)), check_rc=True)
