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
Léo-Paul Géneau
slapos.core
Commits
e489767d
Commit
e489767d
authored
Sep 03, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy show: pretty print _ parameter as json
parent
0a2023cc
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
306 additions
and
0 deletions
+306
-0
CHANGES.txt
CHANGES.txt
+1
-0
slapos/cli/proxy_show.py
slapos/cli/proxy_show.py
+7
-0
slapos/tests/cli.py
slapos/tests/cli.py
+63
-0
slapos/tests/slapproxy/database_dump_version_11.sql
slapos/tests/slapproxy/database_dump_version_11.sql
+235
-0
No files found.
CHANGES.txt
View file @
e489767d
...
...
@@ -5,6 +5,7 @@ Changes
-------------------
* add `--buildout-debug` command line option to `slapos node software` and
`slapos node instance` commands which starts buildout debugger on errors.
* pretty print json serialised instance parameters in `slapos proxy show`
1.4.9 (2018-07-31)
------------------
...
...
slapos/cli/proxy_show.py
View file @
e489767d
...
...
@@ -29,6 +29,7 @@
import
collections
import
hashlib
import
json
import
lxml.etree
import
prettytable
...
...
@@ -141,6 +142,12 @@ def log_params(logger, conn):
text
=
parameter
.
text
if
text
and
name
in
(
'ssh-key'
,
'ssh-public-key'
):
text
=
text
[:
20
]
+
'...'
+
text
[
-
20
:]
# _ is usually json encoded - re-format to make it easier to read
if
name
==
'_'
:
try
:
text
=
json
.
dumps
(
json
.
loads
(
text
),
indent
=
2
)
except
ValueError
:
pass
logger
.
info
(
' %s = %s'
,
name
,
text
)
...
...
slapos/tests/cli.py
View file @
e489767d
...
...
@@ -31,15 +31,21 @@ import unittest
import
tempfile
import
StringIO
import
sys
import
os
import
sqlite3
import
pkg_resources
from
mock
import
patch
,
create_autospec
import
mock
from
slapos.util
import
sqlite_connect
import
slapos.cli.console
import
slapos.cli.entry
import
slapos.cli.info
import
slapos.cli.list
import
slapos.cli.supervisorctl
import
slapos.cli.proxy_show
from
slapos.client
import
ClientConfig
import
slapos.grid.svcbackend
import
slapos.proxy
...
...
@@ -57,6 +63,7 @@ class CliMixin(unittest.TestCase):
self
.
logger
=
create_autospec
(
logging
.
Logger
)
self
.
conf
=
create_autospec
(
ClientConfig
)
class
TestCliProxy
(
CliMixin
):
def
test_generateSoftwareProductListFromString
(
self
):
"""
...
...
@@ -82,6 +89,62 @@ product2 url2"""
{}
)
class
TestCliProxyShow
(
CliMixin
):
def
setUp
(
self
):
super
(
TestCliProxyShow
,
self
).
setUp
()
self
.
db_file
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
,
suffix
=
'.db'
)
self
.
db_file
.
close
()
self
.
conf
.
database_uri
=
self
.
db_file
.
name
self
.
conf
.
logger
=
self
.
logger
# load database
schema
=
pkg_resources
.
resource_stream
(
'slapos.tests.slapproxy'
,
'database_dump_version_11.sql'
)
db
=
sqlite_connect
(
self
.
db_file
.
name
)
db
.
cursor
().
executescript
(
schema
.
read
())
db
.
commit
()
def
tearDown
(
self
):
super
(
TestCliProxyShow
,
self
).
tearDown
()
os
.
remove
(
self
.
db_file
.
name
)
def
test_proxy_show
(
self
):
# simulate "show all" arguments
self
.
conf
.
computers
=
True
self
.
conf
.
software
=
True
self
.
conf
.
partitions
=
True
self
.
conf
.
slaves
=
True
self
.
conf
.
params
=
True
self
.
conf
.
network
=
True
slapos
.
cli
.
proxy_show
.
do_show
(
self
.
conf
)
# installed softwares are listed
self
.
logger
.
info
.
assert_any_call
(
' /srv/slapgrid/slappart8/srv/runner/project/slapos/software/erp5/software.cfg slaprunner 287375f0cba269902ba1bc50242839d7 '
)
# instance parameters are listed
# _ parameter is json formatted
self
.
logger
.
info
.
assert_any_call
(
' %s = %s'
,
'_'
,
'{
\
n
"url": "memcached://10.0.30.235:2003/",
\
n
"monitor-base-url": ""
\
n
}'
)
# other parameters are displayed as simple string
self
.
logger
.
info
.
assert_any_call
(
' %s = %s'
,
'url'
,
'http://10.0.30.235:4444/wd/hub'
)
# if _ cannot be decoded as json, it is displayed "as is"
self
.
logger
.
info
.
assert_any_call
(
' %s = %s'
,
'_'
,
u'Ahah this is not json
\
U0001f61c
'
)
class
TestCliNode
(
CliMixin
):
def
test_node_software
(
self
):
...
...
slapos/tests/slapproxy/database_dump_version_11.sql
0 → 100644
View file @
e489767d
This diff is collapsed.
Click to expand it.
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