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
18
Merge Requests
18
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
4337b2fa
Commit
4337b2fa
authored
Aug 16, 2011
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
merge 'master' into slave_instance
parents
dc812047
1eddcede
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
532 additions
and
28 deletions
+532
-28
master/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestSoftwareInstance.xml
...flow/scripts/SoftwareInstance_requestSoftwareInstance.xml
+9
-3
master/bt5/vifib_base/bt/revision
master/bt5/vifib_base/bt/revision
+1
-1
master/product/Vifib/tests/testVifibSlapWebService.py
master/product/Vifib/tests/testVifibSlapWebService.py
+5
-5
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+56
-2
slapos/tests/mock/httplib.py
slapos/tests/mock/httplib.py
+2
-5
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+459
-12
No files found.
master/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestSoftwareInstance.xml
View file @
4337b2fa
...
...
@@ -74,7 +74,13 @@ graph = {}\n
# Get root software instance and create initial graph\n
predecessor_software_instance = software_instance\n
while (predecessor_software_instance is not None):\n
graph[predecessor_software_instance.getUid()] = predecessor_software_instance.getPredecessorUidList()\n
predecessor_software_instance_pred_uid_list = predecessor_software_instance.getPredecessorUidList()\n
graph[predecessor_software_instance.getUid()] = predecessor_software_instance_pred_uid_list\n
# as this walking is not fetching all instances fill predecessors into graph, in order to have\n
# "nearly" complete representation\n
for uid in predecessor_software_instance_pred_uid_list:\n
if uid not in graph:\n
graph[uid] = []\n
root_software_instance = predecessor_software_instance\n
predecessor_software_instance = predecessor_software_instance.getPredecessorRelatedValue(\n
portal_type="Software Instance")\n
...
...
@@ -160,9 +166,9 @@ if not request_software_instance.getUid() in graph:\n
# update graph to reflect requested operation\n
graph[software_instance.getUid()] = software_instance.getPredecessorUidList() + [request_software_instance.getUid()]\n
\n
# check if all elements are still connected\n
software_instance.checkNotCyclic(graph)\n
# check if all elements are still connected and if there is no cycle\n
software_instance.checkConnected(graph, root_software_instance.getUid())\n
software_instance.checkNotCyclic(graph)\n
\n
software_instance.edit(\n
predecessor_list=predecessor_list,\n
...
...
master/bt5/vifib_base/bt/revision
View file @
4337b2fa
267
\ No newline at end of file
268
master/product/Vifib/tests/testVifibSlapWebService.py
View file @
4337b2fa
...
...
@@ -3149,6 +3149,9 @@ class TestVifibSlapWebService(testVifibMixin):
def
stepCheckSoftwareInstanceAndRelatedComputerPartition
(
self
,
sequence
,
**
kw
):
self
.
stepCheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
(
sequence
,
**
kw
)
software_instance_uid
=
sequence
[
'software_instance_uid'
]
software_instance
=
self
.
portal
.
portal_catalog
.
getResultValue
(
uid
=
software_instance_uid
)
self
.
_checkSoftwareInstanceAndRelatedPartition
(
software_instance
)
def
stepCheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
(
self
,
...
...
@@ -9220,7 +9223,6 @@ class TestVifibSlapWebService(testVifibMixin):
sequence
,
**
kw
):
software_instance
=
self
.
portal
.
portal_catalog
.
getResultValue
(
uid
=
sequence
[
'software_instance_uid'
])
requested_reference
=
sequence
[
'requested_reference'
]
from
erp5.document.SoftwareInstance
import
DisconnectedSoftwareTree
self
.
assertRaises
(
DisconnectedSoftwareTree
,
software_instance
.
requestSoftwareInstance
,
...
...
@@ -9370,7 +9372,6 @@ class TestVifibSlapWebService(testVifibMixin):
sequence
,
**
kw
):
software_instance
=
self
.
portal
.
portal_catalog
.
getResultValue
(
uid
=
sequence
[
'software_instance_uid'
])
requested_reference
=
sequence
[
'requested_reference'
]
from
erp5.document.SoftwareInstance
import
CyclicSoftwareTree
self
.
assertRaises
(
CyclicSoftwareTree
,
software_instance
.
requestSoftwareInstance
,
...
...
@@ -9520,7 +9521,6 @@ class TestVifibSlapWebService(testVifibMixin):
sequence
,
**
kw
):
software_instance
=
self
.
portal
.
portal_catalog
.
getResultValue
(
uid
=
sequence
[
'software_instance_uid'
])
requested_reference
=
sequence
[
'requested_reference'
]
self
.
assertRaises
(
ValueError
,
software_instance
.
requestSoftwareInstance
,
software_release
=
sequence
[
'software_release_uri'
],
...
...
@@ -9764,7 +9764,7 @@ class TestVifibSlapWebService(testVifibMixin):
from
erp5.document.SoftwareInstance
import
CyclicSoftwareTree
self
.
assertRaises
(
CyclicSoftwareTree
,
self
.
checkNotCyclic
,
graph
)
def
test_si_tree_simple_list_cyclic
(
self
):
def
test_si_tree_simple_list_cyclic
_non_root
(
self
):
"""Graph of cyclic list is cyclic
B->C->D->A-
\
...
...
@@ -9862,7 +9862,7 @@ class TestVifibSlapWebService(testVifibMixin):
def
stepRequestCredentialFromWebSite
(
self
,
sequence
,
**
kw
):
sequence
[
'web_user'
]
=
'%s.%s'
%
(
self
.
id
(),
random
())
result
=
self
.
portal
.
ERP5Site_newCredentialRequest
(
\
self
.
portal
.
ERP5Site_newCredentialRequest
(
\
first_name
=
'Homer'
,
last_name
=
'Simpson'
,
reference
=
sequence
[
'web_user'
],
...
...
slapos/grid/slapgrid.py
View file @
4337b2fa
...
...
@@ -35,6 +35,7 @@ if sys.version_info < (2, 6):
import
socket
import
subprocess
import
traceback
import
time
#from time import strftime
from
SlapObject
import
Software
,
Partition
,
WrongPermissionError
,
\
...
...
@@ -105,6 +106,9 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
help
=
"Enables console output and live output from subcommands."
)
parser
.
add_argument
(
"-v"
,
"--verbose"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Be verbose."
)
parser
.
add_argument
(
"--promise-timeout"
,
type
=
int
,
default
=
3
,
help
=
"Promise timeout in seconds."
)
parser
.
add_argument
(
"configuration_file"
,
nargs
=
1
,
type
=
argparse
.
FileType
(),
help
=
"SlapOS configuration file."
)
...
...
@@ -198,7 +202,8 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
master_ca_file
=
master_ca_file
,
certificate_repository_path
=
certificate_repository_path
,
console
=
option_dict
[
'console'
],
buildout
=
option_dict
.
get
(
'buildout'
)),
buildout
=
option_dict
.
get
(
'buildout'
),
promise_timeout
=
option_dict
[
'promise_timeout'
]),
option_dict
])
...
...
@@ -267,7 +272,8 @@ class Slapgrid(object):
cert_file
=
None
,
master_ca_file
=
None
,
certificate_repository_path
=
None
,
console
=
False
):
console
=
False
,
promise_timeout
=
3
):
"""Makes easy initialisation of class parameters"""
# Parses arguments
self
.
software_root
=
os
.
path
.
abspath
(
software_root
)
...
...
@@ -294,6 +300,7 @@ class Slapgrid(object):
os
.
path
.
join
(
self
.
instance_etc_directory
,
'supervisord.conf.d'
)
self
.
console
=
console
self
.
buildout
=
buildout
self
.
promise_timeout
=
promise_timeout
def
checkEnvironmentAndCreateStructure
(
self
):
"""Checks for software_root and instance_root existence, then creates
...
...
@@ -452,6 +459,53 @@ class Slapgrid(object):
exception
=
traceback
.
format_exc
()
logger
.
error
(
exception
)
computer_partition
.
error
(
exception
)
# Promises
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
computer_partition
.
getId
())
uid
,
gid
=
None
,
None
stat_info
=
os
.
stat
(
instance_path
)
#stat sys call to get statistics informations
uid
=
stat_info
.
st_uid
gid
=
stat_info
.
st_gid
# Get the list of promises
promise_dir
=
os
.
path
.
join
(
instance_path
,
'etc'
,
'promise'
)
if
os
.
path
.
exists
(
promise_dir
)
and
os
.
path
.
isdir
(
promise_dir
):
cwd
=
instance_path
promises_list
=
os
.
listdir
(
promise_dir
)
# Check whether every promise is kept
for
promise
in
promises_list
:
command
=
os
.
path
.
join
(
promise_dir
,
promise
)
kw
=
dict
()
if
not
self
.
console
:
kw
.
update
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
process_handler
=
SlapPopen
(
command
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
cwd
,
env
=
None
,
**
kw
)
time
.
sleep
(
self
.
promise_timeout
)
promise
=
os
.
path
.
basename
(
command
)
if
process_handler
.
poll
()
is
None
:
process_handler
.
kill
()
computer_partition
.
error
(
"The promise %r timed out"
%
promise
)
elif
process_handler
.
poll
()
!=
0
:
stderr
=
process_handler
.
communicate
()[
1
]
if
stderr
is
None
:
stderr
=
'No error output from %r.'
%
promise
computer_partition
.
error
(
stderr
)
logger
.
info
(
"Finished computer partitions..."
)
return
clean_run
...
...
slapos/tests/mock/httplib.py
View file @
4337b2fa
...
...
@@ -3,8 +3,6 @@
"""Mocked httplib
"""
from
urlparse
import
urlparse
__all__
=
[]
def
log
(
message
):
...
...
@@ -21,13 +19,13 @@ class HTTPConnection(object):
HTTPConnection._callback. This method received the instance, the path,
method and request body as parameter, and it has to return a tuple with
headers dictionary and body response string.
@param self object instance reference
@param URL the parsed URL
@param method the http method
@param body the request body
@param headers the request headers
@return tuple containing status integer, headers dictionary and body
response"""
return
(
0
,
{},
''
,
)
...
...
@@ -83,7 +81,6 @@ class HTTPSConnection(HTTPConnection):
source_address
=
None
):
super
().
__init__
(
self
,
host
,
port
,
strict
,
timeout
,
source_address
)
pass
class
HTTPResponse
(
object
):
...
...
slapos/tests/slapgrid.py
View file @
4337b2fa
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