コード例 #1
0
 def test_no_lxd_does_nothing(self, mock_util, m_maybe_clean):
     cc = self._get_cloud('ubuntu')
     cc.distro = mock.MagicMock()
     cc_lxd.handle('cc_lxd', {'package_update': True}, cc, self.logger, [])
     self.assertFalse(cc.distro.install_packages.called)
     self.assertFalse(mock_util.subp.called)
     self.assertFalse(m_maybe_clean.called)
コード例 #2
0
ファイル: test_cc_lxd.py プロジェクト: rongz609/cloud-init
 def test_no_lxd_does_nothing(self, mock_subp, m_maybe_clean):
     cc = get_cloud()
     cc.distro = mock.MagicMock()
     cc_lxd.handle("cc_lxd", {"package_update": True}, cc, self.logger, [])
     self.assertFalse(cc.distro.install_packages.called)
     self.assertFalse(mock_subp.subp.called)
     self.assertFalse(m_maybe_clean.called)
コード例 #3
0
 def test_no_init_does_nothing(self, mock_subp, m_maybe_clean):
     cc = self._get_cloud('ubuntu')
     cc.distro = mock.MagicMock()
     cc_lxd.handle('cc_lxd', {'lxd': {}}, cc, self.logger, [])
     self.assertFalse(cc.distro.install_packages.called)
     self.assertFalse(mock_subp.subp.called)
     self.assertFalse(m_maybe_clean.called)
コード例 #4
0
ファイル: test_handler_lxd.py プロジェクト: srz01/cloud-init
 def test_lxd_install(self, mock_util):
     cc = self._get_cloud('ubuntu')
     cc.distro = mock.MagicMock()
     mock_util.which.return_value = None
     cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, LOG, [])
     self.assertTrue(cc.distro.install_packages.called)
     install_pkg = cc.distro.install_packages.call_args_list[0][0][0]
     self.assertEqual(sorted(install_pkg), ['lxd', 'zfs'])
コード例 #5
0
 def test_lxd_install(self, mock_util):
     cc = self._get_cloud('ubuntu')
     cc.distro = mock.MagicMock()
     mock_util.which.return_value = None
     cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, LOG, [])
     self.assertTrue(cc.distro.install_packages.called)
     install_pkg = cc.distro.install_packages.call_args_list[0][0][0]
     self.assertEqual(sorted(install_pkg), ['lxd', 'zfs'])
コード例 #6
0
ファイル: test_handler_lxd.py プロジェクト: srz01/cloud-init
 def test_lxd_init(self, mock_util):
     cc = self._get_cloud('ubuntu')
     mock_util.which.return_value = True
     cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, LOG, [])
     self.assertTrue(mock_util.which.called)
     init_call = mock_util.subp.call_args_list[0][0][0]
     self.assertEqual(init_call, [
         'lxd', 'init', '--auto', '--network-address=0.0.0.0',
         '--storage-backend=zfs', '--storage-pool=poolname'
     ])
コード例 #7
0
 def test_lxd_install(self, mock_util, m_maybe_clean):
     cc = self._get_cloud('ubuntu')
     cc.distro = mock.MagicMock()
     mock_util.which.return_value = None
     cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, self.logger, [])
     self.assertNotIn('WARN', self.logs.getvalue())
     self.assertTrue(cc.distro.install_packages.called)
     cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, self.logger, [])
     self.assertFalse(m_maybe_clean.called)
     install_pkg = cc.distro.install_packages.call_args_list[0][0][0]
     self.assertEqual(sorted(install_pkg), ['lxd', 'zfsutils-linux'])
