Ejemplo n.º 1
0
def init_vg(group, block_dev):
    """Initialize volume group.

    :param group:
        Name of the LVM Volume Group.
    :type group:
        ``str``
    :param block_dev:
        LVM Physical Volume device backing the Volume Group
    :type block_dev:
        ``str``
    """
    # Can we see the Volume Group now that we have the block device? If
    # so, we are done.
    try:
        lvm.vgactivate(group)
        return

    except subproc.CalledProcessError:
        # The Volume group doesn't exist, more work to do
        pass

    # Create Physical Volume backend
    lvm.pvcreate(device=block_dev)
    # Create a Volume Group using the above Physical Volume
    lvm.vgcreate(group, device=block_dev)
    # Activate this Volume Group
    lvm.vgactivate(group)
Ejemplo n.º 2
0
def activate_vg(vg_name):
    """Try activating vg"""
    try:
        lvm.vgactivate(group=vg_name)
        return True
    except subproc.CalledProcessError:
        return False
Ejemplo n.º 3
0
    def test_vgactivate(self):
        """Test LVM Volume Group activation"""
        lvm.vgactivate('some_group')

        treadmill.subproc.check_call.assert_called_with([
            'lvm',
            'vgchange',
            '--activate',
            'y',
            'some_group',
        ])