Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
agentdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8a0740e8
authored
Nov 28, 2025
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fured fix
parent
b40e6ffa
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
53 deletions
+10
-53
agentdriver.py
+3
-15
agentmancelery.py
+1
-16
celeryconfig.py
+2
-2
miscellaneous/agentdriver.incron
+1
-0
protocol.py
+1
-18
utils.py
+2
-2
No files found.
agentdriver.py
View file @
8a0740e8
...
...
@@ -5,44 +5,32 @@ from agentcelery import celery, HOSTNAME
from
protocol
import
inotify_handler
from
os
import
getenv
,
listdir
,
path
,
environ
,
kill
,
getpid
import
signal
import
logging
from
celery.utils.log
import
get_task_logger
from
celery.utils.log
import
get_task_logger
from
celery.signals
import
after_setup_task_logger
from
celery.app.log
import
TaskFormatter
import
sys
from
multiprocessing
import
current_process
process
=
current_process
()
process
.
name
=
sys
.
argv
[
0
]
logger
=
get_task_logger
(
__name__
)
level
=
environ
.
get
(
'LOGLEVEL'
,
'INFO'
)
logger
.
setLevel
(
level
)
#logger = logging.getLogger(__name__)
@after_setup_task_logger.connect
def
setup_task_logger
(
logger
,
*
args
,
**
kwargs
):
for
handler
in
logger
.
handlers
:
handler
.
setFormatter
(
TaskFormatter
(
'
%(asctime)
s -
%(levelname)
s/agentdriver.
%(processName)
s -
%(module)
s -
%(message)
s'
))
handler
.
setFormatter
(
TaskFormatter
(
'[
%(levelname)
s/
%(name)
s]
%(message)
s'
))
SOCKET_DIR
=
getenv
(
'SOCKET_DIR'
,
'/var/lib/libvirt/serial'
)
old_install_platform_tweaks
=
Worker
.
install_platform_tweaks
def
install_platform_tweaks
(
self
,
worker
):
self
.
worker
=
worker
old_install_platform_tweaks
(
self
,
worker
)
Worker
.
install_platform_tweaks
=
install_platform_tweaks
def
reactor_started
():
# print(vars(logger.handlers[0].formatter))
logger
.
info
(
"reactor_started"
)
reactor
.
running_tasks
=
{}
reactor
.
ended_tasks
=
{}
...
...
agentmancelery.py
View file @
8a0740e8
## from twisted.internet.defer import Deferred
#from twisted.internet import reactor # threads
#from celery.result import TimeoutError
from
celery
import
Celery
import
serializers
from
kombu
import
Queue
,
Exchange
from
os
import
getenv
#from socket import gethostname
#from threading import Event
import
logging
from
celery.utils.log
import
get_task_logger
#from celery.signals import after_setup_task_logger
#from celery.app.log import TaskFormatter
logger
=
get_task_logger
(
__name__
)
QUEUE_NAME
=
"localhots.man"
AMQP_URI
=
getenv
(
'AMQP_URI'
)
...
...
@@ -25,11 +14,7 @@ celery.conf.update(
CELERY_QUEUES
=
(
Queue
(
QUEUE_NAME
,
Exchange
(
'manager'
,
type
=
'direct'
),
routing_key
=
'manager'
),
),
task_protocol
=
1
,
# Celery 3 compatibility
task_serializer
=
'json'
,
accept_content
=
[
'json'
],
# Ignore other content
result_serializer
=
'json'
,
timezone
=
'UTC'
,
enable_utc
=
True
,)
)
@celery.task
(
name
=
'vm.tasks.local_agent_tasks.renew'
)
...
...
celeryconfig.py
View file @
8a0740e8
result_backend
=
'amqp://'
task_result_expires
=
300
result_expires
=
300
timezone
=
'
utc
'
timezone
=
'
UTC
'
enable_utc
=
True
accept_content
=
[
'json'
,
'pickle_v2'
]
accept_content
=
[
'json'
,
'pickle_v2'
,
'pickle'
]
task_serializer
=
'json'
result_serializer
=
'pickle_v2'
task_store_errors_even_if_ignored
=
True
...
...
miscellaneous/agentdriver.incron
0 → 100644
View file @
8a0740e8
/var/lib/libvirt/serial IN_CREATE setfacl -m u:cloud:rw $@/$#
protocol.py
View file @
8a0740e8
...
...
@@ -2,7 +2,6 @@
from
twisted.internet
import
protocol
,
reactor
,
inotify
import
pickle
import
logging
import
time
import
struct
from
os
import
getenv
...
...
@@ -105,20 +104,6 @@ class SerialLineReceiver(SerialLineReceiverBase):
routing_key
=
'manager'
)],
)
# st = agent_started.apply_async(
# args=(self.factory.vm, version, system),
# queue='localhost.man',
# exchange='manager',
# routing_key='manager',
# serializer='json',
# )
logger
.
debug
(
"apply_async
%
r"
,
st
.
id
)
logger
.
debug
(
"apply_st
%
r"
,
st
.
status
)
time
.
sleep
(
2
)
logger
.
debug
(
"apply_st2
%
r"
,
st
.
status
)
time
.
sleep
(
8
)
logger
.
debug
(
"apply_st3
%
r"
,
st
.
status
)
elif
command
==
'renew'
:
renew
.
apply_async
(
queue
=
'localhost.man'
,
args
=
(
self
.
factory
.
vm
,
))
...
...
@@ -127,7 +112,7 @@ class SerialLineReceiver(SerialLineReceiverBase):
args
=
args
)
def
handle_response
(
self
,
response
,
args
):
logger
.
info
(
'handle_response:
%
s
%
s'
,
response
,
args
)
logger
.
debug
(
'handle_response:
%
s
%
s'
,
response
,
args
)
vm
=
self
.
factory
.
vm
if
response
==
'status'
:
self
.
send_to_graphite
(
args
)
...
...
@@ -201,5 +186,3 @@ class SerialLineReceiverFactory(protocol.ClientFactory):
reactor
.
running_tasks
[
vm
][
'started'
]
.
pop
(
addr
)
logger
.
info
(
"active connetions:
%
s"
,
reactor
.
running_tasks
[
vm
])
utils.py
View file @
8a0740e8
from
twisted.protocols.basic
import
LineReceiver
import
json
import
logging
from
celery.utils.log
import
get_task_logger
try
:
# Python 2: "unicode" is built-in
...
...
@@ -8,7 +8,7 @@ try:
except
NameError
:
unicode
=
str
logger
=
logging
.
getL
ogger
(
__name__
)
logger
=
get_task_l
ogger
(
__name__
)
class
SerialLineReceiverBase
(
LineReceiver
,
object
):
delimiter
=
b
'
\r
'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment