2020-04-06 18:13:10 +03:00
|
|
|
|
#!/usr/bin/python3
|
|
|
|
|
# -*- coding: utf-8 -*-
|
2020-08-11 11:59:32 +03:00
|
|
|
|
# Author: Hasan Kara <hasankara@pardus.org.tr>
|
2020-04-06 18:13:10 +03:00
|
|
|
|
|
|
|
|
|
from base.model.enum.content_type import ContentType
|
2020-08-11 11:59:32 +03:00
|
|
|
|
import json
|
2020-04-06 18:13:10 +03:00
|
|
|
|
|
2020-08-11 11:59:32 +03:00
|
|
|
|
from base.scope import Scope
|
2020-04-06 18:13:10 +03:00
|
|
|
|
from base.plugin.abstract_plugin import AbstractPlugin
|
2020-08-11 11:59:32 +03:00
|
|
|
|
from base.registration.registration import Registration
|
2020-04-06 18:13:10 +03:00
|
|
|
|
|
|
|
|
|
|
2020-08-11 11:59:32 +03:00
|
|
|
|
class DeleteAgent(AbstractPlugin):
|
2020-04-06 18:13:10 +03:00
|
|
|
|
def __init__(self, data, context):
|
|
|
|
|
super(AbstractPlugin, self).__init__()
|
2020-08-11 11:59:32 +03:00
|
|
|
|
scope = Scope.get_instance()
|
2020-04-06 18:13:10 +03:00
|
|
|
|
self.data = data
|
|
|
|
|
self.context = context
|
|
|
|
|
self.logger = self.get_logger()
|
|
|
|
|
self.message_code = self.get_message_code()
|
|
|
|
|
|
|
|
|
|
def handle_task(self):
|
|
|
|
|
try:
|
|
|
|
|
dn = self.data['dn']
|
2020-08-11 11:59:32 +03:00
|
|
|
|
directory_server = self.data['directory_server']
|
|
|
|
|
registration = Scope.get_instance().get_registration()
|
|
|
|
|
registration.purge_and_unregister(directory_server)
|
2020-04-06 18:13:10 +03:00
|
|
|
|
|
|
|
|
|
self.context.create_response(code=self.message_code.TASK_PROCESSED.value,
|
2020-08-11 11:59:32 +03:00
|
|
|
|
message='Ahenk başarı ile silindi.',
|
|
|
|
|
data=json.dumps({'Dn': dn}),
|
2020-04-06 18:13:10 +03:00
|
|
|
|
content_type=ContentType.APPLICATION_JSON.value)
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
2020-08-11 11:59:32 +03:00
|
|
|
|
self.logger.error(" error on handle deleting agent. Error: " + str(e))
|
2020-04-06 18:13:10 +03:00
|
|
|
|
self.context.create_response(code=self.message_code.TASK_ERROR.value,
|
2020-08-11 11:59:32 +03:00
|
|
|
|
message='Ahenk silinirken hata olustu' + str(e),
|
2020-04-06 18:13:10 +03:00
|
|
|
|
content_type=ContentType.APPLICATION_JSON.value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_task(task, context):
|
2020-08-11 11:59:32 +03:00
|
|
|
|
cls = DeleteAgent(task, context)
|
2020-04-06 18:13:10 +03:00
|
|
|
|
cls.handle_task()
|
2020-08-11 11:59:32 +03:00
|
|
|
|
|