Index: .gitignore
===================================================================
--- .gitignore
+++ .gitignore
@@ -2,3 +2,5 @@
 .*.swp
 *.pyc
 *.pyo
+env_trigger/
+jobtriggers.egg-info/
Index: fedmsg.d/taskotron-trigger.py
===================================================================
--- fedmsg.d/taskotron-trigger.py
+++ fedmsg.d/taskotron-trigger.py
@@ -1,9 +1,4 @@
 config = {
     'taskotron.kojijobtrigger.enabled': True,
     'taskotron.bodhijobtrigger.enabled': True,
-    'taskotron.buildbot': {
-        'username': "username",
-        'password': "password",
-        'url': "http://localhost/buildbot",
-    },
 }
Index: jobtriggers/bodhi_msg.py
===================================================================
--- jobtriggers/bodhi_msg.py
+++ jobtriggers/bodhi_msg.py
@@ -1,10 +1,10 @@
 import logging
-
 import fedmsg
 import fedmsg.encoding
 import fedmsg.consumers
 
-from . import triggers
+from . import triggers, utils, settings
+
 
 UNIT_TYPE = 'bodhi_update'
 
@@ -17,11 +17,9 @@
     jsonify = False
     config_key = 'taskotron.bodhijobtrigger.enabled'
 
-    def __init__(self, hub):
-        self.hub = hub
-
-        super(BodhiJobTrigger, self).__init__(hub)
-        self.trigger = triggers.StreamTrigger(hub.config)
+    def __init__(self, *args, **kw):
+        super(BodhiJobTrigger, self).__init__(*args, **kw)
+        self.trigger = triggers.StreamTrigger()
 
     def consume(self, message):
         usable_message = fedmsg.encoding.loads(message.body)
@@ -32,9 +30,12 @@
             return
 
         updatetitle = usable_message['msg']['update']['title']
+        builds = usable_message['msg']['update']['builds']
+        nvrs = [build['nvr'] for build in builds]
 
-        log.info('forcing update %s', updatetitle)
-
-        self.trigger.trigger_job(updatetitle, UNIT_TYPE, 'examplebodhi')
+        arches = utils.get_arches(nvr=nvrs[0])
 
-        log.info('update forced %s', updatetitle)
+        for task in settings.bodhi_tasks:
+            for arch in arches:
+                log.info('triggering %s for %s on %s', task, updatetitle, arch)
+                self.trigger.trigger_job(updatetitle, UNIT_TYPE, task, arch)
Index: jobtriggers/koji_msg.py
===================================================================
--- jobtriggers/koji_msg.py
+++ jobtriggers/koji_msg.py
@@ -4,7 +4,8 @@
 import fedmsg.encoding
 import fedmsg.consumers
 
-from . import triggers
+from . import triggers, utils, settings
+
 
 UNIT_TYPE = 'koji_build'
 
@@ -17,11 +18,9 @@
     jsonify = False
     config_key = 'taskotron.kojijobtrigger.enabled'
 
-    def __init__(self, hub):
-        self.hub = hub
-
-        super(KojiJobTrigger, self).__init__(hub)
-        self.trigger = triggers.StreamTrigger(hub.config)
+    def __init__(self, *args, **kw):
+        super(KojiJobTrigger, self).__init__(*args, **kw)
+        self.trigger = triggers.StreamTrigger()
 
     def consume(self, message):
         usable_message = fedmsg.encoding.loads(message.body)
@@ -34,11 +33,13 @@
         buildname = usable_message['msg']['name']
         buildversion = usable_message['msg']['version']
         buildrelease = usable_message['msg']['release']
+        buildid = usable_message['msg']['build_id']
 
         envr = "%s-%s-%s" % (buildname, buildversion, buildrelease)
 
-        log.info('forcing build for %s', envr)
-
-        self.trigger.trigger_job(envr, UNIT_TYPE, 'rpmlint')
+        arches = utils.get_arches(buildid=buildid)
 
