Contact Us

support@onapp.com

U.S: (+1) 888-876-8666

UK: +44 (0) 203-318-5364

MySQL - list hostnames and IP addresses for VMs

Follow

Comments

4 comments

  • Avatar
    Nick Fawbert

    Hi,

    Since this post, I gather a lot has changed to the database structure!

    I also am trying to output a list of all IP addresses and VM-hostnames using them, but have got a bit stuck.

     

    SELECT ip_addresses.address,virtual_machines.hostname FROM (ip_address_usages LEFT JOIN ip_addresses ON ip_address_usages.ip_address_id = ip_addresses.id) LEFT JOIN virtual_machines ON ip_address_usages.virtual_machine_id = virtual_machines.id WHERE (ip_address_usages.unassigned_at IS NULL) OR (virtual_machines.hostname IS NULL);

     

    However, this causes duplicate IP addresses to output (if they have been assigned to other VMs in the past) and does not list IPs which have never been assigned to a VM.

    Any chance of some help with this?

  • Avatar
    Derek Smith

    Nick,

    I just updated the command. It should work for the version you are on. Try it out and let us know if it needs anything else.

  • Avatar
    Nick Fawbert

    Many thanks Derek! Precisely what I needed!

  • Avatar
    Sandy

    Hello OnApp,

     Thanks for this. Is it possible to populate this information HV wise ? Wherein we will just get HV name, VM hostname, and primary IP address? This will help to perform audit of our cloud.

    Regards

    Sandy

Please sign in to leave a comment.