Commit 133bd4bd authored by Xavier Thompson's avatar Xavier Thompson

grid: Add shared-parts-list to slap-connection

See merge request !489
parent 47d81bef
...@@ -408,6 +408,7 @@ class Partition(object): ...@@ -408,6 +408,7 @@ class Partition(object):
def __init__(self, def __init__(self,
software_path, software_path,
instance_path, instance_path,
shared_part_list,
supervisord_partition_configuration_path, supervisord_partition_configuration_path,
supervisord_socket, supervisord_socket,
computer_partition, computer_partition,
...@@ -431,6 +432,7 @@ class Partition(object): ...@@ -431,6 +432,7 @@ class Partition(object):
self.logger = logger self.logger = logger
self.software_path = software_path self.software_path = software_path
self.instance_path = instance_path self.instance_path = instance_path
self.shared_part_list = shared_part_list
self.run_path = os.path.join(self.instance_path, 'etc', 'run') self.run_path = os.path.join(self.instance_path, 'etc', 'run')
self.service_path = os.path.join(self.instance_path, 'etc', 'service') self.service_path = os.path.join(self.instance_path, 'etc', 'service')
self.prerm_path = os.path.join(self.instance_path, 'etc', 'prerm') self.prerm_path = os.path.join(self.instance_path, 'etc', 'prerm')
...@@ -639,6 +641,7 @@ class Partition(object): ...@@ -639,6 +641,7 @@ class Partition(object):
'cert_file': self.cert_file, 'cert_file': self.cert_file,
'storage_home': self.instance_storage_home, 'storage_home': self.instance_storage_home,
'global_ipv4_network_prefix': self.ipv4_global_network, 'global_ipv4_network_prefix': self.ipv4_global_network,
'shared_part_list': ' '.join(self.shared_part_list.strip().splitlines(True))
} }
with open(config_location, 'w') as f: with open(config_location, 'w') as f:
f.write(buildout_text) f.write(buildout_text)
......
...@@ -1076,6 +1076,7 @@ stderr_logfile_backups=1 ...@@ -1076,6 +1076,7 @@ stderr_logfile_backups=1
local_partition = Partition( local_partition = Partition(
software_path=software_path, software_path=software_path,
instance_path=instance_path, instance_path=instance_path,
shared_part_list=self.shared_part_list,
supervisord_partition_configuration_path=os.path.join( supervisord_partition_configuration_path=os.path.join(
_getSupervisordConfigurationDirectory(self.instance_root), _getSupervisordConfigurationDirectory(self.instance_root),
computer_partition_id + '.conf'), computer_partition_id + '.conf'),
...@@ -1172,6 +1173,7 @@ stderr_logfile_backups=1 ...@@ -1172,6 +1173,7 @@ stderr_logfile_backups=1
local_partition = Partition( local_partition = Partition(
software_path=software_path, software_path=software_path,
instance_path=instance_path, instance_path=instance_path,
shared_part_list=self.shared_part_list,
supervisord_partition_configuration_path=os.path.join( supervisord_partition_configuration_path=os.path.join(
_getSupervisordConfigurationDirectory(self.instance_root), '%s.conf' % _getSupervisordConfigurationDirectory(self.instance_root), '%s.conf' %
computer_partition_id), computer_partition_id),
...@@ -1833,6 +1835,7 @@ stderr_logfile_backups=1 ...@@ -1833,6 +1835,7 @@ stderr_logfile_backups=1
software_path=software_path, software_path=software_path,
instance_path=os.path.join(self.instance_root, instance_path=os.path.join(self.instance_root,
computer_partition.getId()), computer_partition.getId()),
shared_part_list=self.shared_part_list,
supervisord_partition_configuration_path=os.path.join( supervisord_partition_configuration_path=os.path.join(
_getSupervisordConfigurationDirectory(self.instance_root), '%s.conf' % _getSupervisordConfigurationDirectory(self.instance_root), '%s.conf' %
computer_partition_id), computer_partition_id),
......
...@@ -13,6 +13,8 @@ server-url = %(server_url)s ...@@ -13,6 +13,8 @@ server-url = %(server_url)s
software-release-url = %(software_release_url)s software-release-url = %(software_release_url)s
key-file = %(key_file)s key-file = %(key_file)s
cert-file = %(cert_file)s cert-file = %(cert_file)s
shared-part-list =
%(shared_part_list)s
[slap_connection] [slap_connection]
# Kept for backward compatiblity # Kept for backward compatiblity
......
...@@ -33,6 +33,8 @@ import unittest ...@@ -33,6 +33,8 @@ import unittest
import shutil import shutil
import tempfile import tempfile
from six.moves.configparser import ConfigParser
from slapos.slap import ComputerPartition as SlapComputerPartition from slapos.slap import ComputerPartition as SlapComputerPartition
from slapos.grid.SlapObject import Partition, Software from slapos.grid.SlapObject import Partition, Software
...@@ -135,7 +137,8 @@ class MasterMixin(BasicMixin, unittest.TestCase): ...@@ -135,7 +137,8 @@ class MasterMixin(BasicMixin, unittest.TestCase):
partition_id=None, partition_id=None,
slap_computer_partition=None, slap_computer_partition=None,
retention_delay=None, retention_delay=None,
partition_timeout=None partition_timeout=None,
shared_part_list='',
): ):
""" """
Create a partition, and return a Partition object created Create a partition, and return a Partition object created
...@@ -166,6 +169,7 @@ class MasterMixin(BasicMixin, unittest.TestCase): ...@@ -166,6 +169,7 @@ class MasterMixin(BasicMixin, unittest.TestCase):
partition = Partition( partition = Partition(
software_path=software_path, software_path=software_path,
instance_path=instance_path, instance_path=instance_path,
shared_part_list=shared_part_list,
supervisord_partition_configuration_path=os.path.join( supervisord_partition_configuration_path=os.path.join(
supervisor_configuration_path, partition_id), supervisor_configuration_path, partition_id),
supervisord_socket=os.path.join( supervisord_socket=os.path.join(
...@@ -413,6 +417,18 @@ class TestPartitionSlapObject(MasterMixin, unittest.TestCase): ...@@ -413,6 +417,18 @@ class TestPartitionSlapObject(MasterMixin, unittest.TestCase):
self.assertTrue(utils.launchBuildout.called) self.assertTrue(utils.launchBuildout.called)
def test_instance_is_deploying_if_software_release_exists(self):
"""
Test that slapgrid deploys an instance if its Software Release exists and
instance.cfg in the Software Release exists.
"""
software = self.createSoftware()
partition = self.createPartition(software.url)
partition.install()
self.assertTrue(utils.launchBuildout.called)
def test_backward_compatibility_instance_is_deploying_if_template_cfg_is_used(self): def test_backward_compatibility_instance_is_deploying_if_template_cfg_is_used(self):
""" """
Backward compatibility test, for old software releases. Backward compatibility test, for old software releases.
...@@ -455,6 +471,29 @@ class TestPartitionSlapObject(MasterMixin, unittest.TestCase): ...@@ -455,6 +471,29 @@ class TestPartitionSlapObject(MasterMixin, unittest.TestCase):
# XXX: What should it raise? # XXX: What should it raise?
self.assertRaises(IOError, partition.install) self.assertRaises(IOError, partition.install)
def test_buildout_tail_contains_shared_parts(self):
"""
Check that shared-part-list in included in buildout tail.
"""
software = self.createSoftware()
partition = self.createPartition(
software.url,
shared_part_list='bogus/shared/part')
partition.install()
buildout_cfg = os.path.join(partition.instance_path, 'buildout.cfg')
config = ConfigParser()
config.read(buildout_cfg)
self.assertTrue(config.has_option('slap-connection', 'shared-part-list'))
self.assertEqual(
config.get('slap-connection', 'shared-part-list').strip(),
'bogus/shared/part'
)
class TestPartitionSupervisorConfig(MasterMixin, unittest.TestCase): class TestPartitionSupervisorConfig(MasterMixin, unittest.TestCase):
def setUp(self): def setUp(self):
......
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