Netbox: VM Import Plugin #22
-
|
Hello everyone, |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 39 replies
-
|
Can you show what you have tried, so I can, may help you with the Problem. The Plugins I build for Import, never did filter something based on Rules. If you can read the VM Attributes from the Netbox API, and you have them as a key:value pair, ` host_obj.update_host(attributes) host_obj.save() |
Beta Was this translation helpful? Give feedback.
-
|
I dind't had much time to look further into it but my idea was to add a " Get VMs" Class based on get_devices in syncer.py that looks like this: def get_vm(self, syncer_only=False):
"""
Read full list of devices
"""
print(f"{CC.OKGREEN} -- {CC.ENDC}Netbox: "\
f"Read all devices (Filter only CMDB Syncer: {syncer_only})")
url = 'virtualisation/vitual-machines/?limit=1000'
if syncer_only:
url += f"&cf_cmdbsyncer_id={self.config['_id']}"
vm = self.request(url, "GET")
return {x['display']:x for x in vm}and than later just copy and edit the netbox plugin and replace the get_devices class with my and edit the terminal commands to a degree that make sense. As much as i can tell the handling of all other stuff like labes etc. should be the same. i think. |
Beta Was this translation helpful? Give feedback.
-
|
In the latest git, I build in the VM import too out of the box. I have currently no net box to test, would be nice if you can check if I have broken something. Now, after checking the Code, I see what you meant by no Labels. There is currently no Label import from Netbox implemented. If you can provide me an API Response from the virtual-machines and point me in the direction, what you need as labels there, I will add the function asap. I would then just again need you to test, since still no netbox here :) |
Beta Was this translation helpful? Give feedback.
-
|
Sure. i'm grabbing the latest build in a moment. In the meantime, here is a responebody for a single VM per id: I hope this helps. if you need something more dont hesitate to ask! |
Beta Was this translation helpful? Give feedback.
-
|
@PhXcell |
Beta Was this translation helpful? Give feedback.
-
|
Nope, it's usually because of missing BASE_PREFIX, which needs to be set to your Page Address (Don't have a better solution yet):
Yes, good Ideas, have already somehting in mind |
Beta Was this translation helpful? Give feedback.
-
|
i made sure to safe it and even imported all hosts fresh to CheckMK. |
Beta Was this translation helpful? Give feedback.
-
|
So far i can do everything i need and it works like a charm. my peronal whishlist for QoL improvments:
Im really looking forward for future updates! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Is there a way to debug cronjobs? set up a 3 cronjobs from 0-24 and non of them is triggering. |
Beta Was this translation helpful? Give feedback.
-
|
Long time no response, sorry :) But when you run the Ansible manually anyway, why don't run a second playbook after? |
Beta Was this translation helpful? Give feedback.
-
|
@PhXcell I just pushed a change regarding your wish: Now the Importer tries to get all the fields and custom fields. Can you check if that's working for you? |
Beta Was this translation helpful? Give feedback.
-
|
@PhXcell And another one for you :) You now have Jinja Powers for the Attributes Rewrites. You can use all the other Attributes in the Template as well to create new values. All Documentation here: https://cmdbsyncer.readthedocs.io/en/latest/basics/rewrite_attributes/ Currently only tested locally on my setup. |
Beta Was this translation helpful? Give feedback.








That is just a matter of Whitelist the Attribute.
In the Checkmk Section you have "Filters", there you can Whitelist as Outcome. Set role there, check with
./cmdbsyncer checkmk debug_host YOURHOST, if fine Commit the Changes and export to checkmk