Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Kirill Smelkov
slapos.toolbox
Commits
a537db8b
Commit
a537db8b
authored
Jul 20, 2012
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skeleton of slapcontainer script
parent
873a5b35
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
125 additions
and
0 deletions
+125
-0
setup.py
setup.py
+2
-0
slapos/container/__init__.py
slapos/container/__init__.py
+25
-0
slapos/container/prepare.py
slapos/container/prepare.py
+98
-0
No files found.
setup.py
View file @
a537db8b
...
@@ -41,6 +41,7 @@ setup(name=name,
...
@@ -41,6 +41,7 @@ setup(name=name,
'slapos.core'
,
# as it provides library for slap
'slapos.core'
,
# as it provides library for slap
'xml_marshaller'
,
# needed to dump information
'xml_marshaller'
,
# needed to dump information
'GitPython'
,
#needed for git manipulation into slaprunner
'GitPython'
,
#needed for git manipulation into slaprunner
'lockfile'
,
#needed for interprocess exclusion (in slapcontainer)
]
+
additional_install_requires
,
]
+
additional_install_requires
,
extras_require
=
{
extras_require
=
{
'lampconfigure'
:
[
"mysql-python"
],
#needed for MySQL Database access
'lampconfigure'
:
[
"mysql-python"
],
#needed for MySQL Database access
...
@@ -73,6 +74,7 @@ setup(name=name,
...
@@ -73,6 +74,7 @@ setup(name=name,
'pubsubnotifier = slapos.pubsub.notifier:main'
,
'pubsubnotifier = slapos.pubsub.notifier:main'
,
'slaprunnertest = slapos.runner.testRunner:run'
,
'slaprunnertest = slapos.runner.testRunner:run'
,
'zodbpack = slapos.zodbpack:run [zodbpack]'
,
'zodbpack = slapos.zodbpack:run [zodbpack]'
,
'slapcontainer = slapos.container:main'
,
]
]
},
},
)
)
slapos/container/__init__.py
0 → 100644
View file @
a537db8b
# -*- coding: utf-8 -*-
import
ConfigParser
import
sys
import
os
from
.
import
prepare
def
main
():
slapos_conf
=
ConfigParser
.
ConfigParser
()
slapos_conf
.
read
(
sys
.
argv
[
1
])
current_binary
=
os
.
path
.
join
(
os
.
getcwd
(),
sys
.
argv
[
0
])
binary_directory
=
os
.
path
.
dirname
(
current_binary
)
sr_directory
=
os
.
path
.
realpath
(
os
.
path
.
join
(
binary_directory
,
'..'
))
partition_amount
=
slapos_conf
.
getint
(
'slapformat'
,
'partition_amount'
)
partition_base_name
=
slapos_conf
.
get
(
'slapformat'
,
'partition_base_name'
)
instance_root
=
slapos_conf
.
get
(
'slapos'
,
'instance_root'
)
partition_base_path
=
os
.
path
.
join
(
instance_root
,
partition_base_name
)
partition_list
=
[
'%s%d'
%
(
partition_base_path
,
i
)
for
i
in
range
(
partition_amount
)]
prepare
.
main
(
sr_directory
,
partition_list
)
slapos/container/prepare.py
0 → 100644
View file @
a537db8b
# -*- coding: utf-8 -*-
import
ConfigParser
import
os
import
lockfile
def
main
(
sr_directory
,
partition_list
):
overall_failure
=
0
for
partition_path
in
partition_list
:
slapcontainer_filename
=
os
.
path
.
join
(
partition_path
,
'.slapcontainer'
)
if
os
.
path
.
isfile
(
slapcontainer_filename
):
failure
=
0
lock
=
lockfile
.
FileLock
(
slapcontainer_filename
)
try
:
lock
.
acquire
(
timeout
=
0
)
slapcontainer_conf
=
ConfigParser
.
ConfigParser
()
slapcontainer_conf
.
read
(
slapcontainer_filename
)
requested_status
=
slapcontainer_conf
.
get
(
'requested'
,
'status'
)
if
not
slapcontainer_conf
.
has_section
(
'current'
):
slapcontainer_conf
.
add_section
(
'current'
)
if
not
slapcontainer_conf
.
has_option
(
'current'
,
'created'
):
slapcontainer_conf
.
set
(
'current'
,
'created'
,
'no'
)
if
not
slapcontainer_conf
.
has_option
(
'current'
,
'status'
):
slapcontainer_conf
.
set
(
'current'
,
'status'
,
'stopped'
)
if
requested_status
==
'started'
:
failure
|=
start
(
sr_directory
,
partition_path
,
slapcontainer_conf
)
else
:
failure
|=
stop
(
sr_directory
,
partition_path
,
slapcontainer_conf
)
with
open
(
slapcontainer_filename
,
'w'
)
as
slapcontainer_fp
:
slapcontainer_conf
.
write
(
slapcontainer_fp
)
except
lockfile
.
LockTimeout
:
# Can't do anything, we'll see on the next run
pass
finally
:
lock
.
release
()
overall_failure
|=
failure
return
overall_failure
def
start
(
sr_directory
,
partition_path
,
conf
):
failure
=
0
if
conf
.
get
(
'current'
,
'created'
)
==
'no'
:
failure
|=
create
(
sr_directory
,
partition_path
,
conf
)
if
failure
:
return
failure
else
:
conf
.
set
(
'current'
,
'created'
,
'yes'
)
# TODO: Check if container is started,
# Start container
conf
.
set
(
'current'
,
'status'
,
'started'
)
return
failure
def
stop
(
sr_directory
,
partition_path
,
conf
):
failure
=
0
# TODO : Check if container is stopped
# Stop container
if
conf
.
get
(
'current'
,
'created'
)
==
'yes'
:
failure
|=
destroy
(
partition_path
,
conf
)
return
failure
def
create
(
sr_directory
,
partition_path
,
conf
):
failure
=
0
# TODO : Create container
return
failure
def
destroy
(
partition_path
,
conf
):
failure
=
0
# TODO: Destroy container
return
failure
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