-        log.info('build forced for %s', envr)
+        for task in settings.koji_tasks:
+            for arch in arches:
+                log.info('triggering %s for %s on %s', task, envr, arch)
+                self.trigger.trigger_job(envr, UNIT_TYPE, task, arch)
Index: jobtriggers/settings.py
===================================================================
--- /dev/null
+++ jobtriggers/settings.py
@@ -0,0 +1,9 @@
+buildbot = {
+    'username': "username",
+    'password': "password",
+    'url': "http://localhost/buildbot",
+}
+koji_tasks = ['rpmlint']
+bodhi_tasks = ['examplebodhi']
+valid_arches = ['i386', 'i686', 'x86_64', 'noarch']
+koji_url = "http://koji.fedoraproject.org/kojihub"
Index: jobtriggers/triggers.py
===================================================================
--- jobtriggers/triggers.py
+++ jobtriggers/triggers.py
@@ -1,43 +1,43 @@
 import pprint
 import requests
 
+from . import settings
 
 class BaseTrigger(object):
-    def __init__(self, config):
-        self.config = config
-
-    def trigger_job(self, unit, unit_type, job_type):
+    """
+    Format:
+    {
+        'item': <name of item - envr, update id, koji tag, etc.>,
+        'item_type': <koji_build, koji_tag, bodhi_update>,
+        'taskname': <task to be scheduled>,
+        'arch': <arch needed for execution, x86_64, i386 etc.>
+    }
+    """
+    def trigger_job(self, item, item_type, taskname, arch):
         raise NotImplementedError
 
 
 class StreamTrigger(BaseTrigger):
-    def trigger_job(self, unit, unit_type, job_type):
-        job = {'unit': unit, 'unit_type': unit_type, 'job_type': job_type}
+    def trigger_job(self, item, item_type, taskname, arch):
+        job = {'item': item, 'item_type': item_type, 'taskname': taskname, 'arch': arch}
         pprint.pprint(job)
         print
 
 
 class BuildbotTrigger(BaseTrigger):
-    def __init__(self, config):
-        super(BuildbotTrigger, self).__init__(config)
-
-        buildbot = self.config.get('taskotron.buildbot', {})
-        self.buildbot_url = buildbot['url']
-        self.username = buildbot['username']
-        self.passwd = buildbot['password']
-
-    def trigger_job(self, unit, unit_type, job_type):
-        # TODO the builder is currently only set up for koji jobs
+    def trigger_job(self, item, item_type, taskname, arch):
         s = requests.session()
 
-        s.post('%s/login' % self.buildbot_url,
-               data={'username': self.username,
-                     'passwd': self.passwd})
+        s.post('%s/login' % settings.buildbot['url'],
+               data={'username': settings.buildbot['username'],
+                     'passwd': settings.buildbot['password']})
 
-        s.post('%s/builders/statictasks/force' % self.buildbot_url,
+        s.post('%s/builders/statictasks/force' % settings.buildbot['url'],
                data={'forcescheduler': 'rpmcheck',
                      'reason': 'triggered by fedmsg',
-                     'checkname': job_type,
-                     'envr': unit_type})
+                     'item': item,
+                     'item_type': item_type,
+                     'taskname': taskname,
+                     'arch': arch})
 
-        s.get('%s/logout' % self.buildbot_url)
+        s.get('%s/logout' % settings.buildbot['url'])
Index: jobtriggers/utils.py
===================================================================
--- /dev/null
+++ jobtriggers/utils.py
@@ -0,0 +1,18 @@
+import koji
+
+from . import settings
+
+koji_client = koji.ClientSession(settings.koji_url)
+
+def get_arches(buildid=None, nvr=None):
+    if buildid is None:
+        info = koji_client.getBuild(nvr)
+        buildid = info['id']
+
+    arches = set([rpm['arch'] for rpm in koji_client.listRPMs(buildid) if rpm['arch'] in settings.valid_arches])
+
+    if 'i686' in arches:
+        arches.remove('i686')
+        arches.add('i386')
+
+    return arches
Index: testing/test_bodhi_trigger.py
===================================================================
--- testing/test_bodhi_trigger.py
+++ testing/test_bodhi_trigger.py
@@ -9,43 +9,42 @@
         self.ref_updatetitle = 'foo'
         self.ref_topic = 'org.fedoraproject.prod.bodhi.update.request.stable'
 
