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
Hardik Juneja
slapos.core
Commits
1350e574
Commit
1350e574
authored
Sep 05, 2014
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Computer request software instance workflow
parent
42e72e67
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
400 additions
and
12 deletions
+400
-12
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudWorkflow.py
.../slapos_cloud/TestTemplateItem/testSlapOSCloudWorkflow.py
+225
-11
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/computer_slap_interface_workflow/scripts/Computer_requestSoftwareInstanceChange.xml
...rkflow/scripts/Computer_requestSoftwareInstanceChange.xml
+111
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/computer_slap_interface_workflow/states/draft.xml
...orkflow/computer_slap_interface_workflow/states/draft.xml
+1
-0
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/computer_slap_interface_workflow/transitions/request_software_instance.xml
...erface_workflow/transitions/request_software_instance.xml
+62
-0
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudWorkflow.py
View file @
1350e574
...
...
@@ -333,6 +333,220 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
self
.
computer
.
requestSoftwareRelease
,
software_release_url
=
url
,
state
=
'available'
)
transaction
.
abort
()
def
test_Computer_requestSoftwareInstance_returnHostingSubscription
(
self
):
self
.
_makePerson
()
self
.
computer
.
edit
(
source_administration
=
self
.
person_user
.
getRelativeUrl
())
self
.
tic
()
self
.
login
(
self
.
person_user
.
getReference
())
software_release
=
self
.
generateNewSoftwareReleaseUrl
()
software_title
=
"Test Software Instance from Computer"
software_type
=
"test"
instance_xml
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
shared
=
True
state
=
"started"
computer
=
self
.
computer
expected_sla_xml
=
"""<?xml version='1.0' encoding='utf-8'?><instance>
<parameter id="computer_guid">%s</parameter>
</instance>
"""
%
computer
.
getReference
()
computer
.
requestSoftwareInstance
(
software_release
=
software_release
,
software_title
=
software_title
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
shared
=
shared
,
state
=
state
,
)
hosting_subscription
=
computer
.
REQUEST
.
get
(
'request_hosting_subscription'
)
self
.
assertEquals
(
"Hosting Subscription"
,
hosting_subscription
.
getPortalType
())
self
.
assertEquals
(
computer
.
getRelativeUrl
(),
hosting_subscription
.
getAggregateValue
().
getRelativeUrl
())
self
.
assertEquals
(
hosting_subscription
.
getSlaXml
(),
expected_sla_xml
)
self
.
assertEquals
(
hosting_subscription
.
getPredecessorValue
().
getSlaXml
(),
expected_sla_xml
)
def
test_Computer_requestSoftwareInstance_requiredParameter
(
self
):
self
.
_makePerson
()
self
.
computer
.
edit
(
source_administration
=
self
.
person_user
.
getRelativeUrl
())
self
.
tic
()
self
.
login
(
self
.
person_user
.
getReference
())
software_release
=
self
.
generateNewSoftwareReleaseUrl
()
software_title
=
"Test Software Instance from Computer"
software_type
=
"test"
instance_xml
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
shared
=
True
state
=
"started"
computer
=
self
.
computer
self
.
assertRaises
(
TypeError
,
computer
.
requestSoftwareInstance
)
# software_release is mandatory
self
.
assertRaises
(
TypeError
,
computer
.
requestSoftwareInstance
,
software_title
=
software_title
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
shared
=
shared
,
state
=
state
,
)
# software_title is mandatory
self
.
assertRaises
(
TypeError
,
computer
.
requestSoftwareInstance
,
software_release
=
software_release
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
shared
=
shared
,
state
=
state
,
)
# software_type is mandatory
self
.
assertRaises
(
TypeError
,
computer
.
requestSoftwareInstance
,
software_release
=
software_release
,
software_title
=
software_title
,
instance_xml
=
instance_xml
,
shared
=
shared
,
state
=
state
,
)
# instance_xml is mandatory
self
.
assertRaises
(
TypeError
,
computer
.
requestSoftwareInstance
,
software_release
=
software_release
,
software_title
=
software_title
,
software_type
=
software_type
,
shared
=
shared
,
state
=
state
,
)
# shared is mandatory
self
.
assertRaises
(
TypeError
,
computer
.
requestSoftwareInstance
,
software_release
=
software_release
,
software_title
=
software_title
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
state
=
state
,
)
# state is mandatory
self
.
assertRaises
(
TypeError
,
computer
.
requestSoftwareInstance
,
software_release
=
software_release
,
software_title
=
software_title
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
shared
=
shared
,
)
def
test_Computer_requestSoftwareInstance_acceptedState
(
self
):
self
.
_makePerson
()
self
.
computer
.
edit
(
source_administration
=
self
.
person_user
.
getRelativeUrl
())
self
.
tic
()
self
.
login
(
self
.
person_user
.
getReference
())
software_release
=
self
.
generateNewSoftwareReleaseUrl
()
software_title
=
"Test Software Instance from Computer"
software_type
=
"test"
instance_xml
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
shared
=
True
state
=
"started"
computer
=
self
.
computer
# Only started, stopped, destroyed
self
.
assertRaises
(
ValueError
,
computer
.
requestSoftwareInstance
,
software_release
=
software_release
,
software_title
=
software_title
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
shared
=
shared
,
state
=
"foo"
,
)
computer
.
requestSoftwareInstance
(
software_release
=
software_release
,
software_title
=
"Computer started Software Instance"
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
shared
=
shared
,
state
=
"started"
,
)
hosting_subscription
=
computer
.
REQUEST
.
get
(
'request_hosting_subscription'
)
self
.
assertEquals
(
"start_requested"
,
hosting_subscription
.
getSlapState
())
computer
.
requestSoftwareInstance
(
software_release
=
software_release
,
software_title
=
"Computer stopped Software Instance"
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
shared
=
shared
,
state
=
"stopped"
,
)
hosting_subscription
=
computer
.
REQUEST
.
get
(
'request_hosting_subscription'
)
self
.
assertEquals
(
"stop_requested"
,
hosting_subscription
.
getSlapState
())
computer
.
requestSoftwareInstance
(
software_release
=
software_release
,
software_title
=
"Computer destroyed Software Instance"
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
shared
=
shared
,
state
=
"destroyed"
,
)
hosting_subscription
=
computer
.
REQUEST
.
get
(
'request_hosting_subscription'
)
self
.
assertEquals
(
None
,
hosting_subscription
)
def
test_Computer_requestSoftwareInstance_duplicatedHostingSubscription
(
self
):
self
.
_makePerson
()
self
.
computer
.
edit
(
source_administration
=
self
.
person_user
.
getRelativeUrl
())
self
.
tic
()
self
.
login
(
self
.
person_user
.
getReference
())
software_release
=
self
.
generateNewSoftwareReleaseUrl
()
software_title
=
"Test Software Instance from Computer"
software_type
=
"test"
instance_xml
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
shared
=
True
state
=
"started"
computer
=
self
.
computer
computer
.
requestSoftwareInstance
(
software_release
=
software_release
,
software_title
=
software_title
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
shared
=
shared
,
state
=
state
,
)
hosting_subscription
=
computer
.
REQUEST
.
get
(
'request_hosting_subscription'
)
transaction
.
commit
()
hosting_subscription2
=
hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
hosting_subscription2
.
validate
()
transaction
.
commit
()
self
.
tic
()
self
.
assertRaises
(
NotImplementedError
,
computer
.
requestSoftwareInstance
,
software_release
=
software_release
,
software_title
=
software_title
,
software_type
=
software_type
,
instance_xml
=
instance_xml
,
shared
=
shared
,
state
=
state
,
)
def
test_revokeCertificate
(
self
):
self
.
login
(
self
.
computer
.
getReference
())
...
...
@@ -501,7 +715,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def
test_supply_available_createdSoftwareInstallation
(
self
):
previous_id
=
self
.
getPortalObject
().
portal_ids
\
.
generateNewId
(
id_group
=
'slap_software_installation_reference'
,
.
generateNewId
(
id_group
=
'slap_software_installation_reference'
,
id_generator
=
'uid'
)
software_release
=
self
.
generateNewSoftwareReleaseUrl
()
...
...
@@ -525,7 +739,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def
test_multiple_supply_available_createdSoftwareInstallation
(
self
):
previous_id
=
self
.
getPortalObject
().
portal_ids
\
.
generateNewId
(
id_group
=
'slap_software_installation_reference'
,
.
generateNewId
(
id_group
=
'slap_software_installation_reference'
,
id_generator
=
'uid'
)
software_release
=
self
.
generateNewSoftwareReleaseUrl
()
...
...
@@ -557,7 +771,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def
test_supply_available_destroyed
(
self
):
previous_id
=
self
.
getPortalObject
().
portal_ids
\
.
generateNewId
(
id_group
=
'slap_software_installation_reference'
,
.
generateNewId
(
id_group
=
'slap_software_installation_reference'
,
id_generator
=
'uid'
)
software_release
=
self
.
generateNewSoftwareReleaseUrl
()
...
...
@@ -598,7 +812,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def
test_supply_available_destroyed_available
(
self
):
previous_id
=
self
.
getPortalObject
().
portal_ids
\
.
generateNewId
(
id_group
=
'slap_software_installation_reference'
,
.
generateNewId
(
id_group
=
'slap_software_installation_reference'
,
id_generator
=
'uid'
)
software_release
=
self
.
generateNewSoftwareReleaseUrl
()
...
...
@@ -645,7 +859,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def
test_supply_available_destroyed_finalised_available
(
self
):
previous_id
=
self
.
getPortalObject
().
portal_ids
\
.
generateNewId
(
id_group
=
'slap_software_installation_reference'
,
.
generateNewId
(
id_group
=
'slap_software_installation_reference'
,
id_generator
=
'uid'
)
software_release
=
self
.
generateNewSoftwareReleaseUrl
()
...
...
@@ -2145,7 +2359,7 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin):
state
=
state
,
)
hosting_subscription
=
person
.
REQUEST
.
get
(
'request_hosting_subscription'
)
self
.
assertEquals
(
"Hosting Subscription"
,
self
.
assertEquals
(
"Hosting Subscription"
,
hosting_subscription
.
getPortalType
())
def
test_Person_requestSoftwareInstance_createHostingSubscription
(
self
):
...
...
@@ -2163,7 +2377,7 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin):
state
=
"started"
previous_id
=
self
.
getPortalObject
().
portal_ids
\
.
generateNewId
(
id_group
=
'slap_hosting_subscription_reference'
,
.
generateNewId
(
id_group
=
'slap_hosting_subscription_reference'
,
id_generator
=
'uid'
)
person
.
requestSoftwareInstance
(
...
...
@@ -2753,7 +2967,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
def
verify_activeSense_call
(
self
):
if
self
.
getRelativeUrl
()
==
'portal_alarms/slapos_allocate_instance'
:
instance
.
portal_workflow
.
doActionFor
(
instance
,
action
=
'edit_action'
,
instance
.
portal_workflow
.
doActionFor
(
instance
,
action
=
'edit_action'
,
comment
=
'activeSense triggered'
)
else
:
return
self
.
activeSense_call
()
...
...
@@ -2819,7 +3033,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
def
verify_reindexObject_call
(
self
,
*
args
,
**
kw
):
if
self
.
getRelativeUrl
()
==
computer
.
getRelativeUrl
():
computer
.
portal_workflow
.
doActionFor
(
computer
,
action
=
'edit_action'
,
computer
.
portal_workflow
.
doActionFor
(
computer
,
action
=
'edit_action'
,
comment
=
'reindexObject triggered on %s'
%
method_id
)
else
:
return
self
.
reindexObject_call
(
*
args
,
**
kw
)
...
...
@@ -2880,7 +3094,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
def
verify_reindexObject_call
(
self
,
*
args
,
**
kw
):
if
self
.
getRelativeUrl
()
==
partition
.
getRelativeUrl
():
partition
.
portal_workflow
.
doActionFor
(
partition
,
action
=
'edit_action'
,
partition
.
portal_workflow
.
doActionFor
(
partition
,
action
=
'edit_action'
,
comment
=
'reindexObject triggered on %s'
%
method_id
)
else
:
return
self
.
reindexObject_call
(
*
args
,
**
kw
)
...
...
@@ -3005,7 +3219,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
def
verify_reindexObject_call
(
self
,
*
args
,
**
kw
):
if
self
.
getRelativeUrl
()
in
(
instance2
.
getRelativeUrl
(),
instance3
.
getRelativeUrl
()):
self
.
portal_workflow
.
doActionFor
(
instance1
,
action
=
'edit_action'
,
self
.
portal_workflow
.
doActionFor
(
instance1
,
action
=
'edit_action'
,
comment
=
'reindexObject triggered'
)
else
:
return
self
.
reindexObject_call
(
*
args
,
**
kw
)
...
...
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/computer_slap_interface_workflow/scripts/Computer_requestSoftwareInstanceChange.xml
0 → 100644
View file @
1350e574
<?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
encoding=
"cdata"
>
<![CDATA[
computer = state_change[\'object\']\n
person = computer.getSourceAdministrationValue()\n
\n
# Get required arguments\n
kwargs = state_change.kwargs\n
\n
# Required args\n
# Raise TypeError if all parameters are not provided\n
try:\n
software_release_url_string = kwargs[\'software_release\']\n
software_title = kwargs["software_title"]\n
software_type = kwargs["software_type"]\n
instance_xml = kwargs["instance_xml"]\n
is_slave = kwargs["shared"]\n
root_state = kwargs["state"]\n
except KeyError:\n
raise TypeError, "Computer_requestSoftwareInstance takes exactly 6 arguments"\n
\n
if person is None:\n
return\n
\n
sla_xml = """<?xml version=\'1.0\' encoding=\'utf-8\'?>
<instance>
\n
<parameter
id=
"computer_guid"
>
%s
</parameter>
\n
</instance>
\n
""" % computer.getReference()\n
\n
person.requestSoftwareInstance(\n
state=root_state,\n
software_release=software_release_url_string,\n
software_title=software_title,\n
software_type=software_type,\n
instance_xml=instance_xml,\n
sla_xml=sla_xml,\n
shared=is_slave\n
)\n
\n
hosting_subscription = context.REQUEST.get(\'request_hosting_subscription\', None)\n
if hosting_subscription is None:\n
return\n
\n
hosting_subscription.setAggregateValue(computer)\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>
Computer_requestSoftwareInstanceChange
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/computer_slap_interface_workflow/states/draft.xml
View file @
1350e574
...
...
@@ -26,6 +26,7 @@
<string>
generate_certificate
</string>
<string>
report_computer_bang
</string>
<string>
request_computer_registration
</string>
<string>
request_software_instance
</string>
<string>
request_software_release
</string>
<string>
revoke_certificate
</string>
</tuple>
...
...
master/bt5/slapos_cloud/WorkflowTemplateItem/portal_workflow/computer_slap_interface_workflow/transitions/request_software_instance.xml
0 → 100644
View file @
1350e574
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"TransitionDefinition"
module=
"Products.DCWorkflow.Transitions"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
actbox_category
</string>
</key>
<value>
<string>
workflow
</string>
</value>
</item>
<item>
<key>
<string>
actbox_icon
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
actbox_name
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
actbox_url
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
after_script_name
</string>
</key>
<value>
<string>
Computer_requestSoftwareInstanceChange
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
guard
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
request_software_instance
</string>
</value>
</item>
<item>
<key>
<string>
new_state_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
script_name
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
trigger_type
</string>
</key>
<value>
<int>
2
</int>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/bt/revision
View file @
1350e574
323
\ No newline at end of file
324
\ No newline at end of file
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