コード例 #8
0
ファイル: test_cc_lxd.py プロジェクト: rongz609/cloud-init
 def test_lxd_install(self, mock_subp, m_maybe_clean):
     cc = get_cloud()
     cc.distro = mock.MagicMock()
     mock_subp.which.return_value = None
     cc_lxd.handle("cc_lxd", self.lxd_cfg, cc, self.logger, [])
     self.assertNotIn("WARN", self.logs.getvalue())
     self.assertTrue(cc.distro.install_packages.called)
     cc_lxd.handle("cc_lxd", self.lxd_cfg, cc, self.logger, [])
     self.assertFalse(m_maybe_clean.called)
     install_pkg = cc.distro.install_packages.call_args_list[0][0][0]
     self.assertEqual(sorted(install_pkg), ["lxd", "zfsutils-linux"])
コード例 #9
0
 def test_lxd_init(self, mock_util):
     cc = self._get_cloud('ubuntu')
     mock_util.which.return_value = True
     cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, LOG, [])
     self.assertTrue(mock_util.which.called)
     init_call = mock_util.subp.call_args_list[0][0][0]
     self.assertEqual(init_call,
                      ['lxd', 'init', '--auto',
                       '--network-address=0.0.0.0',
                       '--storage-backend=zfs',
                       '--storage-pool=poolname'])
コード例 #10
0
 def test_lxd_init(self, mock_util, m_maybe_clean):
     cc = self._get_cloud('ubuntu')
     mock_util.which.return_value = True
     m_maybe_clean.return_value = None
     cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, self.logger, [])
     self.assertTrue(mock_util.which.called)
     # no bridge config, so maybe_cleanup should not be called.
     self.assertFalse(m_maybe_clean.called)
     init_call = mock_util.subp.call_args_list[0][0][0]
     self.assertEqual(init_call, [
         'lxd', 'init', '--auto', '--network-address=0.0.0.0',
         '--storage-backend=zfs', '--storage-pool=poolname'
     ])
コード例 #11
0
 def test_lxd_init(self, mock_util, m_maybe_clean):
     cc = self._get_cloud('ubuntu')
     mock_util.which.return_value = True
     m_maybe_clean.return_value = None
     cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, self.logger, [])
     self.assertTrue(mock_util.which.called)
     # no bridge config, so maybe_cleanup should not be called.
     self.assertFalse(m_maybe_clean.called)
     self.assertEqual(
         [mock.call(['lxd', 'waitready', '--timeout=300']),
          mock.call(
              ['lxd', 'init', '--auto', '--network-address=0.0.0.0',
               '--storage-backend=zfs', '--storage-pool=poolname'])],
         mock_util.subp.call_args_list)
コード例 #12
0
ファイル: test_cc_lxd.py プロジェクト: tuapuikia/cloud-init
 def test_lxd_init(self, mock_subp, m_maybe_clean):
     cc = get_cloud()
     mock_subp.which.return_value = True
     m_maybe_clean.return_value = None
     cc_lxd.handle('cc_lxd', self.lxd_cfg, cc, self.logger, [])
     self.assertTrue(mock_subp.which.called)
     # no bridge config, so maybe_cleanup should not be called.
     self.assertFalse(m_maybe_clean.called)
     self.assertEqual([
         mock.call(['lxd', 'waitready', '--timeout=300']),
         mock.call([
             'lxd', 'init', '--auto', '--network-address=0.0.0.0',
             '--storage-backend=zfs', '--storage-pool=poolname'
         ])
     ], mock_subp.subp.call_args_list)
コード例 #13
0
ファイル: test_handler_lxd.py プロジェクト: srz01/cloud-init
 def test_no_init_does_nothing(self, mock_util):
     cc = self._get_cloud('ubuntu')
     cc.distro = mock.MagicMock()
     cc_lxd.handle('cc_lxd', {'lxd': {}}, cc, LOG, [])
     self.assertFalse(cc.distro.install_packages.called)
     self.assertFalse(mock_util.subp.called)
コード例 #14
0
 def test_no_init_does_nothing(self, mock_util):
     cc = self._get_cloud('ubuntu')
     cc.distro = mock.MagicMock()
     cc_lxd.handle('cc_lxd', {'lxd': {}}, cc, LOG, [])
     self.assertFalse(cc.distro.install_packages.called)
     self.assertFalse(mock_util.subp.called)