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

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

See merge request nexedi/slapos.core!489
parent 47d81bef
Pipeline #26844 failed with stage
in 0 seconds
......@@ -408,6 +408,7 @@ class Partition(object):
def __init__(self,
software_path,
instance_path,
shared_part_list,
supervisord_partition_configuration_path,
supervisord_socket,
computer_partition,
......@@ -431,6 +432,7 @@ class Partition(object):
self.logger = logger
self.software_path = software_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.service_path = os.path.join(self.instance_path, 'etc', 'service')
self.prerm_path = os.path.join(self.instance_path, 'etc', 'prerm')
......@@ -639,6 +641,7 @@ class Partition(object):
'cert_file': self.cert_file,
'storage_home': self.instance_storage_home,
'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:
f.write(buildout_text)
......
......@@ -1076,6 +1076,7 @@ stderr_logfile_backups=1
local_partition = Partition(
software_path=software_path,
instance_path=instance_path,
shared_part_list=self.shared_part_list,
supervisord_partition_configuration_path=os.path.join(
_getSupervisordConfigurationDirectory(self.instance_root),
computer_partition_id + '.conf'),
......@@ -1172,6 +1173,7 @@ stderr_logfile_backups=1
local_partition = Partition(
software_path=software_path,
instance_path=instance_path,
shared_part_list=self.shared_part_list,
supervisord_partition_configuration_path=os.path.join(
_getSupervisordConfigurationDirectory(self.instance_root), '%s.conf' %
computer_partition_id),
......@@ -1833,6 +1835,7 @@ stderr_logfile_backups=1
software_path=software_path,
instance_path=os.path.join(self.instance_root,
computer_partition.getId()),
shared_part_list=self.shared_part_list,
supervisord_partition_configuration_path=os.path.join(
_getSupervisordConfigurationDirectory(self.instance_root), '%s.conf' %
computer_partition_id),
......
......@@ -13,6 +13,8 @@ server-url = %(server_url)s
software-release-url = %(software_release_url)s
key-file = %(key_file)s
cert-file = %(cert_file)s
shared-part-list =
%(shared_part_list)s
[slap_connection]
# Kept for backward compatiblity
......
......@@ -33,6 +33,8 @@ import unittest
import shutil
import tempfile
from six.moves.configparser import ConfigParser
from slapos.slap import ComputerPartition as SlapComputerPartition
from slapos.grid.SlapObject import Partition, Software
......@@ -135,7 +137,8 @@ class MasterMixin(BasicMixin, unittest.TestCase):
partition_id=None,
slap_computer_partition=None,
retention_delay=None,
partition_timeout=None
partition_timeout=None,
shared_part_list='',
):
"""
Create a partition, and return a Partition object created
......@@ -166,6 +169,7 @@ class MasterMixin(BasicMixin, unittest.TestCase):
partition = Partition(
software_path=software_path,
instance_path=instance_path,
shared_part_list=shared_part_list,
supervisord_partition_configuration_path=os.path.join(
supervisor_configuration_path, partition_id),
supervisord_socket=os.path.join(
......@@ -413,6 +417,18 @@ class TestPartitionSlapObject(MasterMixin, unittest.TestCase):
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):
"""
Backward compatibility test, for old software releases.
......@@ -455,6 +471,29 @@ class TestPartitionSlapObject(MasterMixin, unittest.TestCase):
# XXX: What should it raise?
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):
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