wpietrzakpl / GlpiTools

PowerShell Module to work with Glpi API
15 stars 8 forks source link

It's just that I never know how to import the information in the sub-project, such as ip address, mac address and so on #17

Closed iamtornado closed 3 years ago

iamtornado commented 3 years ago

hello: I now know how to import basic project information through glpitools, such as computer name, serial number, etc. It's just that I never know how to import the information in the sub-project, such as ip address, mac address and so on. The following figure shows the network information of the server collected by the fusioninventory agent. If I use glpitools, how should I import this information? image thanks

wpietrzakpl commented 3 years ago

Hello, Yes, there is a way to do this Follow the steps to add new parameter called "Item_DeviceNetworkCard" to parameters.json (Here is how to do this - https://www.wpietrzak.pl/glpi/ThingsToKnowGlpiTools/ section parameters.json)

and then: Get-GlpiToolsItems -ItemType Item_DeviceNetworkCard - to find required network which is associated with computer

and you can update with:

$example = @{mac = "20:6a:8a:a9:75:81"} Update-GlpiToolsItems -UpdateTo Item_DeviceNetworkCard -ItemId -ItemsHashtableWithoutId $example

you can easly find me on Discord, feel free to catch me there !

iamtornado commented 3 years ago

Hi, I found that the parameter.json file already contains the networkcard component, but I did not find the associated computer with this command, it is actually associated with a computer, as shown below: image image In addition, the most important thing is that I actually want to achieve this goal: I used the powershell module PowerCLI developed by VMware to obtain the information of virtual machines in VMware vcenter. I want to import the information of these virtual machines into glpi. The following figure illustrates how I obtain the information of virtual machines in VMware vcenter. image Since there is no corresponding relationship between virtual machine and network information in glpi, I really don’t understand how to associate Computer with network information. If this is not clear, then I cannot import the obtained virtual machine information into glpi.

wpietrzakpl commented 3 years ago

Maybe it wasn't clear but as I wrote you need "Item_DeviceNetworkCard" to get the network cards I am pretty sure that you can do it !

wpietrzakpl commented 3 years ago

you can add this endpoint to the parameters.json "ipaddress" this one will give you all IP addresses, and with this information you can filter the list with items_id which is id of computer and then you can update this as I showed you

wpietrzakpl commented 3 years ago

do you have more questions ? if not, I would close the issue

iamtornado commented 3 years ago

hi, According to what you said, I added "ipadress" to the parameters.json file. You can indeed get all the existing ip address information in glpi through the Get-GlpiToolsItems -ItemType ipaddress command. But the current situation is that I want to import the ip information into glpi, but it is not successful, as shown in the following figure: image

wpietrzakpl commented 3 years ago

look how I did it image the most important here is "items_id" parameter - this is ID of Network Name which is Associated with Computer

Without this it would not work

iamtornado commented 3 years ago

I think I understand what you mean, according to what you said, I successfully added ip $example = @{name = "10.30.1.3";items_id = 4;itemtype = "NetworkName"} $networkname =@{name = "dvportgroup-334"} $itemtype = @{itemtype = "networkport"} Add-GlpiToolsItems -AddTo networkname -HashtableToAdd $networkname Update-GlpiToolsItems -UpdateTo networkname -ItemId 4 -ItemsHashtableWithoutId $itemtype Add-GlpiToolsItems -AddTo ipaddress -HashtableToAdd $example image

iamtornado commented 3 years ago

thank you very much! You let me know more about the data structure of glpi. I think that if you want to make full use of glpi restapi, you still have to understand the structure of glpi's database and understand the relationship between the tables. I still have to learn the knowledge of the database

wpietrzakpl commented 3 years ago

That's true I am happy that I could help As I said, you can catch me on my Discord Server - details at my web page Cheers!