Exemplo n.º 1
0
def test_detach_volume_iscsi_attached(monkeypatch, fake_os_brick, tmpdir,
                                      tmp_db, fake_lvm, fake_supervdsm):
    monkeypatch.setenv("FAKE_ATTACH_RESULT", "OK")
    monkeypatch.setattr(managedvolume, "DEV_MAPPER", str(tmpdir))
    connection_info = {
        "driver_volume_type": "iscsi",
        "data": {"some_info": 26}
    }
    managedvolume.attach_volume("fake_sd_id", "fake_vol_id", connection_info)

    # Attaching invalidates the filter, reset.
    fake_lvm.devices_invalidated = False

    tmpdir.join("fakemultipathid").write("")
    managedvolume.detach_volume("fake_sd_id", "fake_vol_id")

    entries = fake_os_brick.log()
    assert len(entries) == 2
    assert entries[0]["action"] == "connect_volume"
    assert entries[1]["action"] == "disconnect_volume"

    with pytest.raises(managedvolumedb.NotFound):
        tmp_db.get_volume("fake_vol_id")

    # Device not owned by managed volume.
    assert not tmp_db.owns_multipath("fakemultipathid")

    # No multipath id added, no need to invalidated filter.
    assert not fake_lvm.devices_invalidated
Exemplo n.º 2
0
def test_detach_volume_iscsi_not_attached(monkeypatch, fake_os_brick, tmp_db,
                                          fake_lvm):
    monkeypatch.setenv("FAKE_ATTACH_RESULT", "OK")
    connection_info = {
        "driver_volume_type": "iscsi",
        "data": {
            "some_info": 26
        }
    }
    managedvolume.attach_volume("fake_vol_id", connection_info)

    # Attaching invalidates the filter, reset.
    fake_lvm.filter_invalidated = False

    managedvolume.detach_volume("fake_vol_id")

    with pytest.raises(managedvolumedb.NotFound):
        tmp_db.get_volume("fake_vol_id")

    entries = fake_os_brick.log()
    assert len(entries) == 1
    assert entries[0]["action"] == "connect_volume"

    # No multipath id added, no need to invalidated filter.
    assert not fake_lvm.filter_invalidated
Exemplo n.º 3
0
def test_detach_volume_iscsi_attached(monkeypatch, fake_os_brick, tmpdir,
                                      tmp_db, fake_lvm):
    monkeypatch.setenv("FAKE_ATTACH_RESULT", "OK")
    monkeypatch.setattr(managedvolume, "DEV_MAPPER", str(tmpdir))
    connection_info = {
        "driver_volume_type": "iscsi",
        "data": {"some_info": 26}
    }
    managedvolume.attach_volume("fake_vol_id", connection_info)

    # Attaching invalidates the filter, reset.
    fake_lvm.filter_invalidated = False

    tmpdir.join("fakemultipathid").write("")
    managedvolume.detach_volume("fake_vol_id")

    entries = fake_os_brick.log()
    assert len(entries) == 2
    assert entries[0]["action"] == "connect_volume"
    assert entries[1]["action"] == "disconnect_volume"

    with pytest.raises(managedvolumedb.NotFound):
        tmp_db.get_volume("fake_vol_id")

    # Device not owned by managed volume.
    assert not tmp_db.owns_multipath("fakemultipathid")

    # No multipath id added, no need to invalidated filter.
    assert not fake_lvm.filter_invalidated
Exemplo n.º 4
0
def test_detach_not_in_db(monkeypatch, fake_os_brick, tmp_db, fake_lvm):
    managedvolume.detach_volume("fake_vol_id")

    # Attaching invalidates the filter, reset.
    fake_lvm.filter_invalidated = False

    with pytest.raises(managedvolumedb.NotFound):
        tmp_db.get_volume("fake_vol_id")
    assert [] == fake_os_brick.log()

    # No multipath id added, no need to invalidated filter.
    assert not fake_lvm.filter_invalidated
Exemplo n.º 5
0
def test_detach_not_in_db(monkeypatch, fake_os_brick, tmp_db, fake_lvm):
    managedvolume.detach_volume("fake_vol_id")

    # Attaching invalidates the filter, reset.
    fake_lvm.filter_invalidated = False

    with pytest.raises(managedvolumedb.NotFound):
        tmp_db.get_volume("fake_vol_id")
    assert [] == fake_os_brick.log()

    # No multipath id added, no need to invalidated filter.
    assert not fake_lvm.filter_invalidated
Exemplo n.º 6
0
def test_detach_volume_not_installed(monkeypatch, fake_os_brick, tmp_db,
                                     fake_lvm):
    # Simulate missing os_brick.
    monkeypatch.setattr(managedvolume, "os_brick", None)

    # Attaching invalidates the filter, reset.
    fake_lvm.devices_invalidated = False

    with pytest.raises(se.ManagedVolumeNotSupported):
        managedvolume.detach_volume("sd_id", "vol_id")

    # No multipath id added, no need to invalidated filter.
    assert not fake_lvm.devices_invalidated
Exemplo n.º 7
0
def test_detach_volume_not_installed(monkeypatch, fake_os_brick, tmp_db,
                                     fake_lvm):
    # Simulate missing os_brick.
    monkeypatch.setattr(managedvolume, "os_brick", None)

    # Attaching invalidates the filter, reset.
    fake_lvm.filter_invalidated = False

    with pytest.raises(se.ManagedVolumeNotSupported):
        managedvolume.detach_volume("vol_id")

    # No multipath id added, no need to invalidated filter.
    assert not fake_lvm.filter_invalidated
Exemplo n.º 8
0
def test_detach_volume_iscsi_not_attached(monkeypatch, fake_os_brick, tmp_db,
                                          fake_lvm):
    monkeypatch.setenv("FAKE_ATTACH_RESULT", "OK")
    connection_info = {
        "driver_volume_type": "iscsi",
        "data": {"some_info": 26}
    }
    managedvolume.attach_volume("fake_vol_id", connection_info)

    # Attaching invalidates the filter, reset.
    fake_lvm.filter_invalidated = False

    managedvolume.detach_volume("fake_vol_id")

    with pytest.raises(managedvolumedb.NotFound):
        tmp_db.get_volume("fake_vol_id")

    entries = fake_os_brick.log()
    assert len(entries) == 1
    assert entries[0]["action"] == "connect_volume"

    # No multipath id added, no need to invalidated filter.
    assert not fake_lvm.filter_invalidated