+        self.ref_tasks = ['bodhi_task1', 'bodhi_task2']
+        self.ref_validarches = ['i386', 'x86_64']
+
         self._create_msg(self.ref_updatetitle, self.ref_topic)
 
-        self.ref_config = {
-            'taskotron.buildbot': {
-                'username': "username",
-                'password': "password",
-                'url': "http://localhost/buildbot/",
-            },
-        }
-        self.stub_hub = Dingus(config__returns = self.ref_config)
+        self.helper = bodhi_msg.BodhiJobTrigger(Dingus())
 
     def _create_msg(self, ref_updatetitle, ref_topic):
         self.ref_message = Bunch(body='{"msg": {"agent": "lmacken",\
-                                        "update": {"submitter": "lmacken", "title": "%s"}},\
+                                        "update": {"submitter": "lmacken",\
+                                                   "title": "%s",\
+                                                   "builds": [{"nvr": "gnome-settings-daemon-3.6.1-1.fc18"}]}},\
                                         "topic": "%s"}' %
                                         (ref_updatetitle, ref_topic))
 
     def test_consume(self, monkeypatch):
-        self.helper = bodhi_msg.BodhiJobTrigger(self.stub_hub)
-
         monkeypatch.setattr(self.helper, 'trigger', Dingus())
+        monkeypatch.setattr(bodhi_msg.settings, 'bodhi_tasks', self.ref_tasks)
+        monkeypatch.setattr(bodhi_msg.settings, 'valid_arches', self.ref_validarches)
+        monkeypatch.setattr(bodhi_msg, 'utils', Dingus(get_arches__returns=self.ref_validarches))
 
         self.helper.consume(self.ref_message)
 
         trigger_calls = self.helper.trigger.trigger_job.calls()
-        requested_updatetitle = trigger_calls[0][1][0]
-        requested_unit_type = trigger_calls[0][1][1]
 
-        assert requested_updatetitle == self.ref_updatetitle
-        assert requested_unit_type == bodhi_msg.UNIT_TYPE
+        assert len(trigger_calls) == 4
+
+        assert trigger_calls[0][1] == (self.ref_updatetitle, bodhi_msg.UNIT_TYPE, self.ref_tasks[0], self.ref_validarches[0])
+        assert trigger_calls[1][1] == (self.ref_updatetitle, bodhi_msg.UNIT_TYPE, self.ref_tasks[0], self.ref_validarches[1])
+        assert trigger_calls[2][1] == (self.ref_updatetitle, bodhi_msg.UNIT_TYPE, self.ref_tasks[1], self.ref_validarches[0])
+        assert trigger_calls[3][1] == (self.ref_updatetitle, bodhi_msg.UNIT_TYPE, self.ref_tasks[1], self.ref_validarches[1])
 
     def test_consume_notwatched_topic(self, monkeypatch):
         ref_topic = 'org.fedoraproject.pro.bodhi.update.request.randomtopic'
         self._create_msg(self.ref_updatetitle, ref_topic)
 
-        self.helper = bodhi_msg.BodhiJobTrigger(self.stub_hub)
-
         monkeypatch.setattr(self.helper, 'trigger', Dingus())
 
         self.helper.consume(self.ref_message)
Index: testing/test_koji_trigger.py
===================================================================
--- testing/test_koji_trigger.py
+++ testing/test_koji_trigger.py
@@ -14,18 +14,15 @@
 
         self._create_msg(self.ref_name, self.ref_release, self.ref_tag, self.ref_version)
 
