Пример #1
0
    def test__execute(self):
        first_host_skip = 'first'
        available_host = 'available'
        hosts = [first_host_skip, self.local_ip, available_host, 'extra']
        test_config = mock.Mock()
        test_config.maprfs_clinode_ip = hosts
        test_config.maprfs_ssh_name = 'fake_maprfs_ssh_name'
        test_maprfs_util = mapru.get_version_handler(test_config)
        # mutable container
        done = [False]
        skips = []

        def fake_ssh_run(host, cmd, check_exit_code):
            if host == available_host:
                done[0] = True
                return '', 0
            else:
                skips.append(host)
                raise Exception()

        test_maprfs_util._run_ssh = fake_ssh_run

        test_maprfs_util._execute('fake', 'cmd')

        self.assertTrue(done[0])
        self.assertEqual(available_host, test_maprfs_util.hosts[0])
        self.assertEqual(first_host_skip, test_maprfs_util.hosts[2])
        self.assertEqual([first_host_skip], skips)
        utils.execute.assert_called_once_with('sudo',
                                              'su',
                                              '-',
                                              'fake_maprfs_ssh_name',
                                              '-c',
                                              'fake cmd',
                                              check_exit_code=True)
Пример #2
0
    def test__execute(self):
        first_host_skip = 'first'
        available_host = 'available'
        hosts = [first_host_skip, self.local_ip, available_host, 'extra']
        test_config = mock.Mock()
        test_config.maprfs_clinode_ip = hosts
        test_config.maprfs_ssh_name = 'fake_maprfs_ssh_name'
        test_maprfs_util = mapru.get_version_handler(test_config)
        # mutable container
        done = [False]
        skips = []

        def fake_ssh_run(host, cmd, check_exit_code):
            if host == available_host:
                done[0] = True
                return '', 0
            else:
                skips.append(host)
                raise Exception()

        test_maprfs_util._run_ssh = fake_ssh_run

        test_maprfs_util._execute('fake', 'cmd')

        self.assertTrue(done[0])
        self.assertEqual(available_host, test_maprfs_util.hosts[0])
        self.assertEqual(first_host_skip, test_maprfs_util.hosts[2])
        self.assertEqual([first_host_skip], skips)
        utils.execute.assert_called_once_with(
            'sudo', 'su', '-', 'fake_maprfs_ssh_name', '-c', 'fake cmd',
            check_exit_code=True)
Пример #3
0
 def do_setup(self, context):
     """Do initialization while the share driver starts."""
     super(MapRFSNativeShareDriver, self).do_setup(context)
     self._maprfs_util = mapru.get_version_handler(self.configuration)
Пример #4
0
 def do_setup(self, context):
     """Do initialization while the share driver starts."""
     super(MapRFSNativeShareDriver, self).do_setup(context)
     self._maprfs_util = mapru.get_version_handler(self.configuration)