Commit 3222e028 authored by echel0n's avatar echel0n
Browse files

Added SiCKRAGE API endpoint for declaring AMQP server queue

AMQP consumer now declares server queue prior to connecting using SiCKRAGE API endpoint
parent 04f01e40
......@@ -45,15 +45,22 @@ class AMQPBase(object):
def connect(self):
# check for api token
if not or not
IOLoop.current().call_later(5, self.reconnect)
# refresh api token if needed
if < (int(['expires_in']) / 2):
if not
IOLoop.current().call_later(5, self.reconnect)
# declare server amqp queue
if not
IOLoop.current().call_later(5, self.reconnect)
# connect to amqp server
credentials = pika.credentials.PlainCredentials(username='sickrage',["access_token"])
import collections
import errno
import time
import traceback
from urllib.parse import urljoin
import errno
import oauthlib.oauth2
import requests
import requests.exceptions
......@@ -15,7 +15,6 @@ from sqlalchemy import orm
import sickrage
from sickrage.core.api.exceptions import APIError
from sickrage.core.databases.cache import CacheDB
from sickrage.core.helpers import get_internal_ip, get_external_ip
class API(object):
......@@ -319,6 +318,9 @@ class API(object):
def get_server_certificate(self, server_id):
return self.api.request('GET', f'server/{server_id}/certificate')
def declare_amqp_queue(self, server_id):
return self.api.request('GET', f'server/{server_id}/declare-amqp-queue')
def upload_config(self, server_id, pkey_sig, config):
data = {
'server-id': server_id,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment