def configure_copytool(id, index, bin_path, archive_number, filesystem, mountpoint, hsm_arguments): copytool = Copytool( id=id, index=index, bin_path=bin_path, filesystem=filesystem, mountpoint=mountpoint, hsm_arguments=hsm_arguments, archive_number=archive_number, ) try: config.set("copytools", copytool.id, copytool.as_dict()) except ConfigKeyExistsError: # This can happen when we've redeployed on a worker that was # already configured (force-removed, etc.) copytool_log.warn( "Copytool %s was already configured -- assuming we need to update" % copytool.id) update_kwargs = copytool.as_dict() del update_kwargs["id"] update_copytool(copytool.id, **update_kwargs) return copytool.id
def _copytool_vars(id): settings = config.get("settings", "agent") copytool = Copytool(**config.get("copytools", id)) ct = copytool.as_dict() ct["event_fifo"] = copytool.event_fifo ct["report_interval"] = COPYTOOL_PROGRESS_INTERVAL return { "id": id, "ct_path": ct["bin_path"], "ct_arguments": settings["copytool_template"] % ct, }
def _copytool_vars(id): settings = config.get('settings', 'agent') copytool = Copytool(**config.get('copytools', id)) ct = copytool.as_dict() ct['event_fifo'] = copytool.event_fifo ct['report_interval'] = COPYTOOL_PROGRESS_INTERVAL return { 'id': id, 'ct_path': ct['bin_path'], 'ct_arguments': settings['copytool_template'] % ct }
class CopytoolTestCase(unittest.TestCase): def setUp(self): super(CopytoolTestCase, self).setUp() from chroma_agent.config_store import ConfigStore self.mock_config = ConfigStore(tempfile.mkdtemp()) patch("chroma_agent.copytool_monitor.config", self.mock_config).start() self.ct_id = "42" self.ct_bin_path = "/usr/sbin/lhsmtool_foo" self.ct_filesystem = "testfs" self.ct_mountpoint = "/mnt/testfs" self.ct_archive = 2 self.ct_index = 0 self.ct = Copytool( self.ct_id, self.ct_index, self.ct_bin_path, self.ct_archive, self.ct_filesystem, self.ct_mountpoint, "", ) self.addCleanup(patch.stopall) def tearDown(self): super(CopytoolTestCase, self).tearDown() shutil.rmtree(self.mock_config.path) def test_copytool_event_fifo(self): self.mock_config.set("settings", "agent", {"copytool_fifo_directory": "/var/spool"}) self.assertEqual(self.ct.event_fifo, "/var/spool/%s-events" % self.ct) def test_copytool_as_dict(self): self.assertDictEqual( self.ct.as_dict(), dict( id=self.ct.id, index=self.ct.index, bin_path=self.ct.bin_path, archive_number=self.ct.archive_number, filesystem=self.ct.filesystem, mountpoint=self.ct.mountpoint, hsm_arguments=self.ct.hsm_arguments, ), )
class CopytoolTestCase(unittest.TestCase): def setUp(self): super(CopytoolTestCase, self).setUp() from chroma_agent.config_store import ConfigStore self.mock_config = ConfigStore(tempfile.mkdtemp()) patch('chroma_agent.copytool_monitor.config', self.mock_config).start() self.ct_id = '42' self.ct_bin_path = '/usr/sbin/lhsmtool_foo' self.ct_filesystem = 'testfs' self.ct_mountpoint = '/mnt/testfs' self.ct_archive = 2 self.ct_index = 0 self.ct = Copytool(self.ct_id, self.ct_index, self.ct_bin_path, self.ct_archive, self.ct_filesystem, self.ct_mountpoint, "") self.addCleanup(patch.stopall) def tearDown(self): super(CopytoolTestCase, self).tearDown() shutil.rmtree(self.mock_config.path) def test_copytool_event_fifo(self): self.mock_config.set('settings', 'agent', {'copytool_fifo_directory': '/var/spool'}) self.assertEqual(self.ct.event_fifo, '/var/spool/%s-events' % self.ct) def test_copytool_as_dict(self): self.assertDictEqual( self.ct.as_dict(), dict(id=self.ct.id, index=self.ct.index, bin_path=self.ct.bin_path, archive_number=self.ct.archive_number, filesystem=self.ct.filesystem, mountpoint=self.ct.mountpoint, hsm_arguments=self.ct.hsm_arguments))