import time
import unittest
import os, os.path

from stratuslab_usecases.cli.TestUtils import *

class testAttachAndDetachDisk(unittest.TestCase):

    vm_image_info = getVmImageInfo()
    marketplaceId = vm_image_info['ubuntu']['id']

    diskSize = 1

    def setUp(self):
        self.uuid = stratusCreateVolume(self.diskSize)
        self.vm_id_1, self.vm_ip_1 = stratusRunInstance(self.marketplaceId)

    def tearDown(self):
        stratusKillInstance(self.vm_id_1)
        time.sleep(5)
        stratusDeleteVolume(self.uuid)

    def test_usecase(self):
        waitVmRunningOrTimeout(self.vm_id_1, timeout=(5*60))
        sshConnectionOrTimeout(self.vm_ip_1, timeout=(4*60))

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

        # Attach and detach disk from machine.
        stratusAttachVolume(self.vm_id_1, self.uuid)
        time.sleep(5)
        stratusDetachVolume(self.vm_id_1, self.uuid)
        time.sleep(5)

def suite():
    return unittest.TestLoader().loadTestsFromTestCase(testPersistentDiskRetainsData)

7adc8977f457d62c5b28b631a31e87188f02c90f
<mask token>


class testAttachAndDetachDisk(unittest.TestCase):
    <mask token>
    <mask token>
    <mask token>

    def setUp(self):
        self.uuid = stratusCreateVolume(self.diskSize)
        self.vm_id_1, self.vm_ip_1 = stratusRunInstance(self.marketplaceId)
    <mask token>
    <mask token>


<mask token>

<mask token>


class testAttachAndDetachDisk(unittest.TestCase):
    <mask token>
    <mask token>
    <mask token>

    def setUp(self):
        self.uuid = stratusCreateVolume(self.diskSize)
        self.vm_id_1, self.vm_ip_1 = stratusRunInstance(self.marketplaceId)

    def tearDown(self):
        stratusKillInstance(self.vm_id_1)
        time.sleep(5)
        stratusDeleteVolume(self.uuid)
    <mask token>


<mask token>

<mask token>


class testAttachAndDetachDisk(unittest.TestCase):
    vm_image_info = getVmImageInfo()
    marketplaceId = vm_image_info['ubuntu']['id']
    diskSize = 1

    def setUp(self):
        self.uuid = stratusCreateVolume(self.diskSize)
        self.vm_id_1, self.vm_ip_1 = stratusRunInstance(self.marketplaceId)

    def tearDown(self):
        stratusKillInstance(self.vm_id_1)
        time.sleep(5)
        stratusDeleteVolume(self.uuid)

    def test_usecase(self):
        waitVmRunningOrTimeout(self.vm_id_1, timeout=5 * 60)
        sshConnectionOrTimeout(self.vm_ip_1, timeout=4 * 60)
        ssh(ip=self.vm_ip_1, cmd='modprobe acpiphp')
        stratusAttachVolume(self.vm_id_1, self.uuid)
        time.sleep(5)
        stratusDetachVolume(self.vm_id_1, self.uuid)
        time.sleep(5)


def suite():
    return unittest.TestLoader().loadTestsFromTestCase(
        testPersistentDiskRetainsData)

import time
import unittest
import os, os.path
from stratuslab_usecases.cli.TestUtils import *


class testAttachAndDetachDisk(unittest.TestCase):
    vm_image_info = getVmImageInfo()
    marketplaceId = vm_image_info['ubuntu']['id']
    diskSize = 1

    def setUp(self):
        self.uuid = stratusCreateVolume(self.diskSize)
        self.vm_id_1, self.vm_ip_1 = stratusRunInstance(self.marketplaceId)

    def tearDown(self):
        stratusKillInstance(self.vm_id_1)
        time.sleep(5)
        stratusDeleteVolume(self.uuid)

    def test_usecase(self):
        waitVmRunningOrTimeout(self.vm_id_1, timeout=5 * 60)
        sshConnectionOrTimeout(self.vm_ip_1, timeout=4 * 60)
        ssh(ip=self.vm_ip_1, cmd='modprobe acpiphp')
        stratusAttachVolume(self.vm_id_1, self.uuid)
        time.sleep(5)
        stratusDetachVolume(self.vm_id_1, self.uuid)
        time.sleep(5)


def suite():
    return unittest.TestLoader().loadTestsFromTestCase(
        testPersistentDiskRetainsData)

import time
import unittest
import os, os.path

from stratuslab_usecases.cli.TestUtils import *

class testAttachAndDetachDisk(unittest.TestCase):

    vm_image_info = getVmImageInfo()
    marketplaceId = vm_image_info['ubuntu']['id']

    diskSize = 1

    def setUp(self):
        self.uuid = stratusCreateVolume(self.diskSize)
        self.vm_id_1, self.vm_ip_1 = stratusRunInstance(self.marketplaceId)

    def tearDown(self):
        stratusKillInstance(self.vm_id_1)
        time.sleep(5)
        stratusDeleteVolume(self.uuid)

    def test_usecase(self):
        waitVmRunningOrTimeout(self.vm_id_1, timeout=(5*60))
        sshConnectionOrTimeout(self.vm_ip_1, timeout=(4*60))

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

        # Attach and detach disk from machine.
        stratusAttachVolume(self.vm_id_1, self.uuid)
        time.sleep(5)
        stratusDetachVolume(self.vm_id_1, self.uuid)
        time.sleep(5)

def suite():
    return unittest.TestLoader().loadTestsFromTestCase(testPersistentDiskRetainsData)
