Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.3.x+xen related updates #162

Merged
merged 157 commits into from
Jun 29, 2018
Merged

2.3.x+xen related updates #162

merged 157 commits into from
Jun 29, 2018

Conversation

g-bougard
Copy link
Contributor

@fquiroga
Copy link

Thank's @g-bougard how can i apply the patch to test the vm inventory working ?

Regards.

@g-bougard
Copy link
Contributor Author

Hi @fquiroga the most simple way for you is to download and replace modified Xen.pm & XenCitrixServer.pm files with the following links:
FusionInventory/Agent/Task/Inventory/Virtualization/Xen.pm
FusionInventory/Agent/Task/Inventory/Virtualization/XenCitrixServer.pm

@g-bougard
Copy link
Contributor Author

@fquiroga Hi, had you time to test this PR on your side ? Thx

@fquiroga
Copy link

fquiroga commented Oct 4, 2016

Hi @g-bougard, i will test the PR this afternoon and feedback.
Thanks !

@fquiroga
Copy link

fquiroga commented Oct 4, 2016

Hi @g-bougard, it seems it's working now with a few issues:

1- In GLPI, the machines are stored as a new Computer.
2. If i go to Assets-> Computers and select the Host Machine with XenServer, in the virtualization tag, it doesn't show the Name, state of virtual machine, neither the amout of cpu and memory configured:

List of virtual machines
Name Automated inventory Virtualization system Virtualization model State of the virtual machine UUID Number of CPUs Memory (MB) Machine
N/A Yes xen xe 95dd679e-a11d-c5a4-f8c8-c1e9d32675ed 0 0 ffff
N/A Yes xen xe 868c4a39-de21-8b2e-42fd-5607db5e97ab 0 0 ffff
N/A Yes xen xe 8e03b956-68da-0990-3285-5fc2fe152f70 0 0 ffff
N/A Yes xen xe 39ca53cf-2524-0095-64db-b25bfddf1e6f 0 0 ffff
N/A Yes xen xe 05338a8c-8acc-198a-a6d8-1bbf1b2add89 0 0 ffff
N/A Yes xen xe d6807c88-9fb3-a8df-7b17-9719b0ca1941 0 0 ffff
N/A Yes xen xe ae054a9d-c050-c73a-da91-11302bba671b 0 0 ffff
N/A Yes xen xe f0e6fcbf-e78f-9b76-bf52-da9718f3f703 0 0 ffff
N/A Yes xen xe 400aff75-b402-222e-87e0-257da00ebe8b 0 0 ffff
N/A Yes xen xe 4ee7d936-bc9f-3acd-affb-745322aa7c78 0 0 ffff
N/A Yes xen xe cd7cf7c5-6274-c938-26c0-d3e0831385c6 0 0 ffff
N/A Yes xen xe a720c468-77f8-a75a-3d04-6bda0eef2da8 0 0 ffff
N/A Yes xen xe 2370d315-6a67-cc22-92b5-5522c585c36d 0 0 ffff
N/A Yes xen xe f3088143-b137-1243-992a-dbd16c390aef 0 0 ffff
N/A Yes xen xe 4e4616c7-9ffe-2445-16cf-e095896204e1 0 0 ffff
N/A Yes xen xe da92c00d-80de-d4a9-3d51-1140a3af97c2 0 0 ffff
N/A Yes xen xe a444ab5d-d1fc-f1a5-5ab4-3f0c3c07352e 0 0 ffff
N/A Yes xen xe 86f7806a-a4ec-1a88-be19-e7e3ed664c19 0 0 ffff
N/A Yes xen xe 6cc10a0d-b607-1339-8cc8-cad4797cd4b8 0 0 ffff
N/A Yes xen xe 3d21cd51-fe70-9462-f979-0b131130321a 0 0 ffff
N/A Yes xen xe cf099910-c6d9-2736-ccaa-feeb831634e8 0 0 ffff
N/A Yes xen xe c6972d8b-1dc0-de79-4208-3d2c7d089fb0 0 0 ffff
N/A Yes xen xe 989947db-7017-3715-eb17-c1ed9bd73883 0 0 ffff
N/A Yes xen xe 578a36fb-9f06-bf35-e4bc-541bb2d38dc0 0 0 ffff
N/A Yes xen xe baf29a39-05d5-10d4-48c1-76648c25867a 0 0 ffff
N/A Yes xen xe 5615ea9d-5865-fb0e-aaef-b8091437dc98 0 0 ffff
N/A Yes xen xe a1c19cb3-3953-bc47-60a2-c84414290562 0 0 ffff
N/A Yes xen xe 7aa76a40-5e05-35eb-f275-e0f6c2c13d8f 0 0 ffff
N/A Yes xen xe 7ee65e39-11ba-a4d4-d2bb-2b0488ad3c55 0 0 ffff
N/A Yes xen xe ecfeaa60-07cf-b710-30c2-d2f6a4cdb152 0 0 ffff
N/A Yes xen xe b8e64daf-0586-eebc-8079-51df97b628cc 0 0 ffff
N/A Yes xen xe aa73f25f-7bb9-0bcd-9d8a-3790d8196d2c 0 0 ffff
N/A Yes xen xe 1b3907d8-7987-9e5f-7e0c-0d0e3885b87b 0 0 ffff
N/A Yes xen xe 969d8ab5-222a-cf88-6c3e-cc9bcca0febb 0 0 ffff
N/A Yes xen xe d00720df-0dcb-5259-9d8d-4bf2fc3a272c 0 0 ffff
N/A Yes xen xe aad6e924-f255-f5f0-710c-be6b8aefd1dd 0 0 ffff
Name Automated inventory Virtualization system Virtualization model State of the virtual machine UUID Number of CPUs Memory (MB) Machine

