當前位置: 首頁>>代碼示例>>Python>>正文


Python base.Nulecule類代碼示例

本文整理匯總了Python中atomicapp.nulecule.base.Nulecule的典型用法代碼示例。如果您正苦於以下問題:Python Nulecule類的具體用法?Python Nulecule怎麽用?Python Nulecule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Nulecule類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_load_components

    def test_load_components(self, MockNuleculeComponent):
        graph = [
            {
                'name': 'app1',
                'source': 'docker://somecontainer',
                'params': []
            },
            {
                'name': 'app2',
                'artifacts': [
                    {'a': 'b'}
                ]
            }
        ]

        config = Config(answers={})

        n = Nulecule('some-id', '0.0.2', graph, 'some/path', config=config)
        n.load_components()

        MockNuleculeComponent.assert_any_call(
            graph[0]['name'], n.basepath, 'somecontainer',
            graph[0]['params'], None, config)
        MockNuleculeComponent.assert_any_call(
            graph[1]['name'], n.basepath, None,
            graph[1].get('params'), graph[1].get('artifacts'), config)
開發者ID:LalatenduMohanty,項目名稱:atomicapp,代碼行數:26,代碼來源:test_nulecule.py

示例2: unpack

    def unpack(self, update=False, dryrun=False, nodeps=False, config=None):
        """
        Unpacks a Nulecule application from a Nulecule image to a path
        or load a Nulecule that already exists locally.

        Args:
            update (bool): Update existing Nulecule application in
                           app_path, if True
            dryrun (bool): Do not make any change to the host system
            nodeps (bool): Do not unpack external dependencies
            config (dict): Config data, if any, to use for unpacking

        Returns:
            A Nulecule instance.
        """
        logger.debug("Request to unpack to %s to %s" % (self.image, self.app_path))

        # If the user provided an image then unpack it and return the
        # resulting Nulecule. Else, load from existing path
        if self.image:
            return Nulecule.unpack(
                self.image, self.app_path, config=config, nodeps=nodeps, dryrun=dryrun, update=update
            )
        else:
            return Nulecule.load_from_path(self.app_path, dryrun=dryrun, config=config)
開發者ID:schmerk,項目名稱:atomicapp,代碼行數:25,代碼來源:main.py

示例3: test_load_config_without_default_provider

    def test_load_config_without_default_provider(self):
        """
        Test Nulecule load_config without specifying a default provider.
        """
        config = Config()

        params = [
            {
                "name": "key1",
                "default": "val1",
            },
            {
                "name": "key3",
                "default": "val3"
            }
        ]

        graph = [
            {
                "name": "component1",
                "params": [
                    {
                        "name": "key1",
                    },
                    {
                        "name": "key2",
                        "default": "val2"
                    }
                ],
                "artifacts": []
            }
        ]

        n = Nulecule(id='some-id', specversion='0.0.2', metadata={},
                     graph=graph, params=params, basepath='some/path',
                     config=config)
        n.load_components()
        n.load_config()

        self.assertEqual(n.config.runtime_answers(), {
            'general': {
                'namespace': 'default',
                'provider': 'kubernetes',
                'key1': 'val1',
                'key3': 'val3'
            },
            'component1': {
                'key2': 'val2'
            }
        })

        self.assertEqual(
            n.components[0].config.context(n.components[0].namespace),
            {'key3': 'val3',
             'key2': 'val2',
             'key1': 'val1',
             'namespace': 'default',
             'provider': 'kubernetes'}
        )
開發者ID:LalatenduMohanty,項目名稱:atomicapp,代碼行數:59,代碼來源:test_nulecule.py

示例4: test_run

    def test_run(self):
        provider = 'docker'
        dryrun = False
        mock_component_1 = mock.Mock()
        mock_component_2 = mock.Mock()

        n = Nulecule('some-id', '0.0.2', {}, [], 'some/path')
        n.components = [mock_component_1, mock_component_2]
        n.run(provider)

        mock_component_1.run.assert_called_once_with(provider, dryrun)
        mock_component_2.run.assert_called_once_with(provider, dryrun)
開發者ID:schmerk,項目名稱:atomicapp,代碼行數:12,代碼來源:test_nulecule.py

