Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
agentdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d9e5655a
authored
Sep 22, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve logging
parent
942d2c17
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
10 deletions
+15
-10
agentcelery.py
+1
-1
agentdriver.py
+7
-2
protocol.py
+2
-1
utils.py
+5
-6
No files found.
agentcelery.py
View file @
d9e5655a
...
...
@@ -6,7 +6,7 @@ from os import getenv
from
socket
import
gethostname
import
logging
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
()
HOSTNAME
=
gethostname
()
AMQP_URI
=
getenv
(
'AMQP_URI'
)
...
...
agentdriver.py
View file @
d9e5655a
...
...
@@ -3,9 +3,14 @@ from twisted.internet import reactor, inotify
from
twisted.python
import
filepath
from
agentcelery
import
celery
,
HOSTNAME
from
protocol
import
inotify_handler
from
os
import
getenv
,
listdir
,
path
from
os
import
getenv
,
listdir
,
path
,
environ
import
logging
logging
.
basicConfig
()
logger
=
logging
.
getLogger
()
level
=
environ
.
get
(
'LOGLEVEL'
,
'INFO'
)
logger
.
setLevel
(
level
)
SOCKET_DIR
=
getenv
(
'SOCKET_DIR'
,
'/var/lib/libvirt/serial'
)
...
...
@@ -33,7 +38,7 @@ def main():
w
=
Worker
(
app
=
celery
,
concurrency
=
1
,
pool_cls
=
'threads'
,
hostname
=
HOSTNAME
+
'.agentdriver'
,
loglevel
=
l
ogging
.
DEBUG
)
loglevel
=
l
evel
)
reactor
.
callInThread
(
w
.
run
)
notifier
=
inotify
.
INotify
(
reactor
)
notifier
.
startReading
()
...
...
protocol.py
View file @
d9e5655a
...
...
@@ -13,7 +13,7 @@ from utils import SerialLineReceiverBase
from
agentcelery
import
agent_started
,
agent_stopped
,
renew
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
()
reactor
.
connections
=
{}
...
...
@@ -47,6 +47,7 @@ def inotify_handler(self, file, mask):
if
vm
in
reactor
.
connections
:
return
serial
=
SerialLineReceiverFactory
(
vm
)
logger
.
info
(
"connecting to
%
s (
%
s)"
,
vm
,
file
.
path
)
reactor
.
connectUNIX
(
file
.
path
,
serial
)
...
...
utils.py
View file @
d9e5655a
...
...
@@ -2,8 +2,7 @@ from twisted.protocols.basic import LineReceiver
import
json
import
logging
root_logger
=
logging
.
getLogger
()
root_logger
.
setLevel
(
logging
.
DEBUG
)
logger
=
logging
.
getLogger
()
class
SerialLineReceiverBase
(
LineReceiver
,
object
):
...
...
@@ -31,14 +30,14 @@ class SerialLineReceiverBase(LineReceiver, object):
args
=
{}
command
=
data
.
get
(
'command'
,
None
)
response
=
data
.
get
(
'response'
,
None
)
logg
ing
.
debug
(
'[serial] valid json:
%
s'
%
(
data
,
))
logg
er
.
debug
(
'[serial] valid json:
%
s'
%
(
data
,
))
except
(
ValueError
,
KeyError
)
as
e
:
logg
ing
.
error
(
'[serial] invalid json:
%
s (
%
s)'
%
(
data
,
e
))
logg
er
.
error
(
'[serial] invalid json:
%
s (
%
s)'
%
(
data
,
e
))
return
if
command
is
not
None
and
isinstance
(
command
,
unicode
):
logg
ing
.
debug
(
'received command:
%
s (
%
s)'
%
(
command
,
args
))
logg
er
.
debug
(
'received command:
%
s (
%
s)'
%
(
command
,
args
))
self
.
handle_command
(
command
,
args
)
elif
response
is
not
None
and
isinstance
(
response
,
unicode
):
logg
ing
.
debug
(
'received reply:
%
s (
%
s)'
%
(
response
,
args
))
logg
er
.
debug
(
'received reply:
%
s (
%
s)'
%
(
response
,
args
))
self
.
handle_response
(
response
,
args
)
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