This are the logs when i manually run fusioninventory-agent:

[root@xcp-01 Inventory]# fusioninventory-agent
[debug] Logger backend File initialised
[debug] FusionInventory Agent (2.3.17)
[debug] Configuration directory: /etc/fusioninventory
[debug] Data directory: /usr/share/fusioninventory
[debug] Storage directory: /var/lib/fusioninventory
[debug] Lib directory: /usr/share/fusioninventory/lib
[debug] [target server0] Next server contact planned for Wed Oct 5 05:46:43 2016
[debug] Available tasks:
[debug] - Inventory: 1.0
[debug] [http client] Using Compress::Zlib for compression
[info] sending prolog request to server server0
[info] running task Inventory
[debug] Net::CUPS Perl module not available, unable to retrieve printers
[debug] module FusionInventory::Agent::Task::Inventory::Virtualization::Xen disabled because of FusionInventory::Agent::Task::Inventory::Virtualization::XenCitrixServer
[debug] Running FusionInventory::Agent::Task::Inventory::AccessLog
[debug] Running FusionInventory::Agent::Task::Inventory::Generic
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Arch
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Dmidecode
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Dmidecode::Battery
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Dmidecode::Bios
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Dmidecode::Memory
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Dmidecode::Ports
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Dmidecode::Slots
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Domains
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Environment
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Hostname
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Ipmi
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::PCI
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::PCI::Controllers
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::PCI::Modems
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::PCI::Sounds
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Processes
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::SSH
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Screen
[debug] retrieving EDID data:
[debug] - reading /sys/devices content: no result
[debug] - running monitor-get-edid-using-vbe command: command not available
[debug] - running monitor-get-edid command: command not available
[debug] - running get-edid command: command not available
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Softwares
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Softwares::RPM
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Storages
[debug] Running FusionInventory::Agent::Task::Inventory::Generic::Users
[debug] Running FusionInventory::Agent::Task::Inventory::Linux
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Distro
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Distro::LSB
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Drives
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Inputs
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::LVM
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Memory
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Networks
[debug] retrieving interfaces list:
[debug] - running /sbin/ip command: success
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Networks::FibreChannel
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Storages
[debug] retrieving devices list:
[debug] - reading /sys/block content: success
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Storages::Adaptec
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Uptime
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::Videos
[debug] retrieving display information:
[debug] - running ddcprobe command: command not available
[debug] - reading Xorg log file: unable to get Xorg PID
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::i386
[debug] Running FusionInventory::Agent::Task::Inventory::Linux::i386::CPU
[debug] Running FusionInventory::Agent::Task::Inventory::Virtualization
[debug] Running FusionInventory::Agent::Task::Inventory::Virtualization::Vmsystem
[debug] Running FusionInventory::Agent::Task::Inventory::Virtualization::XenCitrixServer
[debug] unknown field HASH(0xb487e70) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb487f6c) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb487eb8) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb487e7c) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f8ec) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f910) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb487eac) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f898) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f8d4) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f910) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f928) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb487e70) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f964) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f910) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f970) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb487eac) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f97c) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f928) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f910) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb487eac) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f97c) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f970) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f9ac) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f9d0) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f8e0) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f970) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48fa00) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f910) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f9ac) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48fa00) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f9a0) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f9ac) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48fa0c) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f910) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48fa24) for section VIRTUALMACHINES
[debug] unknown field HASH(0xb48f9dc) for section VIRTUALMACHINES
[debug] Section HARDWARE has changed since last inventory
[debug] Section DRIVES has changed since last inventory
[debug] [http client] Using Compress::Zlib for compression

Regards.

@g-bougard
Copy link
Contributor Author

Thanks for the feed back, [debug] unknown field HASH(0xXXXXXXXX) for section VIRTUALMACHINES lines are clearly showing something is wrong.

I'll investigate.

