Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Xavier Thompson
slapos
Commits
a467c0f0
Commit
a467c0f0
authored
May 16, 2014
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recipes to dump partition configuration or buildout section in json files
parent
8d085230
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
6 deletions
+42
-6
setup.py
setup.py
+2
-0
slapos/recipe/jsondump.py
slapos/recipe/jsondump.py
+19
-0
slapos/recipe/slapconfiguration.py
slapos/recipe/slapconfiguration.py
+21
-6
No files found.
setup.py
View file @
a467c0f0
...
@@ -127,6 +127,7 @@ setup(name=name,
...
@@ -127,6 +127,7 @@ setup(name=name,
'ipv4toipv6 = slapos.recipe.6tunnel:FourToSix'
,
'ipv4toipv6 = slapos.recipe.6tunnel:FourToSix'
,
'ipv6toipv4 = slapos.recipe.6tunnel:SixToFour'
,
'ipv6toipv4 = slapos.recipe.6tunnel:SixToFour'
,
'java = slapos.recipe.java:Recipe'
,
'java = slapos.recipe.java:Recipe'
,
'jsondump = slapos.recipe.jsondump:Recipe'
,
'kumofs = slapos.recipe.kumofs:Recipe'
,
'kumofs = slapos.recipe.kumofs:Recipe'
,
'kvm = slapos.recipe.kvm:Recipe'
,
'kvm = slapos.recipe.kvm:Recipe'
,
'kvm.frontend = slapos.recipe.kvm_frontend:Recipe'
,
'kvm.frontend = slapos.recipe.kvm_frontend:Recipe'
,
...
@@ -180,6 +181,7 @@ setup(name=name,
...
@@ -180,6 +181,7 @@ setup(name=name,
'siptester = slapos.recipe.siptester:SipTesterRecipe'
,
'siptester = slapos.recipe.siptester:SipTesterRecipe'
,
'slapconfiguration = slapos.recipe.slapconfiguration:Recipe'
,
'slapconfiguration = slapos.recipe.slapconfiguration:Recipe'
,
'slapconfiguration.serialised = slapos.recipe.slapconfiguration:Serialised'
,
'slapconfiguration.serialised = slapos.recipe.slapconfiguration:Serialised'
,
'slapconfiguration.jsondump = slapos.recipe.slapconfiguration:JsonDump'
,
'slapcontainer = slapos.recipe.container:Recipe'
,
'slapcontainer = slapos.recipe.container:Recipe'
,
'slapmonitor = slapos.recipe.slapmonitor:MonitorRecipe'
,
'slapmonitor = slapos.recipe.slapmonitor:MonitorRecipe'
,
'slapmonitor-xml = slapos.recipe.slapmonitor:MonitorXMLRecipe'
,
'slapmonitor-xml = slapos.recipe.slapmonitor:MonitorXMLRecipe'
,
...
...
slapos/recipe/jsondump.py
0 → 100644
View file @
a467c0f0
import
json
import
os
class
Recipe
(
object
):
def
__init__
(
self
,
buildout
,
name
,
options
):
parameter_dict
=
{
key
:
value
for
key
,
value
in
options
.
items
()
if
key
not
in
[
'json-output'
,
'recipe'
]
}
with
os
.
fdopen
(
os
.
open
(
options
[
'json-output'
],
os
.
O_WRONLY
|
os
.
O_CREAT
|
os
.
O_TRUNC
,
0o600
),
'w'
)
as
fout
:
fout
.
write
(
json
.
dumps
(
parameter_dict
,
indent
=
2
,
sort_keys
=
True
))
fout
.
close
()
def
install
(
self
):
return
[]
slapos/recipe/slapconfiguration.py
View file @
a467c0f0
...
@@ -24,6 +24,10 @@
...
@@ -24,6 +24,10 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
##############################################################################
##############################################################################
import
json
import
os
import
slapos.slap
import
slapos.slap
from
slapos.recipe.librecipe
import
unwrap
from
slapos.recipe.librecipe
import
unwrap
from
ConfigParser
import
RawConfigParser
from
ConfigParser
import
RawConfigParser
...
@@ -87,6 +91,15 @@ class Recipe(object):
...
@@ -87,6 +91,15 @@ class Recipe(object):
OPTCRE_match
=
RawConfigParser
.
OPTCRE
.
match
OPTCRE_match
=
RawConfigParser
.
OPTCRE
.
match
def
__init__
(
self
,
buildout
,
name
,
options
):
def
__init__
(
self
,
buildout
,
name
,
options
):
parameter_dict
=
self
.
fetch_parameter_dict
(
options
)
match
=
self
.
OPTCRE_match
for
key
,
value
in
parameter_dict
.
iteritems
():
if
match
(
key
)
is
not
None
:
continue
options
[
'configuration.'
+
key
]
=
value
def
fetch_parameter_dict
(
self
,
options
):
slap
=
slapos
.
slap
.
slap
()
slap
=
slapos
.
slap
.
slap
()
slap
.
initializeConnection
(
slap
.
initializeConnection
(
options
[
'url'
],
options
[
'url'
],
...
@@ -138,12 +151,7 @@ class Recipe(object):
...
@@ -138,12 +151,7 @@ class Recipe(object):
options
[
'ipv6-random'
]
=
list
(
ipv6_set
)[
0
].
encode
(
'UTF-8'
)
options
[
'ipv6-random'
]
=
list
(
ipv6_set
)[
0
].
encode
(
'UTF-8'
)
options
[
'tap'
]
=
tap_set
options
[
'tap'
]
=
tap_set
parameter_dict
=
self
.
_expandParameterDict
(
options
,
parameter_dict
)
return
self
.
_expandParameterDict
(
options
,
parameter_dict
)
match
=
self
.
OPTCRE_match
for
key
,
value
in
parameter_dict
.
iteritems
():
if
match
(
key
)
is
not
None
:
continue
options
[
'configuration.'
+
key
]
=
value
def
_expandParameterDict
(
self
,
options
,
parameter_dict
):
def
_expandParameterDict
(
self
,
options
,
parameter_dict
):
options
[
'configuration'
]
=
parameter_dict
options
[
'configuration'
]
=
parameter_dict
...
@@ -158,3 +166,10 @@ class Serialised(Recipe):
...
@@ -158,3 +166,10 @@ class Serialised(Recipe):
return
parameter_dict
return
parameter_dict
else
:
else
:
return
{}
return
{}
class
JsonDump
(
Recipe
):
def
__init__
(
self
,
buildout
,
name
,
options
):
parameter_dict
=
self
.
fetch_parameter_dict
(
options
)
with
os
.
fdopen
(
os
.
open
(
options
[
'json-output'
],
os
.
O_WRONLY
|
os
.
O_CREAT
,
0600
),
'w'
)
as
fout
:
fout
.
write
(
json
.
dumps
(
parameter_dict
,
indent
=
2
,
sort_keys
=
True
))
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