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
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
38888da7
Commit
38888da7
authored
Apr 23, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved old parsers in separate folder
parent
4225bdaa
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
205 additions
and
141 deletions
+205
-141
setup.py
setup.py
+3
-3
slapos/bang.py
slapos/bang.py
+0
-20
slapos/cache.py
slapos/cache.py
+0
-14
slapos/cli/config.py
slapos/cli/config.py
+0
-3
slapos/cli/entry.py
slapos/cli/entry.py
+0
-1
slapos/cli_legacy/__init__.py
slapos/cli_legacy/__init__.py
+0
-0
slapos/cli_legacy/bang.py
slapos/cli_legacy/bang.py
+50
-0
slapos/cli_legacy/cache.py
slapos/cli_legacy/cache.py
+18
-0
slapos/cli_legacy/entry.py
slapos/cli_legacy/entry.py
+3
-3
slapos/cli_legacy/format.py
slapos/cli_legacy/format.py
+131
-0
slapos/format.py
slapos/format.py
+0
-97
No files found.
setup.py
View file @
38888da7
...
@@ -56,20 +56,20 @@ setup(name=name,
...
@@ -56,20 +56,20 @@ setup(name=name,
entry_points
=
{
entry_points
=
{
'console_scripts'
:
[
'console_scripts'
:
[
# One entry point to control them all
# One entry point to control them all
'slapos = slapos.entry:main'
,
'slapos = slapos.
cli_legacy.
entry:main'
,
'slapos-watchdog = slapos.grid.watchdog:main'
,
'slapos-watchdog = slapos.grid.watchdog:main'
,
'slapproxy = slapos.proxy:main'
,
'slapproxy = slapos.proxy:main'
,
'slapproxy-query = slapos.proxy.query:main'
,
'slapproxy-query = slapos.proxy.query:main'
,
# Deprecated entry points
# Deprecated entry points
'slapconsole = slapos.client:slapconsole'
,
'slapconsole = slapos.client:slapconsole'
,
'slapformat = slapos.format:main'
,
'slapformat = slapos.
cli_legacy.
format:main'
,
'slapgrid = slapos.grid.slapgrid:run'
,
'slapgrid = slapos.grid.slapgrid:run'
,
'slapgrid-sr = slapos.grid.slapgrid:runSoftwareRelease'
,
'slapgrid-sr = slapos.grid.slapgrid:runSoftwareRelease'
,
'slapgrid-cp = slapos.grid.slapgrid:runComputerPartition'
,
'slapgrid-cp = slapos.grid.slapgrid:runComputerPartition'
,
'slapgrid-ur = slapos.grid.slapgrid:runUsageReport'
,
'slapgrid-ur = slapos.grid.slapgrid:runUsageReport'
,
'slapgrid-supervisorctl = slapos.grid.svcbackend:supervisorctl'
,
'slapgrid-supervisorctl = slapos.grid.svcbackend:supervisorctl'
,
'slapgrid-supervisord = slapos.grid.svcbackend:supervisord'
,
'slapgrid-supervisord = slapos.grid.svcbackend:supervisord'
,
'bang = slapos.bang:main'
,
'bang = slapos.
cli_legacy.
bang:main'
,
'slap2 = slapos.cli.entry:main'
,
'slap2 = slapos.cli.entry:main'
,
],
],
'slapos.cli'
:
[
'slapos.cli'
:
[
...
...
slapos/bang.py
View file @
38888da7
...
@@ -28,9 +28,6 @@
...
@@ -28,9 +28,6 @@
#
#
##############################################################################
##############################################################################
import
argparse
import
ConfigParser
import
slapos.slap.slap
import
slapos.slap.slap
...
@@ -51,20 +48,3 @@ def do_bang(config, message):
...
@@ -51,20 +48,3 @@ def do_bang(config, message):
print
'Banging to %r'
%
master_url
print
'Banging to %r'
%
master_url
computer
.
bang
(
message
)
computer
.
bang
(
message
)
print
'Bang with message %r'
%
message
print
'Bang with message %r'
%
message
def
main
(
*
args
):
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"-m"
,
"--message"
,
default
=
''
,
help
=
"Message for bang."
)
parser
.
add_argument
(
"configuration_file"
,
nargs
=
1
,
type
=
argparse
.
FileType
(),
help
=
"SlapOS configuration file."
)
if
len
(
args
)
==
0
:
argument
=
parser
.
parse_args
()
else
:
argument
=
parser
.
parse_args
(
list
(
args
))
configuration_file
=
argument
.
configuration_file
[
0
]
message
=
argument
.
message
# Loads config (if config specified)
config
=
ConfigParser
.
SafeConfigParser
()
config
.
readfp
(
configuration_file
)
do_bang
(
config
,
message
)
slapos/cache.py
View file @
38888da7
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
ast
import
ast
import
argparse
import
ConfigParser
import
hashlib
import
hashlib
import
json
import
json
import
re
import
re
...
@@ -58,15 +56,3 @@ def do_lookup(config, software_url):
...
@@ -58,15 +56,3 @@ def do_lookup(config, software_url):
for
os
in
ostable
:
for
os
in
ostable
:
compatible
=
'yes'
if
networkcache
.
os_matches
(
os
,
linux_distribution
)
else
'no'
compatible
=
'yes'
if
networkcache
.
os_matches
(
os
,
linux_distribution
)
else
'no'
print
'%-16s | %12s | %s | %s'
%
(
os
[
0
],
os
[
1
],
os
[
2
].
center
(
14
),
compatible
)
print
'%-16s | %12s | %s | %s'
%
(
os
[
0
],
os
[
1
],
os
[
2
].
center
(
14
),
compatible
)
def
cache_lookup
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"configuration_file"
,
help
=
"SlapOS configuration file"
)
parser
.
add_argument
(
"software_url"
,
help
=
"Your software url or MD5 hash"
)
args
=
parser
.
parse_args
()
config
=
ConfigParser
.
SafeConfigParser
()
config
.
read
(
args
.
configuration_file
)
do_lookup
(
config
,
args
.
software_url
)
slapos/cli/config.py
View file @
38888da7
...
@@ -10,8 +10,6 @@ class ConfigError(Exception):
...
@@ -10,8 +10,6 @@ class ConfigError(Exception):
pass
pass
class
ConfigCommand
(
Command
):
class
ConfigCommand
(
Command
):
"Base class for commands that require a configuration file"
"Base class for commands that require a configuration file"
...
@@ -69,4 +67,3 @@ class ClientConfigCommand(ConfigCommand):
...
@@ -69,4 +67,3 @@ class ClientConfigCommand(ConfigCommand):
# XXX does not fallback to SLAPOS_CONFIGURATION
# XXX does not fallback to SLAPOS_CONFIGURATION
default_config_var
=
'SLAPOS_CLIENT_CONFIGURATION'
default_config_var
=
'SLAPOS_CLIENT_CONFIGURATION'
default_config_path
=
'~/.slapos/slapos.cfg'
default_config_path
=
'~/.slapos/slapos.cfg'
slapos/cli/entry.py
View file @
38888da7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
logging
import
logging
...
...
slapos/cli_legacy/__init__.py
0 → 100644
View file @
38888da7
slapos/cli_legacy/bang.py
0 → 100644
View file @
38888da7
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2011, 2012 Vifib SARL and Contributors.
# All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
argparse
import
ConfigParser
from
slapos.bang
import
do_bang
def
main
(
*
args
):
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-m'
,
'--message'
,
default
=
''
,
help
=
'Message for bang.'
)
parser
.
add_argument
(
'configuration_file'
,
nargs
=
1
,
type
=
argparse
.
FileType
(),
help
=
'SlapOS configuration file.'
)
if
len
(
args
)
==
0
:
argument
=
parser
.
parse_args
()
else
:
argument
=
parser
.
parse_args
(
list
(
args
))
configuration_file
=
argument
.
configuration_file
[
0
]
message
=
argument
.
message
# Loads config (if config specified)
config
=
ConfigParser
.
SafeConfigParser
()
config
.
readfp
(
configuration_file
)
do_bang
(
config
,
message
)
slapos/cli_legacy/cache.py
0 → 100644
View file @
38888da7
# -*- coding: utf-8 -*-
import
argparse
import
ConfigParser
from
slapos.cache
import
do_lookup
def
cache_lookup
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"configuration_file"
,
help
=
"SlapOS configuration file"
)
parser
.
add_argument
(
"software_url"
,
help
=
"Your software url or MD5 hash"
)
args
=
parser
.
parse_args
()
config
=
ConfigParser
.
SafeConfigParser
()
config
.
read
(
args
.
configuration_file
)
do_lookup
(
config
,
args
.
software_url
)
slapos/entry.py
→
slapos/
cli_legacy/
entry.py
View file @
38888da7
...
@@ -30,13 +30,13 @@ import argparse
...
@@ -30,13 +30,13 @@ import argparse
import
ConfigParser
import
ConfigParser
import
os
import
os
import
sys
import
sys
from
slapos.bang
import
main
as
bang
from
slapos.
cli_legacy.
bang
import
main
as
bang
from
slapos.client
import
slapconsole
as
console
from
slapos.client
import
slapconsole
as
console
from
slapos.client
import
request
as
request
from
slapos.client
import
request
as
request
from
slapos.client
import
remove
as
remove
from
slapos.client
import
remove
as
remove
from
slapos.client
import
supply
as
supply
from
slapos.client
import
supply
as
supply
from
slapos.format
import
main
as
format
from
slapos.
cli_legacy.
format
import
main
as
format
from
slapos.cache
import
cache_lookup
from
slapos.c
li_legacy.c
ache
import
cache_lookup
from
slapos.grid.slapgrid
import
runComputerPartition
as
instance
from
slapos.grid.slapgrid
import
runComputerPartition
as
instance
from
slapos.grid.slapgrid
import
runSoftwareRelease
as
software
from
slapos.grid.slapgrid
import
runSoftwareRelease
as
software
from
slapos.grid.slapgrid
import
runUsageReport
as
report
from
slapos.grid.slapgrid
import
runUsageReport
as
report
...
...
slapos/cli_legacy/format.py
0 → 100644
View file @
38888da7
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
# All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
argparse
import
ConfigParser
import
logging
import
sys
from
slapos.format
import
FormatConfig
,
UsageError
,
tracing_monkeypatch
,
do_format
def
main
(
*
args
):
"Run default configuration."
# Parse arguments
ap
=
argparse
.
ArgumentParser
(
usage
=
'usage: %s [options] CONFIGURATION_FILE'
%
sys
.
argv
[
0
])
ap
.
add_argument
(
'-x'
,
'--computer_xml'
,
help
=
"Path to file with computer's XML. If does not exists, will be created"
,
default
=
None
)
ap
.
add_argument
(
'--computer_json'
,
help
=
"Path to a JSON version of the computer's XML (for development only)."
,
default
=
None
)
ap
.
add_argument
(
'-l'
,
'--log_file'
,
help
=
"The path to the log file used by the script."
)
ap
.
add_argument
(
'-i'
,
'--input_definition_file'
,
help
=
"Path to file to read definition of computer instead of "
"declaration. Using definition file allows to disable "
"'discovery' of machine services and allows to define computer "
"configuration in fully controlled manner."
)
ap
.
add_argument
(
'-o'
,
'--output_definition_file'
,
help
=
"Path to file to write definition of computer from "
"declaration."
)
ap
.
add_argument
(
'-n'
,
'--dry_run'
,
help
=
"Don't actually do anything."
,
default
=
False
,
action
=
"store_true"
)
ap
.
add_argument
(
'-v'
,
'--verbose'
,
default
=
False
,
action
=
"store_true"
,
help
=
"Verbose output."
)
# the console option is actually ignored and not used anymore.
ap
.
add_argument
(
'-c'
,
'--console'
,
default
=
False
,
action
=
"store_true"
,
help
=
"Console output."
)
ap
.
add_argument
(
'--alter_user'
,
choices
=
[
'True'
,
'False'
],
help
=
"Shall slapformat alter user database [default: True]"
)
ap
.
add_argument
(
'--alter_network'
,
choices
=
[
'True'
,
'False'
],
help
=
"Shall slapformat alter network configuration [default: True]"
)
ap
.
add_argument
(
'--now'
,
help
=
"Launch slapformat without delay"
,
default
=
False
,
action
=
"store_true"
)
ap
.
add_argument
(
'configuration_file'
,
help
=
'path to slapos.cfg'
)
if
args
:
options
=
ap
.
parse_args
(
list
(
args
))
else
:
options
=
ap
.
parse_args
()
logger
=
logging
.
getLogger
(
"slapformat"
)
logger
.
addHandler
(
logging
.
StreamHandler
())
if
options
.
verbose
:
logger
.
setLevel
(
logging
.
DEBUG
)
logger
.
debug
(
"Verbose mode enabled."
)
else
:
logger
.
setLevel
(
logging
.
INFO
)
config
=
FormatConfig
(
logger
=
logger
)
configuration_parser
=
ConfigParser
.
SafeConfigParser
()
if
configuration_parser
.
read
(
options
.
configuration_file
)
!=
[
options
.
configuration_file
]:
raise
UsageError
(
'Cannot find or parse configuration file: %s'
%
options
.
configuration_file
)
try
:
config
.
setConfig
(
options
,
configuration_parser
)
except
UsageError
as
err
:
sys
.
stderr
.
write
(
err
.
message
+
'
\
n
'
)
sys
.
stderr
.
write
(
"For help use --help
\
n
"
)
sys
.
exit
(
1
)
tracing_monkeypatch
(
config
)
try
:
do_format
(
config
=
config
)
except
:
config
.
logger
.
exception
(
'Uncaught exception:'
)
raise
slapos/format.py
View file @
38888da7
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#
#
##############################################################################
##############################################################################
import
argparse
import
ConfigParser
import
ConfigParser
import
errno
import
errno
import
fcntl
import
fcntl
...
@@ -1265,99 +1264,3 @@ def tracing_monkeypatch(config):
...
@@ -1265,99 +1264,3 @@ def tracing_monkeypatch(config):
config
.
logger
.
debug
(
' '
.
join
(
argument_list
))
config
.
logger
.
debug
(
' '
.
join
(
argument_list
))
return
dry_callAndRead
(
argument_list
,
raise_on_error
)
return
dry_callAndRead
(
argument_list
,
raise_on_error
)
callAndRead
=
logging_callAndRead
callAndRead
=
logging_callAndRead
def
main
(
*
args
):
"Run default configuration."
# Parse arguments
ap
=
argparse
.
ArgumentParser
(
usage
=
'usage: %s [options] CONFIGURATION_FILE'
%
sys
.
argv
[
0
])
ap
.
add_argument
(
'-x'
,
'--computer_xml'
,
help
=
"Path to file with computer's XML. If does not exists, will be created"
,
default
=
None
)
ap
.
add_argument
(
'--computer_json'
,
help
=
"Path to a JSON version of the computer's XML (for development only)."
,
default
=
None
)
ap
.
add_argument
(
'-l'
,
'--log_file'
,
help
=
"The path to the log file used by the script."
)
ap
.
add_argument
(
'-i'
,
'--input_definition_file'
,
help
=
"Path to file to read definition of computer instead of "
"declaration. Using definition file allows to disable "
"'discovery' of machine services and allows to define computer "
"configuration in fully controlled manner."
)
ap
.
add_argument
(
'-o'
,
'--output_definition_file'
,
help
=
"Path to file to write definition of computer from "
"declaration."
)
ap
.
add_argument
(
'-n'
,
'--dry_run'
,
help
=
"Don't actually do anything."
,
default
=
False
,
action
=
"store_true"
)
ap
.
add_argument
(
'-v'
,
'--verbose'
,
default
=
False
,
action
=
"store_true"
,
help
=
"Verbose output."
)
# the console option is actually ignored and not used anymore.
ap
.
add_argument
(
'-c'
,
'--console'
,
default
=
False
,
action
=
"store_true"
,
help
=
"Console output."
)
ap
.
add_argument
(
'--alter_user'
,
choices
=
[
'True'
,
'False'
],
help
=
"Shall slapformat alter user database [default: True]"
)
ap
.
add_argument
(
'--alter_network'
,
choices
=
[
'True'
,
'False'
],
help
=
"Shall slapformat alter network configuration [default: True]"
)
ap
.
add_argument
(
'--now'
,
help
=
"Launch slapformat without delay"
,
default
=
False
,
action
=
"store_true"
)
ap
.
add_argument
(
'configuration_file'
,
help
=
'path to slapos.cfg'
)
if
args
:
options
=
ap
.
parse_args
(
list
(
args
))
else
:
options
=
ap
.
parse_args
()
logger
=
logging
.
getLogger
(
"slapformat"
)
logger
.
addHandler
(
logging
.
StreamHandler
())
if
options
.
verbose
:
logger
.
setLevel
(
logging
.
DEBUG
)
logger
.
debug
(
"Verbose mode enabled."
)
else
:
logger
.
setLevel
(
logging
.
INFO
)
config
=
FormatConfig
(
logger
=
logger
)
configuration_parser
=
ConfigParser
.
SafeConfigParser
()
if
configuration_parser
.
read
(
options
.
configuration_file
)
!=
[
options
.
configuration_file
]:
raise
UsageError
(
'Cannot find or parse configuration file: %s'
%
options
.
configuration_file
)
try
:
config
.
setConfig
(
options
,
configuration_parser
)
except
UsageError
as
err
:
sys
.
stderr
.
write
(
err
.
message
+
'
\
n
'
)
sys
.
stderr
.
write
(
"For help use --help
\
n
"
)
sys
.
exit
(
1
)
tracing_monkeypatch
(
config
)
try
:
do_format
(
config
=
config
)
except
:
config
.
logger
.
exception
(
'Uncaught exception:'
)
raise
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