Feature #1552
Support of lxc-tools under Linux
| Status: | Closed | Start date: | 04/10/2012 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% | ||
| Category: | linux | |||
| Target version: | 2.2.3 | |||
| For junior contributor: | No |
Description
Hi,
Currently fusioninventory agent supports libvirt tools to check any LXC containers (it tries to run virsh to get the list). We're using lxc-tools (lxc-ls, lxc-create, lxc-console, etc.), could this be implemented?
Associated revisions
add support of lxc-tools under Linux
closes: #1552
add test-scripts for Lxc.pm
see: #1552
History
#1
Updated by Gonéri Le Bouder about 1 year ago
Sure, I don't use it myself. Could you provide a patch for that or give us what commands need to be run to get the required informations?
#2
Updated by Gonéri Le Bouder about 1 year ago
- Assignee set to Gonéri Le Bouder
#3
Updated by Egor Morozov about 1 year ago
Could you give me output of libvirt's virsh?
#4
Updated by Gonéri Le Bouder about 1 year ago
I don't understand. Do you use libvirt to controle your lxc container?
#5
Updated by Gonéri Le Bouder about 1 year ago
- Priority changed from Low to Normal
#6
Updated by Egor Morozov about 1 year ago
No, we're using lxc-tools. Just wanna to look at libvirt's output and compare it :)
#7
Updated by Gonéri Le Bouder about 1 year ago
oh. I don't use lxc at all myself :)
#8
Updated by Egor Morozov about 1 year ago
Ok, do we need some kind of unique ID for a container, or just the name & the status would be okay?
#9
Updated by Gonéri Le Bouder about 1 year ago
Hi Egor,
You can get the Inventory format documentation with:
perldoc FusionInventory::Agent::Task::Inventory::Inventory
or directly by browsing:
https://metacpan.org/module/FusionInventory::Agent::Task::Inventory::Inventory
UUID is important in general because, it's the sole information that can be use to create the relation between the VM and the Hypervisor.
Sometime, VMID or the MAC address is enough. I don't know for lxc.
=head2 VIRTUALMACHINES
=item MEMORY Memory size, in MB.
=item NAME The name of the virtual machine.
=item UUID
=item STATUS: the VM status: running, idle, paused, shutdown, crashed, dying, off
=item SUBSYSTEM The virtualisation software. E.g: VmWare ESX
=item VMTYPE The name of the virtualisation system family. The same type found is HARDWARE/VMSYSTEM
=item VCPU Number of CPU affected to the virtual machine
=item VMID The ID of virtual machine in the virtual managment system.
=item MAC The list of the MAC addresses of the virtual machine. The delimiter is '/'. e.g: 00:23:18:91:db:8d/00:23:57:31:sb:8e
=item COMMENT a comment
=item OWNER
#10
Updated by Egor Morozov about 1 year ago
Hi,
LXC doesn't have it's own UUID, but it has independent MAC address. Not sure about VMID and where it can be taken of :)
#11
Updated by Egor Morozov about 1 year ago
It seems we need your help.
We've done filling these fields:
<VIRTUALMACHINES>
<MAC>0A:AB:BC:CD:DE:EF</MAC>
<MEMORY>1024000</MEMORY>
<NAME>test1</NAME>
<STATUS>RUNNING</STATUS>
<VCPU>7</VCPU>
<VMID>13018</VMID>
<VMTYPE>LXC</VMTYPE>
</VIRTUALMACHINES>
But when VCPU or MEMORY is changed, GLPI creates a new VM instead of using the old one :-/ LXC doesn't really have VMID, it's just a PID, should it be excluded from the XML? As an option, I may suggest using MAC address as UUID, but probably it's not a good idea.
#12
Updated by Gonéri Le Bouder about 1 year ago
- Status changed from New to In Progress
I think, this is a bug. I'd just spent 2 hours chasing it... Please try this changes:
http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/repository/revisions/6f4be08f269260d9086361f09a68f25d4d27670d/diff/fusinvinventory/inc/libhook.class.php
You will need to remove/purge the machine after that to recreate to from scratch.
Regarding the lxc inventory, RUNNING should be written in lower-case letter, so it's should be running ( https://metacpan.org/module/FusionInventory::Agent::Task::Inventory::Inventory#VIRTUALMACHINES )
#13
Updated by Egor Morozov about 1 year ago
- File Lxc.pm
added
Yeah, that fixes the problem! :)
Here's a new module for LXC :)
#14
Updated by Gonéri Le Bouder about 1 year ago
Hi Egor,
This look great.
Is it possible for you to use getFileHandle() instead of open. It would be interesting to create specific function for "/usr/bin/lxc-ls -1" and "/usr/bin/lxc-info -n $vm" parsing. This way we will be able to do some unit test scripts like we do for the rest of the Inventory modules (see in t/inventory/virtualization/*).
If you don't want to do that, just attach, some "lxc-ls -1" and "lxc-info -n $vm" outputs. I will do that myself.
Just a minor point, we use 4 spaces instead of tab to indent the code.
Best regards and thank you for your efforts! :)
#15
Updated by Egor Morozov about 1 year ago
Here's the new version :)
And the output for the commands:
# lxc-ls -1 name1 name2 name3 name1 name2 name3
# lxc-info -n name1 state: RUNNING pid: 13018
# cat /var/lib/lxc/mysql-test1/config
lxc.utsname = name1
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.ipv4 = 0.0.0.0
lxc.network.hwaddr = 01:23:45:67:89:0A
lxc.cgroup.memory.limit_in_bytes = 2048000
lxc.cgroup.cpuset.cpus = 0,3-5
lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = /var/lib/lxc/name1/rootfs
lxc.mount = /var/lib/lxc/name1/fstab
lxc.arch =
lxc.cgroup.devices.deny = a
# /dev/null and zero
lxc.cgroup.devices.allow = c 1:3 rwm
lxc.cgroup.devices.allow = c 1:5 rwm
# consoles
lxc.cgroup.devices.allow = c 5:1 rwm
lxc.cgroup.devices.allow = c 5:0 rwm
#lxc.cgroup.devices.allow = c 4:0 rwm
#lxc.cgroup.devices.allow = c 4:1 rwm
# /dev/{,u}random
lxc.cgroup.devices.allow = c 1:9 rwm
lxc.cgroup.devices.allow = c 1:8 rwm
lxc.cgroup.devices.allow = c 136:* rwm
lxc.cgroup.devices.allow = c 5:2 rwm
# rtc
lxc.cgroup.devices.allow = c 254:0 rwm
#fuse
lxc.cgroup.devices.allow = c 10:229 rwm#16
Updated by Egor Morozov about 1 year ago
- File Lxc.pm
added
#17
Updated by Gonéri Le Bouder about 1 year ago
- Target version set to 2.2.3
#18
Updated by Egor Morozov about 1 year ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
Applied in changeset 59c298942ce62ca610bfdc1887c2dbf14c344c54.
#19
Updated by Gonéri Le Bouder about 1 year ago
Pushed in 2.2.x branch. Again Egor, a big thank you!
#20
Updated by Gonéri Le Bouder about 1 year ago
- Status changed from Closed to Resolved
#21
Updated by Egor Morozov about 1 year ago
Great :)
#22
Updated by Gonéri Le Bouder 12 months ago
- Status changed from Resolved to Closed