Beispiel #1
0
    def test_get_free_device_path(self, p_ex_cmd, p_get_username):
        p_get_username.return_value = 'root'

        instance = r.InstanceResource({'instance_id': '123454321',
                                       'node_group': {}})

        stdout = """major minor  #blocks  name

   8        0  488386584 vda
   8        1     102400 vda1"""
        p_ex_cmd.return_value = (0, stdout)
        self.assertEqual(volumes._get_free_device_path(instance), '/dev/vdb')

        stdout = """major minor  #blocks  name

   8        0  488386584 xvda
   8        1     102400 xvda1"""
        p_ex_cmd.return_value = (0, stdout)
        self.assertEqual(volumes._get_free_device_path(instance), '/dev/xvdb')

        stdout = "major minor  #blocks  name\n"
        for idx in range(0, 26):
            line = "   8        0  488386584 vd" + chr(ord('a') + idx) + '\n'
            stdout += line

        p_ex_cmd.return_value = (0, stdout)
        self.assertRaises(RuntimeError, volumes._get_free_device_path,
                          instance)

        p_ex_cmd.side_effect = ex.RemoteCommandException('cmd')
        self.assertRaises(ex.RemoteCommandException,
                          volumes._get_free_device_path, instance)
Beispiel #2
0
    def test_get_free_device_path(self, p_ex_cmd, p_get_username):
        p_get_username.return_value = 'root'

        instance = r.InstanceResource({
            'instance_id': '123454321',
            'node_group': {}
        })

        stdout = """major minor  #blocks  name

   8        0  488386584 vda
   8        1     102400 vda1"""
        p_ex_cmd.return_value = (0, stdout)
        self.assertEqual(volumes._get_free_device_path(instance), '/dev/vdb')

        stdout = """major minor  #blocks  name

   8        0  488386584 xvda
   8        1     102400 xvda1"""
        p_ex_cmd.return_value = (0, stdout)
        self.assertEqual(volumes._get_free_device_path(instance), '/dev/xvdb')

        stdout = "major minor  #blocks  name\n"
        for idx in range(0, 26):
            line = "   8        0  488386584 vd" + chr(ord('a') + idx) + '\n'
            stdout += line

        p_ex_cmd.return_value = (0, stdout)
        self.assertRaises(RuntimeError, volumes._get_free_device_path,
                          instance)

        p_ex_cmd.side_effect = ex.RemoteCommandException('cmd')
        self.assertRaises(ex.RemoteCommandException,
                          volumes._get_free_device_path, instance)
Beispiel #3
0
    def test_get_free_device_path(self, p_ex_cmd):
        instance = r.InstanceResource({'instance_id': '123454321'})

        p_ex_cmd.return_value = (1, None)
        self.assertRaises(RuntimeError, volumes._get_free_device_path,
                          instance)

        stdout = """major minor  #blocks  name

   8        0  488386584 vda
   8        1     102400 vda1"""

        p_ex_cmd.return_value = (0, stdout)
        self.assertEqual(volumes._get_free_device_path(instance), '/dev/vdb')

        stdout = "major minor  #blocks  name\n"
        for idx in range(0, 26):
            line = "   8        0  488386584 vd" + chr(ord('a') + idx) + '\n'
            stdout += line

        p_ex_cmd.return_value = (0, stdout)
        self.assertRaises(RuntimeError, volumes._get_free_device_path,
                          instance)