def test_usecase(self):
        sshConnectionOrTimeout(self.ip_addresses[0], timeout=4*60)

        # Ensure kernel module is available for dynamic disk attachment
        ssh(ip=self.ip_addresses[0], cmd='modprobe acpiphp')

        # Attach and detach disk from machine.
        retval = self.driver.attach_volume(self.node, self.storageVolume)
        self.assertTrue(retval, 'Failed to attach volume %s to node %s' %
                        (self.storageVolume, self.node))
        print 'attach:', self.storageVolume
        time.sleep(5)
        retval = self.driver.detach_volume(self.storageVolume)
        self.assertTrue(retval, '%s: Failed to detach volume' % self.storageVolume)
        print 'detach:', self.storageVolume
        time.sleep(5)
    def test_usecase(self):
        sshConnectionOrTimeout(self.ip_addresses[0], timeout=4*60)

        # Ensure kernel module is available for dynamic disk attachment
        ssh(ip=self.ip_addresses[0], cmd='modprobe acpiphp')

        # Attach disk to machine.
        retval = self.driver.attach_volume(self.node, self.storageVolume)
        self.assertTrue(retval, 'Failed to attach volume %s to node %s' %
                        (self.storageVolume, self.node))
        print 'attach:', self.storageVolume
        time.sleep(5)

        # Ensure that disk is visible in the machine.
        ssh(ip=self.ip_addresses[0], cmd='cat /proc/partitions')
        ssh(ip=self.ip_addresses[0], cmd='grep vda /proc/partitions')

        # Kill the machine.
        super(self.__class__, self).tearDown()
        time.sleep(15)

        # Now delete the volume. This is possible only if all of the mounts are removed.
        self.driver.destroy_volume(self.storageVolume)

        # If the delete worked, then del storageVolume attribute so the tear down doesn't fail.
        del self.storageVolume
    def test_usecase(self):
        for i in xrange(self.vmNum):
            sshConnectionOrTimeout(self.ip_addresses[i][0], timeout=4*60)
            # Ensure kernel module is available for dynamic disk attachment
            ssh(ip=self.ip_addresses[i][0], cmd='modprobe acpiphp')

        # Attach disk to first machine.
        retval = self.driver.attach_volume(self.nodes[0], self.volume)
        self.assertTrue(retval, 'Failed to attach volume %s to node %s' %
                        (self.volume, self.nodes[0]))
        print 'attach:', self.volume

        # Format disk and add data file.
        ssh(ip=self.ip_addresses[0][0], cmd='mkfs.ext3 /dev/vda')
        ssh(ip=self.ip_addresses[0][0], cmd='mkdir -p /mnt/pdisk')
        ssh(ip=self.ip_addresses[0][0], cmd='mount -t ext3 /dev/vda /mnt/pdisk')
        ssh(ip=self.ip_addresses[0][0], cmd='touch /mnt/pdisk/data_file')
        ssh(ip=self.ip_addresses[0][0], cmd='umount /mnt/pdisk')

        # Detach disk from machine.
        retval = self.driver.detach_volume(self.volume)
        self.assertTrue(retval, '%s: Failed to detach volume' % self.volume)
        print 'detach:', self.volume
        time.sleep(5)

        # Attach disk to second machine and ensure data file exists.
        retval = self.driver.attach_volume(self.nodes[1], self.volume)
        self.assertTrue(retval, 'Failed to attach volume %s to node %s' %
                        (self.volume, self.nodes[1]))
        print 'attach:', self.volume
        time.sleep(5)
        ssh(ip=self.ip_addresses[1][0], cmd='mkdir -p /mnt/pdisk')
        ssh(ip=self.ip_addresses[1][0], cmd='mount -t ext3 /dev/vda /mnt/pdisk')
        ssh(ip=self.ip_addresses[1][0], cmd='ls -l /mnt/pdisk/data_file')

        # Detach disk from machine.
        retval = self.driver.detach_volume(self.volume)
        self.assertTrue(retval, '%s: Failed to detach volume' % self.volume)
        print 'detach:', self.volume
        time.sleep(5)