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
Ivan Tyagov
slapos.core
Commits
676f082a
Commit
676f082a
authored
Jun 13, 2012
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not create destroyed software instance.
parent
605ee2ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
55 deletions
+65
-55
master/bt5/vifib_slapos_core/WorkflowTemplateItem/portal_workflow/instance_slap_interface_workflow/scripts/RequesterInstance_request.xml
..._interface_workflow/scripts/RequesterInstance_request.xml
+64
-54
master/bt5/vifib_slapos_core/bt/revision
master/bt5/vifib_slapos_core/bt/revision
+1
-1
No files found.
master/bt5/vifib_slapos_core/WorkflowTemplateItem/portal_workflow/instance_slap_interface_workflow/scripts/RequesterInstance_request.xml
View file @
676f082a
...
@@ -122,33 +122,38 @@ else:\n
...
@@ -122,33 +122,38 @@ else:\n
raise ValueError, "Too many instances \'%s\' found: %s" % (software_title, [x.path for x in request_software_instance_list])\n
raise ValueError, "Too many instances \'%s\' found: %s" % (software_title, [x.path for x in request_software_instance_list])\n
\n
\n
if (request_software_instance is None):\n
if (request_software_instance is None):\n
# First time that the software instance is requested\n
if (root_state == "destroyed"):\n
if is_slave == True:\n
instance_found = False\n
software_instance_portal_type = "Slave Instance"\n
else:\n
else:\n
software_instance_portal_type = "Software Instance"\n
instance_found = True\n
# Create a new one\n
# First time that the software instance is requested\n
reference = "SOFTINST-%s" % portal.portal_ids.generateNewId(\n
if is_slave == True:\n
id_group=\'slap_software_instance_reference\',\n
software_instance_portal_type = "Slave Instance"\n
id_generator=\'uid\')\n
else:\n
certificate_dict = portal.portal_certificate_authority.getNewCertificate(reference)\n
software_instance_portal_type = "Software Instance"\n
\n
# Create a new one\n
module = portal.getDefaultModule(portal_type="Software Instance")\n
reference = "SOFTINST-%s" % portal.portal_ids.generateNewId(\n
request_software_instance = module.newContent(\n
id_group=\'slap_software_instance_reference\',\n
portal_type=software_instance_portal_type,\n
id_generator=\'uid\')\n
title=software_title,\n
certificate_dict = portal.portal_certificate_authority.getNewCertificate(reference)\n
specialise_value=hosting_subscription,\n
\n
reference=reference,\n
module = portal.getDefaultModule(portal_type="Software Instance")\n
destination_reference=certificate_dict[\'id\'],\n
request_software_instance = module.newContent(\n
ssl_key=certificate_dict[\'key\'],\n
portal_type=software_instance_portal_type,\n
ssl_certificate=certificate_dict[\'certificate\'],\n
title=software_title,\n
activate_kw={\'tag\': tag},\n
specialise_value=hosting_subscription,\n
)\n
reference=reference,\n
# request_software_instance.portal_workflow.doActionFor(request_software_instance, \'validate_action\')\n
destination_reference=certificate_dict[\'id\'],\n
request_software_instance.validate()\n
ssl_key=certificate_dict[\'key\'],\n
graph[request_software_instance.getUid()] = []\n
ssl_certificate=certificate_dict[\'certificate\'],\n
activate_kw={\'tag\': tag},\n
)\n
# request_software_instance.portal_workflow.doActionFor(request_software_instance, \'validate_action\')\n
request_software_instance.validate()\n
graph[request_software_instance.getUid()] = []\n
\n
\n
else:\n
else:\n
instance_found = True\n
# Update the predecessor category of the previous requester\n
# Update the predecessor category of the previous requester\n
predecessor = request_software_instance.getPredecessorRelatedValue(portal_type="Software Instance")\n
predecessor = request_software_instance.getPredecessorRelatedValue(portal_type="Software Instance")\n
if (predecessor is None):\n
if (predecessor is None):\n
...
@@ -161,41 +166,46 @@ else:\n
...
@@ -161,41 +166,46 @@ else:\n
predecessor.edit(predecessor_uid_list=predecessor_uid_list)\n
predecessor.edit(predecessor_uid_list=predecessor_uid_list)\n
graph[predecessor.getUid()] = predecessor_uid_list\n
graph[predecessor.getUid()] = predecessor_uid_list\n
\n
\n
# Change desired state\n
if instance_found:\n
promise_kw = {\n
\'instance_xml\': instance_xml,\n
\'software_type\': software_type,\n
\'sla_xml\': sla_xml,\n
\'software_release\': software_release_url_string,\n
\'shared\': is_slave,\n
}\n
request_software_instance_url = request_software_instance.getRelativeUrl()\n
context.REQUEST.set(\'request_instance\', request_software_instance)\n
if (root_state == "started"):\n
request_software_instance.requestStart(**promise_kw)\n
elif (root_state == "stopped"):\n
request_software_instance.requestStop(**promise_kw)\n
elif (root_state == "destroyed"):\n
request_software_instance.requestDestroy(**promise_kw)\n
context.REQUEST.set(\'request_instance\', None)\n
else:\n
raise ValueError, "state should be started, stopped or destroyed"\n
\n
\n
predecessor_list = requester_instance.getPredecessorList() + [request_software_instance_url]\n
# Change desired state\n
uniq_predecessor_list = list(set(predecessor_list))\n
promise_kw = {\n
predecessor_list.sort()\n
\'instance_xml\': instance_xml,\n
uniq_predecessor_list.sort()\n
\'software_type\': software_type,\n
\'sla_xml\': sla_xml,\n
\'software_release\': software_release_url_string,\n
\'shared\': is_slave,\n
}\n
request_software_instance_url = request_software_instance.getRelativeUrl()\n
context.REQUEST.set(\'request_instance\', request_software_instance)\n
if (root_state == "started"):\n
request_software_instance.requestStart(**promise_kw)\n
elif (root_state == "stopped"):\n
request_software_instance.requestStop(**promise_kw)\n
elif (root_state == "destroyed"):\n
request_software_instance.requestDestroy(**promise_kw)\n
context.REQUEST.set(\'request_instance\', None)\n
else:\n
raise ValueError, "state should be started, stopped or destroyed"\n
\n
\n
assert predecessor_list == uniq_predecessor_list, "%s != %s" % (predecessor_list, uniq_predecessor_list)\n
predecessor_list = requester_instance.getPredecessorList() + [request_software_instance_url]\n
uniq_predecessor_list = list(set(predecessor_list))\n
predecessor_list.sort()\n
uniq_predecessor_list.sort()\n
\n
\n
# update graph to reflect requested operation\n
assert predecessor_list == uniq_predecessor_list, "%s != %s" % (predecessor_list, uniq_predecessor_list)\n
graph[requester_instance.getUid()] = requester_instance.getPredecessorUidList() + [request_software_instance.getUid()]\n
\n
\n
# check if all elements are still connected and if there is no cycle\n
# update graph to reflect requested operation\n
request_software_instance.checkConnected(graph, hosting_subscription.getUid())\n
graph[requester_instance.getUid()] = requester_instance.getPredecessorUidList() + [request_software_instance.getUid()]\n
request_software_instance.checkNotCyclic(graph)\n
\n
\n
requester_instance.edit(predecessor_list=predecessor_list)\n
# check if all elements are still connected and if there is no cycle\n
request_software_instance.checkConnected(graph, hosting_subscription.getUid())\n
request_software_instance.checkNotCyclic(graph)\n
\n
requester_instance.edit(predecessor_list=predecessor_list)\n
\n
else:\n
context.REQUEST.set(\'request_instance\', None)\n
]]>
</string>
</value>
]]>
</string>
</value>
...
...
master/bt5/vifib_slapos_core/bt/revision
View file @
676f082a
39
40
\ No newline at end of file
\ 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