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
16
Merge Requests
16
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
nexedi
slapos.core
Commits
fed527ee
Commit
fed527ee
authored
Feb 04, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support writing to computer_json
parent
28d88471
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
slapos/format.py
slapos/format.py
+14
-2
No files found.
slapos/format.py
View file @
fed527ee
...
...
@@ -34,6 +34,7 @@ import ConfigParser
import
errno
import
fcntl
import
grp
import
json
import
logging
import
netaddr
import
netifaces
...
...
@@ -261,7 +262,7 @@ class Computer(object):
"SlapOS Master. Please make sure computer_id of slapos.cfg looks "
"like 'COMP-123' and is correct.
\
n
Error is : 404 Not Found."
%
error
)
def
dump
(
self
,
path_to_xml
):
def
dump
(
self
,
path_to_xml
,
path_to_json
):
"""
Dump the computer object to an xml file via xml_marshaller.
...
...
@@ -272,6 +273,11 @@ class Computer(object):
"""
computer_dict
=
_getDict
(
self
)
if
path_to_json
:
with
open
(
path_to_json
,
'wb'
)
as
fout
:
fout
.
write
(
json
.
dumps
(
computer_dict
,
sort_keys
=
True
,
indent
=
2
))
new_xml
=
xml_marshaller
.
dumps
(
computer_dict
)
new_pretty_xml
=
prettify_xml
(
new_xml
)
...
...
@@ -889,6 +895,10 @@ class Parser(OptionParser):
"will be created"
,
default
=
None
,
type
=
str
),
Option
(
"--computer_json"
,
help
=
"Path to a JSON version of the computer's XML (for development only)."
,
default
=
None
,
type
=
str
),
Option
(
"-l"
,
"--log_file"
,
help
=
"The path to the log file used by the script."
,
type
=
str
),
...
...
@@ -1076,7 +1086,8 @@ def run(config):
# Dumping and sending to the erp5 the current configuration
if
not
config
.
dry_run
:
computer
.
dump
(
config
.
computer_xml
)
computer
.
dump
(
path_to_xml
=
config
.
computer_xml
,
path_to_json
=
config
.
computer_json
)
config
.
logger
.
info
(
'Posting information to %r'
%
config
.
master_url
)
computer
.
send
(
config
)
config
.
logger
.
info
(
'slapformat successfully prepared computer.'
)
...
...
@@ -1089,6 +1100,7 @@ class Config(object):
alter_user
=
None
create_tap
=
None
computer_xml
=
None
computer_json
=
None
logger
=
None
log_file
=
None
verbose
=
None
...
...
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