Use a LVM volume group with libvirt
A short howto how to use a LVM volume group with libvirt on Debian Squeeze (used for KVM VMs in my case). I assume your VG already exists and is dedicated for libvirt usage. In my case it’s /dev/vg1.
First of all, create the XML definition for the storage pool in /etc/libvirt/storage/vg1.xml. This is the minimal configuration needed, libvirt will extend it with things like UUID when you define it.
<pool type='logical'> <name>vg1</name> <target> <path>/dev/vg1</path> </target> </pool>
Now you can tell libvirt about the new storage pool and let it start automatically.
$ virsh pool-define /etc/libvirt/storage/vg1.xml $ virsh pool-start vg1 $ virsh pool-autostart vg1 $ virsh pool-info vg1
Creating virtual machines inside that storage pool is easy as pie:
$ virt-install -d --hvm --vnc --name=vm01 \
--ram 512 --disk pool=vg1,size=10,bus=virtio,cache=none \
--network network=default,model=virtio \
--location=http://ftp.debian.org/debian/dists/squeeze/main/installer-amd64/ \
--os-type=linux --os-variant=debiansqueeze
Cheers!
eZPublish access/change user account from PHP
It took me some time to figure out how to access and change a user account in eZPublish from PHP. Here’s an example how to achieve this:
<?php // user node $node = eZContentObjectTreeNode::fetch($nodeID); // user object $dataMap = $node->dataMap(); // change attribute $firstname = $dataMap['firstname']; $firstname->setAttribute('data_text', 'Foo'); $firstname->sync(); // user account attribute $user = $dataMap['user_account']; $userData = $user->content(); // user settings $userSetting = eZUserSetting::fetch($user->ContentObjectID); // get account status $isEnabled = $userSetting->attribute('is_enabled'); // enable user account $userSetting->setAttribute('is_enabled', 1); $userSetting->store();
Or if you just want to access the user account object or the user setting directly:
<?php // user account object $user = eZUser::fetch($objectID); // user settings $userSetting = eZUserSetting::fetch($objectID);