示例#1
0
    def make_installer(self, loop=None, dc=None):

        if dc is None:
            dc = MagicMock(name="display_controller")
        if loop is None:
            loop = MagicMock(name="loop")

        self.installer = MultiInstallNewMaas(loop, dc, self.conf)
 def _do_install_new_maas(self):
     """ Prepare new maas environment for landscape
     """
     MultiInstallNewMaas(self.loop,
                         self.display_controller,
                         self.config,
                         post_tasks=self.landscape_tasks).run()
    def make_installer(self, loop=None, dc=None):

        if dc is None:
            dc = MagicMock(name="display_controller")
        if loop is None:
            loop = MagicMock(name="loop")

        self.installer = MultiInstallNewMaas(
            loop, dc, self.conf)
class MultiInstallNewMaasTestCase(unittest.TestCase):

    def setUp(self):
        with NamedTemporaryFile(mode='w+', encoding='utf-8') as tempf:
            # Override config file to save to
            self.conf = Config({}, tempf.name)
        self.conf.setopt('openstack_password', 'ampersand&')

    def make_installer(self, loop=None, dc=None):

        if dc is None:
            dc = MagicMock(name="display_controller")
        if loop is None:
            loop = MagicMock(name="loop")

        self.installer = MultiInstallNewMaas(
            loop, dc, self.conf)

    def _create_superuser(self, raises):
        expected = ("maas-region-admin createadmin --username root "
                    "--password 'ampersand&' "
                    "--email [email protected]")

        self.make_installer()
        with patch('cloudinstall.multi_install.utils') as mock_utils:
            if raises:
                mock_utils.get_command_output.return_value = {'status': -1}
                self.assertRaises(MaasInstallError,
                                  self.installer.create_superuser)
            else:
                mock_utils.get_command_output.return_value = {'status': 0}
                self.installer.create_superuser()
                mock_utils.get_command_output.assert_called_with(expected)

    def test_create_superuser_raises(self):
        self._create_superuser(True)

    def test_create_superuser_ok(self):
        self._create_superuser(False)
示例#5
0
class MultiInstallNewMaasTestCase(unittest.TestCase):
    def setUp(self):
        with NamedTemporaryFile(mode='w+', encoding='utf-8') as tempf:
            # Override config file to save to
            self.conf = Config({}, tempf.name)
        self.conf.setopt('openstack_password', 'ampersand&')

    def make_installer(self, loop=None, dc=None):

        if dc is None:
            dc = MagicMock(name="display_controller")
        if loop is None:
            loop = MagicMock(name="loop")

        self.installer = MultiInstallNewMaas(loop, dc, self.conf)

    def _create_superuser(self, raises):
        expected = ("maas-region-admin createadmin --username root "
                    "--password 'ampersand&' "
                    "--email [email protected]")

        self.make_installer()
        with patch('cloudinstall.multi_install.utils') as mock_utils:
            if raises:
                mock_utils.get_command_output.return_value = {'status': -1}
                self.assertRaises(MaasInstallError,
                                  self.installer.create_superuser)
            else:
                mock_utils.get_command_output.return_value = {'status': 0}
                self.installer.create_superuser()
                mock_utils.get_command_output.assert_called_with(expected)

    def test_create_superuser_raises(self):
        self._create_superuser(True)

    def test_create_superuser_ok(self):
        self._create_superuser(False)