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
Klaus Wölfel
slapos.core
Commits
7c121912
Commit
7c121912
authored
Jul 26, 2011
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement request of Slave Instance from Software Instance.
This part contains workflows modifications.
parent
41964a5b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
23 deletions
+43
-23
master/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/slave_instance_slap_interface_workflow/scripts/SlaveInstance_requestComputerPartition.xml
...rkflow/scripts/SlaveInstance_requestComputerPartition.xml
+33
-17
master/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestSoftwareInstance.xml
...flow/scripts/SoftwareInstance_requestSoftwareInstance.xml
+9
-5
master/bt5/vifib_base/bt/revision
master/bt5/vifib_base/bt/revision
+1
-1
No files found.
master/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/slave_instance_slap_interface_workflow/scripts/SlaveInstance_requestComputerPartition.xml
View file @
7c121912
...
...
@@ -52,22 +52,40 @@
<key>
<string>
_body
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
portal = context.getPortalObject()\n
\n
def checkSoftwareInstanceIsInstalledOnComputerPartition(software_release,\n
computer_partition):\n
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
query = ComplexQuery(Query(aggregate_relative_url=software_release.getRelativeUrl()),\n
Query(aggregate_relative_url=computer_partition.getRelativeUrl()),\n
operator="AND",\n
)\n
sale_packing_list_line = portal.portal_catalog.getResultValue(\n
portal_type=\'Sale Packing List Line\', aggregate_relative_url=query)\n
if sale_packing_list_line is not None:\n
return True\n
return False\n
\n
from DateTime import DateTime\n
import random\n
\n
slave_instance = state_change[\'object\']\n
software_release_url_string = state_change.kwargs[\'software_release\']\n
hosting_subscription_uid = state_change.kwargs[\'hosting_subscription_uid\']\n
shared = state_change.kwargs[\'shared\']\n
software_type = state_change.kwargs["software_type"]\n
tag = state_change.kwargs[\'tag\']\n
filter_kw = s
tate_change.kwargs["filter_kw"]
\n
filter_kw = s
lave_instance.getSlaXmlAsDict()
\n
\n
# Assertion: No packing list line should be related to this s
oftwar
e instance\n
# Assertion: No packing list line should be related to this s
lav
e instance\n
packing_list_line = slave_instance.getAggregateRelatedValue(portal_type=\'Sale Packing List Line\')\n
if packing_list_line is not None:\n
raise ValueError("Software Instance %s is already associated to a packing list line" % slave_instance.getRelativeurl())\n
\n
software_release = context.portal_catalog.getResultValue(\n
portal_type=\'Software Release\',\n
url_string=software_release_url_string)\n
\n
# Find a free computer partition. This means:\n
# Computer Partition which doesn\'t have non delivered sale packing list related\n
\n
...
...
@@ -76,17 +94,21 @@ SQL_WINDOW_SIZE = 50\n
computer_partition = None\n
query_kw = {\n
\'software_release_url\': software_release_url_string,\n
\'portal_type\': \'Computer Partition\'\n
\'portal_type\': \'Computer Partition\',\n
\'free_for_request\' : 0\n
}\n
# support SLA\n
if "computer_guid" in filter_kw:\n
query_kw["parent_reference"] = filter_kw["computer_guid"]\n
\n
# fetch at mot 50 random Computer Partitions, and check if they are ok\n
isTransitionPossible = slave_instance.getPortalObject().portal_workflow.isTransitionPossible\n
query_kw.update(free_for_request=1) # is free\n
portal = context.getPortalObject()\n
isTransitionPossible = portal.portal_workflow.isTransitionPossible\n
\n
\n
result_count = slave_instance.portal_catalog.countResults(**query_kw)[0][0]\n
offset = max(0, result_count-1)\n
\n
if offset >
= SQL_WINDOW_SIZE:\n
limit = (random.randint(0, offset), SQL_WINDOW_SIZE)\n
else:\n
...
...
@@ -96,25 +118,18 @@ for computer_partition_candidate in slave_instance.portal_catalog(\n
limit=limit, **query_kw):\n
computer_partition_candidate = computer_partition_candidate.getObject()\n
# Check if the computer partition can be marked as busy (done by an interaction workflow on sale packing list level)\n
if
isTransitionPossible(computer_partition_candidate, \'mark_busy\'
):\n
if
checkSoftwareInstanceIsInstalledOnComputerPartition(software_release, computer_partition_candidate
):\n
computer_partition = computer_partition_candidate\n
break\n
break
\n
\n
if computer_partition is None:\n
raise ValueError(\'It was not possible to find free Computer Partition\')\n
\n
# lock computer partition\n
computer_partition.serialize()\n
software_release_document = context.portal_catalog.getResultValue(\n
portal_type=\'Software Release\',\n
url_string=software_release_url_string)\n
\n
# protect computer partition from being selected again\n
portal = context.getPortalObject()\n
\n
hosting_subscription = slave_instance.portal_catalog.getResultValue(uid=hosting_subscription_uid)\n
sale_packing_list_line = context.HostingSubscription_getInstancePackingListLine(state_change)\n
base_sale_packing_list = sale_packing_list_line.getParentValue()\n
\n
# XXX: SlaveInstance_createSalePackingList shall be used to create new Sale Packing List\n
sale_packing_list_module = portal.getDefaultModule(portal_type=\'Sale Packing List\')\n
\n
...
...
@@ -132,10 +147,11 @@ sale_packing_list = sale_packing_list_module.newContent(\n
source=base_sale_packing_list.getSource(),\n
source_section=base_sale_packing_list.getSourceSection(),\n
price_currency=base_sale_packing_list.getPriceCurrency())\n
\n
sale_packing_list_line = sale_packing_list.newContent(\n
portal_type=\'Sale Packing List Line\',\n
resource=context.portal_preferences.getPreferredInstanceSetupResource(),\n
aggregate_value_list=[slave_instance, software_release
_document
, computer_partition, hosting_subscription]\n
aggregate_value_list=[slave_instance, software_release, computer_partition, hosting_subscription]\n
)\n
\n
# confirm Sale Packing List\n
...
...
master/bt5/vifib_base/WorkflowTemplateItem/portal_workflow/software_instance_slap_interface_workflow/scripts/SoftwareInstance_requestSoftwareInstance.xml
View file @
7c121912
...
...
@@ -58,12 +58,17 @@ portal = software_instance.getPortalObject()\n
kwargs = state_change.kwargs\n
software_release_url_string = state_change.kwargs[\'software_release\']\n
requested_partition_reference = kwargs["partition_reference"]\n
shared = kwargs["shared"]\n
software_type = kwargs["software_type"]\n
instance_xml = kwargs["instance_xml"]\n
is_slave = kwargs.get("slave", False)\n
sla_xml = kwargs["sla_xml"]\n
state = kwargs["state"]\n
\n
if is_slave == True:\n
software_instance_portal_type = "Slave Instance"\n
else:\n
software_instance_portal_type = "Software Instance"\n
\n
# Get root software instance\n
predecessor_software_instance = software_instance\n
while (predecessor_software_instance is not None):\n
...
...
@@ -76,7 +81,7 @@ tag = "%s_%s_%s_inProgress" % (root_software_instance.getUid(), software_type,\n
\n
# Check if it already exists\n
request_software_instance = software_instance.portal_catalog.getResultValue(\n
portal_type=
\'Software Instance\'
,\n
portal_type=
software_instance_portal_type
,\n
# XXX: User based property is used in non manual operation\n
# XXX-2: Do we really need to use root_uid?\n
title=requested_partition_reference,\n
...
...
@@ -94,7 +99,7 @@ if (request_software_instance is None):\n
# Create a new one\n
module = software_instance.getDefaultModule(portal_type="Software Instance")\n
request_software_instance = module.newContent(\n
portal_type=
"Software Instance"
,\n
portal_type=
software_instance_portal_type
,\n
title=requested_partition_reference,\n
source_reference=software_type,\n
text_content=instance_xml,\n
...
...
@@ -108,7 +113,6 @@ if (request_software_instance is None):\n
request_software_instance.requestComputerPartition(\n
software_release=software_release_url_string,\n
hosting_subscription_uid=hosting_subscription_uid,\n
shared=shared,\n
software_type=software_type,\n
tag=tag)\n
else:\n
...
...
@@ -138,8 +142,8 @@ else:\n
request_software_instance.activate(after_tag=tag).requestStopComputerPartition()\n
else:\n
raise ValueError(\'State %r is not supported\' % state)\n
predecessor_list = software_instance.getPredecessorList() + [request_software_instance.getRelativeUrl()]\n
\n
predecessor_list = software_instance.getPredecessorList() + [request_software_instance.getRelativeUrl()]\n
\n
software_instance.edit(\n
predecessor_list=predecessor_list,\n
...
...
master/bt5/vifib_base/bt/revision
View file @
7c121912
257
\ No newline at end of file
258
\ 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