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
Gabriel Monnerat
slapos.core
Commits
06c32a51
Commit
06c32a51
authored
Sep 02, 2013
by
Vivien Alger
Browse files
Options
Browse Files
Download
Plain Diff
merge conflict: revision change
parents
53b4f6bf
e2f5d561
Changes
26
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
463 additions
and
144 deletions
+463
-144
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Person_findPartition.xml
...teItem/portal_skins/slapos_cloud/Person_findPartition.xml
+4
-3
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudWorkflow.py
.../slapos_cloud/TestTemplateItem/testSlapOSCloudWorkflow.py
+20
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/instance_slap_interface_workflow/scripts/RequestedInstance_bangResquesterInstance.xml
...flow/scripts/RequestedInstance_bangResquesterInstance.xml
+75
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/instance_slap_interface_workflow/transitions/update_connection.xml
...slap_interface_workflow/transitions/update_connection.xml
+1
-1
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+2
-1
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Computer_getHateoas.xml
...em/portal_skins/slapos_hypermedia/Computer_getHateoas.xml
+1
-1
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Computer_getHateoasSoftwareInstallationList.xml
...ypermedia/Computer_getHateoasSoftwareInstallationList.xml
+5
-4
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_getHateoasComputerList.xml
...skins/slapos_hypermedia/Person_getHateoasComputerList.xml
+1
-1
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/SoftwareInstallation_getHateoas.xml
...ins/slapos_hypermedia/SoftwareInstallation_getHateoas.xml
+7
-5
master/bt5/slapos_hypermedia/TestTemplateItem/testSlapOSHypermediaScenario.py
...permedia/TestTemplateItem/testSlapOSHypermediaScenario.py
+1
-1
master/bt5/slapos_hypermedia/TestTemplateItem/testSlapOSHypermediaSkins.py
..._hypermedia/TestTemplateItem/testSlapOSHypermediaSkins.py
+246
-104
master/bt5/slapos_hypermedia/bt/revision
master/bt5/slapos_hypermedia/bt/revision
+1
-1
slapos.cfg.example
slapos.cfg.example
+14
-0
slapos/cli/cache.py
slapos/cli/cache.py
+2
-2
slapos/cli/command.py
slapos/cli/command.py
+1
-1
slapos/cli/entry.py
slapos/cli/entry.py
+26
-0
slapos/cli/format.py
slapos/cli/format.py
+2
-0
slapos/format.py
slapos/format.py
+2
-2
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+2
-1
slapos/grid/distribution.py
slapos/grid/distribution.py
+10
-0
slapos/grid/networkcache.py
slapos/grid/networkcache.py
+3
-3
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+7
-0
slapos/slap/interface/slap.py
slapos/slap/interface/slap.py
+5
-0
slapos/slap/slap.py
slapos/slap/slap.py
+12
-0
slapos/tests/slapformat.py
slapos/tests/slapformat.py
+12
-12
slapos/version.py
slapos/version.py
+1
-1
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Person_findPartition.xml
View file @
06c32a51
...
@@ -53,6 +53,7 @@
...
@@ -53,6 +53,7 @@
<value>
<string
encoding=
"cdata"
>
<![CDATA[
<value>
<string
encoding=
"cdata"
>
<![CDATA[
import random\n
import random\n
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery\n
person = context\n
person = context\n
\n
\n
computer_partition = None\n
computer_partition = None\n
...
@@ -75,17 +76,17 @@ else:\n
...
@@ -75,17 +76,17 @@ else:\n
explicit_location = False\n
explicit_location = False\n
if "computer_guid" in filter_kw:\n
if "computer_guid" in filter_kw:\n
explicit_location = True\n
explicit_location = True\n
query_kw["parent_reference"] =
filter_kw.pop("computer_guid"
)\n
query_kw["parent_reference"] =
SimpleQuery(parent_reference=filter_kw.pop("computer_guid")
)\n
\n
\n
if "instance_guid" in filter_kw:\n
if "instance_guid" in filter_kw:\n
explicit_location = True\n
explicit_location = True\n
portal = context.getPortalObject()\n
portal = context.getPortalObject()\n
instance_guid = filter_kw.pop("instance_guid")\n
instance_guid = filter_kw.pop("instance_guid")\n
query_kw["aggregate_related_reference"] =
instance_guid
\n
query_kw["aggregate_related_reference"] =
SimpleQuery(aggregate_related_reference=instance_guid)
\n
\n
\n
if \'network_guid\' in filter_kw:\n
if \'network_guid\' in filter_kw:\n
network_guid = filter_kw.pop(\'network_guid\')\n
network_guid = filter_kw.pop(\'network_guid\')\n
query_kw["default_subordination_reference"] =
network_guid
\n
query_kw["default_subordination_reference"] =
SimpleQuery(default_subordination_reference=network_guid)
\n
\n
\n
computer_base_category_list = [\n
computer_base_category_list = [\n
\'group\',\n
\'group\',\n
...
...
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudWorkflow.py
View file @
06c32a51
...
@@ -1914,6 +1914,26 @@ class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin):
...
@@ -1914,6 +1914,26 @@ class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin):
requested_instance2
.
getSlaXml
())
requested_instance2
.
getSlaXml
())
self
.
assertEqual
(
bang_amount
+
1
,
self
.
_countBang
(
requested_instance
))
self
.
assertEqual
(
bang_amount
+
1
,
self
.
_countBang
(
requested_instance
))
def
test_update_connection_bang_requester
(
self
):
request_kw
=
self
.
request_kw
.
copy
()
request_kw
[
'software_title'
]
=
self
.
generateNewSoftwareTitle
()
self
.
software_instance
.
requestInstance
(
**
request_kw
)
requested_instance
=
self
.
software_instance
.
REQUEST
.
get
(
'request_instance'
)
self
.
tic
()
bang_amount
=
self
.
_countBang
(
self
.
software_instance
)
connection_xml
=
self
.
generateSafeXml
()
requested_instance
.
updateConnection
(
connection_xml
=
connection_xml
)
transaction
.
commit
()
self
.
assertEqual
(
bang_amount
+
1
,
self
.
_countBang
(
self
.
software_instance
))
class
TestSlapOSCorePersonRequest
(
testSlapOSMixin
):
class
TestSlapOSCorePersonRequest
(
testSlapOSMixin
):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
...
...
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/instance_slap_interface_workflow/scripts/RequestedInstance_bangResquesterInstance.xml
0 → 100644
View file @
06c32a51
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
instance = state_change[\'object\']\n
portal = instance.getPortalObject()\n
\n
for requester_instance in portal.portal_catalog(\n
portal_type="Software Instance",\n
default_predecessor_uid=instance.getUid()):\n
requester_instance.getObject().bang(\n
bang_tree=False,\n
comment="%s parameters changed" % instance.getRelativeUrl())\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
state_change
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
RequestedInstance_bangResquesterInstance
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/instance_slap_interface_workflow/transitions/update_connection.xml
View file @
06c32a51
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
script_name
</string>
</key>
<key>
<string>
script_name
</string>
</key>
<value>
<string></string>
</value>
<value>
<string>
RequestedInstance_bangResquesterInstance
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
title
</string>
</key>
<key>
<string>
title
</string>
</key>
...
...
master/bt5/slapos_cloud/bt/revision
View file @
06c32a51
296
296
\ No newline at end of file
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Computer_getHateoas.xml
View file @
06c32a51
...
@@ -80,7 +80,7 @@ else:\n
...
@@ -80,7 +80,7 @@ else:\n
"type": "application/vnd.slapos.org.hal+json; class=slapos.org.computer" },\n
"type": "application/vnd.slapos.org.hal+json; class=slapos.org.computer" },\n
\n
\n
"http://slapos.org/reg/software": {\n
"http://slapos.org/reg/software": {\n
"href": "%s/Computer_getHateoasSoftwareList" % context.absolute_url(),\n
"href": "%s/Computer_getHateoasSoftware
Installation
List" % context.absolute_url(),\n
"type": "application/vnd.slapos.org.hal+json; class=slapos.org.collection",\n
"type": "application/vnd.slapos.org.hal+json; class=slapos.org.collection",\n
},\n
},\n
\n
\n
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Computer_getHateoasSoftwareList.xml
→
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Computer_getHateoasSoftware
Installation
List.xml
View file @
06c32a51
...
@@ -80,12 +80,13 @@ else:\n
...
@@ -80,12 +80,13 @@ else:\n
\n
\n
for sql_obj in context.getPortalObject().portal_catalog(\n
for sql_obj in context.getPortalObject().portal_catalog(\n
portal_type=\'Software Installation\',\n
portal_type=\'Software Installation\',\n
aggregate_relative_url=context.getRelativeUrl(),\n
default_aggregate_uid=context.getUid(),\n
validation_state=\'validated\',\n
):\n
):\n
obj = sql_obj.getObject()\n
obj = sql_obj.getObject()\n
result_dict[\'_links\'][\'item\'].append({\n
result_dict[\'_links\'][\'item\'].append({\n
\'href\': \'%s/Software_getHateoas\' % obj.absolute_url(),\n
\'href\': \'%s/Software
Installation
_getHateoas\' % obj.absolute_url(),\n
\'type\': \'application/vnd.slapos.org.hal+json; class=slapos.org.software\',\n
\'type\': \'application/vnd.slapos.org.hal+json; class=slapos.org.software
_installation
\',\n
})\n
})\n
\n
\n
response.setHeader(\'Content-Type\', type)\n
response.setHeader(\'Content-Type\', type)\n
...
@@ -98,7 +99,7 @@ else:\n
...
@@ -98,7 +99,7 @@ else:\n
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
Computer_getHateoasSoftwareList
</string>
</value>
<value>
<string>
Computer_getHateoasSoftware
Installation
List
</string>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Person_getHateoasComputerList.xml
View file @
06c32a51
...
@@ -80,7 +80,7 @@ else:\n
...
@@ -80,7 +80,7 @@ else:\n
\n
\n
for sql_obj in context.getPortalObject().portal_catalog(\n
for sql_obj in context.getPortalObject().portal_catalog(\n
portal_type="Computer",\n
portal_type="Computer",\n
source_administration_uid=context.getUid(),\n
default_
source_administration_uid=context.getUid(),\n
):\n
):\n
obj = sql_obj.getObject()\n
obj = sql_obj.getObject()\n
result_dict[\'_links\'][\'item\'].append({\n
result_dict[\'_links\'][\'item\'].append({\n
...
...
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Software_getHateoas.xml
→
master/bt5/slapos_hypermedia/SkinTemplateItem/portal_skins/slapos_hypermedia/Software
Installation
_getHateoas.xml
View file @
06c32a51
...
@@ -56,7 +56,7 @@ if REQUEST is None:\n
...
@@ -56,7 +56,7 @@ if REQUEST is None:\n
raise Unauthorized\n
raise Unauthorized\n
\n
\n
response = REQUEST.RESPONSE\n
response = REQUEST.RESPONSE\n
type = \'application/vnd.slapos.org.hal+json; class=slapos.org.software\'\n
type = \'application/vnd.slapos.org.hal+json; class=slapos.org.software
_installation
\'\n
\n
\n
if REQUEST.other[\'method\'] != "GET":\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
response.setStatus(405)\n
...
@@ -78,15 +78,17 @@ else:\n
...
@@ -78,15 +78,17 @@ else:\n
\n
\n
import json\n
import json\n
result_dict = {\n
result_dict = {\n
\'_class\': \'slapos.org.software\',\n
\'_class\': \'slapos.org.software
_installation
\',\n
\'title\': context.getTitle(),\n
\'title\': context.getTitle(),\n
\'software_url\': context.getUrlString(),\n
\'status\': state,\n
\'status\': state,\n
\'_links\': {\n
\'_links\': {\n
"self": { "href": context.Base_getRequestUrl(),\n
"self": { "href": context.Base_getRequestUrl(),\n
"type": "application/vnd.slapos.org.hal+json; class=slapos.org.software" },\n
"type": "application/vnd.slapos.org.hal+json; class=slapos.org.software
_installation
" },\n
},\n
},\n
}\n
}\n
url_string = context.getUrlString(None)\n
if url_string is not None:\n
result_dict["_links"]["software_release"] = { "href": url_string }\n
\n
\n
response.setHeader(\'Content-Type\', type)\n
response.setHeader(\'Content-Type\', type)\n
return json.dumps(result_dict)\n
return json.dumps(result_dict)\n
...
@@ -98,7 +100,7 @@ else:\n
...
@@ -98,7 +100,7 @@ else:\n
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
Software_getHateoas
</string>
</value>
<value>
<string>
Software
Installation
_getHateoas
</string>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
...
...
master/bt5/slapos_hypermedia/TestTemplateItem/testSlapOSHypermediaScenario.py
View file @
06c32a51
...
@@ -322,7 +322,7 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
...
@@ -322,7 +322,7 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
# Get user's software
# Get user's software
#####################################################
#####################################################
content_type
=
"application/vnd.slapos.org.hal+json; "
\
content_type
=
"application/vnd.slapos.org.hal+json; "
\
"class=slapos.org.software"
"class=slapos.org.software
_installation
"
software_link_dict
=
software_collection_hal
[
'_links'
]
\
software_link_dict
=
software_collection_hal
[
'_links'
]
\
[
'item'
][
0
]
[
'item'
][
0
]
...
...
master/bt5/slapos_hypermedia/TestTemplateItem/testSlapOSHypermediaSkins.py
View file @
06c32a51
This diff is collapsed.
Click to expand it.
master/bt5/slapos_hypermedia/bt/revision
View file @
06c32a51
3
4
\ No newline at end of file
\ No newline at end of file
slapos.cfg.example
View file @
06c32a51
...
@@ -54,6 +54,7 @@ download-binary-dir-url = http://www.shacache.org/shadir
...
@@ -54,6 +54,7 @@ download-binary-dir-url = http://www.shacache.org/shadir
# Yingjie Xu
# Yingjie Xu
# Gabriel Monnerat
# Gabriel Monnerat
# Lukasz Nowak
# Lukasz Nowak
# Marco Mariani
# Test Agent Signature
# Test Agent Signature
signature-certificate-list =
signature-certificate-list =
-----BEGIN CERTIFICATE-----
-----BEGIN CERTIFICATE-----
...
@@ -148,6 +149,19 @@ signature-certificate-list =
...
@@ -148,6 +149,19 @@ signature-certificate-list =
Vd0Ozh79JSRpkrdI8R/NRQ2XPHAo+29TT70=
Vd0Ozh79JSRpkrdI8R/NRQ2XPHAo+29TT70=
-----END CERTIFICATE-----
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIB9jCCAV+gAwIBAgIJAL9FOtBJZBqAMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
BAMMCENPTVAtOTIyMCAXDTEyMDkyNjE2MDkwM1oYDzIxMTIwOTAyMTYwOTAzWjAT
MREwDwYDVQQDDAhDT01QLTkyMjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
wlGVd6qOsc2xrtAQ5/rpflzS14/84SE/joaujMw2GGk6EFVSOcqKLq1TnHxkcCkv
nv1NYRPK/hpQOIKcGC1f+DvXXpMJI29R/rt2b2/y1oolxXonSVigBtCQlSyDoOFN
6LBX84CI5aYMvy3mqJCvfGEFBaPqze/PVugq9IpgZg0CAwEAAaNQME4wHQYDVR0O
BBYEFJ7HWyzVKkeSYnSK4FIwcdyng/tRMB8GA1UdIwQYMBaAFJ7HWyzVKkeSYnSK
4FIwcdyng/tRMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAZQWob2ki
ie6h90FgSctozXrotb8NIis2MtLIj+WonE0wSqYefxwBmAGjB9cfWz/sNamhM4rn
BP1A2ojVhF6hOE1qvTP5YxcGXOoYTrEQSuDF1hn12WlA4vqIAz1f+4CiMJNlXPwh
7N+X2kvRpHdXAHkBOxX3j34AeCZrSpu/yDQ=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIB9jCCAV+gAwIBAgIJAKRvzcy7OH0UMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
MIIB9jCCAV+gAwIBAgIJAKRvzcy7OH0UMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
BAMMCENPTVAtNzcyMCAXDTEyMDgxMDE1NDI1MVoYDzIxMTIwNzE3MTU0MjUxWjAT
BAMMCENPTVAtNzcyMCAXDTEyMDgxMDE1NDI1MVoYDzIxMTIwNzE3MTU0MjUxWjAT
MREwDwYDVQQDDAhDT01QLTc3MjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
MREwDwYDVQQDDAhDT01QLTc3MjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
...
...
slapos/cli/cache.py
View file @
06c32a51
...
@@ -10,7 +10,7 @@ import sys
...
@@ -10,7 +10,7 @@ import sys
import
prettytable
import
prettytable
from
slapos.grid
import
networkcache
from
slapos.grid
import
networkcache
from
slapos.grid.distribution
import
patched_linux_distribution
from
slapos.grid.distribution
import
distribution_tuple
from
slapos.cli.config
import
ConfigCommand
from
slapos.cli.config
import
ConfigCommand
...
@@ -76,7 +76,7 @@ def do_lookup(logger, cache_dir, software_url):
...
@@ -76,7 +76,7 @@ def do_lookup(logger, cache_dir, software_url):
pt
=
prettytable
.
PrettyTable
([
'distribution'
,
'version'
,
'id'
,
'compatible?'
])
pt
=
prettytable
.
PrettyTable
([
'distribution'
,
'version'
,
'id'
,
'compatible?'
])
linux_distribution
=
patched_linux_distribution
()
linux_distribution
=
distribution_tuple
()
for
os
in
ostable
:
for
os
in
ostable
:
compatible
=
'yes'
if
networkcache
.
os_matches
(
os
,
linux_distribution
)
else
'no'
compatible
=
'yes'
if
networkcache
.
os_matches
(
os
,
linux_distribution
)
else
'no'
...
...
slapos/cli/command.py
View file @
06c32a51
...
@@ -23,7 +23,7 @@ class Command(cliff.command.Command):
...
@@ -23,7 +23,7 @@ class Command(cliff.command.Command):
def
must_be_root
(
func
):
def
must_be_root
(
func
):
@
functools
.
wraps
(
func
)
@
functools
.
wraps
(
func
)
def
inner
(
self
,
*
args
,
**
kw
):
def
inner
(
self
,
*
args
,
**
kw
):
if
os
.
getuid
()
!=
0
:
if
sys
.
platform
!=
'cygwin'
and
os
.
getuid
()
!=
0
:
self
.
app
.
log
.
error
(
'This slapos command must be run as root.'
)
self
.
app
.
log
.
error
(
'This slapos command must be run as root.'
)
sys
.
exit
(
5
)
sys
.
exit
(
5
)
return
func
(
self
,
*
args
,
**
kw
)
return
func
(
self
,
*
args
,
**
kw
)
...
...
slapos/cli/entry.py
View file @
06c32a51
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
argparse
import
argparse
import
codecs
import
collections
import
collections
import
locale
import
logging
import
logging
import
sys
import
sys
...
@@ -114,6 +116,30 @@ class SlapOSApp(cliff.app.App):
...
@@ -114,6 +116,30 @@ class SlapOSApp(cliff.app.App):
command_manager
=
SlapOSCommandManager
(
'slapos.cli'
),
command_manager
=
SlapOSCommandManager
(
'slapos.cli'
),
)
)
def
_set_streams
(
self
,
stdin
,
stdout
,
stderr
):
try
:
# SlapOS: might fail in some systems
locale
.
setlocale
(
locale
.
LC_ALL
,
''
)
except
locale
.
Error
:
pass
if
sys
.
version_info
[:
2
]
==
(
2
,
6
):
# Configure the input and output streams. If a stream is
# provided, it must be configured correctly by the
# caller. If not, make sure the versions of the standard
# streams used by default are wrapped with encodings. This
# works around a problem with Python 2.6 fixed in 2.7 and
# later (http://hg.python.org/cpython/rev/e60ef17561dc/).
lang
,
encoding
=
locale
.
getdefaultlocale
()
encoding
=
getattr
(
sys
.
stdout
,
'encoding'
,
None
)
or
encoding
self
.
stdin
=
stdin
or
codecs
.
getreader
(
encoding
)(
sys
.
stdin
)
self
.
stdout
=
stdout
or
codecs
.
getwriter
(
encoding
)(
sys
.
stdout
)
self
.
stderr
=
stderr
or
codecs
.
getwriter
(
encoding
)(
sys
.
stderr
)
else
:
self
.
stdin
=
stdin
or
sys
.
stdin
self
.
stdout
=
stdout
or
sys
.
stdout
self
.
stderr
=
stderr
or
sys
.
stderr
def
build_option_parser
(
self
,
*
args
,
**
kw
):
def
build_option_parser
(
self
,
*
args
,
**
kw
):
kw
.
setdefault
(
'argparse_kwargs'
,
{})
kw
.
setdefault
(
'argparse_kwargs'
,
{})
kw
[
'argparse_kwargs'
][
'conflict_handler'
]
=
'resolve'
kw
[
'argparse_kwargs'
][
'conflict_handler'
]
=
'resolve'
...
...
slapos/cli/format.py
View file @
06c32a51
...
@@ -57,6 +57,8 @@ class FormatCommand(ConfigCommand):
...
@@ -57,6 +57,8 @@ class FormatCommand(ConfigCommand):
help
=
"Don't actually do anything"
help
=
"Don't actually do anything"
" (default: %(default)s)"
)
" (default: %(default)s)"
)
ap
.
add_argument
(
'-c'
,
'--console'
,
help
=
"Console output (obsolete)"
)
return
ap
return
ap
@
must_be_root
@
must_be_root
...
...
slapos/format.py
View file @
06c32a51
...
@@ -844,7 +844,7 @@ class Interface(object):
...
@@ -844,7 +844,7 @@ class Interface(object):
def
addIPv4LocalAddress
(
self
,
addr
=
None
):
def
addIPv4LocalAddress
(
self
,
addr
=
None
):
"""Adds local IPv4 address in ipv4_local_network"""
"""Adds local IPv4 address in ipv4_local_network"""
netmask
=
'255.255.255.254'
if
sys
.
platform
==
'cygwin'
\
netmask
=
str
(
netaddr
.
IPNetwork
(
self
.
ipv4_local_network
).
netmask
)
if
sys
.
platform
==
'cygwin'
\
else
'255.255.255.255'
else
'255.255.255.255'
local_address_list
=
self
.
getIPv4LocalAddressList
()
local_address_list
=
self
.
getIPv4LocalAddressList
()
if
addr
is
None
:
if
addr
is
None
:
...
@@ -1211,7 +1211,7 @@ class FormatConfig(object):
...
@@ -1211,7 +1211,7 @@ class FormatConfig(object):
# check root
# check root
# XXX in the new CLI, this is checked by the @must_be_root decorator.
# XXX in the new CLI, this is checked by the @must_be_root decorator.
if
root_needed
and
os
.
getuid
()
!=
0
:
if
sys
.
platform
!=
'cygwin'
and
root_needed
and
os
.
getuid
()
!=
0
:
message
=
"Root rights are needed"
message
=
"Root rights are needed"
self
.
logger
.
error
(
message
)
self
.
logger
.
error
(
message
)
sys
.
stderr
.
write
(
message
+
'
\
n
'
)
sys
.
stderr
.
write
(
message
+
'
\
n
'
)
...
...
slapos/grid/SlapObject.py
View file @
06c32a51
...
@@ -220,7 +220,8 @@ class Software(object):
...
@@ -220,7 +220,8 @@ class Software(object):
# but you can change it for development purposes.
# but you can change it for development purposes.
[buildout]
[buildout]
extends = {url}
extends =
{url}
"""
.
format
(
url
=
url
)))
"""
.
format
(
url
=
url
)))
self
.
_set_ownership
(
buildout_cfg
)
self
.
_set_ownership
(
buildout_cfg
)
...
...
slapos/grid/distribution.py
View file @
06c32a51
...
@@ -13,6 +13,9 @@ patched_linux_distribution(...):
...
@@ -13,6 +13,9 @@ patched_linux_distribution(...):
see http://bugs.python.org/issue9514
see http://bugs.python.org/issue9514
otherwise, Ubuntu will always be reported as an unstable Debian, regardless of the version.
otherwise, Ubuntu will always be reported as an unstable Debian, regardless of the version.
distribution_tuple()
returns a (distname, version, id) tuple under linux or cygwin
"""
"""
import
platform
import
platform
...
@@ -62,3 +65,10 @@ def patched_linux_distribution(distname='', version='', id='',
...
@@ -62,3 +65,10 @@ def patched_linux_distribution(distname='', version='', id='',
pass
pass
return
platform
.
linux_distribution
(
distname
,
version
,
id
,
supported_dists
,
full_distribution_name
)
return
platform
.
linux_distribution
(
distname
,
version
,
id
,
supported_dists
,
full_distribution_name
)
def
distribution_tuple
():
if
platform
.
system
().
startswith
(
'CYGWIN_'
):
return
(
platform
.
system
(),
platform
.
platform
(),
''
)
else
:
return
patched_linux_distribution
()
slapos/grid/networkcache.py
View file @
06c32a51
...
@@ -18,7 +18,7 @@ import platform
...
@@ -18,7 +18,7 @@ import platform
import
shutil
import
shutil
import
traceback
import
traceback
from
slapos.grid.distribution
import
os_matches
,
patched_linux_distribution
from
slapos.grid.distribution
import
os_matches
,
distribution_tuple
try
:
try
:
try
:
try
:
...
@@ -88,7 +88,7 @@ def download_network_cached(cache_url, dir_url, software_url, software_root,
...
@@ -88,7 +88,7 @@ def download_network_cached(cache_url, dir_url, software_url, software_root,
if
tags
.
get
(
'machine'
)
!=
platform
.
machine
():
if
tags
.
get
(
'machine'
)
!=
platform
.
machine
():
continue
continue
if
not
os_matches
(
ast
.
literal_eval
(
tags
.
get
(
'os'
)),
if
not
os_matches
(
ast
.
literal_eval
(
tags
.
get
(
'os'
)),
patched_linux_distribution
()):
distribution_tuple
()):
continue
continue
if
tags
.
get
(
'software_url'
)
!=
software_url
:
if
tags
.
get
(
'software_url'
)
!=
software_url
:
continue
continue
...
@@ -134,7 +134,7 @@ def upload_network_cached(software_root, software_url, cached_key,
...
@@ -134,7 +134,7 @@ def upload_network_cached(software_root, software_url, cached_key,
software_url
=
software_url
,
software_url
=
software_url
,
software_root
=
software_root
,
software_root
=
software_root
,
machine
=
platform
.
machine
(),
machine
=
platform
.
machine
(),
os
=
str
(
patched_linux_distribution
())
os
=
str
(
distribution_tuple
())
)
)
f
=
open
(
path
,
'r'
)
f
=
open
(
path
,
'r'
)
...
...
slapos/grid/slapgrid.py
View file @
06c32a51
...
@@ -627,6 +627,11 @@ class Slapgrid(object):
...
@@ -627,6 +627,11 @@ class Slapgrid(object):
logger
=
self
.
logger
)
logger
=
self
.
logger
)
computer_partition_state
=
computer_partition
.
getState
()
computer_partition_state
=
computer_partition
.
getState
()
# XXX this line breaks 37 tests
# self.logger.info(' Instance type: %s' % computer_partition.getType())
self
.
logger
.
info
(
' Instance status: %s'
%
computer_partition_state
)
if
computer_partition_state
==
COMPUTER_PARTITION_STARTED_STATE
:
if
computer_partition_state
==
COMPUTER_PARTITION_STARTED_STATE
:
local_partition
.
install
()
local_partition
.
install
()
computer_partition
.
available
()
computer_partition
.
available
()
...
@@ -635,6 +640,8 @@ class Slapgrid(object):
...
@@ -635,6 +640,8 @@ class Slapgrid(object):
computer_partition
.
started
()
computer_partition
.
started
()
elif
computer_partition_state
==
COMPUTER_PARTITION_STOPPED_STATE
:
elif
computer_partition_state
==
COMPUTER_PARTITION_STOPPED_STATE
:
try
:
try
:
# We want to process the partition, even if stopped, because it should
# propagate the state to children if any.
local_partition
.
install
()
local_partition
.
install
()
computer_partition
.
available
()
computer_partition
.
available
()
finally
:
finally
:
...
...
slapos/slap/interface/slap.py
View file @
06c32a51
...
@@ -222,6 +222,11 @@ class IComputerPartition(IBuildoutController, IRequester):
...
@@ -222,6 +222,11 @@ class IComputerPartition(IBuildoutController, IRequester):
The contained values are connection parameters of a compute partition.
The contained values are connection parameters of a compute partition.
"""
"""
def
getType
():
"""
Returns the Software Type of the instance.
"""
def
setUsage
(
usage_log
):
def
setUsage
(
usage_log
):
"""
"""
Associate a usage log to the computer partition.
Associate a usage log to the computer partition.
...
...
slapos/slap/slap.py
View file @
06c32a51
...
@@ -482,6 +482,18 @@ class ComputerPartition(SlapRequester):
...
@@ -482,6 +482,18 @@ class ComputerPartition(SlapRequester):
raise
ResourceNotReady
()
raise
ResourceNotReady
()
return
self
.
_requested_state
return
self
.
_requested_state
def
getType
(
self
):
"""
return the Software Type of the instance.
Raise RessourceNotReady if not present.
"""
# XXX: software type should not belong to the parameter dict.
software_type
=
self
.
getInstanceParameterDict
().
get
(
'slap_software_type'
,
None
)
if
not
software_type
:
raise
ResourceNotReady
()
return
software_type
def
getInstanceParameterDict
(
self
):
def
getInstanceParameterDict
(
self
):
return
getattr
(
self
,
'_parameter_dict'
,
None
)
or
{}
return
getattr
(
self
,
'_parameter_dict'
,
None
)
or
{}
...
...
slapos/tests/slapformat.py
View file @
06c32a51
...
@@ -270,7 +270,7 @@ class TestComputer(SlapformatMixin):
...
@@ -270,7 +270,7 @@ class TestComputer(SlapformatMixin):
self
.
assertEqual
([
self
.
assertEqual
([
'ip addr list bridge'
,
'ip addr list bridge'
,
'groupadd slapsoft'
,
'groupadd slapsoft'
,
'useradd -d /software_root -g slapsoft
-s /bin/false
slapsoft -r'
'useradd -d /software_root -g slapsoft slapsoft -r'
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -308,7 +308,7 @@ class TestComputer(SlapformatMixin):
...
@@ -308,7 +308,7 @@ class TestComputer(SlapformatMixin):
self
.
assertEqual
([
self
.
assertEqual
([
'ip addr list bridge'
,
'ip addr list bridge'
,
'groupadd slapsoft'
,
'groupadd slapsoft'
,
'useradd -d /software_root -g slapsoft
-s /bin/false
slapsoft -r'
'useradd -d /software_root -g slapsoft slapsoft -r'
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -363,9 +363,9 @@ class TestComputer(SlapformatMixin):
...
@@ -363,9 +363,9 @@ class TestComputer(SlapformatMixin):
self
.
assertEqual
([
self
.
assertEqual
([
'ip addr list bridge'
,
'ip addr list bridge'
,
'groupadd slapsoft'
,
'groupadd slapsoft'
,
'useradd -d /software_root -g slapsoft
-s /bin/false
slapsoft -r'
,
'useradd -d /software_root -g slapsoft slapsoft -r'
,
'groupadd testuser'
,
'groupadd testuser'
,
'useradd -d /instance_root/partition -g testuser -
s /bin/false -
G slapsoft testuser -r'
,
'useradd -d /instance_root/partition -g testuser -G slapsoft testuser -r'
,
'tunctl -t tap -u testuser'
,
'tunctl -t tap -u testuser'
,
'ip link set tap up'
,
'ip link set tap up'
,
'brctl show'
,
'brctl show'
,
...
@@ -452,9 +452,9 @@ class TestComputer(SlapformatMixin):
...
@@ -452,9 +452,9 @@ class TestComputer(SlapformatMixin):
self
.
assertEqual
([
self
.
assertEqual
([
# 'ip addr list bridge',
# 'ip addr list bridge',
'groupadd slapsoft'
,
'groupadd slapsoft'
,
'useradd -d /software_root -g slapsoft
-s /bin/false
slapsoft -r'
,
'useradd -d /software_root -g slapsoft slapsoft -r'
,
'groupadd testuser'
,
'groupadd testuser'
,
'useradd -d /instance_root/partition -g testuser -
s /bin/false -
G slapsoft testuser -r'
,
'useradd -d /instance_root/partition -g testuser -G slapsoft testuser -r'
,
# 'ip addr add ip/255.255.255.255 dev bridge',
# 'ip addr add ip/255.255.255.255 dev bridge',
# 'ip addr list bridge',
# 'ip addr list bridge',
# 'ip addr add ip/ffff:ffff:ffff:ffff:: dev bridge',
# 'ip addr add ip/ffff:ffff:ffff:ffff:: dev bridge',
...
@@ -533,7 +533,7 @@ class TestUser(SlapformatMixin):
...
@@ -533,7 +533,7 @@ class TestUser(SlapformatMixin):
self
.
assertEqual
([
self
.
assertEqual
([
'groupadd doesnotexistsyet'
,
'groupadd doesnotexistsyet'
,
'useradd -d /doesnotexistsyet -g doesnotexistsyet
-s /bin/false
'
\
'useradd -d /doesnotexistsyet -g doesnotexistsyet '
\
'doesnotexistsyet -r'
'doesnotexistsyet -r'
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -546,7 +546,7 @@ class TestUser(SlapformatMixin):
...
@@ -546,7 +546,7 @@ class TestUser(SlapformatMixin):
self
.
assertEqual
([
self
.
assertEqual
([
'groupadd doesnotexistsyet'
,
'groupadd doesnotexistsyet'
,
'useradd -d /doesnotexistsyet -g doesnotexistsyet -
s /bin/false -
G '
\
'useradd -d /doesnotexistsyet -g doesnotexistsyet -G '
\
'additionalgroup1,additionalgroup2 doesnotexistsyet -r'
'additionalgroup1,additionalgroup2 doesnotexistsyet -r'
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -559,7 +559,7 @@ class TestUser(SlapformatMixin):
...
@@ -559,7 +559,7 @@ class TestUser(SlapformatMixin):
user
.
create
()
user
.
create
()
self
.
assertEqual
([
self
.
assertEqual
([
'useradd -d /testuser -g testuser
-s /bin/false
testuser -r'
'useradd -d /testuser -g testuser testuser -r'
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -573,7 +573,7 @@ class TestUser(SlapformatMixin):
...
@@ -573,7 +573,7 @@ class TestUser(SlapformatMixin):
self
.
assertEqual
([
self
.
assertEqual
([
'groupadd testuser'
,
'groupadd testuser'
,
'usermod -d /testuser -g testuser -
s /bin/false -
G '
\
'usermod -d /testuser -g testuser -G '
\
'additionalgroup1,additionalgroup2 testuser'
'additionalgroup1,additionalgroup2 testuser'
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -587,7 +587,7 @@ class TestUser(SlapformatMixin):
...
@@ -587,7 +587,7 @@ class TestUser(SlapformatMixin):
self
.
assertEqual
([
self
.
assertEqual
([
'groupadd testuser'
,
'groupadd testuser'
,
'usermod -d /testuser -g testuser
-s /bin/false
testuser'
'usermod -d /testuser -g testuser testuser'
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
@@ -601,7 +601,7 @@ class TestUser(SlapformatMixin):
...
@@ -601,7 +601,7 @@ class TestUser(SlapformatMixin):
user
.
create
()
user
.
create
()
self
.
assertEqual
([
self
.
assertEqual
([
'usermod -d /testuser -g testuser
-s /bin/false
testuser'
'usermod -d /testuser -g testuser testuser'
],
],
self
.
fakeCallAndRead
.
external_command_list
)
self
.
fakeCallAndRead
.
external_command_list
)
...
...
slapos/version.py
View file @
06c32a51
version
=
'1.0.0rc
4
'
version
=
'1.0.0rc
5
'
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