Commit df12a335 by Chif Gergő

Fix import error, delete unnecessary files

parent 9bb31ea6
Pipeline #1077 passed with stage
in 1 minute 40 seconds
# import json
from asgiref.sync import async_to_sync
from channels.generic.websocket import WebsocketConsumer
from recircle.instance.models import Instance
from instance.models import Instance
import logging
logger = logging.getLogger(__name__)
......
from django.apps import AppConfig
class StatusConfig(AppConfig):
name = 'status'
# import json
from asgiref.sync import async_to_sync
from channels.generic.websocket import WebsocketConsumer
from recircle.instance.models import Instance
import logging
logger = logging.getLogger(__name__)
class StatusConsumer(WebsocketConsumer):
def connect(self):
instances = Instance.objects.all()
for inst in instances:
async_to_sync(self.channel_layer.group_add)(
str(inst.id),
self.channel_name
)
def disconnect(self):
instances = Instance.objects.all()
for inst in instances:
async_to_sync(self.channel_layer.group_discard)(
str(inst.id),
self.channel_name
)
def receive(self, text_message):
pass
def status_changed(self, event):
logger.info("Event received")
self.send(text_data=event["status"])
from django.urls import re_path
from . import consumers
websocket_urlpatterns = [
re_path(r'ws/instance/(?P<vm_id>\w+)/$', consumers.StatusConsumer),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment