Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Boxiang Sun
slapos.core
Commits
93f77978
Commit
93f77978
authored
Jun 25, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli: simpler logging, always use self.app.log
parent
a99e2e16
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
14 additions
and
68 deletions
+14
-68
slapos/cli/bang.py
slapos/cli/bang.py
+0
-4
slapos/cli/cache.py
slapos/cli/cache.py
+0
-4
slapos/cli/config.py
slapos/cli/config.py
+1
-3
slapos/cli/configure_client.py
slapos/cli/configure_client.py
+1
-4
slapos/cli/console.py
slapos/cli/console.py
+0
-4
slapos/cli/entry.py
slapos/cli/entry.py
+1
-1
slapos/cli/format.py
slapos/cli/format.py
+2
-4
slapos/cli/proxy_show.py
slapos/cli/proxy_show.py
+1
-4
slapos/cli/proxy_start.py
slapos/cli/proxy_start.py
+2
-4
slapos/cli/register.py
slapos/cli/register.py
+1
-4
slapos/cli/remove.py
slapos/cli/remove.py
+0
-4
slapos/cli/request.py
slapos/cli/request.py
+0
-3
slapos/cli/slapgrid.py
slapos/cli/slapgrid.py
+3
-13
slapos/cli/supervisorctl.py
slapos/cli/supervisorctl.py
+1
-4
slapos/cli/supervisord.py
slapos/cli/supervisord.py
+1
-4
slapos/cli/supply.py
slapos/cli/supply.py
+0
-4
No files found.
slapos/cli/bang.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
logging
from
slapos.cli.command
import
must_be_root
from
slapos.cli.config
import
ConfigCommand
from
slapos.bang
import
do_bang
...
...
@@ -12,8 +10,6 @@ class BangCommand(ConfigCommand):
request update on all partitions
"""
log
=
logging
.
getLogger
(
'bang'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
BangCommand
,
self
).
get_parser
(
prog_name
)
ap
.
add_argument
(
'-m'
,
'--message'
,
...
...
slapos/cli/cache.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
logging
from
slapos.cli.config
import
ConfigCommand
from
slapos.cache
import
do_lookup
...
...
@@ -17,8 +15,6 @@ class CacheLookupCommand(ConfigCommand):
with the OS you are currently running.
"""
log
=
logging
.
getLogger
(
'cache-lookup'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
CacheLookupCommand
,
self
).
get_parser
(
prog_name
)
ap
.
add_argument
(
'software_url'
,
...
...
slapos/cli/config.py
View file @
93f77978
...
...
@@ -13,8 +13,6 @@ class ConfigError(Exception):
class
ConfigCommand
(
Command
):
"Base class for commands that require a configuration file"
log
=
None
default_config_var
=
'SLAPOS_CONFIGURATION'
# use this if default_config_var does not exist
...
...
@@ -45,7 +43,7 @@ class ConfigCommand(Command):
cfg_path
=
self
.
config_path
(
args
)
self
.
log
.
debug
(
'Loading config: %s'
,
cfg_path
)
self
.
app
.
log
.
debug
(
'Loading config: %s'
,
cfg_path
)
if
not
os
.
path
.
exists
(
cfg_path
):
raise
ConfigError
(
'Configuration file does not exist: %s'
%
cfg_path
)
...
...
slapos/cli/configure_client.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
logging
import
re
import
os
import
sys
...
...
@@ -16,8 +15,6 @@ class ConfigureClientCommand(ClientConfigCommand):
register a node in the SlapOS cloud
"""
log
=
logging
.
getLogger
(
'configure-client'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
ConfigureClientCommand
,
self
).
get_parser
(
prog_name
)
...
...
@@ -38,7 +35,7 @@ class ConfigureClientCommand(ClientConfigCommand):
return
ap
def
take_action
(
self
,
args
):
do_configure_client
(
logger
=
self
.
log
,
do_configure_client
(
logger
=
self
.
app
.
log
,
master_url_web
=
args
.
master_url_web
,
token
=
args
.
token
,
config_path
=
self
.
config_path
(
args
),
...
...
slapos/cli/console.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
logging
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.client
import
init
,
do_console
,
ClientConfig
...
...
@@ -22,8 +20,6 @@ class ConsoleCommand(ClientConfigCommand):
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")
"""
log
=
logging
.
getLogger
(
'console'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
ConsoleCommand
,
self
).
get_parser
(
prog_name
)
...
...
slapos/cli/entry.py
View file @
93f77978
...
...
@@ -57,7 +57,7 @@ class SlapOSApp(cliff.app.App):
log
=
logging
.
getLogger
(
'slapos'
)
CONSOLE_MESSAGE_FORMAT
=
'%(message)s'
LOG_FILE_MESSAGE_FORMAT
=
'[%(asctime)s] %(levelname)-8s %(
name)s %(
message)s'
LOG_FILE_MESSAGE_FORMAT
=
'[%(asctime)s] %(levelname)-8s %(message)s'
def
__init__
(
self
):
super
(
SlapOSApp
,
self
).
__init__
(
...
...
slapos/cli/format.py
View file @
93f77978
...
...
@@ -13,8 +13,6 @@ class FormatCommand(ConfigCommand):
create users, partitions and network configuration
"""
log
=
logging
.
getLogger
(
'format'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
FormatCommand
,
self
).
get_parser
(
prog_name
)
...
...
@@ -64,7 +62,7 @@ class FormatCommand(ConfigCommand):
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
conf
=
FormatConfig
(
logger
=
self
.
log
)
conf
=
FormatConfig
(
logger
=
self
.
app
.
log
)
conf
.
mergeConfig
(
args
,
configp
)
...
...
@@ -74,7 +72,7 @@ class FormatCommand(ConfigCommand):
file_handler
=
logging
.
FileHandler
(
conf
.
log_file
)
formatter
=
logging
.
Formatter
(
self
.
app
.
LOG_FILE_MESSAGE_FORMAT
)
file_handler
.
setFormatter
(
formatter
)
self
.
log
.
addHandler
(
file_handler
)
self
.
app
.
log
.
addHandler
(
file_handler
)
try
:
conf
.
setConfig
()
...
...
slapos/cli/proxy_show.py
View file @
93f77978
...
...
@@ -2,7 +2,6 @@
import
collections
import
hashlib
import
logging
import
lxml.etree
import
prettytable
...
...
@@ -18,8 +17,6 @@ class ProxyShowCommand(ConfigCommand):
display proxy instances and parameters
"""
log
=
logging
.
getLogger
(
'proxy'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
ProxyShowCommand
,
self
).
get_parser
(
prog_name
)
...
...
@@ -54,7 +51,7 @@ class ProxyShowCommand(ConfigCommand):
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
conf
=
ProxyConfig
(
logger
=
self
.
log
)
conf
=
ProxyConfig
(
logger
=
self
.
app
.
log
)
conf
.
mergeConfig
(
args
,
configp
)
conf
.
setConfig
()
do_show
(
conf
=
conf
)
...
...
slapos/cli/proxy_start.py
View file @
93f77978
...
...
@@ -12,8 +12,6 @@ class ProxyStartCommand(ConfigCommand):
minimalist, stand-alone SlapOS Master
"""
log
=
logging
.
getLogger
(
'proxy'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
ProxyStartCommand
,
self
).
get_parser
(
prog_name
)
...
...
@@ -26,7 +24,7 @@ class ProxyStartCommand(ConfigCommand):
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
conf
=
ProxyConfig
(
logger
=
self
.
log
)
conf
=
ProxyConfig
(
logger
=
self
.
app
.
log
)
conf
.
mergeConfig
(
args
,
configp
)
...
...
@@ -36,7 +34,7 @@ class ProxyStartCommand(ConfigCommand):
file_handler
=
logging
.
FileHandler
(
conf
.
log_file
)
formatter
=
logging
.
Formatter
(
self
.
app
.
LOG_FILE_MESSAGE_FORMAT
)
file_handler
.
setFormatter
(
formatter
)
self
.
log
.
addHandler
(
file_handler
)
self
.
app
.
log
.
addHandler
(
file_handler
)
conf
.
setConfig
()
...
...
slapos/cli/register.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
logging
import
sys
from
slapos.cli.command
import
Command
,
must_be_root
...
...
@@ -12,8 +11,6 @@ class RegisterCommand(Command):
register a node in the SlapOS cloud
"""
log
=
logging
.
getLogger
(
'register'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
RegisterCommand
,
self
).
get_parser
(
prog_name
)
...
...
@@ -85,7 +82,7 @@ class RegisterCommand(Command):
@
must_be_root
def
take_action
(
self
,
args
):
try
:
conf
=
RegisterConfig
(
logger
=
self
.
log
)
conf
=
RegisterConfig
(
logger
=
self
.
app
.
log
)
conf
.
setConfig
(
args
)
return_code
=
do_register
(
conf
)
except
SystemExit
as
err
:
...
...
slapos/cli/remove.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
logging
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.client
import
init
,
ClientConfig
...
...
@@ -11,8 +9,6 @@ class RemoveCommand(ClientConfigCommand):
remove a Software from a node
"""
log
=
logging
.
getLogger
(
'remove'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
RemoveCommand
,
self
).
get_parser
(
prog_name
)
...
...
slapos/cli/request.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
logging
import
pprint
from
slapos.cli.config
import
ClientConfigCommand
...
...
@@ -25,8 +24,6 @@ def parse_option_dict(options):
class
RequestCommand
(
ClientConfigCommand
):
"""request an instance and get status and parameters of instance"""
log
=
logging
.
getLogger
(
'request'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
RequestCommand
,
self
).
get_parser
(
prog_name
)
...
...
slapos/cli/slapgrid.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
logging
from
slapos.cli.command
import
must_be_root
from
slapos.cli.config
import
ConfigCommand
...
...
@@ -12,8 +10,6 @@ from slapos.grid.slapgrid import (merged_options, check_missing_parameters, chec
class
SlapgridCommand
(
ConfigCommand
):
log
=
None
method_name
=
NotImplemented
default_pidfile
=
NotImplemented
...
...
@@ -73,14 +69,14 @@ class SlapgridCommand(ConfigCommand):
check_missing_parameters
(
options
)
check_missing_files
(
options
)
random_delay
(
options
,
logger
=
self
.
log
)
random_delay
(
options
,
logger
=
self
.
app
.
log
)
slapgrid_object
=
create_slapgrid_object
(
options
,
logger
=
self
.
log
)
slapgrid_object
=
create_slapgrid_object
(
options
,
logger
=
self
.
app
.
log
)
pidfile
=
options
.
get
(
'pidfile'
)
or
self
.
default_pidfile
if
pidfile
:
setRunning
(
logger
=
self
.
log
,
pidfile
=
pidfile
)
setRunning
(
logger
=
self
.
app
.
log
,
pidfile
=
pidfile
)
try
:
return
getattr
(
slapgrid_object
,
self
.
method_name
)()
finally
:
...
...
@@ -91,8 +87,6 @@ class SlapgridCommand(ConfigCommand):
class
SoftwareCommand
(
SlapgridCommand
):
"""run software installation/deletion"""
log
=
logging
.
getLogger
(
'software'
)
method_name
=
'processSoftwareReleaseList'
default_pidfile
=
'/opt/slapos/slapgrid-sr.pid'
...
...
@@ -112,8 +106,6 @@ class SoftwareCommand(SlapgridCommand):
class
InstanceCommand
(
SlapgridCommand
):
"""run instance deployment"""
log
=
logging
.
getLogger
(
'instance'
)
method_name
=
'processComputerPartitionList'
default_pidfile
=
'/opt/slapos/slapgrid-cp.pid'
...
...
@@ -133,7 +125,5 @@ class InstanceCommand(SlapgridCommand):
class
ReportCommand
(
SlapgridCommand
):
"""run instance reports and garbage collection"""
log
=
logging
.
getLogger
(
'report'
)
method_name
=
'agregateAndSendUsage'
default_pidfile
=
'/opt/slapos/slapgrid-ur.pid'
slapos/cli/supervisorctl.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
argparse
import
logging
import
os
from
slapos.cli.command
import
must_be_root
...
...
@@ -14,8 +13,6 @@ import supervisor.supervisorctl
class
SupervisorctlCommand
(
ConfigCommand
):
"""open supervisor console, for process management"""
log
=
logging
.
getLogger
(
'supervisorctl'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
SupervisorctlCommand
,
self
).
get_parser
(
prog_name
)
ap
.
add_argument
(
'supervisor_args'
,
...
...
@@ -30,7 +27,7 @@ class SupervisorctlCommand(ConfigCommand):
configuration_file
=
os
.
path
.
join
(
instance_root
,
'etc'
,
'supervisord.conf'
)
launchSupervisord
(
socket
=
os
.
path
.
join
(
instance_root
,
'supervisord.socket'
),
configuration_file
=
configuration_file
,
logger
=
self
.
log
)
logger
=
self
.
app
.
log
)
supervisor
.
supervisorctl
.
main
(
args
=
[
'-c'
,
configuration_file
]
+
args
.
supervisor_args
)
...
...
slapos/cli/supervisord.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
logging
import
os
from
slapos.cli.command
import
must_be_root
...
...
@@ -11,12 +10,10 @@ from slapos.grid.svcbackend import launchSupervisord
class
SupervisordCommand
(
ConfigCommand
):
"""launch, if not already running, supervisor daemon"""
log
=
logging
.
getLogger
(
'supervisord'
)
@
must_be_root
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
instance_root
=
configp
.
get
(
'slapos'
,
'instance_root'
)
launchSupervisord
(
socket
=
os
.
path
.
join
(
instance_root
,
'supervisord.socket'
),
configuration_file
=
os
.
path
.
join
(
instance_root
,
'etc'
,
'supervisord.conf'
),
logger
=
self
.
log
)
logger
=
self
.
app
.
log
)
slapos/cli/supply.py
View file @
93f77978
# -*- coding: utf-8 -*-
import
logging
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.client
import
init
,
ClientConfig
...
...
@@ -11,8 +9,6 @@ class SupplyCommand(ClientConfigCommand):
supply a Software to a node
"""
log
=
logging
.
getLogger
(
'supply'
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
SupplyCommand
,
self
).
get_parser
(
prog_name
)
...
...
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