예제 #1
0
    def test_find_instance_volume_devices(self):
        instance = self._get_instance()
        ex_cmd = instance.remote().execute_command

        attached_info = "/dev/vda /dev/vda1 /dev/vdb /dev/vdc"
        mounted_info = "/dev/vda1"
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info)]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(["/dev/vdb", "/dev/vdc"], diff)

        attached_info = "/dev/vda /dev/vda1 /dev/vdb /dev/vdb1 /dev/vdb2"
        mounted_info = "/dev/vda1"
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info)]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(["/dev/vdb"], diff)

        attached_info = "/dev/vda /dev/vda1 /dev/vdb /dev/vdb1 /dev/vdb2"
        mounted_info = "/dev/vda1 /dev/vdb1"
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info)]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(["/dev/vdb2"], diff)

        attached_info = "/dev/vda /dev/vda1 /dev/vdb /dev/vdb1 /dev/vdb2"
        mounted_info = "/dev/vda1 /dev/vdb2"
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info)]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(["/dev/vdb1"], diff)
예제 #2
0
    def test_find_instance_volume_devices(self):
        instance = self._get_instance()
        ex_cmd = instance.remote().execute_command

        attached_info = '/dev/vda /dev/vda1 /dev/vdb /dev/vdc'
        mounted_info = '/dev/vda1'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (2, "")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(['/dev/vdb', '/dev/vdc'], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb /dev/vdb1 /dev/vdb2'
        mounted_info = '/dev/vda1'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (2, "")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(['/dev/vdb'], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb /dev/vdb1 /dev/vdb2'
        mounted_info = '/dev/vda1 /dev/vdb1'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (2, "")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(['/dev/vdb2'], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb /dev/vdb1 /dev/vdb2'
        mounted_info = '/dev/vda1 /dev/vdb2'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (2, "")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(['/dev/vdb1'], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb'
        mounted_info = '/dev/vda1 /dev/vdb'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (2, "")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual([], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb'
        mounted_info = '/dev/vda1'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info),
                              (0, "/dev/vdb")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual([], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb'
        mounted_info = '/dev/vda1'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info),
                              (2, ""), (0, "/dev/vdb")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual([], diff)
예제 #3
0
    def test_find_instance_volume_devices(self):
        instance = self._get_instance()
        ex_cmd = instance.remote().execute_command

        attached_info = '/dev/vda /dev/vda1 /dev/vdb /dev/vdc'
        mounted_info = '/dev/vda1'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (2, "")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(['/dev/vdb', '/dev/vdc'], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb /dev/vdb1 /dev/vdb2'
        mounted_info = '/dev/vda1'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (2, "")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(['/dev/vdb'], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb /dev/vdb1 /dev/vdb2'
        mounted_info = '/dev/vda1 /dev/vdb1'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (2, "")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(['/dev/vdb2'], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb /dev/vdb1 /dev/vdb2'
        mounted_info = '/dev/vda1 /dev/vdb2'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (2, "")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual(['/dev/vdb1'], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb'
        mounted_info = '/dev/vda1 /dev/vdb'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (2, "")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual([], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb'
        mounted_info = '/dev/vda1'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info),
                              (0, "/dev/vdb")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual([], diff)

        attached_info = '/dev/vda /dev/vda1 /dev/vdb'
        mounted_info = '/dev/vda1'
        ex_cmd.side_effect = [(0, attached_info), (0, mounted_info), (2, ""),
                              (0, "/dev/vdb")]

        diff = volumes._find_instance_devices(instance)
        self.assertEqual([], diff)