コード例 #1
0
ファイル: installation.py プロジェクト: yugart/anaconda
 def run(self):
     # apply System Purpose data
     return system_purpose.give_the_system_purpose(
         sysroot=self._sysroot,
         role=self._system_purpose_data.role,
         sla=self._system_purpose_data.sla,
         usage=self._system_purpose_data.usage,
         addons=self._system_purpose_data.addons
     )
コード例 #2
0
ファイル: runtime.py プロジェクト: zhoupeng/anaconda
 def run(self):
     # the task is always expected to run in the installation environment
     # - if existing data is present, it will be cleared and then
     #   replaced by new data
     return system_purpose.give_the_system_purpose(
         sysroot="/",
         role=self._system_purpose_data.role,
         sla=self._system_purpose_data.sla,
         usage=self._system_purpose_data.usage,
         addons=self._system_purpose_data.addons)
コード例 #3
0
 def test_set_system_pourpose_no_purpose(self):
     """Test that nothing is done if system has no purpose."""
     with tempfile.TemporaryDirectory() as sysroot:
         # create fake RHSM Syspurpose DBus proxy
         syspurpose_proxy = Mock()
         assert give_the_system_purpose(sysroot=sysroot,
                                        rhsm_syspurpose_proxy=syspurpose_proxy,
                                        role="",
                                        sla="",
                                        usage="",
                                        addons=[])
         syspurpose_proxy.SetSyspurpose.assert_not_called()
コード例 #4
0
 def test_set_system_pourpose(self):
     """Test that system purpose is set if syspurpose & data are both available."""
     with tempfile.TemporaryDirectory() as sysroot:
         # create fake RHSM Syspurpose DBus proxy
         syspurpose_proxy = Mock()
         # set system purpose
         assert give_the_system_purpose(sysroot=sysroot,
                                        rhsm_syspurpose_proxy=syspurpose_proxy,
                                        role="foo",
                                        sla="bar",
                                        usage="baz",
                                        addons=["a", "b", "c"])
         # check syspurpose invocations look correct
         syspurpose_proxy.SetSyspurpose.assert_called_once_with(
             {
                 "role": get_variant(Str, "foo"),
                 "service_level_agreement": get_variant(Str, "bar"),
                 "usage": get_variant(Str, "baz"),
                 "addons": get_variant(List[Str], ["a", "b", "c"])
             },
             'en_US.UTF-8'
         )
コード例 #5
0
 def test_set_system_pourpose_failure(self):
     """Test that exception raised by SetSyspurpose DBus call is handled correctly."""
     with tempfile.TemporaryDirectory() as sysroot:
         # create fake RHSM Syspurpose DBus proxy
         syspurpose_proxy = Mock()
         # raise DBusError with error message in JSON
         syspurpose_proxy.SetSyspurpose.side_effect = DBusError("syspurpose error")
         # set system purpose & False is returned due to the exception
         assert not give_the_system_purpose(sysroot=sysroot,
                                            rhsm_syspurpose_proxy=syspurpose_proxy,
                                            role="foo",
                                            sla="bar",
                                            usage="baz",
                                            addons=["a", "b", "c"])
         # check the fake DBus method still was called correctly
         syspurpose_proxy.SetSyspurpose.assert_called_once_with(
             {
                 "role": get_variant(Str, "foo"),
                 "service_level_agreement": get_variant(Str, "bar"),
                 "usage": get_variant(Str, "baz"),
                 "addons": get_variant(List[Str], ["a", "b", "c"])
             },
             'en_US.UTF-8'
         )