def run(self, provider_key=None, dryrun=False): """ Runs a nulecule application. Args: provider_key (str): Provider to use for running Nulecule application dryrun (bool): Do not make changes to host when True Returns: None """ provider_key, provider = self.get_provider(provider_key, dryrun) # Process preliminary requirements # Pass configuration, path of the app, graph, provider as well as dry-run # for provider init() if REQUIREMENTS_KEY in self.graph[0]: logger.debug("Requirements key detected. Running action.") r = Requirements(self.config, self.basepath, self.graph[0][REQUIREMENTS_KEY], provider_key, dryrun) r.run() # Process components for component in self.components: component.run(provider_key, dryrun) cockpit_logger.info("Component %s installed successfully" % provider_key)
class TestPersistentStorage(unittest.TestCase): # Create a tmp dir and add graph and config information def setUp(self): config = {'helloapache-app': {'image': 'centos/httpd', 'hostport': 80}, 'general': {'namespace': 'default', 'provider': 'kubernetes'}} graph = [{'persistentVolume': {'accessMode': 'ReadWrite', 'name': 'var-lib-mongodb-data', 'size': 4}}, {'persistentVolume': {'accessMode': 'ReadWrite', 'name': 'var-log-mongodb', 'size': 4}}] self.tmpdir = tempfile.mkdtemp(prefix="atomicapp-test", dir="/tmp") self.test = Requirements( config=config, basepath=self.tmpdir, graph=graph, provider="kubernetes", dryrun=True) def tearDown(self): pass def test_missing_requirement(self): with self.assertRaises(RequirementFailedException) as context: self.test._find_requirement_function_name('foo') self.assertTrue("Requirement foo does not exist." in context.exception) # Rest of these tests checks to see if dryrunning the provider passes correctly def test_run(self): self.test.run() def test_stop(self): self.test.stop()
class TestPersistentStorage(unittest.TestCase): # Create a tmp dir and add graph and config information def setUp(self): config = { "helloapache-app": {"image": "centos/httpd", "hostport": 80}, "general": {"namespace": "default", "provider": "kubernetes"}, } graph = [ {"persistentVolume": {"accessMode": "ReadWriteOnce", "name": "var-lib-mongodb-data", "size": 4}}, {"persistentVolume": {"accessMode": "ReadWriteOnce", "name": "var-log-mongodb", "size": 4}}, ] self.tmpdir = tempfile.mkdtemp(prefix="atomicapp-test", dir="/tmp") self.test = Requirements(config=config, basepath=self.tmpdir, graph=graph, provider="kubernetes", dryrun=True) def tearDown(self): pass def test_missing_requirement(self): with self.assertRaises(RequirementFailedException) as context: self.test._find_requirement_function_name("foo") self.assertTrue("Requirement foo does not exist." in context.exception) # Rest of these tests checks to see if dryrunning the provider passes correctly def test_run(self): self.test.run() def test_stop(self): self.test.stop()
class TestPersistentStorage(unittest.TestCase): # Create a tmp dir and add graph and config information def setUp(self): config = { 'helloapache-app': { 'image': 'centos/httpd', 'hostport': 80 }, 'general': { 'namespace': 'default', 'provider': 'kubernetes' } } graph = [{ 'persistentVolume': { 'accessMode': 'ReadWrite', 'name': 'var-lib-mongodb-data', 'size': 4 } }, { 'persistentVolume': { 'accessMode': 'ReadWrite', 'name': 'var-log-mongodb', 'size': 4 } }] self.tmpdir = tempfile.mkdtemp(prefix="atomicapp-test", dir="/tmp") self.test = Requirements(config=config, basepath=self.tmpdir, graph=graph, provider="kubernetes", dryrun=True) def tearDown(self): pass def test_missing_requirement(self): with self.assertRaises(RequirementFailedException) as context: self.test._find_requirement_function_name('foo') self.assertTrue("Requirement foo does not exist." in context.exception) # Rest of these tests checks to see if dryrunning the provider passes correctly def test_run(self): self.test.run() def test_stop(self): self.test.stop()