g-bougard and others added 19 commits February 21, 2018 18:20
Support DEVICE given PID
Bump NetInventory task version to 3.0
Get rid of START/END messages in newer server protocol
Add NetInventory protocol unittest
failing to run NetInventory task
Move common SNMP values getter to SNMP::Device class
This fix a regression where MEMORY, RAM & CPU was removed from net inventory.
Support port & protocol options for NetInventory & NetDiscovery tasks
* Fix nmap output used toward 2 ips and the checked result was a merge of the 2
* Fix device discovery with only ping responding and without dns
* Updated unittest to show the ping without dns support
Update nmap options for NetDiscovery task
The dependency was only used for few old MacOS tests and was failing for few cpantesters
so reducing our cpantester score...
Cleanup related unittest
Register planned task by Target
Modify code to use getAllLines() API on the command get-edid output for the monitors
@nathanbritonsb
Copy link

nathanbritonsb commented May 16, 2018

IT WORKED!
Gentlemen, I'm not a programmer. But I solved it in a way that I believe to be quite amateurish. I used logic to understand code and google to help me understand some syntax. hahaha
Now finally FusionInventory is properly inventorying virtual machines with correct names.
I will not suggest a commit, because as I said, I am not a programmer and there is certainly a cleaner way to solve the problem. So I'm going to show what solved the problem so some programmer can commit. But anyway ... Here are the changes I made:

File: /usr/share/fusioninventory/lib/FusionInventory/Agent/Task/Inventory/Virtualization/XenCitrixServer.pm

1 - REMOVE: Through debugging I noticed that this foreach is not feeding the hash "$ machine" correctly, so I removed it.

#        foreach my $key ($machineextend) {
#            $machine->{$key} = $machineextend->{$key};
#        }

2 - ADD: as the above foreach did not work, I fed the hash $ machine manually. So I added the following lines just below the lines commented above:

my $machine = {
        NAME	  => $machineextend->{NAME},
        STATUS    => $machineextend->{STATUS},
        MEMORY    => $machineextend->{MEMORY},
        VCPU	  => $machineextend->{VCPU},
        COMMENT   => $machineextend->{COMMENT},
        UUID	  => $machine->{UUID},
        SUBSYSTEM => 'xe',
        VMTYPE    => 'xen',
    };

3 - ALTER: I noticed that the_getUUID function was returning the UUID with a space at the beginning, so the "xe vm-param-list uuid=$machine->{UUID}" command did not return the correct content. So I edited the _getUUID function by adding a space after the ":".

Before:
my (undef, $uuid) = split(':', $line);

After:
my (undef, $uuid) = split(': ', $line);

4 - ALTER: In the _getVirtualMachines function the labels for memory and processor are wrong.

Before:

if ($extendedlabel =~ /VCPUs-number/) {
            $machine->{VCPU} = $value;
            next;
}

After:

if ($extendedlabel =~ /VCPUs-max/) {
            $machine->{VCPU} = $value;
            next;
}

Before:

if ($extendedlabel =~ /memory-actual/) {
            $machine->{MEMORY} = ($value / 1048576);
            next;
}

After:

if ($extendedlabel =~ /memory-static-max/) {
            $machine->{MEMORY} = ($value / 1048576);
            next;
}

@fquiroga Man, can you make a test?

@g-bougard Could you help me make a better code and then publish this fix properly? Like I said, I'm not a programmer. I just interpret codes well. hehe

@g-bougard
Copy link
Contributor Author

Hi @ntnbrito
I rebased my PR against 2.4.x branch and checked your code updates. Your updates was not related to my PR. I added a commit to fix your first point, making second point useless. This commit should also fix the problem @fquiroga reported.
About your third point, it was fixed in my PR using a regex.
About your last point, I checked the xm output added in my PR and VCPU-number is set to 0 when the related machine is halted or in dom-0, so I think this is an error to use VCPU-max. In the same way, the only case I saw with a memory-actual at 0 was for the halted vm. So I don't see memory-static-max is the right value to take.
If you have other cases, can you attach a xe vm-list output and xe vm-param-list uuid=XXXXX related outputs, replacing XXXXX by machine UUID ?

@nathanbritonsb
Copy link

excellent friend!
On data that is cleared when the machine is off:
In particular, I find it more convenient to show the actual data of the machine even if it is off. For my need at least this data is important. But that's a peculiarity.
Thankful for the return!

@g-bougard g-bougard merged commit 4fd258a into fusioninventory:2.3.x Jun 29, 2018
@g-bougard g-bougard deleted the 2.3.x+xen-related-updates branch June 29, 2018 08:24
@g-bougard g-bougard restored the 2.3.x+xen-related-updates branch June 29, 2018 08:26
@g-bougard g-bougard deleted the 2.3.x+xen-related-updates branch June 29, 2018 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants