Commit f449cb6c authored by Alain Takoudjou's avatar Alain Takoudjou

slapos_cloud migrated to new business template format

parent 66cb8262
......@@ -56,11 +56,6 @@
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string>DROP TABLE IF EXISTS computer_partition\n
</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
......@@ -50,11 +50,6 @@
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string>DROP TABLE IF EXISTS software_instance_tree\n
</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
......@@ -50,15 +50,6 @@
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
DELETE FROM computer_partition WHERE <dtml-sqltest uid op=eq type=int>\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
DELETE FROM email WHERE <dtml-sqltest uid op=eq type=int>
\ No newline at end of file
......@@ -18,14 +18,6 @@
<key> <string>id</string> </key>
<value> <string>z0_uncatalog_email</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
DELETE FROM email WHERE <dtml-sqltest uid op=eq type=int>
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
......@@ -50,15 +50,6 @@
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
DELETE FROM software_instance_tree WHERE <dtml-sqltest uid op=eq type=int>\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
DELETE FROM
computer_partition
WHERE
<dtml-in uid>
uid=<dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>
</dtml-in>
;
<dtml-var "'\0'">
<dtml-let row_list="[]">
<dtml-in prefix="loop" expr="_.range(_.len(uid))">
<dtml-let free_for_request="ComputerPartition_isFreeForRequest[loop_item]">
<dtml-let software_type="ComputerPartition_getSoftwareType[loop_item]">
<dtml-in prefix="url" expr="ComputerPartition_getAvailableSoftwareReleaseUrlStringList[loop_item]" no_push_item>
<dtml-call expr="row_list.append([
uid[loop_item],
url_item,
free_for_request,
software_type])">
</dtml-in>
</dtml-let>
</dtml-let>
</dtml-in>
<dtml-if "row_list">
INSERT INTO
computer_partition
VALUES
<dtml-in prefix="row" expr="row_list">
(
<dtml-sqlvar expr="row_item[0]" type="int">,
<dtml-sqlvar expr="row_item[1]" type="string">,
<dtml-sqlvar expr="row_item[2]" type="int">,
<dtml-sqlvar expr="row_item[3]" type="string">
)
<dtml-if sequence-end><dtml-else>,</dtml-if>
</dtml-in>
</dtml-if>
</dtml-let>
......@@ -53,54 +53,6 @@ ComputerPartition_getSoftwareType</string> </value>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
DELETE FROM\n
computer_partition\n
WHERE\n
<dtml-in uid>\n
uid=<dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>\n
</dtml-in>\n
;\n
\n
<dtml-var "\'\\0\'">\n
\n
<dtml-let row_list="[]">\n
<dtml-in prefix="loop" expr="_.range(_.len(uid))">\n
<dtml-let free_for_request="ComputerPartition_isFreeForRequest[loop_item]">\n
<dtml-let software_type="ComputerPartition_getSoftwareType[loop_item]">\n
<dtml-in prefix="url" expr="ComputerPartition_getAvailableSoftwareReleaseUrlStringList[loop_item]" no_push_item>\n
<dtml-call expr="row_list.append([\n
uid[loop_item],\n
url_item,\n
free_for_request,\n
software_type])">\n
</dtml-in>\n
</dtml-let>\n
</dtml-let>\n
</dtml-in>\n
\n
<dtml-if "row_list">\n
INSERT INTO\n
computer_partition\n
VALUES\n
<dtml-in prefix="row" expr="row_list">\n
(\n
<dtml-sqlvar expr="row_item[0]" type="int">,\n
<dtml-sqlvar expr="row_item[1]" type="string">,\n
<dtml-sqlvar expr="row_item[2]" type="int">,\n
<dtml-sqlvar expr="row_item[3]" type="string">\n
)\n
<dtml-if sequence-end><dtml-else>,</dtml-if>\n
</dtml-in>\n
</dtml-if>\n
</dtml-let>\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
<dtml-let email_list="[]">
<dtml-in prefix="loop" expr="_.range(_.len(uid))">
<dtml-if expr="getPortalType[loop_item] in ['Email', 'Software Release', 'Software Installation', 'Software Instance', 'Hosting Subscription']">
<dtml-call expr="email_list.append(loop_item)">
</dtml-if>
</dtml-in>
<dtml-if expr="_.len(email_list) > 0">
REPLACE INTO
email
VALUES
<dtml-in prefix="loop" expr="email_list">
(
<dtml-sqlvar expr="uid[loop_item]" type="int">,
<dtml-sqlvar expr="getUrlString[loop_item]" type="string" optional>
)
<dtml-if sequence-end><dtml-else>,</dtml-if>
</dtml-in>
</dtml-if>
</dtml-let>
\ No newline at end of file
......@@ -20,32 +20,6 @@ getPortalType</string> </value>
<key> <string>id</string> </key>
<value> <string>z_catalog_email_list</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-let email_list="[]">\n
<dtml-in prefix="loop" expr="_.range(_.len(uid))">\n
<dtml-if expr="getPortalType[loop_item] in [\'Email\', \'Software Release\', \'Software Installation\', \'Software Instance\', \'Hosting Subscription\']">\n
<dtml-call expr="email_list.append(loop_item)">\n
</dtml-if>\n
</dtml-in>\n
<dtml-if expr="_.len(email_list) > 0">\n
REPLACE INTO\n
email\n
VALUES\n
<dtml-in prefix="loop" expr="email_list">\n
(\n
<dtml-sqlvar expr="uid[loop_item]" type="int">, \n
<dtml-sqlvar expr="getUrlString[loop_item]" type="string" optional>\n
)\n
<dtml-if sequence-end><dtml-else>,</dtml-if>\n
</dtml-in>\n
</dtml-if>\n
</dtml-let>
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
REPLACE INTO
catalog
(`uid`, `security_uid`, `owner`, `viewable_owner`, `path`, `relative_url`, `parent_uid`, `id`, `description`, `title`, `meta_type`,
`portal_type`, `opportunity_state`, `corporate_registration_code`, `ean13_code`, `validation_state`, `simulation_state`,
`causality_state`, `invoice_state`, `payment_state`, `event_state`, `immobilisation_state`, `reference`, `grouping_reference`,
`source_reference`, `destination_reference`, `string_index`, `int_index`, `float_index`, `has_cell_content`, `modification_date`)
VALUES
<dtml-in prefix="loop" expr="_.range(_.len(uid))">
(
<dtml-sqlvar expr="uid[loop_item]" type="int">,
<dtml-sqlvar expr="security_uid[loop_item]" type="int">,
<dtml-sqlvar expr="getOwnerInfo[loop_item]['id']" type="string">,
<dtml-sqlvar expr="(getViewPermissionOwner[loop_item] is not None) and getViewPermissionOwner[loop_item] or ''" type="string" optional>,
<dtml-sqlvar expr="getPath[loop_item]" type="string">,
<dtml-sqlvar expr="getRelativeUrl[loop_item]" type="string">,
<dtml-sqlvar expr="getParentUid[loop_item]" type="int">,
<dtml-sqlvar expr="id[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getDescription[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getTitle[loop_item]" type="string" optional>,
<dtml-sqlvar expr="meta_type[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getPortalType[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getOpportunityState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getCorporateRegistrationCode[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getEan13Code[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getValidationState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getSimulationState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getCausalityState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getInvoiceState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getPaymentState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getEventState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getImmobilisationState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getGroupingReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getSourceReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getDestinationReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getStringIndex[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getIntIndex[loop_item]" type="int" optional>,
<dtml-sqlvar expr="getFloatIndex[loop_item]" type="float" optional>,
<dtml-sqlvar expr="hasCellContent[loop_item]" type="int" optional>,
<dtml-sqlvar expr="getModificationDate[loop_item]" type="datetime" optional>
)
<dtml-if sequence-end><dtml-else>,</dtml-if>
</dtml-in>
......@@ -80,57 +80,6 @@ getModificationDate</string> </value>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
REPLACE INTO\n
catalog\n
(`uid`, `security_uid`, `owner`, `viewable_owner`, `path`, `relative_url`, `parent_uid`, `id`, `description`, `title`, `meta_type`,\n
`portal_type`, `opportunity_state`, `corporate_registration_code`, `ean13_code`, `validation_state`, `simulation_state`,\n
`causality_state`, `invoice_state`, `payment_state`, `event_state`, `immobilisation_state`, `reference`, `grouping_reference`,\n
`source_reference`, `destination_reference`, `string_index`, `int_index`, `float_index`, `has_cell_content`, `modification_date`)\n
VALUES\n
<dtml-in prefix="loop" expr="_.range(_.len(uid))">\n
(\n
<dtml-sqlvar expr="uid[loop_item]" type="int">, \n
<dtml-sqlvar expr="security_uid[loop_item]" type="int">,\n
<dtml-sqlvar expr="getOwnerInfo[loop_item][\'id\']" type="string">,\n
<dtml-sqlvar expr="(getViewPermissionOwner[loop_item] is not None) and getViewPermissionOwner[loop_item] or \'\'" type="string" optional>,\n
<dtml-sqlvar expr="getPath[loop_item]" type="string">,\n
<dtml-sqlvar expr="getRelativeUrl[loop_item]" type="string">,\n
<dtml-sqlvar expr="getParentUid[loop_item]" type="int">,\n
<dtml-sqlvar expr="id[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getDescription[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getTitle[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="meta_type[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getPortalType[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getOpportunityState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getCorporateRegistrationCode[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getEan13Code[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getValidationState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getSimulationState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getCausalityState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getInvoiceState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getPaymentState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getEventState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getImmobilisationState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getReference[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getGroupingReference[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getSourceReference[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getDestinationReference[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getStringIndex[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getIntIndex[loop_item]" type="int" optional>,\n
<dtml-sqlvar expr="getFloatIndex[loop_item]" type="float" optional>,\n
<dtml-sqlvar expr="hasCellContent[loop_item]" type="int" optional>,\n
<dtml-sqlvar expr="getModificationDate[loop_item]" type="datetime" optional>\n
)\n
<dtml-if sequence-end><dtml-else>,</dtml-if>\n
</dtml-in>\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
REPLACE INTO
catalog
(`uid`, `security_uid`, `owner`, `viewable_owner`, `path`, `relative_url`, `parent_uid`, `id`, `description`, `title`, `meta_type`,
`portal_type`, `opportunity_state`, `corporate_registration_code`, `ean13_code`, `validation_state`, `simulation_state`,
`causality_state`, `invoice_state`, `payment_state`, `event_state`, `immobilisation_state`, `reference`, `grouping_reference`, `grouping_date`,
`source_reference`, `destination_reference`, `string_index`, `int_index`, `float_index`, `has_cell_content`, `creation_date`,
`modification_date`)
VALUES
<dtml-in prefix="loop" expr="_.range(_.len(uid))">
(
<dtml-sqlvar expr="uid[loop_item]" type="int">,
<dtml-sqlvar expr="security_uid[loop_item]" type="int">,
<dtml-sqlvar expr="getOwnerInfo[loop_item]['id']" type="string">,
<dtml-sqlvar expr="(getViewPermissionOwner[loop_item] is not None) and getViewPermissionOwner[loop_item] or ''" type="string" optional>,
<dtml-sqlvar expr="getPath[loop_item]" type="string">,
<dtml-sqlvar expr="getRelativeUrl[loop_item]" type="string">,
<dtml-sqlvar expr="getParentUid[loop_item]" type="int">,
<dtml-sqlvar expr="id[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getDescription[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getTitle[loop_item]" type="string" optional>,
<dtml-sqlvar expr="meta_type[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getPortalType[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getOpportunityState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getCorporateRegistrationCode[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getEan13Code[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getValidationState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getSimulationState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getCausalityState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getInvoiceState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getPaymentState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getEventState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getImmobilisationState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getGroupingReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getGroupingDate[loop_item]" type="datetime" optional>,
<dtml-sqlvar expr="getSourceReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getDestinationReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getStringIndex[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getIntIndex[loop_item]" type="int" optional>,
<dtml-sqlvar expr="getFloatIndex[loop_item]" type="float" optional>,
<dtml-sqlvar expr="hasCellContent[loop_item]" type="int" optional>,
<dtml-sqlvar expr="getCreationDate[loop_item]" type="datetime" optional>,
<dtml-sqlvar expr="getModificationDate[loop_item]" type="datetime" optional>
)
<dtml-if sequence-end><dtml-else>,</dtml-if>
</dtml-in>
......@@ -82,60 +82,6 @@ getModificationDate</string> </value>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
REPLACE INTO\n
catalog\n
(`uid`, `security_uid`, `owner`, `viewable_owner`, `path`, `relative_url`, `parent_uid`, `id`, `description`, `title`, `meta_type`,\n
`portal_type`, `opportunity_state`, `corporate_registration_code`, `ean13_code`, `validation_state`, `simulation_state`,\n
`causality_state`, `invoice_state`, `payment_state`, `event_state`, `immobilisation_state`, `reference`, `grouping_reference`, `grouping_date`,\n
`source_reference`, `destination_reference`, `string_index`, `int_index`, `float_index`, `has_cell_content`, `creation_date`,\n
`modification_date`)\n
VALUES\n
<dtml-in prefix="loop" expr="_.range(_.len(uid))">\n
(\n
<dtml-sqlvar expr="uid[loop_item]" type="int">, \n
<dtml-sqlvar expr="security_uid[loop_item]" type="int">,\n
<dtml-sqlvar expr="getOwnerInfo[loop_item][\'id\']" type="string">,\n
<dtml-sqlvar expr="(getViewPermissionOwner[loop_item] is not None) and getViewPermissionOwner[loop_item] or \'\'" type="string" optional>,\n
<dtml-sqlvar expr="getPath[loop_item]" type="string">,\n
<dtml-sqlvar expr="getRelativeUrl[loop_item]" type="string">,\n
<dtml-sqlvar expr="getParentUid[loop_item]" type="int">,\n
<dtml-sqlvar expr="id[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getDescription[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getTitle[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="meta_type[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getPortalType[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getOpportunityState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getCorporateRegistrationCode[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getEan13Code[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getValidationState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getSimulationState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getCausalityState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getInvoiceState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getPaymentState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getEventState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getImmobilisationState[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getReference[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getGroupingReference[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getGroupingDate[loop_item]" type="datetime" optional>,\n
<dtml-sqlvar expr="getSourceReference[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getDestinationReference[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getStringIndex[loop_item]" type="string" optional>,\n
<dtml-sqlvar expr="getIntIndex[loop_item]" type="int" optional>,\n
<dtml-sqlvar expr="getFloatIndex[loop_item]" type="float" optional>,\n
<dtml-sqlvar expr="hasCellContent[loop_item]" type="int" optional>,\n
<dtml-sqlvar expr="getCreationDate[loop_item]" type="datetime" optional>,\n
<dtml-sqlvar expr="getModificationDate[loop_item]" type="datetime" optional>\n
)\n
<dtml-if sequence-end><dtml-else>,</dtml-if>\n
</dtml-in>\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
DELETE FROM
software_instance_tree
WHERE
<dtml-in uid>
uid=<dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>
</dtml-in>
;
<dtml-var "'\0'">
<dtml-let row_list="[]">
<dtml-in prefix="loop" expr="_.range(_.len(uid))">
<dtml-if expr="getSpecialiseUid[loop_item]">
<dtml-call expr="row_list.append([
uid[loop_item],
getSpecialiseUid[loop_item]])">
</dtml-if>
</dtml-in>
<dtml-if "row_list">
INSERT INTO
software_instance_tree
VALUES
<dtml-in prefix="row" expr="row_list">
(
<dtml-sqlvar expr="row_item[0]" type="int">,
<dtml-sqlvar expr="row_item[1]" type="int">
)
<dtml-if sequence-end><dtml-else>,</dtml-if>
</dtml-in>
</dtml-if>
</dtml-let>
......@@ -51,46 +51,6 @@ getSpecialiseUid</string> </value>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
DELETE FROM\n
software_instance_tree\n
WHERE\n
<dtml-in uid>\n
uid=<dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>\n
</dtml-in>\n
;\n
\n
<dtml-var "\'\\0\'">\n
\n
<dtml-let row_list="[]">\n
<dtml-in prefix="loop" expr="_.range(_.len(uid))">\n
<dtml-if expr="getSpecialiseUid[loop_item]">\n
<dtml-call expr="row_list.append([\n
uid[loop_item],\n
getSpecialiseUid[loop_item]])">\n
</dtml-if>\n
</dtml-in>\n
\n
<dtml-if "row_list">\n
INSERT INTO\n
software_instance_tree\n
VALUES\n
<dtml-in prefix="row" expr="row_list">\n
(\n
<dtml-sqlvar expr="row_item[0]" type="int">,\n
<dtml-sqlvar expr="row_item[1]" type="int">\n
)\n
<dtml-if sequence-end><dtml-else>,</dtml-if>\n
</dtml-in>\n
</dtml-if>\n
</dtml-let>\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
# Host:
# Database: test
# Table: 'computer_partition'
#
CREATE TABLE `computer_partition` (
`uid` BIGINT UNSIGNED NOT NULL,
`software_release_url` varchar(255),
`free_for_request` INT(1),
`software_type` VARCHAR(255),
PRIMARY KEY (`uid`, `software_release_url`)
) ENGINE=InnoDB;
......@@ -56,21 +56,6 @@
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string># Host:\n
# Database: test\n
# Table: \'computer_partition\'\n
#\n
CREATE TABLE `computer_partition` (\n
`uid` BIGINT UNSIGNED NOT NULL,\n
`software_release_url` varchar(255),\n
`free_for_request` INT(1),\n
`software_type` VARCHAR(255),\n
PRIMARY KEY (`uid`, `software_release_url`)\n
) ENGINE=InnoDB;\n
</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
# Host:
# Database: test
# Table: 'software_instance_tree'
#
CREATE TABLE `software_instance_tree` (
`uid` BIGINT UNSIGNED NOT NULL,
`root_uid` BIGINT UNSIGNED NOT NULL,
PRIMARY KEY (`uid`, `root_uid`)
) ENGINE=InnoDB;
......@@ -56,19 +56,6 @@
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string># Host:\n
# Database: test\n
# Table: \'software_instance_tree\'\n
#\n
CREATE TABLE `software_instance_tree` (\n
`uid` BIGINT UNSIGNED NOT NULL,\n
`root_uid` BIGINT UNSIGNED NOT NULL,\n
PRIMARY KEY (`uid`, `root_uid`)\n
) ENGINE=InnoDB;\n
</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
CREATE TABLE `versioning` (
`uid` BIGINT UNSIGNED NOT NULL,
`version` varchar(255) default '',
`language` varchar(5) default '',
`revision` varchar(10) default '',
`subject_set_uid` INT UNSIGNED,
`effective_date` datetime default NULL,
`expiration_date` datetime default NULL,
`creation_date_index` INT,
`frequency_index` INT,
PRIMARY KEY (`uid`),
KEY `version` (`version`),
KEY `language` (`language`),
KEY `subject_set_uid` (`subject_set_uid`),
KEY `effective_date` (`effective_date`),
KEY `expiration_date` (`expiration_date`),
KEY `frequency_index` (`creation_date_index`, `frequency_index`)
) ENGINE=InnoDB;
......@@ -24,28 +24,6 @@
<key> <string>id</string> </key>
<value> <string>z_create_versioning</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string>CREATE TABLE `versioning` (\n
`uid` BIGINT UNSIGNED NOT NULL,\n
`version` varchar(255) default \'\',\n
`language` varchar(5) default \'\',\n
`revision` varchar(10) default \'\',\n
`subject_set_uid` INT UNSIGNED,\n
`effective_date` datetime default NULL,\n
`expiration_date` datetime default NULL,\n
`creation_date_index` INT,\n
`frequency_index` INT,\n
PRIMARY KEY (`uid`),\n
KEY `version` (`version`),\n
KEY `language` (`language`),\n
KEY `subject_set_uid` (`subject_set_uid`),\n
KEY `effective_date` (`effective_date`),\n
KEY `expiration_date` (`expiration_date`),\n
KEY `frequency_index` (`creation_date_index`, `frequency_index`)\n
) ENGINE=InnoDB;\n
</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
portal = context.getPortalObject()
select_dict= {'default_aggregate_uid': None}
portal.portal_catalog.searchAndActivate(
portal_type=('Slave Instance', 'Software Instance'),
validation_state='validated',
default_aggregate_uid=None,
select_dict=select_dict,
left_join_list=select_dict.keys(),
method_id='SoftwareInstance_tryToAllocatePartition',
packet_size=1, # Separate calls to many transactions
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,25 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
select_dict= {\'default_aggregate_uid\': None}\n
portal.portal_catalog.searchAndActivate(\n
portal_type=(\'Slave Instance\', \'Software Instance\'),\n
validation_state=\'validated\',\n
default_aggregate_uid=None,\n
select_dict=select_dict,\n
left_join_list=select_dict.keys(),\n
\n
method_id=\'SoftwareInstance_tryToAllocatePartition\',\n
packet_size=1, # Separate calls to many transactions\n
activate_kw={\'tag\': tag}\n
)\n
\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery
portal.portal_catalog.searchAndActivate(
portal_type='Hosting Subscription',
validation_state='validated',
where_expression="related_predecessor_title_1_catalog.title <> catalog.title",
predecessor_title=NegatedQuery(SimpleQuery(predecessor_title=None, comparison_operator='is')),
method_id='HostingSubscription_assertPredecessor',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,27 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
portal = context.getPortalObject()\n
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery\n
\n
portal.portal_catalog.searchAndActivate(\n
portal_type=\'Hosting Subscription\',\n
validation_state=\'validated\',\n
where_expression="related_predecessor_title_1_catalog.title <> catalog.title",\n
predecessor_title=NegatedQuery(SimpleQuery(predecessor_title=None, comparison_operator=\'is\')),\n
method_id=\'HostingSubscription_assertPredecessor\',\n
activate_kw={\'tag\': tag}\n
)\n
\n
context.activate(after_tag=tag).getId()\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type=["Slave Instance", "Software Instance"],
validation_state="validated",
specialise_validation_state="archived",
method_id='Instance_tryToGarbageCollect',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,21 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
portal.portal_catalog.searchAndActivate(\n
portal_type=["Slave Instance", "Software Instance"],\n
validation_state="validated",\n
specialise_validation_state="archived",\n
method_id=\'Instance_tryToGarbageCollect\',\n
activate_kw={\'tag\': tag}\n
)\n
\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
select_dict= {'default_aggregate_uid': None}
portal.portal_catalog.searchAndActivate(
portal_type=('Slave Instance', 'Software Instance'),
validation_state='validated',
default_aggregate_uid=None,
select_dict=select_dict,
left_join_list=select_dict.keys(),
method_id='Instance_tryToGarbageCollectNonAllocatedRootTree',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,24 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
select_dict= {\'default_aggregate_uid\': None}\n
portal.portal_catalog.searchAndActivate(\n
portal_type=(\'Slave Instance\', \'Software Instance\'),\n
validation_state=\'validated\',\n
default_aggregate_uid=None,\n
select_dict=select_dict,\n
left_join_list=select_dict.keys(),\n
\n
method_id=\'Instance_tryToGarbageCollectNonAllocatedRootTree\',\n
activate_kw={\'tag\': tag}\n
)\n
\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
select_dict= {'default_aggregate_uid': None}
portal.portal_catalog.searchAndActivate(
portal_type=('Slave Instance', 'Software Instance'),
validation_state='validated',
default_aggregate_uid=None,
select_dict=select_dict,
left_join_list=select_dict.keys(),
method_id='SoftwareInstance_tryToInvalidateIfDestroyed',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,24 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
select_dict= {\'default_aggregate_uid\': None}\n
portal.portal_catalog.searchAndActivate(\n
portal_type=(\'Slave Instance\', \'Software Instance\'),\n
validation_state=\'validated\',\n
default_aggregate_uid=None,\n
select_dict=select_dict,\n
left_join_list=select_dict.keys(),\n
\n
method_id=\'SoftwareInstance_tryToInvalidateIfDestroyed\',\n
activate_kw={\'tag\': tag}\n
)\n
\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
category = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None)
if category is not None:
portal.portal_catalog.searchAndActivate(
portal_type='Computer',
default_allocation_scope_uid=category.getUid(),
validation_state="validated",
method_id='Computer_checkAndUpdateCapacityScope',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,22 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
category = portal.restrictedTraverse("portal_categories/allocation_scope/open/public", None)\n
if category is not None:\n
portal.portal_catalog.searchAndActivate(\n
portal_type=\'Computer\',\n
default_allocation_scope_uid=category.getUid(),\n
validation_state="validated",\n
method_id=\'Computer_checkAndUpdateCapacityScope\',\n
activate_kw={\'tag\': tag}\n
)\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type=["Software Instance", "Slave Instance"],
default_aggregate_relative_url="computer_module/%/%",
validation_state="invalidated",
method_id='Instance_tryToUnallocatePartition',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,21 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
portal.portal_catalog.searchAndActivate(\n
portal_type=["Software Instance", "Slave Instance"],\n
default_aggregate_relative_url="computer_module/%/%",\n
validation_state="invalidated",\n
method_id=\'Instance_tryToUnallocatePartition\',\n
activate_kw={\'tag\': tag}\n
)\n
\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type=["Slave Instance", "Software Instance"],
validation_state="validated",
specialise_validation_state="validated",
method_id='Instance_tryToStopCollect',
activate_kw={'tag': tag}
)
context.activate(after_tag=tag).getId()
......@@ -48,21 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
portal.portal_catalog.searchAndActivate(\n
portal_type=["Slave Instance", "Software Instance"],\n
validation_state="validated",\n
specialise_validation_state="validated",\n
method_id=\'Instance_tryToStopCollect\',\n
activate_kw={\'tag\': tag}\n
)\n
\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
computer = context.REQUEST.get('here')
software_release = context
return computer.Computer_getSoftwareReleaseState(software_release.getUid())
......@@ -48,14 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>computer = context.REQUEST.get(\'here\')\n
software_release = context\n
\n
return computer.Computer_getSoftwareReleaseState(software_release.getUid())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>*args, **kwargs</string> </value>
......
current = context.REQUEST.get('here')
if current.getPortalType() == 'Software Release':
software_release = current
computer = context
else:
computer = current
software_release = context
return computer.Computer_getSoftwareReleaseUsage(software_release.getUid())
......@@ -48,19 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>current = context.REQUEST.get(\'here\')\n
if current.getPortalType() == \'Software Release\': \n
software_release = current\n
computer = context\n
else:\n
computer = current\n
software_release = context\n
\n
return computer.Computer_getSoftwareReleaseUsage(software_release.getUid())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>*args, **kwargs</string> </value>
......
portal = context.getPortalObject()
network = context
computter_list_uid = [x.getUid() for x in network.getSubordinationRelatedValueList()]
kw['portal_type']='Software Installation'
kw['validation_state']='validated'
kw['default_aggregate_uid']=computter_list_uid
return portal.portal_catalog(**kw)
......@@ -48,19 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
network = context\n
\n
computter_list_uid = [x.getUid() for x in network.getSubordinationRelatedValueList()]\n
kw[\'portal_type\']=\'Software Installation\'\n
kw[\'validation_state\']=\'validated\'\n
kw[\'default_aggregate_uid\']=computter_list_uid\n
\n
return portal.portal_catalog(**kw)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......
network = context
portal = context.getPortalObject()
software_release = context.REQUEST.get('here')
computer_uid_list = [x.getUid() for x in context.getSubordinationRelatedValueList()]
return portal.portal_catalog.countResults(
portal_type='Computer Partition',
parent_uid=computer_uid_list,
free_for_request=0,
software_release_url=software_release.getUrlString()
)[0][0]
......@@ -48,22 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>network = context\n
portal = context.getPortalObject()\n
software_release = context.REQUEST.get(\'here\')\n
\n
computer_uid_list = [x.getUid() for x in context.getSubordinationRelatedValueList()]\n
\n
return portal.portal_catalog.countResults(\n
portal_type=\'Computer Partition\',\n
parent_uid=computer_uid_list,\n
free_for_request=0,\n
software_release_url=software_release.getUrlString()\n
)[0][0]\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>*args, **kwargs</string> </value>
......
network = context
# XXX - The use of current authenticated person will return always 'Close' if
# the person is administrator (such as 'zope' user) but not the owner of computer
#
# person = context.ERP5Site_getAuthenticatedMemberPersonValue()
allocation_state = 'Close'
software_type = ''
filter_kw = {}
for computer in network.getSubordinationRelatedValueList():
person = computer.getSourceAdministrationValue()
filter_kw['computer_guid']=computer.getReference()
try:
isAllowed = person.Person_restrictMethodAsShadowUser(shadow_document=person,
callable_object=person.Person_findPartition,
argument_list=[software_release_url, software_type, 'Software Instance',
filter_kw],
argument_dict={'test_mode': True}
)
if isAllowed:
allocation_state = 'Open'
break
except:
continue
return allocation_state
......@@ -48,37 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>network = context\n
\n
# XXX - The use of current authenticated person will return always \'Close\' if \n
# the person is administrator (such as \'zope\' user) but not the owner of computer\n
# \n
# person = context.ERP5Site_getAuthenticatedMemberPersonValue()\n
allocation_state = \'Close\'\n
software_type = \'\'\n
filter_kw = {}\n
\n
for computer in network.getSubordinationRelatedValueList():\n
person = computer.getSourceAdministrationValue()\n
filter_kw[\'computer_guid\']=computer.getReference()\n
try:\n
isAllowed = person.Person_restrictMethodAsShadowUser(shadow_document=person,\n
callable_object=person.Person_findPartition,\n
argument_list=[software_release_url, software_type, \'Software Instance\',\n
filter_kw], \n
argument_dict={\'test_mode\': True}\n
)\n
if isAllowed:\n
allocation_state = \'Open\'\n
break\n
except:\n
continue\n
\n
return allocation_state\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>software_release_url</string> </value>
......
software_installation = context
portal = context.getPortalObject()
url_string = ""
software_release = portal.portal_catalog.getResultValue(
portal_type='Software Release',
url_string=software_installation.getUrlString()
)
if software_release:
url_string = "%s?editable_mode:int=1" % software_release.getAbsoluteUrl()
return url_string
......@@ -48,22 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>software_installation = context\n
portal = context.getPortalObject()\n
\n
url_string = ""\n
software_release = portal.portal_catalog.getResultValue(\n
portal_type=\'Software Release\',\n
url_string=software_installation.getUrlString()\n
)\n
if software_release:\n
url_string = "%s?editable_mode:int=1" % software_release.getAbsoluteUrl()\n
\n
return url_string\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......
slap_state = context.getSlapState()
portal = context.getPortalObject()
portal_preferences = portal.portal_preferences
if slap_state == 'free':
computer = context.getParentValue()
return computer.Computer_getSoftwareReleaseUrlStringList()
elif slap_state == 'busy':
instance = portal.portal_catalog.getResultValue(
portal_type="Software Instance",
validation_state="validated",
default_aggregate_uid=context.getUid(),
)
if (instance is None) or (instance.getSlapState() != "start_requested"):
return []
else:
return [instance.getUrlString()]
else:
return []
......@@ -48,32 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>slap_state = context.getSlapState()\n
portal = context.getPortalObject()\n
portal_preferences = portal.portal_preferences\n
\n
if slap_state == \'free\':\n
computer = context.getParentValue()\n
return computer.Computer_getSoftwareReleaseUrlStringList()\n
\n
elif slap_state == \'busy\':\n
\n
instance = portal.portal_catalog.getResultValue(\n
portal_type="Software Instance",\n
validation_state="validated",\n
default_aggregate_uid=context.getUid(),\n
)\n
if (instance is None) or (instance.getSlapState() != "start_requested"):\n
return []\n
else:\n
return [instance.getUrlString()]\n
\n
else:\n
return []\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
......@@ -48,13 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>query_kw = dict()\n
\n
return query_kw\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>software_release_url, software_type, software_instance_portal_type, filter_kw, computer_network_query=None, test_mode=False</string> </value>
......
partition = context
software_instance_list = partition.getAggregateRelatedValueList(portal_type=["Software Instance"])
for si in software_instance_list:
obj = si.getObject()
return "%s?editable_mode:int=1" % obj.getRelativeUrl()
......@@ -48,16 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>partition = context\n
\n
software_instance_list = partition.getAggregateRelatedValueList(portal_type=["Software Instance"])\n
for si in software_instance_list:\n
obj = si.getObject()\n
return "%s?editable_mode:int=1" % obj.getRelativeUrl()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......
from DateTime import DateTime
portal = context.getPortalObject()
import json
partition = context
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
result = ""
date = None
for si in partition.getAggregateRelatedValueList(portal_type=["Software Instance", "Slave Instance"]):
obj = si.getObject()
if obj.getValidationState() != "validated":
continue
if obj.getSlapState() == "destroy_requested":
continue
try:
d = memcached_dict[obj.getReference()]
except KeyError:
result = "#missing no data found for %s" % obj.getReference()
else:
d = json.loads(d)
date = DateTime(d['created_at'])
result = date.strftime('%Y/%m/%d %H:%M')
return result
......@@ -48,40 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
portal = context.getPortalObject()\n
import json\n
\n
partition = context\n
memcached_dict = context.getPortalObject().portal_memcached.getMemcachedDict(\n
key_prefix=\'slap_tool\',\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
\n
result = ""\n
date = None\n
\n
for si in partition.getAggregateRelatedValueList(portal_type=["Software Instance", "Slave Instance"]):\n
obj = si.getObject() \n
\n
if obj.getValidationState() != "validated":\n
continue\n
if obj.getSlapState() == "destroy_requested":\n
continue\n
\n
try:\n
d = memcached_dict[obj.getReference()]\n
except KeyError:\n
result = "#missing no data found for %s" % obj.getReference()\n
else:\n
d = json.loads(d)\n
date = DateTime(d[\'created_at\'])\n
result = date.strftime(\'%Y/%m/%d %H:%M\')\n
\n
return result\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
partition = context
si = partition.getAggregateRelatedValue(portal_type=["Software Instance", "Slave Instance"])
if si:
person = si.getSpecialiseValue().getDestinationSectionValue()
return '<a href="%s?editable_mode:int=1">%s</a>' % (person.getRelativeUrl(), person.getTitle())
......@@ -48,20 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
partition = context\n
\n
si = partition.getAggregateRelatedValue(portal_type=["Software Instance", "Slave Instance"])\n
if si:\n
person = si.getSpecialiseValue().getDestinationSectionValue()\n
return \'<a href="%s?editable_mode:int=1">%s</a>\' % (person.getRelativeUrl(), person.getTitle())\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
partition = context
portal = context.getPortalObject()
image_url = ""
software_instance = partition.getAggregateRelatedValue(portal_type="Software Instance")
release = portal.portal_catalog.getResultValue(
portal_type="Software Release",
url_string=software_instance.getUrlString(),
)
if release is not None:
software_product = release.getAggregateValue()
image_url = '%s/index_html' % software_product.getDefaultImageAbsoluteUrl()
return image_url
......@@ -48,25 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>partition = context\n
portal = context.getPortalObject()\n
image_url = ""\n
\n
software_instance = partition.getAggregateRelatedValue(portal_type="Software Instance")\n
\n
release = portal.portal_catalog.getResultValue(\n
portal_type="Software Release",\n
url_string=software_instance.getUrlString(),\n
)\n
if release is not None:\n
software_product = release.getAggregateValue()\n
image_url = \'%s/index_html\' % software_product.getDefaultImageAbsoluteUrl()\n
\n
return image_url\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
from DateTime import DateTime
partition = context
software_instance = partition.getAggregateRelatedValueList(portal_type=["Software Instance", "Slave Instance"])[0].getObject()
date = DateTime(software_instance.getCreationDate())
return date.strftime('%Y/%m/%d %H:%M')
......@@ -48,17 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
\n
partition = context\n
\n
software_instance = partition.getAggregateRelatedValueList(portal_type=["Software Instance", "Slave Instance"])[0].getObject()\n
date = DateTime(software_instance.getCreationDate())\n
return date.strftime(\'%Y/%m/%d %H:%M\')\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
software_instance = context.getAggregateRelatedValue(portal_type='Software Instance')
status = ""
state = 'green'
if software_instance is not None:
status = software_instance.SoftwareInstance_getCurrentStatus()
if status.startswith('#error '):
state = "red"
return '<a href="%s" style="background-color: %s; display: block; height: 2em; width: 2em; float: left; margin: 5px;"></a> ' \
'<p style="float: left; line-height: 10px; margin-left: 10px;">%s</p>' % (
software_instance.getUrl(), state, status)
......@@ -48,27 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
software_instance = context.getAggregateRelatedValue(portal_type=\'Software Instance\')\n
\n
status = ""\n
state = \'green\'\n
if software_instance is not None:\n
status = software_instance.SoftwareInstance_getCurrentStatus()\n
\n
if status.startswith(\'#error \'):\n
state = "red"\n
\n
return \'<a href="%s" style="background-color: %s; display: block; height: 2em; width: 2em; float: left; margin: 5px;"></a> \' \\\n
\'<p style="float: left; line-height: 10px; margin-left: 10px;">%s</p>\' % (\n
software_instance.getUrl(), state, status)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
instance = context.getPortalObject().portal_catalog.getResultValue(
portal_type="Software Instance",
validation_state="validated",
default_aggregate_uid=context.getUid(),
)
if (instance is None) or (instance.getSlapState() != "start_requested"):
return ""
else:
return instance.getSourceReference()
......@@ -48,19 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>instance = context.getPortalObject().portal_catalog.getResultValue(\n
portal_type="Software Instance",\n
validation_state="validated",\n
default_aggregate_uid=context.getUid(),\n
)\n
if (instance is None) or (instance.getSlapState() != "start_requested"):\n
return ""\n
else:\n
return instance.getSourceReference()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
......@@ -48,11 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return context.absolute_url() + \'/Item_viewTrackingList?current:int=0\'\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......
if context.getPortalObject().portal_workflow.isTransitionPossible(context, 'mark_busy') and context.getParentValue().isMemberOf('allocation_scope/open'):
return 1
return 0
......@@ -48,13 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if context.getPortalObject().portal_workflow.isTransitionPossible(context, \'mark_busy\') and context.getParentValue().isMemberOf(\'allocation_scope/open\'):\n
return 1\n
return 0\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
computer = context
Base_translateString = context.Base_translateString
computer_model_portal_type = 'Computer Model'
computer_model = computer.getSpecialiseValue(
portal_type=computer_model_portal_type)
if computer_model is None:
message = Base_translateString('No Computer Model.')
result = False
else :
category_list = [
'cpu_core',
'cpu_frequency',
'cpu_type',
'function',
'group',
'local_area_network_type',
'memory_size',
'memory_type',
'role',
'region',
'storage_capacity',
'storage_interface',
'storage_redundancy',
'wide_area_network_type',
]
property_list = [
'capacity_quantity'
]
new_category_dict = {}
for category in category_list:
if force or not computer.getPropertyList(category):
v = computer_model.getPropertyList(category)
if v:
new_category_dict[category] = v
for property in property_list:
if force or not computer.getProperty(property):
v = computer_model.getProperty(property)
if v:
new_category_dict[property] = v
if new_category_dict:
computer.edit(**new_category_dict)
message = Base_translateString('Computer Model applied.')
result = True
else:
message = Base_translateString('No changes applied.')
result = False
if not batch_mode:
return context.Base_redirect(form_id,
keep_items=dict(portal_status_message=message))
else:
return result
......@@ -48,68 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>computer = context\n
Base_translateString = context.Base_translateString\n
computer_model_portal_type = \'Computer Model\'\n
\n
computer_model = computer.getSpecialiseValue(\n
portal_type=computer_model_portal_type)\n
\n
if computer_model is None:\n
message = Base_translateString(\'No Computer Model.\')\n
result = False\n
else :\n
category_list = [\n
\'cpu_core\',\n
\'cpu_frequency\',\n
\'cpu_type\',\n
\'function\',\n
\'group\',\n
\'local_area_network_type\',\n
\'memory_size\',\n
\'memory_type\',\n
\'role\',\n
\'region\',\n
\'storage_capacity\',\n
\'storage_interface\',\n
\'storage_redundancy\',\n
\'wide_area_network_type\',\n
]\n
\n
property_list = [\n
\'capacity_quantity\'\n
]\n
\n
new_category_dict = {}\n
for category in category_list:\n
if force or not computer.getPropertyList(category):\n
v = computer_model.getPropertyList(category)\n
if v:\n
new_category_dict[category] = v\n
\n
for property in property_list:\n
if force or not computer.getProperty(property):\n
v = computer_model.getProperty(property)\n
if v:\n
new_category_dict[property] = v\n
\n
if new_category_dict:\n
computer.edit(**new_category_dict)\n
message = Base_translateString(\'Computer Model applied.\')\n
result = True\n
else:\n
message = Base_translateString(\'No changes applied.\')\n
result = False\n
\n
if not batch_mode:\n
return context.Base_redirect(form_id,\n
keep_items=dict(portal_status_message=message))\n
else:\n
return result\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'view\', batch_mode=0, force=0</string> </value>
......
import json
computer = context
portal = context.getPortalObject()
if computer.getAllocationScope() != 'open/public':
# Don't update non public computer
return
can_allocate = True
comment = ''
# First and simple way to see if computer is dead
# modification_date = portal.portal_workflow.getInfoFor(computer, 'time', wf_id='edit_workflow')
# if (DateTime() - modification_date) > 1:
# # Computer didn't talk to vifib for 1 days, do not consider it as a trustable public server for now
# # slapformat is supposed to run at least once per day
# can_allocate = False
# comment = "Computer didn't contact the server for more than one day"
if can_allocate:
# Check if computer has error reported
memcached_dict = portal.portal_memcached.getMemcachedDict(
key_prefix='slap_tool',
plugin_path='portal_memcached/default_memcached_plugin')
try:
d = memcached_dict[computer.getReference()]
except KeyError:
can_allocate = False
comment = "Computer didn't contact the server"
else:
log_dict = json.loads(d)
if '#error' in log_dict.get('text', '#error'):
can_allocate = False
comment = 'Computer reported an error'
# XXX TODO: compare creation date of #ok message
elif int(DateTime()) - int(DateTime(log_dict.get('created_at'))) > 600:
can_allocate = False
comment = "Computer didn't contact for more than 10 minutes"
if can_allocate:
# Check the computer capacity.
# there is a arbitrary hardcoded default value: not more than 1000000 (!) instances on
# a computer.
default_maximum_value = 1000000
computer_capacity_quantity = computer.getCapacityQuantity(default_maximum_value)
if computer_capacity_quantity == default_maximum_value:
# Verify if Computer Model defines it:
computer_model = computer.getSpecialiseValue(portal_type='Computer Model')
if computer_model is not None:
computer_capacity_quantity = computer_model.getCapacityQuantity(default_maximum_value)
# The update the computer with the initial value.
if computer_capacity_quantity != default_maximum_value:
computer.edit(capacity_quantity=computer_capacity_quantity)
software_release_capacity_dict = {}
consumed_capacity = 0
for instance in portal.portal_catalog.portal_catalog(
default_aggregate_relative_url='%s/%%' % computer.getRelativeUrl(),
portal_type=['Software Instance', 'Slave Instance'],
validation_state='validated'):
instance = instance.getObject()
software_release_url = instance.getUrlString()
if software_release_url in software_release_capacity_dict:
software_release_capacity = software_release_capacity_dict[software_release_url]
else:
software_release = portal.portal_catalog.getResultValue(
portal_type='Software Release',
url_string={'query': software_release_url, 'key': 'ExactMatch'})
if software_release is not None:
software_release_capacity = software_release.getCapacityQuantity(1)
else:
software_release_capacity = 1
software_release_capacity_dict[software_release_url] = software_release_capacity
consumed_capacity += software_release_capacity
if consumed_capacity >= computer_capacity_quantity:
can_allocate = False
comment = 'Computer capacity limit exceeded'
break
# if can_allocate:
# result_list = portal.portal_catalog.portal_catalog(
# parent_uid=computer.getUid(),
# portal_type='Computer Partition',
# free_for_request=1,
# limit=1)
# if len(result_list) == 0:
# can_allocate = False
# comment = 'No free partition left'
new_value = None
if can_allocate:
if computer.getCapacityScope() == 'close':
new_value = 'open'
else:
if computer.getCapacityScope() == 'open':
new_value = 'close'
if new_value is not None:
computer.edit(capacity_scope=new_value)
if comment:
portal.portal_workflow.doActionFor(computer, 'edit_action', comment=comment)
......@@ -48,119 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
import json\n
computer = context\n
portal = context.getPortalObject()\n
\n
if computer.getAllocationScope() != \'open/public\':\n
# Don\'t update non public computer\n
return\n
\n
can_allocate = True\n
comment = \'\'\n
\n
# First and simple way to see if computer is dead\n
# modification_date = portal.portal_workflow.getInfoFor(computer, \'time\', wf_id=\'edit_workflow\')\n
# if (DateTime() - modification_date) > 1:\n
# # Computer didn\'t talk to vifib for 1 days, do not consider it as a trustable public server for now\n
# # slapformat is supposed to run at least once per day\n
# can_allocate = False\n
# comment = "Computer didn\'t contact the server for more than one day"\n
\n
if can_allocate:\n
# Check if computer has error reported\n
memcached_dict = portal.portal_memcached.getMemcachedDict(\n
key_prefix=\'slap_tool\',\n
plugin_path=\'portal_memcached/default_memcached_plugin\')\n
try:\n
d = memcached_dict[computer.getReference()]\n
except KeyError:\n
can_allocate = False\n
comment = "Computer didn\'t contact the server"\n
else:\n
log_dict = json.loads(d)\n
if \'#error\' in log_dict.get(\'text\', \'#error\'):\n
can_allocate = False\n
comment = \'Computer reported an error\'\n
# XXX TODO: compare creation date of #ok message\n
elif int(DateTime()) - int(DateTime(log_dict.get(\'created_at\'))) > 600:\n
can_allocate = False\n
comment = "Computer didn\'t contact for more than 10 minutes"\n
\n
if can_allocate:\n
# Check the computer capacity.\n
# there is a arbitrary hardcoded default value: not more than 1000000 (!) instances on\n
# a computer.\n
default_maximum_value = 1000000\n
computer_capacity_quantity = computer.getCapacityQuantity(default_maximum_value)\n
if computer_capacity_quantity == default_maximum_value:\n
# Verify if Computer Model defines it:\n
computer_model = computer.getSpecialiseValue(portal_type=\'Computer Model\')\n
if computer_model is not None:\n
computer_capacity_quantity = computer_model.getCapacityQuantity(default_maximum_value)\n
\n
# The update the computer with the initial value.\n
if computer_capacity_quantity != default_maximum_value:\n
computer.edit(capacity_quantity=computer_capacity_quantity)\n
\n
software_release_capacity_dict = {}\n
consumed_capacity = 0\n
\n
for instance in portal.portal_catalog.portal_catalog(\n
default_aggregate_relative_url=\'%s/%%\' % computer.getRelativeUrl(),\n
portal_type=[\'Software Instance\', \'Slave Instance\'],\n
validation_state=\'validated\'):\n
\n
instance = instance.getObject()\n
\n
software_release_url = instance.getUrlString()\n
if software_release_url in software_release_capacity_dict:\n
software_release_capacity = software_release_capacity_dict[software_release_url]\n
else:\n
software_release = portal.portal_catalog.getResultValue(\n
portal_type=\'Software Release\',\n
url_string={\'query\': software_release_url, \'key\': \'ExactMatch\'})\n
if software_release is not None:\n
software_release_capacity = software_release.getCapacityQuantity(1)\n
else:\n
software_release_capacity = 1\n
software_release_capacity_dict[software_release_url] = software_release_capacity\n
consumed_capacity += software_release_capacity\n
if consumed_capacity >= computer_capacity_quantity:\n
can_allocate = False\n
comment = \'Computer capacity limit exceeded\'\n
break\n
\n
# if can_allocate:\n
# result_list = portal.portal_catalog.portal_catalog(\n
# parent_uid=computer.getUid(),\n
# portal_type=\'Computer Partition\',\n
# free_for_request=1,\n
# limit=1)\n
# if len(result_list) == 0:\n
# can_allocate = False\n
# comment = \'No free partition left\'\n
\n
new_value = None\n
if can_allocate:\n
if computer.getCapacityScope() == \'close\':\n
new_value = \'open\'\n
else:\n
if computer.getCapacityScope() == \'open\':\n
new_value = \'close\'\n
\n
if new_value is not None:\n
computer.edit(capacity_scope=new_value)\n
if comment:\n
portal.portal_workflow.doActionFor(computer, \'edit_action\', comment=comment)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
return [x for x in context.contentValues(**kw) if x.getSlapState() == 'busy']
......@@ -48,11 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return [x for x in context.contentValues(**kw) if x.getSlapState() == \'busy\']\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......
"""Fetch computer to find witch software is installed"""
portal = context.getPortalObject()
portal_type = "Software Release"
url_string_list = context.Computer_getSoftwareReleaseUrlStringList()
if url_string_list:
return context.portal_catalog(
portal_type=portal_type,
url_string=url_string_list)
else:
return []
......@@ -48,21 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""Fetch computer to find witch software is installed"""\n
portal = context.getPortalObject()\n
portal_type = "Software Release"\n
\n
url_string_list = context.Computer_getSoftwareReleaseUrlStringList()\n
if url_string_list:\n
return context.portal_catalog(\n
portal_type=portal_type,\n
url_string=url_string_list)\n
else:\n
return []\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......
computer = context
portal = context.getPortalObject()
software_installation_list = portal.portal_catalog(
portal_type='Software Installation',
default_aggregate_uid=context.getUid(),
validation_state='validated',
limit=1,
url_string={'query': portal.portal_catalog.getResultValue(uid=software_release_uid).getUrlString(), 'key': 'ExactMatch'},
sort_on=(('creation_date', 'DESC'),)
)
if len(software_installation_list) == 0:
return 'Destroyed'
software_installation = software_installation_list[0].getObject()
s = software_installation.getSlapState()
if s == 'start_requested':
return 'Installation requested'
else:
return 'Destruction requested'
......@@ -48,32 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>computer = context\n
portal = context.getPortalObject()\n
\n
software_installation_list = portal.portal_catalog(\n
portal_type=\'Software Installation\',\n
default_aggregate_uid=context.getUid(),\n
validation_state=\'validated\',\n
limit=1,\n
url_string={\'query\': portal.portal_catalog.getResultValue(uid=software_release_uid).getUrlString(), \'key\': \'ExactMatch\'},\n
sort_on=((\'creation_date\', \'DESC\'),)\n
)\n
\n
if len(software_installation_list) == 0:\n
return \'Destroyed\' \n
\n
software_installation = software_installation_list[0].getObject()\n
\n
s = software_installation.getSlapState()\n
if s == \'start_requested\':\n
return \'Installation requested\'\n
else:\n
return \'Destruction requested\'\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>software_release_uid</string> </value>
......
url_string_list = []
for software_installation in context.getPortalObject().portal_catalog(
portal_type='Software Installation',
validation_state='validated',
default_aggregate_uid=context.getUid()
):
if software_installation.getSlapState() == 'start_requested':
url_string = software_installation.getUrlString()
if url_string:
url_string_list.append(url_string)
return url_string_list
......@@ -48,21 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>url_string_list = []\n
for software_installation in context.getPortalObject().portal_catalog(\n
portal_type=\'Software Installation\',\n
validation_state=\'validated\',\n
default_aggregate_uid=context.getUid()\n
):\n
if software_installation.getSlapState() == \'start_requested\':\n
url_string = software_installation.getUrlString()\n
if url_string:\n
url_string_list.append(url_string)\n
return url_string_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery
portal = context.getPortalObject()
computer = context
return portal.portal_catalog.countResults(
portal_type='Computer Partition',
parent_uid=computer.getUid(),
free_for_request=0,
software_release_url=portal.portal_catalog.getResultValue(uid=software_release_uid).getUrlString()
)[0][0]
......@@ -48,21 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
portal = context.getPortalObject()\n
\n
computer = context\n
\n
return portal.portal_catalog.countResults(\n
portal_type=\'Computer Partition\',\n
parent_uid=computer.getUid(),\n
free_for_request=0,\n
software_release_url=portal.portal_catalog.getResultValue(uid=software_release_uid).getUrlString()\n
)[0][0]\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>software_release_uid</string> </value>
......
......@@ -48,11 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return context.absolute_url() + \'/Computer_viewCurrentUsage\'\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
......
if context.getPortalType() != 'Hosting Subscription' \
or context.getValidationState() != 'validated' \
or context.getSlapState() not in ['start_requested', 'stop_requested'] \
or context.getTitle() in context.getPredecessorTitleList():
# nothing to do
return
context.requestInstance(
software_release=context.getUrlString(),
software_title=context.getTitle(),
software_type=context.getSourceReference(),
instance_xml=context.getTextContent(),
sla_xml=context.getSlaXml(),
shared=context.isRootSlave(),
state={'start_requested': 'started', 'stop_requested': 'stopped'}[context.getSlapState()],
)
......@@ -48,26 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if context.getPortalType() != \'Hosting Subscription\' \\\n
or context.getValidationState() != \'validated\' \\\n
or context.getSlapState() not in [\'start_requested\', \'stop_requested\'] \\\n
or context.getTitle() in context.getPredecessorTitleList():\n
# nothing to do\n
return\n
\n
context.requestInstance(\n
software_release=context.getUrlString(),\n
software_title=context.getTitle(),\n
software_type=context.getSourceReference(),\n
instance_xml=context.getTextContent(),\n
sla_xml=context.getSlaXml(),\n
shared=context.isRootSlave(),\n
state={\'start_requested\': \'started\', \'stop_requested\': \'stopped\'}[context.getSlapState()],\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
instance = context
if (instance.getSlapState() != "destroy_requested"):
hosting_subscription = instance.getSpecialiseValue(portal_type="Hosting Subscription")
if (hosting_subscription.getValidationState() == "archived"):
# Buildout didn't propagate the destruction request
requester = instance.getPredecessorRelatedValue()
if (instance.getRelativeUrl() in requester.getPredecessorList()) and \
(requester.getSlapState() == "destroy_requested"):
# For security, only destroyed if parent is also destroyed
if instance.getPortalType() == 'Software Instance':
is_slave = False
elif instance.getPortalType() == 'Slave Instance':
is_slave = True
else:
raise NotImplementedError, "Unknown portal type %s of %s" % \
(instance.getPortalType(), instance.getRelativeUrl())
requester.requestInstance(
software_release=instance.getUrlString(),
software_title=instance.getTitle(),
software_type=instance.getSourceReference(),
instance_xml=instance.getTextContent(),
sla_xml=instance.getSlaXml(),
shared=is_slave,
state="destroyed",
comment="Garbage collect %s" % instance.getRelativeUrl()
)
......@@ -48,39 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>instance = context\n
\n
if (instance.getSlapState() != "destroy_requested"):\n
hosting_subscription = instance.getSpecialiseValue(portal_type="Hosting Subscription")\n
if (hosting_subscription.getValidationState() == "archived"):\n
# Buildout didn\'t propagate the destruction request\n
requester = instance.getPredecessorRelatedValue()\n
if (instance.getRelativeUrl() in requester.getPredecessorList()) and \\\n
(requester.getSlapState() == "destroy_requested"):\n
# For security, only destroyed if parent is also destroyed\n
\n
if instance.getPortalType() == \'Software Instance\':\n
is_slave = False\n
elif instance.getPortalType() == \'Slave Instance\':\n
is_slave = True\n
else:\n
raise NotImplementedError, "Unknown portal type %s of %s" % \\\n
(instance.getPortalType(), instance.getRelativeUrl())\n
\n
requester.requestInstance(\n
software_release=instance.getUrlString(),\n
software_title=instance.getTitle(),\n
software_type=instance.getSourceReference(),\n
instance_xml=instance.getTextContent(),\n
sla_xml=instance.getSlaXml(),\n
shared=is_slave,\n
state="destroyed",\n
comment="Garbage collect %s" % instance.getRelativeUrl()\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
instance = context
portal = context.getPortalObject()
if instance.getValidationState() != 'validated' \
or instance.getSlapState() not in ('start_requested', 'stop_requested') \
or instance.getAggregateValue(portal_type='Computer Partition') is not None:
return
latest_comment = portal.portal_workflow.getInfoFor(instance, 'comment', wf_id='edit_workflow')
if latest_comment != 'Allocation failed: no free Computer Partition':
# No nothing if allocation alarm didn't run on it
return
latest_edit_time = portal.portal_workflow.getInfoFor(instance, 'time', wf_id='edit_workflow')
if (int(DateTime()) - int(latest_edit_time)) < 259200:
# Allow 3 days gap betweeb latest allocation try and deletion
return
# Only destroy if the instance is the only one in the tree
hosting_subscription = instance.getSpecialiseValue("Hosting Subscription")
if (hosting_subscription.getPredecessor() != instance.getRelativeUrl()):
return
if (len(hosting_subscription.getPredecessorList()) != 1):
return
instance_list = portal.portal_catalog(
portal_type=["Software Instance", "Slave Instance"],
default_specialise_uid=hosting_subscription.getUid(),
limit=2)
if len(instance_list) != 1:
return
# OK, destroy hosting subscription
hosting_subscription.requestDestroy(
software_release=hosting_subscription.getUrlString(),
software_title=hosting_subscription.getTitle(),
software_type=hosting_subscription.getSourceReference(),
instance_xml=hosting_subscription.getTextContent(),
sla_xml=hosting_subscription.getSlaXml(),
shared=hosting_subscription.isRootSlave(),
state='destroyed',
comment="Garbage collect %s not allocated for more than 3 days" % instance.getRelativeUrl(),
)
hosting_subscription.archive()
......@@ -48,61 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
instance = context\n
portal = context.getPortalObject()\n
\n
if instance.getValidationState() != \'validated\' \\\n
or instance.getSlapState() not in (\'start_requested\', \'stop_requested\') \\\n
or instance.getAggregateValue(portal_type=\'Computer Partition\') is not None:\n
return\n
\n
latest_comment = portal.portal_workflow.getInfoFor(instance, \'comment\', wf_id=\'edit_workflow\')\n
if latest_comment != \'Allocation failed: no free Computer Partition\':\n
# No nothing if allocation alarm didn\'t run on it\n
return\n
\n
latest_edit_time = portal.portal_workflow.getInfoFor(instance, \'time\', wf_id=\'edit_workflow\')\n
if (int(DateTime()) - int(latest_edit_time)) < 259200:\n
# Allow 3 days gap betweeb latest allocation try and deletion\n
return\n
\n
# Only destroy if the instance is the only one in the tree\n
hosting_subscription = instance.getSpecialiseValue("Hosting Subscription")\n
if (hosting_subscription.getPredecessor() != instance.getRelativeUrl()):\n
return\n
if (len(hosting_subscription.getPredecessorList()) != 1):\n
return\n
instance_list = portal.portal_catalog(\n
portal_type=["Software Instance", "Slave Instance"],\n
default_specialise_uid=hosting_subscription.getUid(),\n
limit=2)\n
if len(instance_list) != 1:\n
return\n
\n
# OK, destroy hosting subscription\n
hosting_subscription.requestDestroy(\n
software_release=hosting_subscription.getUrlString(),\n
software_title=hosting_subscription.getTitle(),\n
software_type=hosting_subscription.getSourceReference(),\n
instance_xml=hosting_subscription.getTextContent(),\n
sla_xml=hosting_subscription.getSlaXml(),\n
shared=hosting_subscription.isRootSlave(),\n
state=\'destroyed\',\n
comment="Garbage collect %s not allocated for more than 3 days" % instance.getRelativeUrl(),\n
)\n
hosting_subscription.archive()\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
instance = context
if (instance.getSlapState() == "start_requested"):
hosting_subscription = instance.getSpecialiseValue(portal_type="Hosting Subscription")
if (hosting_subscription.getSlapState() == "stop_requested"):
# Buildout may not propagate the stop request
requester = instance.getPredecessorRelatedValue()
if (instance.getRelativeUrl() in requester.getPredecessorList()) and \
(requester.getSlapState() == "stop_requested"):
# For security, only stop if parent is also stopped
if instance.getPortalType() == 'Software Instance':
is_slave = False
elif instance.getPortalType() == 'Slave Instance':
is_slave = True
else:
raise NotImplementedError, "Unknown portal type %s of %s" % \
(instance.getPortalType(), instance.getRelativeUrl())
requester.requestInstance(
software_release=instance.getUrlString(),
software_title=instance.getTitle(),
software_type=instance.getSourceReference(),
instance_xml=instance.getTextContent(),
sla_xml=instance.getSlaXml(),
shared=is_slave,
state="stopped",
comment="Stop collect %s" % instance.getRelativeUrl()
)
......@@ -48,43 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
instance = context\n
\n
if (instance.getSlapState() == "start_requested"):\n
hosting_subscription = instance.getSpecialiseValue(portal_type="Hosting Subscription")\n
if (hosting_subscription.getSlapState() == "stop_requested"):\n
# Buildout may not propagate the stop request\n
requester = instance.getPredecessorRelatedValue()\n
if (instance.getRelativeUrl() in requester.getPredecessorList()) and \\\n
(requester.getSlapState() == "stop_requested"):\n
# For security, only stop if parent is also stopped\n
\n
if instance.getPortalType() == \'Software Instance\':\n
is_slave = False\n
elif instance.getPortalType() == \'Slave Instance\':\n
is_slave = True\n
else:\n
raise NotImplementedError, "Unknown portal type %s of %s" % \\\n
(instance.getPortalType(), instance.getRelativeUrl())\n
\n
requester.requestInstance(\n
software_release=instance.getUrlString(),\n
software_title=instance.getTitle(),\n
software_type=instance.getSourceReference(),\n
instance_xml=instance.getTextContent(),\n
sla_xml=instance.getSlaXml(),\n
shared=is_slave,\n
state="stopped",\n
comment="Stop collect %s" % instance.getRelativeUrl()\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment