Commit 342718e6 authored by Alain Takoudjou's avatar Alain Takoudjou

migrate business template to new format

parent 52d66594
"""
For all software releases, upgrade the Average CPU and Memory Capacity
"""
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Software Release",
method_id="SotftwareRelease_updateCapacityQuantity",
)
......@@ -48,20 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
For all software releases, upgrade the Average CPU and Memory Capacity\n
"""\n
\n
portal = context.getPortalObject()\n
\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Software Release",\n
method_id="SotftwareRelease_updateCapacityQuantity",\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
from zExceptions import Unauthorized
if REQUEST is not None:
pass #raise Unauthorized
document = context
portal = document.getPortalObject()
result = []
tioxml_dict = document.ComputerConsumptionTioXMLFile_parseXml()
if tioxml_dict is None:
document.reject(comment="Not usable TioXML data")
else:
packing_list_dict = {}
for movement_dict in tioxml_dict["movement"]:
reference = movement_dict['reference']
if reference in packing_list_dict:
packing_list_dict[reference].append(movement_dict)
else:
packing_list_dict[reference] = [movement_dict]
computer = context.getContributorValue(portal_type="Computer")
for reference, movement_list in packing_list_dict.items():
# Time to create the PL
delivery_template = portal.restrictedTraverse(
portal.portal_preferences.getPreferredInstanceDeliveryTemplate())
delivery = delivery_template.Base_createCloneDocument(batch_mode=1)
# It had been reported for the computer itself so it is pure
# informative.
if computer.getReference() == reference:
person = computer.getSourceAdministrationValue(portal_type="Person")
aggregate_value_list = [computer]
delivery_title = "%s Information Report" % computer.getReference()
else:
if reference.startswith("slapuser"):
reference = reference.replace("slapuser", "slappart")
# Find the partition / software instance / user
partition = portal.portal_catalog.getResultValue(
parent_uid=computer.getUid(),
reference=reference,
portal_type="Computer Partition",
validation_state="validated")
assert partition.getSlapState() == 'busy'
instance = portal.portal_catalog.getResultValue(
default_aggregate_uid=partition.getUid(),
portal_type="Software Instance",
validation_state="validated")
subscription = instance.getSpecialiseValue(
portal_type="Hosting Subscription")
person = subscription.getDestinationSectionValue(
portal_type="Person")
aggregate_value_list = [partition, instance, subscription]
delivery_title = "%s Consumption Usage" % instance.getReference()
delivery.edit(
title=delivery_title,
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
start_date=context.getCreationDate(),
)
result.append(delivery.getRelativeUrl())
for movement in movement_list:
service = portal.restrictedTraverse(movement['resource'])
delivery.newContent(
portal_type="Sale Packing List Line",
title=movement['title'],
quantity=movement['quantity'],
aggregate_value_list=aggregate_value_list,
resource_value=service,
quantity_unit=service.getQuantityUnit(),
)
delivery.confirm(comment="Created from %s" % context.getRelativeUrl())
delivery.start()
delivery.stop()
delivery.deliver()
delivery.startBuilding()
document.share(comment="Created packing list: %s" % result)
return result
......@@ -48,97 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
pass #raise Unauthorized\n
\n
document = context\n
portal = document.getPortalObject()\n
result = []\n
\n
tioxml_dict = document.ComputerConsumptionTioXMLFile_parseXml()\n
if tioxml_dict is None:\n
document.reject(comment="Not usable TioXML data")\n
else:\n
packing_list_dict = {}\n
for movement_dict in tioxml_dict["movement"]:\n
reference = movement_dict[\'reference\']\n
if reference in packing_list_dict:\n
packing_list_dict[reference].append(movement_dict)\n
else:\n
packing_list_dict[reference] = [movement_dict]\n
\n
computer = context.getContributorValue(portal_type="Computer")\n
for reference, movement_list in packing_list_dict.items():\n
\n
# Time to create the PL\n
delivery_template = portal.restrictedTraverse(\n
portal.portal_preferences.getPreferredInstanceDeliveryTemplate())\n
delivery = delivery_template.Base_createCloneDocument(batch_mode=1)\n
\n
# It had been reported for the computer itself so it is pure\n
# informative.\n
if computer.getReference() == reference:\n
person = computer.getSourceAdministrationValue(portal_type="Person")\n
aggregate_value_list = [computer]\n
delivery_title = "%s Information Report" % computer.getReference()\n
else:\n
if reference.startswith("slapuser"):\n
reference = reference.replace("slapuser", "slappart") \n
# Find the partition / software instance / user\n
partition = portal.portal_catalog.getResultValue(\n
parent_uid=computer.getUid(),\n
reference=reference,\n
portal_type="Computer Partition",\n
validation_state="validated")\n
assert partition.getSlapState() == \'busy\'\n
\n
instance = portal.portal_catalog.getResultValue(\n
default_aggregate_uid=partition.getUid(),\n
portal_type="Software Instance",\n
validation_state="validated")\n
\n
subscription = instance.getSpecialiseValue(\n
portal_type="Hosting Subscription")\n
\n
person = subscription.getDestinationSectionValue(\n
portal_type="Person")\n
\n
aggregate_value_list = [partition, instance, subscription]\n
delivery_title = "%s Consumption Usage" % instance.getReference()\n
\n
delivery.edit(\n
title=delivery_title,\n
destination=person.getRelativeUrl(),\n
destination_decision=person.getRelativeUrl(),\n
start_date=context.getCreationDate(),\n
)\n
\n
result.append(delivery.getRelativeUrl())\n
\n
for movement in movement_list:\n
service = portal.restrictedTraverse(movement[\'resource\'])\n
delivery.newContent(\n
portal_type="Sale Packing List Line",\n
title=movement[\'title\'],\n
quantity=movement[\'quantity\'],\n
aggregate_value_list=aggregate_value_list,\n
resource_value=service,\n
quantity_unit=service.getQuantityUnit(),\n
)\n
delivery.confirm(comment="Created from %s" % context.getRelativeUrl())\n
delivery.start()\n
delivery.stop()\n
delivery.deliver()\n
delivery.startBuilding()\n
\n
document.share(comment="Created packing list: %s" % result)\n
\n
return result\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
if REQUEST is not None:
raise Unauthorized("Unauthorized call script from URL")
portal = context.getPortalObject()
packing_list_line = portal.portal_catalog.getResultValue(
sort_on=("creation_date", "DESC"),
portal_type="Sale Packing List Line",
default_resource_uid = context.service_module.cpu_load_percent.getUid(),
default_aggregate_uid=context.getUid())
if packing_list_line is not None:
return packing_list_line.getQuantity()
return 0.0
......@@ -48,25 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST is not None:\n
raise Unauthorized("Unauthorized call script from URL")\n
\n
portal = context.getPortalObject()\n
\n
packing_list_line = portal.portal_catalog.getResultValue(\n
sort_on=("creation_date", "DESC"),\n
portal_type="Sale Packing List Line",\n
default_resource_uid = context.service_module.cpu_load_percent.getUid(),\n
default_aggregate_uid=context.getUid())\n
\n
if packing_list_line is not None:\n
return packing_list_line.getQuantity()\n
\n
return 0.0\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
if REQUEST is not None:
raise Unauthorized("Unauthorized call script from URL")
model_id = context.getWattConsumptionModel("no_model")
######
# Introduce your Consumption Model here
######
def consumption_model_shuttle_ds61_i7(load):
""" Expected consumed watts for the computer load
"""
if load <= 25:
return 21.5 + 1.06*load
else:
return 48 + 0.29*load
def consumption_model_shuttle_nuc_i7(load):
""" Expected consumed watts for the computer load
"""
if load <= 25:
return 8.5 + 0.46*load
else:
return 20 + 0.08*load
def consumption_model_rikomagic_mk802iv(load):
""" Expected consumed watts for the computer load
"""
if load <= 25:
return 2.2 + 0.04*load
else:
return 3.2 + 0.008*load
def no_model(load):
return 0
model_map = {
"shuttle_ds61_i7" : consumption_model_shuttle_ds61_i7,
"rikomagic_mk802iv": consumption_model_rikomagic_mk802iv,
"intel_nuc_i7": consumption_model_shuttle_nuc_i7
}
if cpu_load_percentage is None:
cpu_load_percentage = context.Computer_getLatestCPUPercentLoad()
cpu_load_percentage += partition_increment
return model_map.get(model_id, no_model)(cpu_load_percentage)
......@@ -48,60 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
if REQUEST is not None:\n
raise Unauthorized("Unauthorized call script from URL")\n
\n
model_id = context.getWattConsumptionModel("no_model")\n
\n
######\n
# Introduce your Consumption Model here\n
######\n
def consumption_model_shuttle_ds61_i7(load):\n
""" Expected consumed watts for the computer load\n
"""\n
if load <= 25:\n
return 21.5 + 1.06*load\n
else:\n
return 48 + 0.29*load\n
\n
def consumption_model_shuttle_nuc_i7(load):\n
""" Expected consumed watts for the computer load\n
"""\n
if load <= 25:\n
return 8.5 + 0.46*load\n
else:\n
return 20 + 0.08*load\n
\n
def consumption_model_rikomagic_mk802iv(load):\n
""" Expected consumed watts for the computer load\n
"""\n
if load <= 25:\n
return 2.2 + 0.04*load\n
else:\n
return 3.2 + 0.008*load\n
\n
def no_model(load):\n
return 0\n
\n
model_map = {\n
"shuttle_ds61_i7" : consumption_model_shuttle_ds61_i7,\n
"rikomagic_mk802iv": consumption_model_rikomagic_mk802iv,\n
"intel_nuc_i7": consumption_model_shuttle_nuc_i7\n
}\n
if cpu_load_percentage is None:\n
cpu_load_percentage = context.Computer_getLatestCPUPercentLoad()\n
\n
cpu_load_percentage += partition_increment\n
\n
return model_map.get(model_id, no_model)(cpu_load_percentage)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>cpu_load_percentage=None, partition_increment=0, REQUEST=None</string> </value>
......
if REQUEST is not None:
raise Unauthorized("Unauthorized call script from URL")
portal = context.getPortalObject()
resource_uid = context.service_module.zero_emission_ratio.getUid()
packing_list_line_list = portal.portal_catalog(
limit=1,
sort_on=("creation_date", "DESC"),
portal_type="Sale Packing List Line",
default_resource_uid = resource_uid,
default_aggregate_uid=context.getUid())
if len(packing_list_line_list):
quantity = packing_list_line_list[0].getQuantity()
if quantity > 0:
return quantity
return 0.0
......@@ -48,34 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
if REQUEST is not None:\n
raise Unauthorized("Unauthorized call script from URL")\n
\n
portal = context.getPortalObject()\n
\n
resource_uid = context.service_module.zero_emission_ratio.getUid()\n
\n
packing_list_line_list = portal.portal_catalog(\n
limit=1,\n
sort_on=("creation_date", "DESC"),\n
portal_type="Sale Packing List Line",\n
default_resource_uid = resource_uid,\n
default_aggregate_uid=context.getUid())\n
\n
if len(packing_list_line_list):\n
quantity = packing_list_line_list[0].getQuantity()\n
if quantity > 0:\n
return quantity\n
\n
return 0.0\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
portal = context.getPortalObject()
computer = context
reference = "TIOCONS-%s-%s" % (computer.getReference(), source_reference)
version = "%s" % context.getPortalObject().portal_ids.generateNewId(
id_group=('slap_tioxml_consumption_reference', reference), default=1)
document = portal.consumption_document_module.newContent(
portal_type="Computer Consumption TioXML File",
source_reference=source_reference,
title="%s consumption (%s)" % (computer.getReference(), source_reference),
reference=reference,
version=version,
data=consumption_xml,
classification="personal",
publication_section="other",
contributor_value=computer,
)
document.submit()
return document.getRelativeUrl()
......@@ -48,34 +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
portal = context.getPortalObject()\n
computer = context\n
\n
reference = "TIOCONS-%s-%s" % (computer.getReference(), source_reference)\n
version = "%s" % context.getPortalObject().portal_ids.generateNewId(\n
id_group=(\'slap_tioxml_consumption_reference\', reference), default=1)\n
\n
document = portal.consumption_document_module.newContent(\n
portal_type="Computer Consumption TioXML File",\n
source_reference=source_reference,\n
title="%s consumption (%s)" % (computer.getReference(), source_reference),\n
reference=reference,\n
version=version,\n
data=consumption_xml,\n
classification="personal",\n
publication_section="other",\n
contributor_value=computer,\n
)\n
document.submit()\n
return document.getRelativeUrl()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>source_reference, consumption_xml, REQUEST=None</string> </value>
......
instance, delta_co2 = context.HostingSubscription_getMostEcoEfficientSoftwareInstance()
if instance is None:
return None
master_node = instance.SoftwareInstance_getResilientMasterNode()
if master_node is None:
return None
if instance.getRelativeUrl() != master_node.getRelativeUrl():
master_delta_co2 = master_node.SoftwareInstance_getFutureDeltaCO2()
saving_ratio = (master_delta_co2-delta_co2)/master_delta_co2
return "Improve Power efficiency in %s%% by using %s instance as Main Node. We recommend you to a take over." % (int(saving_ratio*100), instance.getTitle())
return None
......@@ -48,27 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>instance, delta_co2 = context.HostingSubscription_getMostEcoEfficientSoftwareInstance()\n
\n
if instance is None:\n
return None \n
\n
master_node = instance.SoftwareInstance_getResilientMasterNode()\n
\n
if master_node is None:\n
return None \n
\n
if instance.getRelativeUrl() != master_node.getRelativeUrl():\n
master_delta_co2 = master_node.SoftwareInstance_getFutureDeltaCO2()\n
saving_ratio = (master_delta_co2-delta_co2)/master_delta_co2\n
return "Improve Power efficiency in %s%% by using %s instance as Main Node. We recommend you to a take over." % (int(saving_ratio*100), instance.getTitle())\n
\n
\n
return None\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
partition_co2_dict = {}
min_delta_co2 = 2000
minimal_candidate = None
for software_instance in context.getSpecialiseRelatedValueList(portal_type="Software Instance"):
delta_co2 = software_instance.SoftwareInstance_getFutureDeltaCO2()
if delta_co2 != "Not Applicable":
if delta_co2 < min_delta_co2:
minimal_candidate = software_instance
min_delta_co2 = delta_co2
elif (delta_co2 == min_delta_co2) and \
(software_instance.getTitle() in ["kvm0", "runner0"]):
minimal_candidate = software_instance
return minimal_candidate, min_delta_co2
......@@ -48,29 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
partition_co2_dict = {}\n
min_delta_co2 = 2000\n
minimal_candidate = None\n
\n
for software_instance in context.getSpecialiseRelatedValueList(portal_type="Software Instance"):\n
delta_co2 = software_instance.SoftwareInstance_getFutureDeltaCO2() \n
if delta_co2 != "Not Applicable":\n
if delta_co2 < min_delta_co2:\n
minimal_candidate = software_instance\n
min_delta_co2 = delta_co2\n
elif (delta_co2 == min_delta_co2) and \\\n
(software_instance.getTitle() in ["kvm0", "runner0"]):\n
minimal_candidate = software_instance\n
\n
return minimal_candidate, min_delta_co2\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
import random
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
person = context
computer_partition = None
query_kw = {
'software_release_url': software_release_url,
'portal_type': 'Computer Partition',
}
if software_instance_portal_type == "Slave Instance":
query_kw['free_for_request'] = 0
query_kw['software_type'] = software_type
elif software_instance_portal_type == "Software Instance":
query_kw['free_for_request'] = 1
else:
raise NotImplementedError("Unknown portal type %s"%
software_instance_portal_type)
# support SLA
# Explicit location
explicit_location = False
if "computer_guid" in filter_kw:
explicit_location = True
query_kw["parent_reference"] = SimpleQuery(parent_reference=filter_kw.pop("computer_guid"))
if "instance_guid" in filter_kw:
explicit_location = True
portal = context.getPortalObject()
instance_guid = filter_kw.pop("instance_guid")
query_kw["aggregate_related_reference"] = SimpleQuery(aggregate_related_reference=instance_guid)
if 'network_guid' in filter_kw:
network_guid = filter_kw.pop('network_guid')
query_kw["default_subordination_reference"] = SimpleQuery(default_subordination_reference=network_guid)
if computer_network_query:
if query_kw.get("default_subordination_reference"):
query_kw["default_subordination_reference"] = ComplexQuery(
query_kw["default_subordination_reference"],
computer_network_query
)
else:
query_kw["default_subordination_reference"] = computer_network_query
if "retention_delay" in filter_kw:
filter_kw.pop("retention_delay")
computer_base_category_list = [
'group',
'cpu_core',
'cpu_frequency',
'cpu_type',
'local_area_network_type',
'region',
'memory_size',
'memory_type',
'storage_capacity',
'storage_interface',
'storage_redundancy',
]
for base_category in computer_base_category_list:
if base_category in filter_kw:
category_relative_url = "%s" % filter_kw.pop(base_category)
# XXX Small protection to prevent entering strange strings
category = context.getPortalObject().portal_categories[base_category].restrictedTraverse(str(category_relative_url), None)
if category is None:
query_kw["uid"] = "-1"
else:
query_kw["%s_uid" % base_category] = category.getUid()
query_kw["capacity_scope_uid"] = context.getPortalObject().portal_categories.capacity_scope.open.getUid()
# if not explicit_location:
# # Only allocation on public computer
# query_kw["allocation_scope_uid"] = context.getPortalObject().portal_categories.allocation_scope.open.public.getUid()
if filter_kw.keys():
# XXX Drop all unexpected keys
query_kw["uid"] = "-1"
if test_mode:
return bool(len(context.portal_catalog(limit=1, **query_kw)))
# Get only one computer_partition per computer
computer_partition_list = context.portal_catalog(group_by="parent_uid", **query_kw)
software_release_list = context.portal_catalog(
portal_type="Software Release",
url_string=software_release_url
)
if len(software_release_list) == 0:
# Forbid to allocate partitions without an existing Software Release Document.
raise KeyError(len(software_release_list))
delta_co2_contribution_list = software_release_list[0].SoftwareRelease_getDeltaCO2List(computer_partition_list)
isTransitionPossible = context.getPortalObject().portal_workflow.isTransitionPossible
while len(delta_co2_contribution_list):
partition_candidate_list = delta_co2_contribution_list.pop(min(delta_co2_contribution_list))
for computer_partition_candidate in partition_candidate_list:
computer_partition_candidate = computer_partition_candidate.getObject()
if software_instance_portal_type == "Software Instance":
# Check if the computer partition can be marked as busy
if isTransitionPossible(computer_partition_candidate, 'mark_busy'):
computer_partition = computer_partition_candidate
computer_partition.markBusy()
break
elif computer_partition_candidate.getSlapState() == "busy":
# Only assign slave instance on busy partition
computer_partition = computer_partition_candidate
break
if computer_partition is None:
raise ValueError('It was not possible to find free Computer Partition')
# lock computer partition
computer_partition.serialize()
return computer_partition.getRelativeUrl()
......@@ -48,132 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>import random\n
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery\n
person = context\n
\n
computer_partition = None\n
query_kw = {\n
\'software_release_url\': software_release_url,\n
\'portal_type\': \'Computer Partition\',\n
}\n
if software_instance_portal_type == "Slave Instance":\n
query_kw[\'free_for_request\'] = 0\n
query_kw[\'software_type\'] = software_type\n
elif software_instance_portal_type == "Software Instance":\n
query_kw[\'free_for_request\'] = 1\n
else:\n
raise NotImplementedError("Unknown portal type %s"%\n
software_instance_portal_type)\n
\n
# support SLA\n
\n
# Explicit location\n
explicit_location = False\n
if "computer_guid" in filter_kw:\n
explicit_location = True\n
query_kw["parent_reference"] = SimpleQuery(parent_reference=filter_kw.pop("computer_guid"))\n
\n
if "instance_guid" in filter_kw:\n
explicit_location = True\n
portal = context.getPortalObject()\n
instance_guid = filter_kw.pop("instance_guid")\n
query_kw["aggregate_related_reference"] = SimpleQuery(aggregate_related_reference=instance_guid)\n
\n
if \'network_guid\' in filter_kw:\n
network_guid = filter_kw.pop(\'network_guid\')\n
query_kw["default_subordination_reference"] = SimpleQuery(default_subordination_reference=network_guid)\n
\n
if computer_network_query:\n
if query_kw.get("default_subordination_reference"):\n
query_kw["default_subordination_reference"] = ComplexQuery(\n
query_kw["default_subordination_reference"],\n
computer_network_query\n
)\n
else:\n
query_kw["default_subordination_reference"] = computer_network_query\n
\n
if "retention_delay" in filter_kw:\n
filter_kw.pop("retention_delay")\n
\n
computer_base_category_list = [\n
\'group\',\n
\'cpu_core\',\n
\'cpu_frequency\',\n
\'cpu_type\',\n
\'local_area_network_type\',\n
\'region\',\n
\'memory_size\',\n
\'memory_type\',\n
\'storage_capacity\',\n
\'storage_interface\',\n
\'storage_redundancy\',\n
]\n
for base_category in computer_base_category_list:\n
if base_category in filter_kw:\n
category_relative_url = "%s" % filter_kw.pop(base_category)\n
# XXX Small protection to prevent entering strange strings\n
category = context.getPortalObject().portal_categories[base_category].restrictedTraverse(str(category_relative_url), None)\n
if category is None:\n
query_kw["uid"] = "-1"\n
else:\n
query_kw["%s_uid" % base_category] = category.getUid()\n
\n
query_kw["capacity_scope_uid"] = context.getPortalObject().portal_categories.capacity_scope.open.getUid()\n
# if not explicit_location:\n
# # Only allocation on public computer\n
# query_kw["allocation_scope_uid"] = context.getPortalObject().portal_categories.allocation_scope.open.public.getUid()\n
\n
if filter_kw.keys():\n
# XXX Drop all unexpected keys\n
query_kw["uid"] = "-1"\n
\n
if test_mode:\n
return bool(len(context.portal_catalog(limit=1, **query_kw)))\n
\n
# Get only one computer_partition per computer\n
computer_partition_list = context.portal_catalog(group_by="parent_uid", **query_kw)\n
\n
software_release_list = context.portal_catalog(\n
portal_type="Software Release",\n
url_string=software_release_url\n
) \n
\n
if len(software_release_list) == 0:\n
# Forbid to allocate partitions without an existing Software Release Document.\n
raise KeyError(len(software_release_list))\n
\n
delta_co2_contribution_list = software_release_list[0].SoftwareRelease_getDeltaCO2List(computer_partition_list)\n
\n
isTransitionPossible = context.getPortalObject().portal_workflow.isTransitionPossible\n
\n
while len(delta_co2_contribution_list):\n
partition_candidate_list = delta_co2_contribution_list.pop(min(delta_co2_contribution_list))\n
\n
for computer_partition_candidate in partition_candidate_list:\n
computer_partition_candidate = computer_partition_candidate.getObject()\n
if software_instance_portal_type == "Software Instance":\n
# Check if the computer partition can be marked as busy\n
if isTransitionPossible(computer_partition_candidate, \'mark_busy\'):\n
computer_partition = computer_partition_candidate\n
computer_partition.markBusy()\n
break\n
elif computer_partition_candidate.getSlapState() == "busy":\n
# Only assign slave instance on busy partition\n
computer_partition = computer_partition_candidate\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
\n
return computer_partition.getRelativeUrl()\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>
......
portal = context.getPortalObject()
software_release_url = context.getUrlString()
resource_uid = context.service_module.cpu_load_percent.getUid()
# Select all software instances from a certain Software Release
packing_list_line_list = portal.portal_catalog(
limit=20,
sort_on=("creation_date", "DESC"),
portal_type="Sale Packing List Line",
default_resource_uid = resource_uid,
default_aggregate_uid=[context.getUid()]
)
if len(packing_list_line_list):
# Remove the /8 and update the value on the clients.
return sum([i.getQuantity() for i in packing_list_line_list])/len(packing_list_line_list)
return 0.0
......@@ -48,30 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
software_release_url = context.getUrlString()\n
\n
resource_uid = context.service_module.cpu_load_percent.getUid()\n
\n
# Select all software instances from a certain Software Release\n
packing_list_line_list = portal.portal_catalog(\n
limit=20,\n
sort_on=("creation_date", "DESC"),\n
portal_type="Sale Packing List Line",\n
default_resource_uid = resource_uid,\n
default_aggregate_uid=[context.getUid()]\n
)\n
\n
if len(packing_list_line_list):\n
# Remove the /8 and update the value on the clients.\n
return sum([i.getQuantity() for i in packing_list_line_list])/len(packing_list_line_list)\n
\n
return 0.0\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
if REQUEST is not None:
raise Unauthorized
computer_partition_list = context.getAggregateValueList(portal_type="Computer Partition")
current_watt = context.SoftwareRelease_getDeltaCO2List(
computer_partition_list, context.SoftwareInstance_getAverageCPULoad()
)
return current_watt.keys()[0]
......@@ -48,20 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST is not None:\n
raise Unauthorized\n
\n
computer_partition_list = context.getAggregateValueList(portal_type="Computer Partition")\n
\n
current_watt = context.SoftwareRelease_getDeltaCO2List(\n
computer_partition_list, context.SoftwareInstance_getAverageCPULoad()\n
)\n
\n
return current_watt.keys()[0]\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
if REQUEST is not None:
raise Unauthorized
computer_partition_list = context.getAggregateValueList(portal_type="Computer Partition")
future_watt = "Not Applicable"
master_node = context.SoftwareInstance_getResilientMasterNode()
if master_node is not None:
future_watt = context.SoftwareRelease_getDeltaCO2List(
computer_partition_list, master_node.SoftwareInstance_getAverageCPULoad()
)
future_watt = future_watt.keys()[0]
return future_watt
......@@ -48,25 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST is not None:\n
raise Unauthorized\n
\n
computer_partition_list = context.getAggregateValueList(portal_type="Computer Partition")\n
\n
future_watt = "Not Applicable"\n
\n
master_node = context.SoftwareInstance_getResilientMasterNode()\n
if master_node is not None:\n
future_watt = context.SoftwareRelease_getDeltaCO2List(\n
computer_partition_list, master_node.SoftwareInstance_getAverageCPULoad()\n
)\n
future_watt = future_watt.keys()[0]\n
\n
return future_watt\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
portal = context.getPortalObject()
packing_list_line = portal.portal_catalog.getResultValue(
sort_on=("creation_date", "DESC"),
portal_type="Sale Packing List Line",
default_resource_uid = context.service_module.cpu_load_percent.getUid(),
default_aggregate_uid=context.getUid())
if packing_list_line is not None:
return packing_list_line.getQuantity()
return 0.0
......@@ -48,22 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
packing_list_line = portal.portal_catalog.getResultValue(\n
sort_on=("creation_date", "DESC"),\n
portal_type="Sale Packing List Line",\n
default_resource_uid = context.service_module.cpu_load_percent.getUid(),\n
default_aggregate_uid=context.getUid())\n
\n
if packing_list_line is not None:\n
return packing_list_line.getQuantity()\n
\n
return 0.0\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
"""
This script may contains specific prototyping code for
get master done for resilience.
"""
title = context.getTitle()
if not (title.startswith("kvm") or title.startswith("runner")):
# This instance is not a clone from resilience
return None
hosting_subscription = context.getSpecialiseValue()
for instance in hosting_subscription.getSpecialiseRelatedValueList(
portal_type="Software Instance"):
if instance.getTitle() in ["kvm0", "runner0"]:
return instance
return None
......@@ -48,29 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
This script may contains specific prototyping code for \n
get master done for resilience.\n
"""\n
\n
title = context.getTitle()\n
\n
if not (title.startswith("kvm") or title.startswith("runner")):\n
# This instance is not a clone from resilience\n
return None \n
\n
hosting_subscription = context.getSpecialiseValue()\n
\n
for instance in hosting_subscription.getSpecialiseRelatedValueList(\n
portal_type="Software Instance"):\n
if instance.getTitle() in ["kvm0", "runner0"]:\n
return instance\n
\n
return None\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
computer_partition_list = context.getAggregateValueList(portal_type="Computer Partition")
master_node = context.SoftwareInstance_getResilientMasterNode()
current_watt = context.SoftwareRelease_getDeltaCO2List(
computer_partition_list, context.SoftwareInstance_getAverageCPULoad()
)
current_watt = current_watt.keys()
master_node = context.SoftwareInstance_getResilientMasterNode()
if master_node is not None:
future_watt = context.SoftwareRelease_getDeltaCO2List(
computer_partition_list, master_node.SoftwareInstance_getAverageCPULoad()
)
future_watt = future_watt.keys()[0]
return current_watt, future_watt
......@@ -48,27 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>computer_partition_list = context.getAggregateValueList(portal_type="Computer Partition")\n
\n
master_node = context.SoftwareInstance_getResilientMasterNode()\n
\n
current_watt = context.SoftwareRelease_getDeltaCO2List(\n
computer_partition_list, context.SoftwareInstance_getAverageCPULoad()\n
)\n
current_watt = current_watt.keys()\n
\n
master_node = context.SoftwareInstance_getResilientMasterNode()\n
if master_node is not None:\n
future_watt = context.SoftwareRelease_getDeltaCO2List(\n
computer_partition_list, master_node.SoftwareInstance_getAverageCPULoad()\n
)\n
future_watt = future_watt.keys()[0]\n
\n
return current_watt, future_watt\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
portal = context.getPortalObject()
software_release_url = context.getUrlString()
resource_uid = context.service_module.cpu_load_percent.getUid()
# Select all software instances from a certain Software Release
software_instance_list = portal.portal_catalog(
portal_type="Software Instance",
limit=100,
url_string=software_release_url)
packing_list_line_list = portal.portal_catalog(
limit=100,
sort_on=("creation_date", "DESC"),
portal_type="Sale Packing List Line",
default_resource_uid = resource_uid,
default_aggregate_uid=[i.getUid() for i in software_instance_list]
)
if len(packing_list_line_list):
return sum([i.getQuantity() for i in packing_list_line_list])/len(packing_list_line_list)
return 0.0
......@@ -48,34 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
software_release_url = context.getUrlString()\n
\n
resource_uid = context.service_module.cpu_load_percent.getUid()\n
\n
# Select all software instances from a certain Software Release\n
software_instance_list = portal.portal_catalog(\n
portal_type="Software Instance",\n
limit=100,\n
url_string=software_release_url)\n
\n
packing_list_line_list = portal.portal_catalog(\n
limit=100,\n
sort_on=("creation_date", "DESC"),\n
portal_type="Sale Packing List Line",\n
default_resource_uid = resource_uid,\n
default_aggregate_uid=[i.getUid() for i in software_instance_list]\n
)\n
\n
if len(packing_list_line_list):\n
return sum([i.getQuantity() for i in packing_list_line_list])/len(packing_list_line_list)\n
\n
return 0.0\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
portal = context.getPortalObject()
software_release_url = context.getUrlString()
resource_uid = context.service_module.memory_used.getUid()
# Select all software instances from a certain Software Release
software_instance_list = portal.portal_catalog(
portal_type="Software Instance",
limit=100,
url_string=software_release_url)
packing_list_line_list = portal.portal_catalog(
limit=100,
sort_on=("creation_date", "DESC"),
portal_type="Sale Packing List Line",
default_resource_uid = resource_uid,
default_aggregate_uid=[i.getUid() for i in software_instance_list]
)
if len(packing_list_line_list):
return sum([i.getQuantity() for i in packing_list_line_list])/len(packing_list_line_list)
return 0.0
......@@ -48,34 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
\n
software_release_url = context.getUrlString()\n
\n
resource_uid = context.service_module.memory_used.getUid()\n
\n
# Select all software instances from a certain Software Release\n
software_instance_list = portal.portal_catalog(\n
portal_type="Software Instance",\n
limit=100,\n
url_string=software_release_url)\n
\n
packing_list_line_list = portal.portal_catalog(\n
limit=100,\n
sort_on=("creation_date", "DESC"),\n
portal_type="Sale Packing List Line",\n
default_resource_uid = resource_uid,\n
default_aggregate_uid=[i.getUid() for i in software_instance_list]\n
)\n
\n
if len(packing_list_line_list):\n
return sum([i.getQuantity() for i in packing_list_line_list])/len(packing_list_line_list)\n
\n
return 0.0\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
"""
Make a list with delta CO2 values
"""
if simulated_cpu_load is not None:
partition_average_cpu_load = simulated_cpu_load
else:
partition_average_cpu_load = context.getCpuCapacityQuantity()
partition_delta_co2_dict = {}
for computer_partition in computer_partition_list:
computer = computer_partition.getParentValue()
computer_zero_emission_ratio = computer.Computer_getZeroEmissionRatio()
computer_cpu_load_percentage = computer.Computer_getLatestCPUPercentLoad()
computer_watt = computer.Computer_getWattConsumption(computer_cpu_load_percentage)
partition_watt = computer.Computer_getWattConsumption(
computer_cpu_load_percentage + partition_average_cpu_load)
delta_watt = (partition_watt-computer_watt)
delta_co2 = delta_watt - delta_watt*(computer_zero_emission_ratio/100)
if delta_co2 in partition_delta_co2_dict:
partition_delta_co2_dict[delta_co2].append(computer_partition)
else:
partition_delta_co2_dict[delta_co2] = [computer_partition]
return partition_delta_co2_dict
......@@ -48,40 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Make a list with delta CO2 values\n
"""\n
\n
if simulated_cpu_load is not None:\n
partition_average_cpu_load = simulated_cpu_load\n
else:\n
partition_average_cpu_load = context.getCpuCapacityQuantity()\n
\n
partition_delta_co2_dict = {} \n
\n
for computer_partition in computer_partition_list:\n
computer = computer_partition.getParentValue()\n
computer_zero_emission_ratio = computer.Computer_getZeroEmissionRatio()\n
computer_cpu_load_percentage = computer.Computer_getLatestCPUPercentLoad()\n
computer_watt = computer.Computer_getWattConsumption(computer_cpu_load_percentage)\n
\n
partition_watt = computer.Computer_getWattConsumption(\n
computer_cpu_load_percentage + partition_average_cpu_load)\n
\n
delta_watt = (partition_watt-computer_watt)\n
\n
delta_co2 = delta_watt - delta_watt*(computer_zero_emission_ratio/100)\n
\n
if delta_co2 in partition_delta_co2_dict:\n
partition_delta_co2_dict[delta_co2].append(computer_partition)\n
else:\n
partition_delta_co2_dict[delta_co2] = [computer_partition]\n
\n
return partition_delta_co2_dict\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>computer_partition_list, simulated_cpu_load=None</string> </value>
......
"""
"""
edit_kw = {}
average_cpu_load = context.SoftwareRelease_getAverageConsumedCPULoad()
average_memory_usage = context.SoftwareRelease_getAverageConsumedMemory()
if average_cpu_load != context.getCpuCapacityQuantity():
edit_kw["cpu_capacity_quantity"] = average_cpu_load
if average_memory_usage != context.getMemoryCapacityQuantity():
edit_kw["memory_capacity_quantity"] = average_memory_usage
if len(edit_kw) > 0:
context.edit(**edit_kw)
......@@ -48,29 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
"""\n
edit_kw = {}\n
average_cpu_load = context.SoftwareRelease_getAverageConsumedCPULoad()\n
average_memory_usage = context.SoftwareRelease_getAverageConsumedMemory()\n
\n
\n
if average_cpu_load != context.getCpuCapacityQuantity():\n
edit_kw["cpu_capacity_quantity"] = average_cpu_load\n
\n
if average_memory_usage != context.getMemoryCapacityQuantity(): \n
edit_kw["memory_capacity_quantity"] = average_memory_usage\n
\n
if len(edit_kw) > 0:\n
context.edit(**edit_kw)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
......@@ -32,211 +32,6 @@
</object>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<!-- Tested with chromium 12 and --ignore-certificate-errors --disable-translate --disable-web-security options -->\n
<html xmlns:tal="http://xml.zope.org/namespaces/tal"\n
xmlns:metal="http://xml.zope.org/namespaces/metal">\n
<head>\n
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n
<title>Test KVM</title>\n
</head>\n
<body>\n
<table cellpadding="1" cellspacing="1" border="1">\n
<thead>\n
<tr><td rowspan="1" colspan="3">testkvm</td></tr>\n
</thead><tbody>\n
<tal:block metal:use-macro="container/Zuite_vifib_instanciation_macro_library/macros/init_environment" />\n
<tr>\n
<td>phantomRender</td>\n
<td>webrequest1.png</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>link=Order a KVM now</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>link=Order a KVM now</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>phantomRender</td>\n
<td>webrequest2.png</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>//div[text()="Your instance is under creation. Please wait few minutes for partitions to appear."]</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>storeLocation</td>\n
<td>hosting_subscription_url</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>echo</td>\n
<td>${hosting_subscription_url}</td>\n
<td></td>\n
</tr>\n
<!--\n
Unfortunately there is currently now way to do good client-server waiting for reindexation\n
of Software Instance, so just wait 60s.\n
\n
It shall be maximum of reindexation.\n
\n
-->\n
<tr>\n
<td>pause</td>\n
<td>60000</td>\n
<td></td>\n
</tr>\n
\n
<tr>\n
<td>open</td>\n
<td>${hosting_subscription_url}</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>link=Vifib KVM*</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>link=Vifib KVM*</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>storeLocation</td>\n
<td>software_instance_url</td>\n
<td></td>\n
</tr>\n
<!-- Allows to fetch clean instance status -->\n
<tr>\n
<td>storeEval</td>\n
<td>window.location.pathname</td>\n
<td>software_instance_path</td>\n
</tr>\n
<tr>\n
<td>echo</td>\n
<td>${software_instance_path}</td>\n
<td></td>\n
</tr>\n
\n
<!-- Hackish, but there is no other way to fetch software instance status -->\n
<!-- XXX: It is hammering server, needs to make it a bit nicer -->\n
<!--tr>\n
<td>waitForCondition</td>\n
<td>new\n
Ajax.Request(\'${software_instance_path}/SoftwareInstance_getStatus\',\n
{asynchronous: false}).transport.responseText === "Started"; var i;\n
for (i = 0; i < 10000000; i++) { };</td>\n
<td>600000</td>\n
</tr-->\n
<tr>\n
<td>pause</td>\n
<td>5400000</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>open</td>\n
<td>${software_instance_url}</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>css=span:contains("Started")</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>css=td:contains("url")</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>css=td:contains("password")</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>storeText</td>\n
<td>css=td:contains(\'url\') + td</td>\n
<td>ip</td>\n
</tr>\n
<tr>\n
<td>storeText</td>\n
<td>css=td:contains(\'password\') + td</td>\n
<td>password</td>\n
</tr>\n
<!--tr>\n
<td>openAndWait</td>\n
<td>${ip}</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>pause</td>\n
<td>2000</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertElementPresent</td>\n
<td>id=password_input</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>type</td>\n
<td>id=password_input</td>\n
<td>${password}</td>\n
</tr>\n
<tr>\n
<td>keyPress</td>\n
<td>id=password_input</td>\n
<td>13</td>\n
</tr>\n
<tr>\n
<td>pause</td>\n
<td>1000</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>submit</td>\n
<td>//input[@id=&quot;password_input&quot;]/..</td>\n
<td>\\13</td>\n
</tr>\n
<tr>\n
<td>pause</td>\n
<td>10000</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>assertTextPresent</td>\n
<td>Connected (encrypted) to</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>phantomRender</td>\n
<td>webrequest9.png</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>openAndWait</td>\n
<td>${software_instance_url}</td>\n
<td></td>\n
</tr-->\n
<!--span metal:use-macro="container/Zuite_vifib_instanciation_macro_library/macros/destroy_instance" /-->\n
</tbody>\n
</table>\n
</body>\n
</html>
]]></unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
......
<!-- Tested with chromium 12 and --ignore-certificate-errors --disable-translate --disable-web-security options -->
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test KVM</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">testkvm</td></tr>
</thead><tbody>
<tal:block metal:use-macro="container/Zuite_vifib_instanciation_macro_library/macros/init_environment" />
<tr>
<td>phantomRender</td>
<td>webrequest1.png</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>link=Order a KVM now</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Order a KVM now</td>
<td></td>
</tr>
<tr>
<td>phantomRender</td>
<td>webrequest2.png</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[text()="Your instance is under creation. Please wait few minutes for partitions to appear."]</td>
<td></td>
</tr>
<tr>
<td>storeLocation</td>
<td>hosting_subscription_url</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${hosting_subscription_url}</td>
<td></td>
</tr>
<!--
Unfortunately there is currently now way to do good client-server waiting for reindexation
of Software Instance, so just wait 60s.
It shall be maximum of reindexation.
-->
<tr>
<td>pause</td>
<td>60000</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${hosting_subscription_url}</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>link=Vifib KVM*</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Vifib KVM*</td>
<td></td>
</tr>
<tr>
<td>storeLocation</td>
<td>software_instance_url</td>
<td></td>
</tr>
<!-- Allows to fetch clean instance status -->
<tr>
<td>storeEval</td>
<td>window.location.pathname</td>
<td>software_instance_path</td>
</tr>
<tr>
<td>echo</td>
<td>${software_instance_path}</td>
<td></td>
</tr>
<!-- Hackish, but there is no other way to fetch software instance status -->
<!-- XXX: It is hammering server, needs to make it a bit nicer -->
<!--tr>
<td>waitForCondition</td>
<td>new
Ajax.Request('${software_instance_path}/SoftwareInstance_getStatus',
{asynchronous: false}).transport.responseText === "Started"; var i;
for (i = 0; i < 10000000; i++) { };</td>
<td>600000</td>
</tr-->
<tr>
<td>pause</td>
<td>5400000</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${software_instance_url}</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>css=span:contains("Started")</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>css=td:contains("url")</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>css=td:contains("password")</td>
<td></td>
</tr>
<tr>
<td>storeText</td>
<td>css=td:contains('url') + td</td>
<td>ip</td>
</tr>
<tr>
<td>storeText</td>
<td>css=td:contains('password') + td</td>
<td>password</td>
</tr>
<!--tr>
<td>openAndWait</td>
<td>${ip}</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>2000</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>id=password_input</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=password_input</td>
<td>${password}</td>
</tr>
<tr>
<td>keyPress</td>
<td>id=password_input</td>
<td>13</td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>submit</td>
<td>//input[@id=&quot;password_input&quot;]/..</td>
<td>\13</td>
</tr>
<tr>
<td>pause</td>
<td>10000</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Connected (encrypted) to</td>
<td></td>
</tr>
<tr>
<td>phantomRender</td>
<td>webrequest9.png</td>
<td></td>
</tr>
<tr>
<td>openAndWait</td>
<td>${software_instance_url}</td>
<td></td>
</tr-->
<!--span metal:use-macro="container/Zuite_vifib_instanciation_macro_library/macros/destroy_instance" /-->
</tbody>
</table>
</body>
</html>
\ No newline at end of file
from Products.CMFActivity.ActiveResult import ActiveResult
# XXX rafael: Hardcoded value is a convention on Vifib.
vifib = context.organisation_module['vifib_internet']
year = DateTime().year()
start_date = '%s/01/01' % year
stop_date = '%s/12/31' % (year + 1)
accounting_period = context.portal_catalog.getResultValue(
portal_type='Accounting Period',
parent_uid=vifib.getUid(),
simulation_state='started',
**{'delivery.start_date': start_date,
'delivery.stop_date': stop_date
}
)
if accounting_period is None and fixit:
accounting_period = vifib.newContent(portal_type='Accounting Period',
start_date=start_date, stop_date=stop_date)
accounting_period.start()
if accounting_period is None:
summary = "Unable to find Accounting Plan for the current year."
if fixit:
summary += ", fixed."
severity = 0
else:
severity = 1
detail = "Period %s to %s" % (start_date, stop_date)
else:
severity = 0
summary = "Nothing to do."
detail = ""
active_result = ActiveResult()
active_result.edit(
summary=summary,
severity=severity,
detail=detail)
context.newActiveProcess().postResult(active_result)
......@@ -48,53 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.CMFActivity.ActiveResult import ActiveResult\n
\n
# XXX rafael: Hardcoded value is a convention on Vifib.\n
vifib = context.organisation_module[\'vifib_internet\']\n
\n
year = DateTime().year()\n
start_date = \'%s/01/01\' % year\n
stop_date = \'%s/12/31\' % (year + 1)\n
\n
accounting_period = context.portal_catalog.getResultValue(\n
portal_type=\'Accounting Period\',\n
parent_uid=vifib.getUid(),\n
simulation_state=\'started\',\n
**{\'delivery.start_date\': start_date,\n
\'delivery.stop_date\': stop_date\n
}\n
)\n
\n
if accounting_period is None and fixit:\n
accounting_period = vifib.newContent(portal_type=\'Accounting Period\',\n
start_date=start_date, stop_date=stop_date)\n
accounting_period.start()\n
\n
if accounting_period is None:\n
summary = "Unable to find Accounting Plan for the current year."\n
if fixit:\n
summary += ", fixed."\n
severity = 0\n
else:\n
severity = 1\n
detail = "Period %s to %s" % (start_date, stop_date)\n
else:\n
severity = 0\n
summary = "Nothing to do."\n
detail = ""\n
\n
active_result = ActiveResult()\n
active_result.edit(\n
summary=summary, \n
severity=severity,\n
detail=detail)\n
\n
context.newActiveProcess().postResult(active_result)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit=False, **kw</string> </value>
......
......@@ -48,11 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>context.activeSense(fixit=1)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
from Products.ZSQLCatalog.SQLCatalog import NegatedQuery, Query
portal = context.getPortalObject()
person = portal.restrictedTraverse('person_module/20120411-A56ED', None)
if person is None:
return
person_reference = person.getReference()
setup_service = portal.restrictedTraverse(portal.portal_preferences.getPreferredInstanceSetupResource())
# XXX Owner column should not be used to fetch the list!
# Data model of hosting subscription should be fixed to allow direct query
portal.portal_catalog.searchAndActivate(
portal_type="Hosting Subscription",
owner=person_reference,
validation_state="validated",
method_id='HostingSubcription_requestDestructionSeleniumTester',
method_kw={'tag': tag},
activate_kw={'tag': tag},
)
context.activate(after_tag=tag).getId()
......@@ -48,32 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ZSQLCatalog.SQLCatalog import NegatedQuery, Query\n
\n
portal = context.getPortalObject()\n
person = portal.restrictedTraverse(\'person_module/20120411-A56ED\', None)\n
if person is None:\n
return\n
person_reference = person.getReference()\n
\n
setup_service = portal.restrictedTraverse(portal.portal_preferences.getPreferredInstanceSetupResource())\n
\n
# XXX Owner column should not be used to fetch the list!\n
# Data model of hosting subscription should be fixed to allow direct query\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Hosting Subscription",\n
owner=person_reference,\n
validation_state="validated",\n
method_id=\'HostingSubcription_requestDestructionSeleniumTester\',\n
method_kw={\'tag\': tag},\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_catalog = context.getPortalObject().portal_catalog
from DateTime import DateTime
method_kw = {}
method_kw.update(
maximum_balance=context.portal_preferences.getPreferredMaximumBalance(),
maximum_due_date=(DateTime() - context.portal_preferences.getPreferredMaximumDueDay()).Date(),
simulation_state=context.getPortalCurrentInventoryStateList() + context.getPortalTransitInventoryStateList(),
ongoing_simulation_state=context.getPortalFutureInventoryStateList() + context.getPortalReservedInventoryStateList(),
section_uid=context.restrictedTraverse('organisation_module/vifib_internet').getUid(),
operation='lock'
)
portal_catalog.searchAndActivate(
method_id='Person_manageLockByBalance',
payment_state='!= locked',
portal_type='Person',
activate_kw={'tag': tag},
method_kw=method_kw
)
......@@ -48,28 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal_catalog = context.getPortalObject().portal_catalog\n
from DateTime import DateTime\n
method_kw = {}\n
method_kw.update(\n
maximum_balance=context.portal_preferences.getPreferredMaximumBalance(),\n
maximum_due_date=(DateTime() - context.portal_preferences.getPreferredMaximumDueDay()).Date(),\n
simulation_state=context.getPortalCurrentInventoryStateList() + context.getPortalTransitInventoryStateList(),\n
ongoing_simulation_state=context.getPortalFutureInventoryStateList() + context.getPortalReservedInventoryStateList(),\n
section_uid=context.restrictedTraverse(\'organisation_module/vifib_internet\').getUid(),\n
operation=\'lock\'\n
)\n
portal_catalog.searchAndActivate(\n
method_id=\'Person_manageLockByBalance\',\n
payment_state=\'!= locked\',\n
portal_type=\'Person\',\n
activate_kw={\'tag\': tag},\n
method_kw=method_kw\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal_catalog = context.getPortalObject().portal_catalog
portal_catalog.searchAndActivate(
method_id='SoftwareInstance_lockForLockedPerson',
portal_type=('Software Instance', 'Slave Instance'),
payment_state='!= locked',
activate_kw={'tag': tag}
)
......@@ -48,18 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal_catalog = context.getPortalObject().portal_catalog\n
\n
portal_catalog.searchAndActivate(\n
method_id=\'SoftwareInstance_lockForLockedPerson\',\n
portal_type=(\'Software Instance\', \'Slave Instance\'),\n
payment_state=\'!= locked\',\n
activate_kw={\'tag\': tag}\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
context.z_set_priority_one_message_table()
context.z_set_priority_one_message_queue_table()
......@@ -48,12 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>context.z_set_priority_one_message_table()\n
context.z_set_priority_one_message_queue_table()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
portal_catalog = context.getPortalObject().portal_catalog
from DateTime import DateTime
method_kw = {}
method_kw.update(
maximum_balance=context.portal_preferences.getPreferredMaximumBalance(),
maximum_due_date=(DateTime() - context.portal_preferences.getPreferredMaximumDueDay()).Date(),
simulation_state=context.getPortalCurrentInventoryStateList() + context.getPortalTransitInventoryStateList(),
ongoing_simulation_state=context.getPortalFutureInventoryStateList() + context.getPortalReservedInventoryStateList(),
section_uid=context.restrictedTraverse('organisation_module/vifib_internet').getUid(),
operation='unlock'
)
portal_catalog.searchAndActivate(
method_id='Person_manageLockByBalance',
payment_state='locked',
portal_type='Person',
activate_kw={'tag': tag},
method_kw=method_kw
)
......@@ -48,28 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal_catalog = context.getPortalObject().portal_catalog\n
from DateTime import DateTime\n
method_kw = {}\n
method_kw.update(\n
maximum_balance=context.portal_preferences.getPreferredMaximumBalance(),\n
maximum_due_date=(DateTime() - context.portal_preferences.getPreferredMaximumDueDay()).Date(),\n
simulation_state=context.getPortalCurrentInventoryStateList() + context.getPortalTransitInventoryStateList(),\n
ongoing_simulation_state=context.getPortalFutureInventoryStateList() + context.getPortalReservedInventoryStateList(),\n
section_uid=context.restrictedTraverse(\'organisation_module/vifib_internet\').getUid(),\n
operation=\'unlock\'\n
)\n
portal_catalog.searchAndActivate(\n
method_id=\'Person_manageLockByBalance\',\n
payment_state=\'locked\',\n
portal_type=\'Person\',\n
activate_kw={\'tag\': tag},\n
method_kw=method_kw\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
portal_catalog = context.getPortalObject().portal_catalog
portal_catalog.searchAndActivate(
method_id='SoftwareInstance_unlockForUnlockedPerson',
portal_type=('Software Instance', 'Slave Instance'),
payment_state='locked',
activate_kw={'tag': tag}
)
......@@ -48,18 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal_catalog = context.getPortalObject().portal_catalog\n
\n
portal_catalog.searchAndActivate(\n
method_id=\'SoftwareInstance_unlockForUnlockedPerson\',\n
portal_type=(\'Software Instance\', \'Slave Instance\'),\n
payment_state=\'locked\',\n
activate_kw={\'tag\': tag}\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
......
from Products.ERP5Type.Constraint import PropertyTypeValidity
from Products.CMFActivity.ActiveResult import ActiveResult
if context.getId().startswith('template_'):
return
constraint_message_list = []
if context.providesIConstraint():
# it is not possible to checkConsistency of Constraint itself, as method
# of this name implement consistency checking on object
return constraint_message_list
traverse = context.getPortalObject().restrictedTraverse
property_type_validity = PropertyTypeValidity(id='type_check', description='Type Validity Check')
if fixit:
constraint_message_list.extend(context.fixConsistency())
constraint_message_list.extend(property_type_validity.fixConsistency(context))
else:
constraint_message_list.extend(context.checkConsistency(fixit=fixit))
constraint_message_list.extend(property_type_validity.checkConsistency(context, fixit=fixit))
if constraint_message_list:
traverse(active_process).postResult(ActiveResult(severity=100,
constraint_message_list=constraint_message_list))
......@@ -48,36 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Constraint import PropertyTypeValidity\n
from Products.CMFActivity.ActiveResult import ActiveResult\n
\n
if context.getId().startswith(\'template_\'):\n
return\n
\n
constraint_message_list = []\n
\n
if context.providesIConstraint():\n
# it is not possible to checkConsistency of Constraint itself, as method\n
# of this name implement consistency checking on object\n
return constraint_message_list\n
\n
traverse = context.getPortalObject().restrictedTraverse\n
property_type_validity = PropertyTypeValidity(id=\'type_check\', description=\'Type Validity Check\')\n
\n
if fixit:\n
constraint_message_list.extend(context.fixConsistency())\n
constraint_message_list.extend(property_type_validity.fixConsistency(context))\n
else:\n
constraint_message_list.extend(context.checkConsistency(fixit=fixit))\n
constraint_message_list.extend(property_type_validity.checkConsistency(context, fixit=fixit))\n
\n
if constraint_message_list:\n
traverse(active_process).postResult(ActiveResult(severity=100,\n
constraint_message_list=constraint_message_list))\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit, active_process</string> </value>
......
# try to find, if needed create and publish
portal = context.getPortalObject()
software_release_document = portal.portal_catalog.getResultValue(portal_type='Software Release',
url_string=software_release_url)
if software_release_document is None:
digest = context.Base_getSha512Hexdiest(software_release_url)
tag = '%s_inProgress' % digest
if portal.portal_activities.countMessageWithTag(tag) == 0:
# can create new one
software_release_document = portal.software_release_module.newContent(
portal_type='Software Release',
reference=digest,
version=digest,
url_string=software_release_url,
language='en',
activate_kw={'tag': tag}
)
software_release_document.publish(comment='Automatically created.')
return software_release_document
......@@ -48,29 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># try to find, if needed create and publish\n
portal = context.getPortalObject()\n
software_release_document = portal.portal_catalog.getResultValue(portal_type=\'Software Release\',\n
url_string=software_release_url)\n
if software_release_document is None:\n
digest = context.Base_getSha512Hexdiest(software_release_url)\n
tag = \'%s_inProgress\' % digest\n
if portal.portal_activities.countMessageWithTag(tag) == 0:\n
# can create new one\n
software_release_document = portal.software_release_module.newContent(\n
portal_type=\'Software Release\',\n
reference=digest,\n
version=digest,\n
url_string=software_release_url,\n
language=\'en\',\n
activate_kw={\'tag\': tag}\n
)\n
software_release_document.publish(comment=\'Automatically created.\')\n
return software_release_document\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>software_release_url</string> </value>
......
# XXX: Convert to preference?
portal = context.getPortalObject()
usage_report_service_reference = 'usage_report'
catalog_result = portal.portal_catalog(
portal_type=portal.getPortalServiceTypeList(),
reference=usage_report_service_reference
)
if len(catalog_result) == 1:
return catalog_result[0].getObject()
return None
......@@ -48,20 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># XXX: Convert to preference?\n
portal = context.getPortalObject()\n
usage_report_service_reference = \'usage_report\'\n
catalog_result = portal.portal_catalog(\n
portal_type=portal.getPortalServiceTypeList(),\n
reference=usage_report_service_reference\n
)\n
if len(catalog_result) == 1:\n
return catalog_result[0].getObject()\n
return None\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
if context.getPortalType() != 'Computer':
raise TypeError('%s is not Computer' % context.getPath())
isTransitionPossible = context.getPortalObject().portal_workflow.isTransitionPossible
def updatePartitionList(computer, partition_list):
existing_partition_dict = {}
for c in context.contentValues():
existing_partition_dict[c.getReference()] = c
for partition_dict in partition_list:
partition = existing_partition_dict.get(partition_dict['title'])
if partition is None:
partition = computer.newContent(portal_type='Computer Partition', reference=partition_dict['title'])
if isTransitionPossible(partition, 'validate'):
partition.validate()
if isTransitionPossible(partition, 'mark_free'):
partition.markFree()
if partition.getDefaultNetworkAddressIpAddress() != partition_dict['public_ip']:
partition.setDefaultNetworkAddressIpAddress(partition_dict['public_ip'])
if partition.getDefaultNetworkAddressNetworkInterface() != partition_dict['tap_interface']:
partition.setDefaultNetworkAddressNetworkInterface(partition_dict['tap_interface'])
to_delete_list = []
private_set = False
for address in partition.contentValues(portal_type='Internet Protocol Address'):
if address.getIpAddress() == partition_dict['public_ip']:
continue
if not private_set and address.getIpAddress() == partition_dict['private_ip']:
if address.getNetworkInterface() != partition_dict['tap_interface']:
address.setNetworkInterface(partition_dict['tap_interface'])
private_set = True
continue
to_delete_list.append(address)
if not private_set:
if len(to_delete_list):
address = to_delete_list.pop()
else:
address = partition.newContent(portal_type='Internet Protocol Address')
address.setIpAddress(partition_dict['private_ip'])
address.setNetworkInterface(partition_dict['tap_interface'])
partition.deleteContent([q.getId() for q in to_delete_list])
def updateSoftwareList(computer, software_list):
for software_dict in software_list:
status = software_dict['status']
try:
if status == 'installed':
computer.stopSoftwareReleaseInstallation(software_release_url=software_dict['software_release'], comment=software_dict['log'])
elif status == 'uninstalled':
computer.cleanupSoftwareReleaseInstallation(software_release_url=software_dict['software_release'], comment=software_dict['log'])
elif status == 'error':
computer.reportSoftwareReleaseInstallationError(software_release_url=software_dict['software_release'], comment=software_dict['log'])
except ValueError:
# BBB: Underlying code is state based, does not support multiple information
pass
if 'partition' in computer_json:
updatePartitionList(context, computer_json['partition'])
if 'software' in computer_json:
updateSoftwareList(context, computer_json['software'])
......@@ -48,69 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if context.getPortalType() != \'Computer\':\n
raise TypeError(\'%s is not Computer\' % context.getPath())\n
\n
isTransitionPossible = context.getPortalObject().portal_workflow.isTransitionPossible\n
def updatePartitionList(computer, partition_list):\n
existing_partition_dict = {}\n
for c in context.contentValues():\n
existing_partition_dict[c.getReference()] = c\n
for partition_dict in partition_list:\n
partition = existing_partition_dict.get(partition_dict[\'title\'])\n
if partition is None:\n
partition = computer.newContent(portal_type=\'Computer Partition\', reference=partition_dict[\'title\'])\n
if isTransitionPossible(partition, \'validate\'):\n
partition.validate()\n
if isTransitionPossible(partition, \'mark_free\'):\n
partition.markFree()\n
if partition.getDefaultNetworkAddressIpAddress() != partition_dict[\'public_ip\']:\n
partition.setDefaultNetworkAddressIpAddress(partition_dict[\'public_ip\'])\n
if partition.getDefaultNetworkAddressNetworkInterface() != partition_dict[\'tap_interface\']:\n
partition.setDefaultNetworkAddressNetworkInterface(partition_dict[\'tap_interface\'])\n
to_delete_list = []\n
private_set = False\n
for address in partition.contentValues(portal_type=\'Internet Protocol Address\'):\n
if address.getIpAddress() == partition_dict[\'public_ip\']:\n
continue\n
if not private_set and address.getIpAddress() == partition_dict[\'private_ip\']:\n
if address.getNetworkInterface() != partition_dict[\'tap_interface\']:\n
address.setNetworkInterface(partition_dict[\'tap_interface\'])\n
private_set = True\n
continue\n
to_delete_list.append(address)\n
if not private_set:\n
if len(to_delete_list):\n
address = to_delete_list.pop()\n
else:\n
address = partition.newContent(portal_type=\'Internet Protocol Address\')\n
address.setIpAddress(partition_dict[\'private_ip\'])\n
address.setNetworkInterface(partition_dict[\'tap_interface\'])\n
partition.deleteContent([q.getId() for q in to_delete_list])\n
\n
def updateSoftwareList(computer, software_list):\n
for software_dict in software_list:\n
status = software_dict[\'status\']\n
try:\n
if status == \'installed\':\n
computer.stopSoftwareReleaseInstallation(software_release_url=software_dict[\'software_release\'], comment=software_dict[\'log\'])\n
elif status == \'uninstalled\':\n
computer.cleanupSoftwareReleaseInstallation(software_release_url=software_dict[\'software_release\'], comment=software_dict[\'log\'])\n
elif status == \'error\':\n
computer.reportSoftwareReleaseInstallationError(software_release_url=software_dict[\'software_release\'], comment=software_dict[\'log\'])\n
except ValueError:\n
# BBB: Underlying code is state based, does not support multiple information\n
pass\n
\n
if \'partition\' in computer_json:\n
updatePartitionList(context, computer_json[\'partition\'])\n
\n
if \'software\' in computer_json:\n
updateSoftwareList(context, computer_json[\'software\'])\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>computer_json</string> </value>
......
from DateTime import DateTime
portal = context.getPortalObject()
hosting_subscription = context
now = DateTime()
if hosting_subscription.getDestinationSectionValue().getReference() == 'seleniumtester' and \
hosting_subscription.getModificationDate() < (now - 1):
person = hosting_subscription.getDestinationSectionValue(portal_type="Person")
person.requestSoftwareInstance(
software_release=hosting_subscription.getUrlString(),
instance_xml=hosting_subscription.getTextContent(),
software_type=hosting_subscription.getSourceReference(),
sla_xml=hosting_subscription.getSlaXml(),
shared=hosting_subscription.getRootSlave(),
state="destroyed",
software_title=hosting_subscription.getTitle(),
comment='Requested by clenaup alarm',
activate_kw={'tag': tag}
)
......@@ -48,35 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from DateTime import DateTime\n
portal = context.getPortalObject()\n
hosting_subscription = context\n
\n
now = DateTime()\n
\n
if hosting_subscription.getDestinationSectionValue().getReference() == \'seleniumtester\' and \\\n
hosting_subscription.getModificationDate() < (now - 1):\n
\n
person = hosting_subscription.getDestinationSectionValue(portal_type="Person")\n
person.requestSoftwareInstance(\n
software_release=hosting_subscription.getUrlString(),\n
instance_xml=hosting_subscription.getTextContent(),\n
software_type=hosting_subscription.getSourceReference(),\n
sla_xml=hosting_subscription.getSlaXml(),\n
shared=hosting_subscription.getRootSlave(),\n
state="destroyed",\n
software_title=hosting_subscription.getTitle(),\n
comment=\'Requested by clenaup alarm\', \n
activate_kw={\'tag\': tag}\n
)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag</string> </value>
......
#We extract informations from SPL
packing_list_dict = {'packing_list_title': context.getTitle()}
#We extract informations from SPLL
sale_packing_list_line_list = [line for line in context.objectValues(
portal_type='Sale Packing List Line')
]
xml_head = ""
xml_movements = ""
xml_foot = ""
xml_head = "<?xml version='1.0' encoding='utf-8'?>" \
"<journal>" \
"<transaction type=\"Sale Packing List\">" \
"<title>%(packing_list_title)s</title>" \
"<start_date></start_date>" \
"<stop_date></stop_date>" \
"<reference></reference>" \
"<currency></currency>" \
"<payment_mode></payment_mode>" \
"<category></category>" \
"<arrow type=\"Administration\">" \
"<source></source>" \
"<destination></destination>" \
"</arrow>" \
% packing_list_dict
for sale_packing_list_line in sale_packing_list_line_list:
packing_list_line_dict = {'packing_list_line_title': sale_packing_list_line.getTitle(),
'packing_list_line_resource': sale_packing_list_line.getResourceTitle(),
'packing_list_line_reference': sale_packing_list_line.getAggregateValue().getTitle(),
'packing_list_line_quantity': sale_packing_list_line.getQuantity(),
}
xml_movements += "<movement>" \
"<resource>%(packing_list_line_resource)s</resource>" \
"<title>%(packing_list_line_title)s</title>" \
"<reference>%(packing_list_line_reference)s</reference>" \
"<quantity>%(packing_list_line_quantity)s</quantity>" \
"<price>0.00</price>" \
"<VAT>None</VAT>" \
"<category>None</category>" \
"</movement>" \
% packing_list_line_dict
xml_foot = "</transaction>" \
"</journal>"
xml = xml_head + xml_movements + xml_foot
return xml
......@@ -48,66 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
#We extract informations from SPL\n
packing_list_dict = {\'packing_list_title\': context.getTitle()}\n
\n
#We extract informations from SPLL\n
sale_packing_list_line_list = [line for line in context.objectValues(\n
portal_type=\'Sale Packing List Line\')\n
]\n
\n
xml_head = ""\n
xml_movements = ""\n
xml_foot = ""\n
\n
xml_head = "<?xml version=\'1.0\' encoding=\'utf-8\'?>" \\\n
"<journal>" \\\n
"<transaction type=\\"Sale Packing List\\">" \\\n
"<title>%(packing_list_title)s</title>" \\\n
"<start_date></start_date>" \\\n
"<stop_date></stop_date>" \\\n
"<reference></reference>" \\\n
"<currency></currency>" \\\n
"<payment_mode></payment_mode>" \\\n
"<category></category>" \\\n
"<arrow type=\\"Administration\\">" \\\n
"<source></source>" \\\n
"<destination></destination>" \\\n
"</arrow>" \\\n
% packing_list_dict\n
\n
for sale_packing_list_line in sale_packing_list_line_list:\n
\n
packing_list_line_dict = {\'packing_list_line_title\': sale_packing_list_line.getTitle(),\n
\'packing_list_line_resource\': sale_packing_list_line.getResourceTitle(),\n
\'packing_list_line_reference\': sale_packing_list_line.getAggregateValue().getTitle(),\n
\'packing_list_line_quantity\': sale_packing_list_line.getQuantity(),\n
}\n
\n
xml_movements += "<movement>" \\\n
"<resource>%(packing_list_line_resource)s</resource>" \\\n
"<title>%(packing_list_line_title)s</title>" \\\n
"<reference>%(packing_list_line_reference)s</reference>" \\\n
"<quantity>%(packing_list_line_quantity)s</quantity>" \\\n
"<price>0.00</price>" \\\n
"<VAT>None</VAT>" \\\n
"<category>None</category>" \\\n
"</movement>" \\\n
% packing_list_line_dict\n
\n
xml_foot = "</transaction>" \\\n
"</journal>"\n
\n
xml = xml_head + xml_movements + xml_foot\n
return xml\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
locked = context.getSlapState() == 'locked'
customer_uid = context.getUid()
balance = context.portal_simulation.getInventoryAssetPrice(
node_category='account_type/asset/receivable',
simulation_state=simulation_state,
section_uid=section_uid,
mirror_section_uid=customer_uid)
if maximum_balance > balance:
# customer reached his balance, shall be locked
if not locked and operation == 'lock':
context.lock(comment="Balance value is %s" % balance)
return
# check ongoing payments and check that date if is acceptable, if not lock
if context.portal_simulation.getInventoryAssetPrice(
parent_portal_type='Payment Transaction',
node_category='account_type/asset/receivable',
simulation_state=ongoing_simulation_state,
section_uid=section_uid,
mirror_section_uid=customer_uid,
at_date=maximum_due_date,
) > 0:
# there are ongoing old payments, shall be locked
if not locked and operation == 'lock':
context.lock(comment="Payment transaction not paid for more than %s days" % maximum_due_date)
elif balance >= 0.0:
# there are no ongoing payments and customer owns nothing
if locked and operation == 'unlock':
context.unlock()
......@@ -48,44 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
locked = context.getSlapState() == \'locked\'\n
customer_uid = context.getUid()\n
balance = context.portal_simulation.getInventoryAssetPrice(\n
node_category=\'account_type/asset/receivable\',\n
simulation_state=simulation_state,\n
section_uid=section_uid,\n
mirror_section_uid=customer_uid)\n
\n
if maximum_balance > balance:\n
# customer reached his balance, shall be locked\n
if not locked and operation == \'lock\':\n
context.lock(comment="Balance value is %s" % balance)\n
return\n
\n
# check ongoing payments and check that date if is acceptable, if not lock\n
if context.portal_simulation.getInventoryAssetPrice(\n
parent_portal_type=\'Payment Transaction\',\n
node_category=\'account_type/asset/receivable\',\n
simulation_state=ongoing_simulation_state,\n
section_uid=section_uid,\n
mirror_section_uid=customer_uid,\n
at_date=maximum_due_date,\n
) > 0:\n
# there are ongoing old payments, shall be locked\n
if not locked and operation == \'lock\':\n
context.lock(comment="Payment transaction not paid for more than %s days" % maximum_due_date)\n
elif balance >= 0.0:\n
# there are no ongoing payments and customer owns nothing\n
if locked and operation == \'unlock\':\n
context.unlock()\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>maximum_balance, maximum_due_date, simulation_state, section_uid, ongoing_simulation_state, operation</string> </value>
......
software_instance = context
if software_instance.getSlapState() == 'locked':
return
if software_instance.SoftwareInstance_getStatus() == 'destroyed':
return
try:
packing_list_line = software_instance.Item_getInstancePackingListLine()
except ValueError:
return
person = packing_list_line.getDestinationValue()
if person.getSlapState() == 'locked':
software_instance.lock()
......@@ -48,24 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>software_instance = context\n
if software_instance.getSlapState() == \'locked\':\n
return\n
if software_instance.SoftwareInstance_getStatus() == \'destroyed\':\n
return\n
\n
try:\n
packing_list_line = software_instance.Item_getInstancePackingListLine()\n
except ValueError:\n
return\n
person = packing_list_line.getDestinationValue()\n
\n
if person.getSlapState() == \'locked\':\n
software_instance.lock()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
software_instance = context
if software_instance.getSlapState() != 'locked':
return
if software_instance.SoftwareInstance_getStatus() == 'destroyed':
return
try:
packing_list_line = software_instance.Item_getInstancePackingListLine()
except ValueError:
return
person = packing_list_line.getDestinationValue()
if person.getSlapState() != 'locked':
software_instance.unlock()
......@@ -48,24 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>software_instance = context\n
if software_instance.getSlapState() != \'locked\':\n
return\n
if software_instance.SoftwareInstance_getStatus() == \'destroyed\':\n
return\n
\n
try:\n
packing_list_line = software_instance.Item_getInstancePackingListLine()\n
except ValueError:\n
return\n
person = packing_list_line.getDestinationValue()\n
\n
if person.getSlapState() != \'locked\':\n
software_instance.unlock()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
......
update message_queue set priority = 1 where processing_node in (0, -1) and priority > 1
\ No newline at end of file
......@@ -24,14 +24,6 @@
<key> <string>id</string> </key>
<value> <string>z_set_priority_one_message_queue_table</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
update message_queue set priority = 1 where processing_node in (0, -1) and priority > 1
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
update message set priority = 1 where processing_node in (0, -1) and priority > 1
\ No newline at end of file
......@@ -24,14 +24,6 @@
<key> <string>id</string> </key>
<value> <string>z_set_priority_one_message_table</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
update message set priority = 1 where processing_node in (0, -1) and priority > 1
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......
"""
This script generate a usage report test sample for one or two partitions
"""
# First we check the number of partition to invoice
if number in [1, 2]:
# We build movements
movement = """
<movement>
<resource>%s</resource>
<title>%s</title>
<reference>%s</reference>
<quantity>%s</quantity>
<price>0.00</price>
<VAT>None</VAT>
<category>None</category>
</movement>"""
# Then, we create two movements for each partition, one for the CPU consumption, and the other for the memory
movements = ""
for nb in range(number):
if nb == 0:
movements += movement % ('CPU Consumption', 'Title Sale Packing List Line 1', 'slappart0', '42.42')
movements += movement % ('Memory Consumption', 'Title Sale Packing List Line 2', 'slappart0', '42.42')
else:
movements += movement % ('CPU Consumption', 'Title Sale Packing List Line 1', 'slappart1', '46.46')
movements += movement % ('Memory Consumption', 'Title Sale Packing List Line 2', 'slappart1', '46.46')
# Finally, we build the XML usage report
xml = """<?xml version='1.0' encoding='utf-8'?>
<journal>
<transaction type="Sale Packing List">
<title>Resource consumptions</title>
<start_date></start_date>
<stop_date></stop_date>
<reference></reference>
<currency></currency>
<payment_mode></payment_mode>
<category></category>
<arrow type="Administration">
<source></source>
<destination></destination>
</arrow>""" + movements + """
</transaction>
</journal>"""
return xml
else:
return 'This script can generate movements for one or two partitions maximum'
......@@ -48,65 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
""" \n
This script generate a usage report test sample for one or two partitions\n
"""\n
\n
# First we check the number of partition to invoice\n
if number in [1, 2]:\n
\n
# We build movements\n
movement = """\n
<movement>\n
<resource>%s</resource>\n
<title>%s</title>\n
<reference>%s</reference> \n
<quantity>%s</quantity>\n
<price>0.00</price> \n
<VAT>None</VAT>\n
<category>None</category>\n
</movement>"""\n
\n
# Then, we create two movements for each partition, one for the CPU consumption, and the other for the memory\n
movements = ""\n
for nb in range(number):\n
if nb == 0:\n
movements += movement % (\'CPU Consumption\', \'Title Sale Packing List Line 1\', \'slappart0\', \'42.42\')\n
movements += movement % (\'Memory Consumption\', \'Title Sale Packing List Line 2\', \'slappart0\', \'42.42\')\n
else:\n
movements += movement % (\'CPU Consumption\', \'Title Sale Packing List Line 1\', \'slappart1\', \'46.46\')\n
movements += movement % (\'Memory Consumption\', \'Title Sale Packing List Line 2\', \'slappart1\', \'46.46\')\n
\n
# Finally, we build the XML usage report\n
xml = """<?xml version=\'1.0\' encoding=\'utf-8\'?>\n
<journal>\n
<transaction type="Sale Packing List">\n
<title>Resource consumptions</title>\n
<start_date></start_date>\n
<stop_date></stop_date>\n
<reference></reference>\n
<currency></currency>\n
<payment_mode></payment_mode>\n
<category></category>\n
<arrow type="Administration">\n
<source></source>\n
<destination></destination>\n
</arrow>""" + movements + """\n
</transaction>\n
</journal>"""\n
\n
return xml\n
\n
else:\n
return \'This script can generate movements for one or two partitions maximum\'\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>number</string> </value>
......
"""
Storage for the login and password of the test user
"""
return {'test_user_login' :'test_customer_vifib_web',
'test_user_password': 'testuser'}
......@@ -48,16 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Storage for the login and password of the test user\n
"""\n
\n
return {\'test_user_login\' :\'test_customer_vifib_web\',\n
\'test_user_password\': \'testuser\'}\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......
......@@ -32,60 +32,6 @@
</object>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<tal:block metal:define-macro="init_environment">\n
<!-- Initialize test environment -->\n
<tr>\n
<td>setTimeout</td>\n
<td>120000</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>store</td>\n
<td tal:content="python:\n
context.REQUEST.get(\'URL\')[0:here.REQUEST.get(\'URL\').find(\'/portal_tests/\')]">erp5</td>\n
<td>base_url</td>\n
</tr>\n
<tr>\n
<td>openAndWait</td>\n
<td>${base_url}/web_site_module/hosting</td>\n
<td></td>\n
</tr>\n
</tal:block>\n
\n
<tal:block metal:define-macro="destroy_instance">\n
<!-- Order the destruction of the instance and check for it -->\n
<tr>\n
<td>assertElementPresent</td>\n
<td>name=SoftwareInstance_requestDestroy:method</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>clickAndWait</td>\n
<td>name=SoftwareInstance_requestDestroy:method</td>\n
<td></td>\n
</tr>\n
<tr>\n
<td>waitForCondition</td>\n
<!-- XXX-Cedric : should be "Destroyed". -->\n
<td>new\n
Ajax.Request(\'${software_instance_path}/SoftwareInstance_getStatus\',\n
{asynchronous: false}).transport.responseText === "Destruction in progress"; var\n
i; for (i = 0; i < 10000000; i++){};</td>\n
<td>600000</td>\n
</tr>\n
<tr>\n
<td>openAndWait</td>\n
<td>${address}</td>\n
<td></td>\n
</tr>\n
</tal:block>
]]></unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
......
<tal:block metal:define-macro="init_environment">
<!-- Initialize test environment -->
<tr>
<td>setTimeout</td>
<td>120000</td>
<td></td>
</tr>
<tr>
<td>store</td>
<td tal:content="python:
context.REQUEST.get('URL')[0:here.REQUEST.get('URL').find('/portal_tests/')]">erp5</td>
<td>base_url</td>
</tr>
<tr>
<td>openAndWait</td>
<td>${base_url}/web_site_module/hosting</td>
<td></td>
</tr>
</tal:block>
<tal:block metal:define-macro="destroy_instance">
<!-- Order the destruction of the instance and check for it -->
<tr>
<td>assertElementPresent</td>
<td>name=SoftwareInstance_requestDestroy:method</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>name=SoftwareInstance_requestDestroy:method</td>
<td></td>
</tr>
<tr>
<td>waitForCondition</td>
<!-- XXX-Cedric : should be "Destroyed". -->
<td>new
Ajax.Request('${software_instance_path}/SoftwareInstance_getStatus',
{asynchronous: false}).transport.responseText === "Destruction in progress"; var
i; for (i = 0; i < 10000000; i++){};</td>
<td>600000</td>
</tr>
<tr>
<td>openAndWait</td>
<td>${address}</td>
<td></td>
</tr>
</tal:block>
\ No newline at end of file
Business Process
Business Process Module
\ No newline at end of file
<registered_skin_selection>
<skin_folder_selection>
<skin_folder>slapos_hal_json_style</skin_folder>
<skin_selection>HalRestricted,Hal</skin_selection>
<skin_selection>Hal,HalRestricted</skin_selection>
</skin_folder_selection>
</registered_skin_selection>
\ No newline at end of file
if REQUEST.other['method'] != "POST":
response.setStatus(405)
return ""
computer = context
computer.requestSoftwareRelease(software_release_url=software_release, state='available')
return context.REQUEST.get('software_installation_url').Base_redirect()
......@@ -48,18 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
computer = context\n
computer.requestSoftwareRelease(software_release_url=software_release, state=\'available\')\n
\n
return context.REQUEST.get(\'software_installation_url\').Base_redirect()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>software_release, REQUEST=None</string> </value>
......
if REQUEST.other['method'] != "POST":
response.setStatus(405)
return ""
import json
computer = context
request = context.REQUEST
response = REQUEST.RESPONSE
context.Base_prepareCorsResponse(RESPONSE=response)
computer.generateCertificate()
return json.dumps({
'certificate': request.get('computer_certificate'),
'key': request.get('computer_key')
}, indent=2)
......@@ -48,28 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
import json\n
\n
computer = context\n
request = context.REQUEST\n
response = REQUEST.RESPONSE\n
\n
context.Base_prepareCorsResponse(RESPONSE=response)\n
\n
computer.generateCertificate()\n
\n
return json.dumps({\n
\'certificate\': request.get(\'computer_certificate\'),\n
\'key\': request.get(\'computer_key\')\n
}, indent=2)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
if REQUEST.other['method'] != "POST":
response.setStatus(405)
return ""
computer = context
response = REQUEST.RESPONSE
context.Base_prepareCorsResponse(RESPONSE=response)
computer.revokeCertificate()
return ""
......@@ -48,21 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
computer = context\n
response = REQUEST.RESPONSE\n
context.Base_prepareCorsResponse(RESPONSE=response)\n
\n
computer.revokeCertificate()\n
\n
return ""\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
......
if REQUEST.other['method'] != "POST":
response.setStatus(405)
return ""
portal = context.getPortalObject()
computer = context
response = REQUEST.RESPONSE
context.Base_prepareCorsResponse(RESPONSE=response)
if allocation_scope == 'open/public':
# Public computer capacity is handle by an alarm
capacity_scope = 'close'
elif allocation_scope.startswith('open'):
# Capacity is not handled for 'private' computers
capacity_scope = 'open'
else:
capacity_scope = 'close'
edit_kw = {
'allocation_scope': allocation_scope,
'capacity_scope': capacity_scope,
}
self_person = computer.getSourceAdministrationValue(portal_type="Person")
self_email = self_person.getDefaultEmailCoordinateText()
if allocation_scope == 'open/public':
# reset friends and update in place
edit_kw['subject_list'] = ['']
edit_kw['destination_section'] = None
elif allocation_scope == 'open/personal':
# reset friends to self and update in place
edit_kw['subject_list'] = [self_email]
edit_kw['destination_section_value'] = self_person
else:
if self_email not in subject_list:
# add self as friend
subject_list.append(self_email)
edit_kw['subject_list'] = subject_list
computer.edit(**edit_kw)
return ""
......@@ -48,53 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
portal = context.getPortalObject()\n
computer = context\n
response = REQUEST.RESPONSE\n
\n
context.Base_prepareCorsResponse(RESPONSE=response)\n
\n
if allocation_scope == \'open/public\':\n
# Public computer capacity is handle by an alarm\n
capacity_scope = \'close\'\n
elif allocation_scope.startswith(\'open\'):\n
# Capacity is not handled for \'private\' computers\n
capacity_scope = \'open\'\n
else:\n
capacity_scope = \'close\'\n
\n
edit_kw = {\n
\'allocation_scope\': allocation_scope,\n
\'capacity_scope\': capacity_scope,\n
}\n
\n
self_person = computer.getSourceAdministrationValue(portal_type="Person")\n
self_email = self_person.getDefaultEmailCoordinateText()\n
if allocation_scope == \'open/public\':\n
# reset friends and update in place\n
edit_kw[\'subject_list\'] = [\'\']\n
edit_kw[\'destination_section\'] = None\n
elif allocation_scope == \'open/personal\':\n
# reset friends to self and update in place\n
edit_kw[\'subject_list\'] = [self_email]\n
edit_kw[\'destination_section_value\'] = self_person\n
else:\n
if self_email not in subject_list:\n
# add self as friend\n
subject_list.append(self_email)\n
edit_kw[\'subject_list\'] = subject_list\n
\n
computer.edit(**edit_kw)\n
\n
return ""\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>allocation_scope, subject_list, REQUEST=None</string> </value>
......
if REQUEST.other['method'] != "POST":
response.setStatus(405)
return ""
if action not in ("started", "stopped", "destroyed"):
raise NotImplementedError, "Unknown action %s" % action
person = context.getDestinationSectionValue()
person.requestSoftwareInstance(
state=action,
software_release=context.getUrlString(),
software_title=context.getTitle(),
software_type=context.getSourceReference(),
instance_xml=context.getTextContent(),
sla_xml=context.getSlaXml(),
shared=context.isRootSlave()
)
context.Base_redirect()
......@@ -48,29 +48,6 @@
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
\n
if action not in ("started", "stopped", "destroyed"):\n
raise NotImplementedError, "Unknown action %s" % action\n
\n
person = context.getDestinationSectionValue()\n
person.requestSoftwareInstance(\n
state=action,\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
)\n
\n
context.Base_redirect()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>action, 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