Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies = [
"pecan-notario",
"requests",
"jinja2",
"pika",
]
classifiers = [
'Development Status :: 4 - Beta',
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ alembic==1.13.2
ipython==5.0.0
requests==2.25.1
jinja2==3.1.4
pika==1.2.0
enum34==1.1.10
1 change: 0 additions & 1 deletion shaman/controllers/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import shaman.controllers.api.repos # noqa
import shaman.controllers.api.nodes # noqa
import shaman.controllers.api.builds # noqa
import shaman.controllers.api.bus # noqa
26 changes: 0 additions & 26 deletions shaman/controllers/api/bus/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion shaman/controllers/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def index(self):
nodes = api.nodes.NodesController()
search = _search.SearchController()
builds = api.builds.ProjectsAPIController()
bus = api.bus.BusController()


class RootController(object):
Expand Down
18 changes: 0 additions & 18 deletions shaman/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
import json
from sqlalchemy import create_engine, MetaData, event
from sqlalchemy.orm import scoped_session, sessionmaker, object_session, mapper
from sqlalchemy.ext.declarative import declarative_base
Expand Down Expand Up @@ -70,23 +69,6 @@ def _date_json_converter(item):
if isinstance(item, datetime.datetime):
return str(item)


def publish_update_message(mapper, connection, target):
"""
Send a message to RabbitMQ everytime a Repo
is updated
"""
from shaman.util import publish_message

if isinstance(target, Build):
topic = "builds"
elif isinstance(target, Repo):
topic = "repos"
routing_key = "{}.{}".format(target.project.name, topic)
body = json.dumps(target.__json__(), default=_date_json_converter)
publish_message(routing_key, body)


# Utilities:

def get_or_create(model, **kwargs):
Expand Down
3 changes: 1 addition & 2 deletions shaman/models/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlalchemy.orm import relationship, backref, deferred
from sqlalchemy.event import listen
from sqlalchemy.orm.exc import DetachedInstanceError
from shaman.models import Base, update_timestamp, publish_update_message
from shaman.models import Base, update_timestamp
from shaman.models.types import JSONType


Expand Down Expand Up @@ -125,4 +125,3 @@ def get_url(self, up_to_part=None):
# listen for timestamp modifications
listen(Build, 'before_insert', update_timestamp)
listen(Build, 'before_update', update_timestamp)
listen(Build, 'after_update', publish_update_message)
3 changes: 1 addition & 2 deletions shaman/models/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sqlalchemy.orm import relationship, backref, deferred
from sqlalchemy.event import listen
from sqlalchemy.orm.exc import DetachedInstanceError
from shaman.models import Base, update_timestamp, publish_update_message
from shaman.models import Base, update_timestamp
from shaman.models.types import JSONType


Expand Down Expand Up @@ -101,4 +101,3 @@ def get_url(self):
# listen for timestamp modifications
listen(Repo, 'before_insert', update_timestamp)
listen(Repo, 'before_update', update_timestamp)
listen(Repo, 'after_update', publish_update_message)
18 changes: 0 additions & 18 deletions shaman/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,6 @@ def factory():
return Factory


@pytest.fixture(autouse=True)
def no_pika_requests(monkeypatch, factory):
"""
If you don't do anything to patch pika, this fxiture will automatically
patchn it and prevent outbound requests.
"""
fake_connection = factory(
queue_bind=lambda: True,
close=lambda: True,
channel=lambda: factory(
exchange_declare=lambda *a, **kw: True,
queue_bind=lambda *a: True,
basic_publish=lambda *a, **kw: True,
queue_declare=lambda *a, **kw: True,),
)
monkeypatch.setattr("pika.BlockingConnection", lambda *a: fake_connection)


def config_file():
here = os.path.abspath(os.path.dirname(__file__))
return os.path.join(here, 'config.py')
Expand Down
27 changes: 0 additions & 27 deletions shaman/tests/controllers/test_bus.py

This file was deleted.

26 changes: 0 additions & 26 deletions shaman/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import requests
import pika
from requests.exceptions import BaseHTTPError, RequestException
import datetime
import logging
Expand Down Expand Up @@ -190,28 +189,3 @@ def get_repo_url(query, arch, path=None, repo_file=True):
# yum or apt repo file
repo_url = os.path.join(repo.chacra_url, 'repo')
return repo_url


def publish_message(routing_key, body):
"""
Publishes a message to RabbitMQ
"""
credentials = pika.PlainCredentials(conf.RABBIT_USER, conf.RABBIT_PW)
connection = pika.BlockingConnection(pika.ConnectionParameters(
host=conf.RABBIT_HOST,
credentials=credentials
))
channel = connection.channel()
channel.exchange_declare(
exchange="shaman",
exchange_type="topic",
)

properties = pika.BasicProperties(content_type='application/json')
channel.basic_publish(
exchange="shaman",
routing_key=routing_key,
body=body,
properties=properties,
)
connection.close()