-        self.ref_config = {
-            'taskotron.buildbot': {
-                'username': "username",
-                'password': "password",
-                'url': "http://localhost/buildbot/",
-            },
-        }
-        self.stub_hub = Dingus(config__returns = self.ref_config)
+        self.ref_tasks = ['koji_task1', 'koji_task2']
+        self.ref_validarches = ['i386', 'x86_64']
+
+        self.helper = koji_msg.KojiJobTrigger(Dingus())
 
     def _create_msg(self, ref_name, ref_release, ref_tag, ref_version):
         self.ref_message = Bunch(body='{"i": 1,\
-                                        "msg": {"name": "%s",\
+                                        "msg": {"build_id": 221146,\
+                                                "name": "%s",\
                                                 "owner": "ralph",\
                                                 "release": "%s",\
                                                 "tag": "%s",\
@@ -38,27 +35,27 @@
                                         (ref_name, ref_release, ref_tag, ref_version))
 
     def test_consume(self, monkeypatch):
-        self.helper = koji_msg.KojiJobTrigger(self.stub_hub)
-
         monkeypatch.setattr(self.helper, 'trigger', Dingus())
+        monkeypatch.setattr(koji_msg.settings, 'koji_tasks', self.ref_tasks)
+        monkeypatch.setattr(koji_msg.settings, 'valid_arches', self.ref_validarches)
+        monkeypatch.setattr(koji_msg, 'utils', Dingus(get_arches__returns=self.ref_validarches))
 
         self.helper.consume(self.ref_message)
 
         trigger_calls = self.helper.trigger.trigger_job.calls()
-        requested_nvr = trigger_calls[0][1][0]
-        requested_unit_type = trigger_calls[0][1][1]
 
-        assert requested_nvr == self.ref_nvr
-        assert requested_unit_type == koji_msg.UNIT_TYPE
+        assert len(trigger_calls) == 4
+
+        assert trigger_calls[0][1] == (self.ref_nvr, koji_msg.UNIT_TYPE, self.ref_tasks[0], self.ref_validarches[0])
+        assert trigger_calls[1][1] == (self.ref_nvr, koji_msg.UNIT_TYPE, self.ref_tasks[0], self.ref_validarches[1])
+        assert trigger_calls[2][1] == (self.ref_nvr, koji_msg.UNIT_TYPE, self.ref_tasks[1], self.ref_validarches[0])
+        assert trigger_calls[3][1] == (self.ref_nvr, koji_msg.UNIT_TYPE, self.ref_tasks[1], self.ref_validarches[1])
 
     def test_consume_notwatched_tag(self, monkeypatch):
         ref_tag = 'f18-randomtag'
         self._create_msg(self.ref_name, self.ref_release, ref_tag, self.ref_version)
 
-        self.helper = koji_msg.KojiJobTrigger(self.stub_hub)
-
         monkeypatch.setattr(self.helper, 'trigger', Dingus())
-
         self.helper.consume(self.ref_message)
 
         trigger_calls = self.helper.trigger.trigger_job.calls()
Index: testing/test_utils.py
===================================================================
--- /dev/null
+++ testing/test_utils.py
@@ -0,0 +1,26 @@
+from dingus import Dingus
+
+from jobtriggers import utils
+
+
+class TestBodhiJobTrigger():
+    def setup_method(self, method):
+        self.ref_validarches = ['i386', 'x86_64']
+        self.ref_nvr = 'foo'
+        self.ref_buildid = 1
+        self.ref_rpmarches = [{'arch': 'i386'}, {'arch': 'x86_64'}]
+        self.ref_build = {'id': self.ref_buildid}
+
+    def test_get_arches_by_buildid(self, monkeypatch):
+        monkeypatch.setattr(utils, 'koji_client', Dingus(listRPMs__returns=self.ref_rpmarches))
+
+        res = utils.get_arches(buildid=self.ref_buildid)
+
+        assert res == set(self.ref_validarches)
+
+    def test_get_arches_by_nvr(self, monkeypatch):
+        monkeypatch.setattr(utils, 'koji_client', Dingus(listRPMs__returns=self.ref_rpmarches, getBuild__returns=self.ref_build))
+
+        res = utils.get_arches(nvr=self.ref_nvr)
+
+        assert res == set(self.ref_validarches)
