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)
示例#2
0
    def test_vgcreate(self):
        """Test LVM Volume Group creation"""
        lvm.vgcreate('some_group', 'some_blockdev')

        treadmill.subproc.check_call.assert_called_with([
            'lvm',
            'vgcreate',
            '--autobackup',
            'n',
            'some_group',
            'some_blockdev',
        ])