示例5: test_stop

    def test_stop(self):
        provider = "docker"
        dryrun = False
        mock_component_1 = mock.Mock()
        mock_component_2 = mock.Mock()

        n = Nulecule("some-id", "0.0.2", {}, [], "some/path")
        n.components = [mock_component_1, mock_component_2]
        n.stop(provider)

        mock_component_1.stop.assert_called_once_with(provider, dryrun)
        mock_component_2.stop.assert_called_once_with(provider, dryrun)
開發者ID:Ritsyy,項目名稱:atomicapp,代碼行數:12,代碼來源:test_nulecule.py

示例6: test_render

    def test_render(self):
        mock_component_1 = mock.Mock()
        mock_component_2 = mock.Mock()
        provider_key = "foo"
        dryrun = True

        n = Nulecule("some-id", "0.0.2", {}, [], "some/path")
        n.components = [mock_component_1, mock_component_2]
        n.render(provider_key, dryrun)

        mock_component_1.render.assert_called_once_with(provider_key=provider_key, dryrun=dryrun)
        mock_component_2.render.assert_called_once_with(provider_key=provider_key, dryrun=dryrun)
開發者ID:Ritsyy,項目名稱:atomicapp,代碼行數:12,代碼來源:test_nulecule.py

示例7: test_stop

    def test_stop(self):
        provider = 'docker'
        dryrun = False
        mock_component_1 = mock.Mock()
        mock_component_2 = mock.Mock()

        config = Config(answers={})

        n = Nulecule('some-id', '0.0.2', {}, [], 'some/path', config=config)
        n.components = [mock_component_1, mock_component_2]
        n.stop(provider)

        mock_component_1.stop.assert_called_once_with(provider, dryrun)
        mock_component_2.stop.assert_called_once_with(provider, dryrun)
開發者ID:LalatenduMohanty,項目名稱:atomicapp,代碼行數:14,代碼來源:test_nulecule.py

示例8: test_render

    def test_render(self):
        mock_component_1 = mock.Mock()
        mock_component_2 = mock.Mock()
        provider_key = 'foo'
        dryrun = True

        n = Nulecule('some-id', '0.0.2', {}, [], 'some/path')
        n.components = [mock_component_1, mock_component_2]
        n.render(provider_key, dryrun)

        mock_component_1.render.assert_called_once_with(
            provider_key=provider_key, dryrun=dryrun)
        mock_component_2.render.assert_called_once_with(
            provider_key=provider_key, dryrun=dryrun)
開發者ID:schmerk,項目名稱:atomicapp,代碼行數:14,代碼來源:test_nulecule.py

示例9: test_load_config_without_specified_provider

    def test_load_config_without_specified_provider(self):
        """
        Test Nulecule load_config without specifying a provider.
        """
        config = {"general": {}, "group1": {"a": "b"}}
        mock_component_1 = mock.Mock()
        mock_component_1.config = {"group1": {"a": "c", "k": "v"}, "group2": {"1": "2"}}

        n = Nulecule(id="some-id", specversion="0.0.2", metadata={}, graph=[], basepath="some/path")
        n.components = [mock_component_1]
        n.load_config(config)

        self.assertEqual(
            n.config, {"general": {"provider": "kubernetes"}, "group1": {"a": "b", "k": "v"}, "group2": {"1": "2"}}
        )
開發者ID:Ritsyy,項目名稱:atomicapp,代碼行數:15,代碼來源:test_nulecule.py

示例10: test_load_components

    def test_load_components(self, MockNuleculeComponent):
        graph = [
            {"name": "app1", "source": "docker://somecontainer", "params": []},
            {"name": "app2", "artifacts": [{"a": "b"}]},
        ]

        n = Nulecule("some-id", "0.0.2", graph, "some/path", {})
        n.load_components()

        MockNuleculeComponent.assert_any_call(
            graph[0]["name"], n.basepath, "somecontainer", graph[0]["params"], None, {}
        )
        MockNuleculeComponent.assert_any_call(
            graph[1]["name"], n.basepath, None, graph[1].get("params"), graph[1].get("artifacts"), {}
        )
開發者ID:Ritsyy,項目名稱:atomicapp,代碼行數:15,代碼來源:test_nulecule.py

