Ejemplo n.º 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 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)
Ejemplo n.º 4
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'])
 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'])
Ejemplo n.º 6
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'
     ])
Ejemplo n.º 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'])
Ejemplo n.º 8
0
 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"])
 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'])
Ejemplo n.º 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'
     ])
Ejemplo n.º 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)
Ejemplo n.º 12
0
 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)
Ejemplo n.º 13
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)
Ejemplo n.º 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)