Commit 70dfeda7 authored by Łukasz Nowak's avatar Łukasz Nowak

Merge remote-tracking branch 'origin/master' into payzen-fixup

parents 2173d319 35752d44
...@@ -4,10 +4,8 @@ Changes ...@@ -4,10 +4,8 @@ Changes
0.25 (Unreleased) 0.25 (Unreleased)
----------------- -----------------
* Bugfix: Remove CONFIG_SITE from environment variables. On some platforms, it * Fix support for no_bridge option in configuration files for some values:
can change any software's libdir name (to things like lib64) and thus no_bridge = false was stated as true. [Cedric de Saint Martin]
break all other software trying to fetch libraries.
[Cedric de Saint Martin]
0.24 (2012-03-29) 0.24 (2012-03-29)
----------------- -----------------
......
...@@ -68,7 +68,7 @@ CREATE TABLE `computer_partition` (\n ...@@ -68,7 +68,7 @@ CREATE TABLE `computer_partition` (\n
`free_for_request` INT(1),\n `free_for_request` INT(1),\n
`software_type` VARCHAR(255),\n `software_type` VARCHAR(255),\n
PRIMARY KEY (`uid`, `software_release_url`)\n PRIMARY KEY (`uid`, `software_release_url`)\n
) TYPE=InnoDB;\n ) ENGINE=InnoDB;\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -66,7 +66,7 @@ CREATE TABLE `software_instance_tree` (\n ...@@ -66,7 +66,7 @@ CREATE TABLE `software_instance_tree` (\n
`uid` BIGINT UNSIGNED NOT NULL,\n `uid` BIGINT UNSIGNED NOT NULL,\n
`root_uid` BIGINT UNSIGNED NOT NULL,\n `root_uid` BIGINT UNSIGNED NOT NULL,\n
PRIMARY KEY (`uid`, `root_uid`)\n PRIMARY KEY (`uid`, `root_uid`)\n
) TYPE=InnoDB;\n ) ENGINE=InnoDB;\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
`url` varchar(255),\n `url` varchar(255),\n
`state` varchar(255),\n `state` varchar(255),\n
PRIMARY KEY (`uid`, `delivery_line_uid`)\n PRIMARY KEY (`uid`, `delivery_line_uid`)\n
) TYPE=InnoDB;\n ) ENGINE=InnoDB;\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
KEY `effective_date` (`effective_date`),\n KEY `effective_date` (`effective_date`),\n
KEY `expiration_date` (`effective_date`),\n KEY `expiration_date` (`effective_date`),\n
KEY `frequency_index` (`creation_date_index`, `frequency_index`)\n KEY `frequency_index` (`creation_date_index`, `frequency_index`)\n
) TYPE=InnoDB;\n ) ENGINE=InnoDB;\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
36 37
\ No newline at end of file \ No newline at end of file
...@@ -74,6 +74,11 @@ else:\n ...@@ -74,6 +74,11 @@ else:\n
tag = "%s_%s_inProgress" % (person.getUid(), \n tag = "%s_%s_inProgress" % (person.getUid(), \n
software_title)\n software_title)\n
\n \n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
# The software instance is already under creation but can not be fetched from catalog\n
# As it is not possible to fetch informations, it is better to raise an error\n
raise NotImplementedError(tag)\n
\n
# Check if it already exists\n # Check if it already exists\n
cleanup_resource = portal.portal_preferences.getPreferredInstanceCleanupResource()\n cleanup_resource = portal.portal_preferences.getPreferredInstanceCleanupResource()\n
request_hosting_subscription = None\n request_hosting_subscription = None\n
...@@ -86,6 +91,8 @@ for hs in portal.portal_catalog(\n ...@@ -86,6 +91,8 @@ for hs in portal.portal_catalog(\n
try:\n try:\n
cleanup_delivery_line = si.Item_getInstancePackingListLine(cleanup_resource)\n cleanup_delivery_line = si.Item_getInstancePackingListLine(cleanup_resource)\n
except ValueError:\n except ValueError:\n
order_line = si.getAggregateRelatedValue(portal_type=\'Sale Order Line\')\n
if order_line.getSimulationState() != \'cancelled\':\n
request_hosting_subscription = hs\n request_hosting_subscription = hs\n
break\n break\n
else:\n else:\n
...@@ -93,11 +100,6 @@ for hs in portal.portal_catalog(\n ...@@ -93,11 +100,6 @@ for hs in portal.portal_catalog(\n
request_hosting_subscription = hs\n request_hosting_subscription = hs\n
break\n break\n
\n \n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
# The software instance is already under creation but can not be fetched from catalog\n
# As it is not possible to fetch informations, it is better to raise an error\n
raise NotImplementedError(tag)\n
\n
if (request_hosting_subscription is None):\n if (request_hosting_subscription is None):\n
hosting_subscription_reference = "HOSTSUBS-%s" % context.getPortalObject().portal_ids\\\n hosting_subscription_reference = "HOSTSUBS-%s" % context.getPortalObject().portal_ids\\\n
.generateNewId(id_group=\'slap_hosting_subscription_reference\', id_generator=\'uid\')\n .generateNewId(id_group=\'slap_hosting_subscription_reference\', id_generator=\'uid\')\n
......
689 691
\ No newline at end of file \ No newline at end of file
...@@ -1212,6 +1212,73 @@ class TestVifibSlapBug(TestVifibSlapWebServiceMixin): ...@@ -1212,6 +1212,73 @@ class TestVifibSlapBug(TestVifibSlapWebServiceMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def test_request_new_with_destroyed_while_looking_for_partition_reference(self):
"""Prove that having destroyed SI allows to request new one with same
reference, when destruction was done while looking for new partition"""
self.computer_partition_amount = 0
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
SetRandomRequestedReference
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
ConfirmOrderedSaleOrderActiveSense
Tic
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
CheckSoftwareInstanceNoDeliveryRelated
Logout
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckSoftwareInstanceCancelledSaleOrderLine
Tic # in order to give chance to update Open Order
CheckOpenOrderLineRemoved
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
CheckSoftwareInstanceOrderedSaleOrderLine
CheckSoftwareInstanceNoDeliveryRelated
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_request_new_with_destroyed_reference(self): def test_request_new_with_destroyed_reference(self):
"""Prove that having destroyed SI allows to request new one with same """Prove that having destroyed SI allows to request new one with same
reference""" reference"""
......
...@@ -128,18 +128,6 @@ class TestVifibSlapOpenOrderRequest(TestVifibSlapWebServiceMixin): ...@@ -128,18 +128,6 @@ class TestVifibSlapOpenOrderRequest(TestVifibSlapWebServiceMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepCheckSoftwareInstanceNoDeliveryRelated(self, sequence, **kw):
self.assertEqual(None, self.portal.portal_catalog.getResultValue(
default_aggregate_uid=sequence['software_instance_uid'],
portal_type=self.sale_packing_list_line_portal_type
))
def stepCheckSoftwareInstanceCancelledSaleOrderLine(self, sequence, **kw):
self.assertEqual('cancelled', self.portal.portal_catalog.getResultValue(
default_aggregate_uid=sequence['software_instance_uid'],
portal_type=self.sale_order_line_portal_type
).getSimulationState())
def test_person_destroy_not_instanciable_software_instance(self): def test_person_destroy_not_instanciable_software_instance(self):
"""Check that if there is no way to instantiate software instance """Check that if there is no way to instantiate software instance
on any partition person is able to destroy it""" on any partition person is able to destroy it"""
......
...@@ -177,6 +177,24 @@ class TestVifibSlapWebServiceMixin(testVifibMixin): ...@@ -177,6 +177,24 @@ class TestVifibSlapWebServiceMixin(testVifibMixin):
######################################## ########################################
# Steps -- scenarios # Steps -- scenarios
######################################## ########################################
def stepCheckSoftwareInstanceNoDeliveryRelated(self, sequence, **kw):
self.assertEqual(None, self.portal.portal_catalog.getResultValue(
default_aggregate_uid=sequence['software_instance_uid'],
portal_type=self.sale_packing_list_line_portal_type
))
def stepCheckSoftwareInstanceCancelledSaleOrderLine(self, sequence, **kw):
self.assertEqual('cancelled', self.portal.portal_catalog.getResultValue(
default_aggregate_uid=sequence['software_instance_uid'],
portal_type=self.sale_order_line_portal_type
).getSimulationState())
def stepCheckSoftwareInstanceOrderedSaleOrderLine(self, sequence, **kw):
self.assertEqual('ordered', self.portal.portal_catalog.getResultValue(
default_aggregate_uid=sequence['software_instance_uid'],
portal_type=self.sale_order_line_portal_type
).getSimulationState())
def stepCheckOpenOrderLineRemoved(self, sequence, **kw): def stepCheckOpenOrderLineRemoved(self, sequence, **kw):
software_instance = self.portal.portal_catalog.getResultValue( software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid']) uid=sequence['software_instance_uid'])
...@@ -354,9 +372,7 @@ class TestVifibSlapWebServiceMixin(testVifibMixin): ...@@ -354,9 +372,7 @@ class TestVifibSlapWebServiceMixin(testVifibMixin):
portal_type=self.software_instance_portal_type, portal_type=self.software_instance_portal_type,
title=sequence['requested_reference']): title=sequence['requested_reference']):
# only not yet destroyed ones # only not yet destroyed ones
try: if software_instance.SoftwareInstance_getStatus() != 'Destroyed':
software_instance.Item_getInstancePackingListLine(cleanup_resource)
except ValueError:
software_instance_list.append(software_instance) software_instance_list.append(software_instance)
self.assertEqual(1, len(software_instance_list)) self.assertEqual(1, len(software_instance_list))
......
...@@ -2,21 +2,22 @@ ...@@ -2,21 +2,22 @@
software_root = /opt/slapgrid software_root = /opt/slapgrid
instance_root = /srv/slapgrid instance_root = /srv/slapgrid
master_url = https://slap.vifib.com/ master_url = https://slap.vifib.com/
computer_id = your computer id # Replace computer_id by the unique identifier of your computer on vifib.net,
buildout = /path/to/buildout/binary # 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/
[slapformat] [slapformat]
# Replace by your network interface like eth0, eth1, slapbr0...
interface_name = interfacename
computer_xml = /opt/slapos/slapos.xml computer_xml = /opt/slapos/slapos.xml
log_file = /opt/slapos/slapformat.log log_file = /opt/slapos/slapformat.log
partition_amount = 200 partition_amount = 20
interface_name = br0
partition_base_name = slappart partition_base_name = slappart
user_base_name = slapuser user_base_name = slapuser
tap_base_name = slaptap tap_base_name = slaptap
# You can choose any other local network which does not conflict with your
# current machine configuration
ipv4_local_network = 10.0.0.0/16 ipv4_local_network = 10.0.0.0/16
[slapproxy]
host = 127.0.0.1
port = 5000
# You could also specify: /path/to/file
database_uri = :memory:
...@@ -1080,12 +1080,13 @@ class Config(object): ...@@ -1080,12 +1080,13 @@ class Config(object):
self.logger.addHandler(logging.StreamHandler()) self.logger.addHandler(logging.StreamHandler())
# Convert strings to booleans # Convert strings to booleans
root_needed = False for o in ['alter_network', 'alter_user', 'no_bridge']:
for o in ['alter_network', 'alter_user']: attr = getattr(self, o)
if getattr(self, o).lower() == 'true': if isinstance(attr, str):
if attr.lower() == 'true':
root_needed = True root_needed = True
setattr(self, o, True) setattr(self, o, True)
elif getattr(self, o).lower() == 'false': elif attr.lower() == 'false':
setattr(self, o, False) setattr(self, o, False)
else: else:
message = 'Option %r needs to be "True" or "False", wrong value: ' \ message = 'Option %r needs to be "True" or "False", wrong value: ' \
...@@ -1102,7 +1103,10 @@ class Config(object): ...@@ -1102,7 +1103,10 @@ class Config(object):
if self.alter_network: if self.alter_network:
self.checkRequiredBinary(['brctl']) self.checkRequiredBinary(['brctl'])
if self.dry_run: # Check if root is needed
if (self.alter_network or self.alter_user) and not self.dry_run:
root_needed = True
else:
root_needed = False root_needed = False
# check root # check root
......
...@@ -57,6 +57,8 @@ import tempfile ...@@ -57,6 +57,8 @@ import tempfile
from time import strftime from time import strftime
import StringIO import StringIO
from lxml import etree from lxml import etree
from time import sleep
from random import random
MANDATORY_PARAMETER_LIST = [ MANDATORY_PARAMETER_LIST = [
...@@ -114,6 +116,8 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple): ...@@ -114,6 +116,8 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
help="Promise timeout in seconds.") help="Promise timeout in seconds.")
parser.add_argument("configuration_file", nargs=1, type=argparse.FileType(), parser.add_argument("configuration_file", nargs=1, type=argparse.FileType(),
help="SlapOS configuration file.") help="SlapOS configuration file.")
parser.add_argument("--maximal_delay", help="The maximal delay value in seconds. " \
"A negative value leads start immediately.")
# Parses arguments # Parses arguments
if argument_tuple == (): if argument_tuple == ():
...@@ -215,6 +219,13 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple): ...@@ -215,6 +219,13 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
else: else:
signature_certificate_list = None signature_certificate_list = None
maximal_delay = float(option_dict.get("maximal_delay", "300"))
if maximal_delay > 0:
duration = maximal_delay * random()
logging.info("Sleeping for %s seconds. To disable this feature, " \
"check maximal_delay parameter in manual." % duration)
time.sleep(duration)
# Returning new Slapgrid instance and options # Returning new Slapgrid instance and options
return ([Slapgrid(software_root=option_dict['software_root'], return ([Slapgrid(software_root=option_dict['software_root'],
instance_root=option_dict['instance_root'], instance_root=option_dict['instance_root'],
......
...@@ -62,7 +62,6 @@ SYSTEM_ENVIRONMENT_REMOVE_LIST = [ ...@@ -62,7 +62,6 @@ SYSTEM_ENVIRONMENT_REMOVE_LIST = [
'TMP', 'TMP',
'TMPDIR', 'TMPDIR',
'USER', 'USER',
'CONFIG_SITE',
] ]
LOCALE_ENVIRONMENT_REMOVE_LIST = [ LOCALE_ENVIRONMENT_REMOVE_LIST = [
......
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