Commit aa5e1094 authored by Cédric de Saint Martin's avatar Cédric de Saint Martin

Merge branch 'master' into cache

parents 845652db 6872ca03
......@@ -11,7 +11,12 @@ Changes
(folder_id)
- only_cp filter which computer patition, will be runned. it can be a
list, splited by comman (slappartX,slappartY ...) [Rafael Monnerat]
* Cleanup unused option (--usage-report-periodicity). [Cedric de Saint Martin]
* slapgrid: Cleanup unused option (--usage-report-periodicity). [Cedric de
Saint Martin]
* slapgrid: --develop will work also for Computer Partitions. [Cedric de Saint
Martin]
* slaplib: setConnectionDict won't call Master if parameters haven't changed.
[Cedric de Saint Martin]
0.26.2 (2012-07-09)
-----------------
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/int</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Used to inform client to update the instance.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>bang_timestamp_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
468
\ No newline at end of file
469
\ No newline at end of file
......@@ -18,7 +18,7 @@
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -85,7 +85,7 @@
\n
# Getting existing partitions\n
existing_partition_dict = {}\n
for c in context.contentValues():\n
for c in context.contentValues(portal_type="Computer Partition"):\n
existing_partition_dict[c.getReference()] = c\n
\n
# update computer data\n
......@@ -94,18 +94,31 @@ context.edit(\n
)\n
\n
compareAndUpdateAddressList(context, [{\'addr\': computer_dict[\'address\'], \'netmask\': computer_dict[\'netmask\']}])\n
expected_partition_dict = {}\n
for send_partition in computer_dict[\'partition_list\']:\n
partition = existing_partition_dict.get(send_partition[\'reference\'], None)\n
expected_partition_dict[send_partition[\'reference\']] = True\n
if partition is None:\n
partition = context.newContent(portal_type=\'Computer Partition\')\n
partition.validate()\n
partition.markFree()\n
elif partition.getSlapState() == \'inactive\':\n
# Reactivate partition\n
partition.markFree()\n
partition.markFree(comment="Reactivated by slapformat")\n
\n
if partition.getValidationState() == "invalidated":\n
partition.validate(comment="Reactivated by slapformat")\n
partition.edit(reference=send_partition[\'reference\'])\n
network_interface = send_partition[\'tap\'][\'name\']\n
compareAndUpdateAddressList(partition, send_partition[\'address_list\'], {\'network_interface\': network_interface})\n
\n
# Desactivate all other partitions\n
for key, value in existing_partition_dict.items():\n
if key not in expected_partition_dict:\n
if value.getSlapState() == "free":\n
value.markInactive(comment="Desactivated by slapformat")\n
if value.getValidationState() == "validated":\n
value.invalidate(comment="Desactivated by slapformat")\n
</string> </value>
</item>
<item>
......
......@@ -2,98 +2,97 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
<global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_searchInstanceAndRequestDestruction</string> </value>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Finds all instances related to archived hosting subscriptions and request their destruction.</string> </value>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>cleanup_archived_hs_instances</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value> <int>12</int> </value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<key> <string>after_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<key> <string>before_commit_script_name</string> </key>
<value>
<none/>
<list>
<string>Instance_changePromiseParameter</string>
</list>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<tuple/>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<key> <string>id</string> </key>
<value> <string>change_instance_parameter</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<tuple/>
<list>
<string>_setRootSoftwareReleaseUrl</string>
<string>_setTextContent</string>
<string>_setSourceReference</string>
<string>_setSlaXml</string>
</list>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<key> <string>once_per_transaction</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1288051200.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
<list>
<string>Slave Instance</string>
<string>Software Instance</string>
</list>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<key> <string>script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>sense_method_id</string> </key>
<value>
<none/>
</value>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Cleanup archived Hosting Subscription Instances</string> </value>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>instance = state_change[\'object\']\n
instance.bang(bang_tree=False, comment="Parameter changed")\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Instance_changePromiseParameter</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
788
\ No newline at end of file
794
\ No newline at end of file
portal_alarms/cleanup_archived_hs_instances
portal_alarms/confirm_ordered_sale_order
portal_alarms/confirm_planned_sale_invoice_transaction
portal_alarms/deliver_subscription_sale_packing_list
......
......@@ -74,6 +74,7 @@ if (state in (started, stopped)):\n
new_delivery.start()\n
new_delivery.stop()\n
new_delivery.deliver()\n
new_delivery.startBuilding()\n
</string> </value>
</item>
<item>
......
......@@ -155,6 +155,7 @@ else:\n
packing_list.confirm()\n
elif (state == destroyed):\n
packing_list.confirm()\n
packing_list.startBuilding()\n
\n
elif delivery.getPortalType() == "Sale Packing List":\n
line_list = delivery.contentValues(portal_type="Sale Packing List Line")\n
......
......@@ -81,7 +81,6 @@ packing_list_line = packing_list.newContent(\n
)\n
\n
\n
packing_list.startBuilding()\n
return packing_list\n
</string> </value>
</item>
......
23
\ No newline at end of file
24
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>instance = state_change[\'object\']\n
if (instance.getPortalType() in ["Software Instance", "Slave Instance"]) and (instance.getSlapState() != \'destroy_requested\'):\n
instance.bang(bang_tree=False, comment="State changed from %s to destroy_requested" % instance.getSlapState())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>RequestedInstance_bangIfStateChangeToDestroyed</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>instance = state_change[\'object\']\n
if (instance.getPortalType() in ["Software Instance", "Slave Instance"]) and (instance.getSlapState() != \'start_requested\'):\n
instance.bang(bang_tree=False, comment="State changed from %s to start_requested" % instance.getSlapState())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>RequestedInstance_bangIfStateChangeToStarted</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>instance = state_change[\'object\']\n
if (instance.getPortalType() in ["Software Instance", "Slave Instance"]) and (instance.getSlapState() != \'stop_requested\'):\n
instance.bang(bang_tree=False, comment="State changed from %s to stop_requested" % instance.getSlapState())\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>RequestedInstance_bangIfStateChangeToStopped</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -50,9 +50,12 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>instance = state_change[\'object\']\n
<value> <string>from DateTime import DateTime\n
instance = state_change[\'object\']\n
assert instance.getPortalType() in ["Slave Instance", "Software Instance"]\n
\n
instance.edit(bang_timestamp=int(DateTime()))\n
\n
if state_change.kwargs[\'bang_tree\']:\n
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery\n
portal = instance.getPortalObject()\n
......
......@@ -22,6 +22,7 @@
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>bang</string>
<string>request_start</string>
<string>request_stop</string>
</tuple>
......
......@@ -46,7 +46,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
<value> <string>RequestedInstance_bangIfStateChangeToDestroyed</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -46,7 +46,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
<value> <string>RequestedInstance_bangIfStateChangeToStarted</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -46,7 +46,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
<value> <string>RequestedInstance_bangIfStateChangeToStopped</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
41
\ No newline at end of file
42
\ No newline at end of file
......@@ -143,15 +143,23 @@ class SlapTool(BaseTool):
"""
def _getComputerInformation(computer_id, user):
user_document = self.getPortalObject().portal_catalog.getResultValue(
reference=user, portal_type=['Person', 'Computer', 'Software Instance'])
user_type = user_document.getPortalType()
self.REQUEST.response.setHeader('Content-Type', 'text/xml')
slap_computer = Computer(computer_id)
parent_uid = self._getComputerUidByReference(computer_id)
slap_computer._computer_partition_list = []
if user_type == 'Computer':
slap_computer._software_release_list = \
self._getSoftwareReleaseValueListForComputer(computer_id)
else:
slap_computer._software_release_list = []
for computer_partition in self.getPortalObject().portal_catalog(
parent_uid=parent_uid,
validation_state="validated",
portal_type="Computer Partition"):
slap_computer._computer_partition_list.append(
self._getSlapPartitionByPackingList(computer_partition.getObject()))
......@@ -171,19 +179,31 @@ class SlapTool(BaseTool):
Reuses slap library for easy marshalling.
"""
def _getFullComputerInformation(computer_id, user):
user_document = self.getPortalObject().portal_catalog.getResultValue(
reference=user, portal_type=['Person', 'Computer', 'Software Instance'])
user_type = user_document.getPortalType()
self.REQUEST.response.setHeader('Content-Type', 'text/xml')
slap_computer = Computer(computer_id)
parent_uid = self._getComputerUidByReference(computer_id)
slap_computer._computer_partition_list = []
if user_type == 'Computer':
slap_computer._software_release_list = \
self._getSoftwareReleaseValueListForComputer(computer_id, full=True)
else:
slap_computer._software_release_list = []
for computer_partition in self.getPortalObject().portal_catalog(
parent_uid=parent_uid,
validation_state="validated",
portal_type="Computer Partition"):
slap_computer._computer_partition_list.append(
self._getSlapPartitionByPackingList(computer_partition.getObject()))
return xml_marshaller.xml_marshaller.dumps(slap_computer)
user = self.getPortalObject().portal_membership.getAuthenticatedMember().getUserName()
return CachingMethod(_getFullComputerInformation,
id='_getFullComputerInformation',
cache_factory='slap_cache_factory')(computer_id, user)
security.declareProtected(Permissions.AccessContentsInformation,
'getComputerPartitionCertificate')
......@@ -428,11 +448,64 @@ class SlapTool(BaseTool):
"""
# Try to get the computer partition to raise an exception if it doesn't
# exist
self._getComputerPartitionDocument(
portal = self.getPortalObject()
computer_partition_document = self._getComputerPartitionDocument(
computer_reference, computer_partition_reference)
return xml_marshaller.xml_marshaller.dumps(
SlapComputerPartition(computer_reference,
computer_partition_reference))
slap_partition = SlapComputerPartition(computer_reference,
computer_partition_reference)
slap_partition._software_release_document = None
slap_partition._requested_state = 'destroyed'
slap_partition._need_modification = 0
software_instance = None
if computer_partition_document.getSlapState() == 'busy':
software_instance_list = portal.portal_catalog(
portal_type="Software Instance",
default_aggregate_uid=computer_partition_document.getUid(),
validation_state="validated",
limit=2,
)
software_instance_count = len(software_instance_list)
if software_instance_count == 1:
software_instance = software_instance_list[0].getObject()
elif software_instance_count > 1:
# XXX do not prevent the system to work if one partition is broken
raise NotImplementedError, "Too many instances %s linked to %s" % \
([x.path for x in software_instance_list],
computer_partition_document.getRelativeUrl())
if software_instance is not None:
# trick client side, that data has been synchronised already for given
# document
slap_partition._synced = True
state = software_instance.getSlapState()
if state == "stop_requested":
slap_partition._requested_state = 'stopped'
if state == "start_requested":
slap_partition._requested_state = 'started'
slap_partition._software_release_document = SoftwareRelease(
software_release=software_instance.getRootSoftwareReleaseUrl(),
computer_guid=computer_reference)
slap_partition._need_modification = 1
parameter_dict = self._getSoftwareInstanceAsParameterDict(
software_instance)
# software instance has to define an xml parameter
slap_partition._parameter_dict = self._instanceXmlToDict(
parameter_dict.pop('xml'))
slap_partition._connection_dict = self._instanceXmlToDict(
parameter_dict.pop('connection_xml'))
for slave_instance_dict in parameter_dict.get("slave_instance_list", []):
if slave_instance_dict.has_key("connection_xml"):
slave_instance_dict.update(self._instanceXmlToDict(
slave_instance_dict.pop("connection_xml")))
if slave_instance_dict.has_key("xml"):
slave_instance_dict.update(self._instanceXmlToDict(
slave_instance_dict.pop("xml")))
slap_partition._parameter_dict.update(parameter_dict)
return xml_marshaller.xml_marshaller.dumps(slap_partition)
####################################################
# Internal methods
......@@ -933,7 +1006,7 @@ class SlapTool(BaseTool):
computer_partition = software_instance.getAggregateValue(portal_type="Computer Partition")
timestamp = int(computer_partition.getModificationDate())
newtimestamp = int(software_instance.getModificationDate())
newtimestamp = int(software_instance.getBangTimestamp(int(software_instance.getModificationDate())))
if (newtimestamp > timestamp):
timestamp = newtimestamp
......@@ -960,7 +1033,7 @@ class SlapTool(BaseTool):
'xml': slave_instance.getTextContent(),
'connection_xml': slave_instance.getConnectionXml(),
})
newtimestamp = int(slave_instance.getModificationDate())
newtimestamp = int(slave_instance.getBangTimestamp(int(software_instance.getModificationDate())))
if (newtimestamp > timestamp):
timestamp = newtimestamp
return {
......@@ -972,7 +1045,7 @@ class SlapTool(BaseTool):
'slap_software_release_url': software_instance.getRootSoftwareReleaseUrl(),
'slave_instance_list': slave_instance_list,
'ip_list': ip_list,
'timestamp': "%s" % timestamp,
'timestamp': "%i" % timestamp,
}
@UnrestrictedMethod
......
......@@ -32,7 +32,7 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
transaction_list = list(set(transaction_list))
self.assertEquals(1, len(transaction_list))
return transaction_list[0].getObject().getParentValue()
return transaction_list[0].getObject()
def stepCheckRegistrationAccounting(self, sequence, **kw):
"""
......@@ -481,7 +481,7 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
# 1 invoice line is expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(3, len(invoice_line_list))
self.assertEquals(4, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
......@@ -489,6 +489,8 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
if x.getResource() == 'service_module/vifib_instance_subscription'][0]
hosting_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_hosting'][0]
update_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_update'][0]
self.assertEquals(True, service_line.hasPrice())
self.assertAlmostEquals(0, service_line.getPrice(), 3)
......@@ -502,6 +504,10 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
self.assertAlmostEquals(0, hosting_line.getPrice(), 3)
self.assertEquals(1, hosting_line.getQuantity())
self.assertEquals(True, update_line.hasPrice())
self.assertAlmostEquals(0, update_line.getPrice(), 3)
self.assertEquals(1, update_line.getQuantity())
# 0 transaction line
transaction_line_list = sale_invoice.contentValues(
portal_type="Sale Invoice Transaction Line")
......@@ -567,7 +573,7 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
# 1 invoice line is expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(4, len(invoice_line_list))
self.assertEquals(5, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
......@@ -577,6 +583,8 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
if x.getResource() == 'service_module/vifib_instance_hosting'][0]
destroy_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_cleanup'][0]
update_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_update'][0]
self.assertEquals(True, service_line.hasPrice())
self.assertAlmostEquals(0, service_line.getPrice(), 3)
......@@ -594,6 +602,10 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
self.assertAlmostEquals(0, destroy_line.getPrice(), 3)
self.assertEquals(1, destroy_line.getQuantity())
self.assertEquals(True, update_line.hasPrice())
self.assertAlmostEquals(0, update_line.getPrice(), 3)
self.assertEquals(2, update_line.getQuantity())
# 0 transaction line
transaction_line_list = sale_invoice.contentValues(
portal_type="Sale Invoice Transaction Line")
......@@ -612,7 +624,10 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
portal_type="Sale Invoice Transaction",
simulation_state="planned"):
invoice = invoice.getObject()
invoice.confirm()
invoice.SaleInvoiceTransaction_confirmPlanned(
# force invoice confirmation (or moving to next month)
this_month=invoice.getStartDate() + 1
)
def stepCheckWaitingInvoice(self, sequence, **kw):
"""
......@@ -650,10 +665,10 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
self.assertAlmostEquals(
1, sale_invoice.getTotalPrice(), 3)
# 5 invoice lines are expected
# 6 invoice lines are expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(5, len(invoice_line_list))
self.assertEquals(6, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
......@@ -663,6 +678,8 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
if x.getResource() == 'service_module/vifib_instance_hosting'][0]
destroy_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_cleanup'][0]
update_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_update'][0]
tax_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_tax'][0]
......@@ -682,6 +699,10 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
self.assertAlmostEquals(0, destroy_line.getPrice(), 3)
self.assertEquals(1, destroy_line.getQuantity())
self.assertEquals(True, update_line.hasPrice())
self.assertAlmostEquals(0, update_line.getPrice(), 3)
self.assertEquals(2, update_line.getQuantity())
self.assertEquals(True, tax_line.hasPrice())
self.assertAlmostEquals(0.196, tax_line.getPrice(), 3)
self.assertAlmostEquals(0.836, tax_line.getQuantity(), 3)
......@@ -823,7 +844,7 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
# 5 invoice lines are expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(5, len(invoice_line_list))
self.assertEquals(6, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
......@@ -833,6 +854,8 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
if x.getResource() == 'service_module/vifib_instance_hosting'][0]
destroy_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_cleanup'][0]
update_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_update'][0]
tax_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_tax'][0]
......@@ -852,6 +875,10 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
self.assertAlmostEquals(0, destroy_line.getPrice(), 3)
self.assertEquals(1, destroy_line.getQuantity())
self.assertEquals(True, update_line.hasPrice())
self.assertAlmostEquals(0, update_line.getPrice(), 3)
self.assertEquals(2, update_line.getQuantity())
self.assertEquals(True, tax_line.hasPrice())
self.assertAlmostEquals(0.196, tax_line.getPrice(), 3)
self.assertAlmostEquals(0.836, tax_line.getQuantity(), 3)
......@@ -1130,7 +1157,7 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
# 5 invoice lines are expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(5, len(invoice_line_list))
self.assertEquals(6, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
......@@ -1140,6 +1167,8 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
if x.getResource() == 'service_module/vifib_instance_hosting'][0]
destroy_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_cleanup'][0]
update_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_update'][0]
tax_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_tax'][0]
......@@ -1159,6 +1188,10 @@ class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
self.assertAlmostEquals(0, destroy_line.getPrice(), 3)
self.assertEquals(2, destroy_line.getQuantity())
self.assertEquals(True, update_line.hasPrice())
self.assertAlmostEquals(0, update_line.getPrice(), 3)
self.assertEquals(6, update_line.getQuantity())
self.assertEquals(True, tax_line.hasPrice())
self.assertAlmostEquals(0.196, tax_line.getPrice(), 3)
self.assertAlmostEquals(1.672, tax_line.getQuantity(), 3)
......
......@@ -5,9 +5,9 @@ master_url = https://slap.vifib.com/
# Replace computer_id by the unique identifier of your computer on vifib.net,
# starting by COMP-
computer_id = COMP-12345
key_file = /etc/opt/slapos/key
cert_file = /etc/opt/slapos/certificate
certificate_repository_path = /etc/opt/slapos/pki/
key_file = /etc/opt/slapos/ssl/computer.key
cert_file = /etc/opt/slapos/ssl/computer.crt
certificate_repository_path = /etc/opt/slapos/ssl/partition_pki
[slapformat]
# Replace by your network interface like eth0, eth1, slapbr0...
......
......@@ -489,6 +489,7 @@ class ComputerPartition(SlapDocument):
return self._software_release_document
def setConnectionDict(self, connection_dict, slave_reference=None):
if self.getConnectionParameterDict() != connection_dict:
self._connection_helper.POST('/setComputerPartitionConnectionXml', {
'computer_id': self._computer_id,
'computer_partition_id': self._partition_id,
......
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