mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
added model for holding channel group information, updating asgi_amsqp req
This commit is contained in:
parent
9049fb208f
commit
39f337d933
@ -7,7 +7,6 @@ from channels.sessions import channel_session
|
||||
def discard_groups(message):
|
||||
if 'groups' in message.channel_session:
|
||||
for group in message.channel_session['groups']:
|
||||
print("removing from group: {}".format(group))
|
||||
Group(group).discard(message.reply_channel)
|
||||
|
||||
@channel_session
|
||||
@ -16,9 +15,7 @@ def ws_disconnect(message):
|
||||
|
||||
@channel_session
|
||||
def ws_receive(message):
|
||||
print(message)
|
||||
raw_data = message.content['text']
|
||||
print(raw_data)
|
||||
data = json.loads(raw_data)
|
||||
|
||||
if 'groups' in data:
|
||||
@ -29,16 +26,14 @@ def ws_receive(message):
|
||||
if type(v) is list:
|
||||
for oid in v:
|
||||
name = '{}-{}'.format(group_name, oid)
|
||||
print("listening to group: {}".format(name))
|
||||
current_groups.append(name)
|
||||
Group(name).add(message.reply_channel)
|
||||
else:
|
||||
print("listening to group: {}".format(group_name))
|
||||
current_groups.append(group_name)
|
||||
Group(group_name).add(message.reply_channel)
|
||||
message.channel_session['groups'] = current_groups
|
||||
|
||||
|
||||
def emit_channel_notification(group, payload):
|
||||
print("sending message to group {}".format(group))
|
||||
payload = json.dumps(payload)
|
||||
Group(group).send({"text": json.dumps(payload)})
|
||||
|
||||
22
awx/main/migrations/0039_v310_channelgroup.py
Normal file
22
awx/main/migrations/0039_v310_channelgroup.py
Normal file
@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0038_v310_workflow_rbac_prompts'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ChannelGroup',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('group', models.CharField(unique=True, max_length=200)),
|
||||
('channels', models.TextField()),
|
||||
],
|
||||
),
|
||||
]
|
||||
@ -22,6 +22,7 @@ from awx.main.models.notifications import * # noqa
|
||||
from awx.main.models.fact import * # noqa
|
||||
from awx.main.models.label import * # noqa
|
||||
from awx.main.models.workflow import * # noqa
|
||||
from awx.main.models.channels import * # noqa
|
||||
|
||||
# Monkeypatch Django serializer to ignore django-taggit fields (which break
|
||||
# the dumpdata command; see https://github.com/alex/django-taggit/issues/155).
|
||||
|
||||
5
awx/main/models/channels.py
Normal file
5
awx/main/models/channels.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.db import models
|
||||
|
||||
class ChannelGroup(models.Model):
|
||||
group = models.CharField(max_length=200, unique=True)
|
||||
channels = models.TextField()
|
||||
@ -9,7 +9,7 @@ billiard==3.3.0.16
|
||||
boto==2.40.0
|
||||
celery==3.1.23
|
||||
channels==0.17.2
|
||||
asgi_amqp==0.2.1
|
||||
asgi_amqp==0.3
|
||||
cliff==1.15.0
|
||||
cmd2==0.6.8
|
||||
d2to1==0.2.11 # TODO: Still needed?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user