示例11: test_load_config

    def test_load_config(self):
        config = {'group1': {'a': 'b'}}
        mock_component_1 = mock.Mock()
        mock_component_1.config = {
            'group1': {'a': 'c', 'k': 'v'},
            'group2': {'1': '2'}
        }

        n = Nulecule('some-id', '0.0.2', {}, [], 'some/path')
        n.components = [mock_component_1]
        n.load_config(config)

        self.assertEqual(n.config, {
            'group1': {'a': 'b', 'k': 'v'},
            'group2': {'1': '2'}
        })
開發者ID:schmerk,項目名稱:atomicapp,代碼行數:16,代碼來源:test_nulecule.py

示例12: test_load_config_without_specified_provider

    def test_load_config_without_specified_provider(self):
        """
        Test Nulecule load_config without specifying a provider.
        """
        config = {'general': {}, 'group1': {'a': 'b'}}
        mock_component_1 = mock.Mock()
        mock_component_1.config = {
            'group1': {'a': 'c', 'k': 'v'},
            'group2': {'1': '2'}
        }

        n = Nulecule(id='some-id', specversion='0.0.2', metadata={}, graph=[], basepath='some/path')
        n.components = [mock_component_1]
        n.load_config(config)

        self.assertEqual(n.config, {
            'general': {'provider': 'kubernetes'},
            'group1': {'a': 'b', 'k': 'v'},
            'group2': {'1': '2'}
        })
開發者ID:surajssd,項目名稱:atomicapp,代碼行數:20,代碼來源:test_nulecule.py

示例13: test_load_config_with_defaultprovider

    def test_load_config_with_defaultprovider(self):
        """
        Test Nulecule load_config with default provider specified
        in global params in Nulecule spec.
        """
        config = {'general': {}, 'group1': {'a': 'b'}}
        mock_component_1 = mock.Mock()
        mock_component_1.config = {
            'group1': {'a': 'c', 'k': 'v'},
            'group2': {'1': '2'}
        }

        n = Nulecule(id='some-id', specversion='0.0.2', metadata={}, graph=[],
                     basepath='some/path',
                     params=[{'name': 'provider', 'default': 'some-provider'}])
        n.components = [mock_component_1]
        n.load_config(config)

        self.assertEqual(n.config, {
            'general': {'provider': 'some-provider'},
            'group1': {'a': 'b', 'k': 'v'},
            'group2': {'1': '2'}
        })
開發者ID:surajssd,項目名稱:atomicapp,代碼行數:23,代碼來源:test_nulecule.py

示例14: test_load_config_with_defaultprovider_overridden_by_provider_in_answers

    def test_load_config_with_defaultprovider_overridden_by_provider_in_answers(self):
        """
        Test Nulecule load_config with default provider specified
        in global params in Nulecule spec, but overridden in answers config.
        """
        config = {"general": {"provider": "new-provider"}, "group1": {"a": "b"}}
        mock_component_1 = mock.Mock()
        mock_component_1.config = {"group1": {"a": "c", "k": "v"}, "group2": {"1": "2"}}

        n = Nulecule(
            id="some-id",
            specversion="0.0.2",
            metadata={},
            graph=[],
            basepath="some/path",
            params=[{"name": "provider", "default": "some-provider"}],
        )
        n.components = [mock_component_1]
        n.load_config(config)

        self.assertEqual(
            n.config, {"general": {"provider": "new-provider"}, "group1": {"a": "b", "k": "v"}, "group2": {"1": "2"}}
        )
開發者ID:Ritsyy,項目名稱:atomicapp,代碼行數:23,代碼來源:test_nulecule.py

示例15: stop

    def stop(self, cli_provider, **kwargs):
        """
        Stops a running Nulecule application.

        Args:
            cli_provider (str): Provider running the Nulecule application
            kwargs (dict): Extra keyword arguments
        """
        # For stop we use the generated answer file from the run
        self.answers = Utils.loadAnswers(os.path.join(self.app_path, ANSWERS_RUNTIME_FILE))

        dryrun = kwargs.get("dryrun") or False
        self.nulecule = Nulecule.load_from_path(self.app_path, config=self.answers, dryrun=dryrun)
        self.nulecule.load_config(config=self.answers)
        self.nulecule.render(cli_provider, dryrun=dryrun)
        self.nulecule.stop(cli_provider, dryrun)
開發者ID:schmerk,項目名稱:atomicapp,代碼行數:16,代碼來源:main.py


注:本文中的atomicapp.nulecule.base.Nulecule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。