Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rafael Monnerat
slapos.toolbox
Commits
118cb3e0
Commit
118cb3e0
authored
Apr 23, 2012
by
Yingjie Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite log format.
parent
37e370a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
9 deletions
+5
-9
slapos/agent/agent.py
slapos/agent/agent.py
+5
-9
No files found.
slapos/agent/agent.py
View file @
118cb3e0
import
ConfigParser
import
ConfigParser
,
argparse
import
argparse
import
json
import
json
from
random
import
random
,
choice
from
random
import
random
,
choice
import
os
import
os
,
socket
,
time
import
socket
import
time
from
datetime
import
datetime
from
datetime
import
datetime
from
datetime
import
timedelta
from
datetime
import
timedelta
import
xmlrpclib
import
xmlrpclib
...
@@ -52,7 +49,7 @@ class Agent:
...
@@ -52,7 +49,7 @@ class Agent:
self
.
log_directory
=
configuration
.
get
(
"agent"
,
"log_directory"
)
self
.
log_directory
=
configuration
.
get
(
"agent"
,
"log_directory"
)
self
.
state_file
=
configuration
.
get
(
"agent"
,
"state_file"
)
self
.
state_file
=
configuration
.
get
(
"agent"
,
"state_file"
)
filename
=
os
.
path
.
join
(
self
.
log_directory
,
"agent-%s.log"
%
datetime
.
strftime
(
datetime
.
now
(),
"%Y
-%m-
%d"
))
filename
=
os
.
path
.
join
(
self
.
log_directory
,
"agent-%s.log"
%
datetime
.
strftime
(
datetime
.
now
(),
"%Y
%m
%d"
))
basicConfig
(
filename
=
filename
,
format
=
"%(asctime)-15s %(message)s"
,
level
=
"INFO"
)
basicConfig
(
filename
=
filename
,
format
=
"%(asctime)-15s %(message)s"
,
level
=
"INFO"
)
self
.
logger
=
getLogger
()
self
.
logger
=
getLogger
()
...
@@ -91,18 +88,18 @@ class Agent:
...
@@ -91,18 +88,18 @@ class Agent:
return
safeRpcCall
(
portal
,
"Agent_getSoftwareReleaseUsageOnComputer"
,
computer
,
software
)
return
safeRpcCall
(
portal
,
"Agent_getSoftwareReleaseUsageOnComputer"
,
computer
,
software
)
def
requestSoftwareReleaseCleanupOnComputer
(
self
,
computer
,
software
):
def
requestSoftwareReleaseCleanupOnComputer
(
self
,
computer
,
software
):
self
.
logger
.
info
(
"Request to cleanup %s on %s."
%
(
software
,
computer
))
try
:
try
:
self
.
supply
.
supply
(
self
.
software_uri
[
software
],
computer
,
"destroyed"
)
self
.
supply
.
supply
(
self
.
software_uri
[
software
],
computer
,
"destroyed"
)
self
.
logger
.
info
(
"Successfully requested to cleanup %s on %s."
%
(
software
,
computer
))
return
True
return
True
except
:
except
:
self
.
logger
.
info
(
"Failed to request to cleanup %s on %s."
%
(
software
,
computer
))
self
.
logger
.
info
(
"Failed to request to cleanup %s on %s."
%
(
software
,
computer
))
return
False
return
False
def
requestSoftwareReleaseInstallationOnComputer
(
self
,
computer
,
software
):
def
requestSoftwareReleaseInstallationOnComputer
(
self
,
computer
,
software
):
self
.
logger
.
info
(
"Request to install %s on %s."
%
(
software
,
computer
))
try
:
try
:
self
.
supply
.
supply
(
self
.
software_uri
[
software
],
computer
,
"available"
)
self
.
supply
.
supply
(
self
.
software_uri
[
software
],
computer
,
"available"
)
self
.
logger
.
info
(
"Successfully requested to install %s on %s."
%
(
software
,
computer
))
return
True
return
True
except
:
except
:
self
.
logger
.
info
(
"Failed to request to install %s on %s."
%
(
software
,
computer
))
self
.
logger
.
info
(
"Failed to request to install %s on %s."
%
(
software
,
computer
))
...
@@ -116,7 +113,6 @@ class Agent:
...
@@ -116,7 +113,6 @@ class Agent:
json
.
dumps
(
_encode_software_dict
(
self
.
installing_software_dict
[
computer
])))
json
.
dumps
(
_encode_software_dict
(
self
.
installing_software_dict
[
computer
])))
state
.
set
(
computer
,
"installed_software"
,
\
state
.
set
(
computer
,
"installed_software"
,
\
json
.
dumps
(
_encode_software_dict
(
self
.
installed_software_dict
[
computer
])))
json
.
dumps
(
_encode_software_dict
(
self
.
installed_software_dict
[
computer
])))
dirname
=
os
.
path
.
dirname
(
__file__
)
state
.
write
(
open
(
self
.
state_file
,
"w"
))
state
.
write
(
open
(
self
.
state_file
,
"w"
))
def
main
(
*
args
):
def
main
(
*
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