ninech / netbox-client-ruby

A ruby client library for Netbox v2.
MIT License
24 stars 21 forks source link

Unable to fetch VirtualMachine.Primary_IP.address #36

Closed valentin2105 closed 2 years ago

valentin2105 commented 4 years ago

Hello,

I'm building an RoR app that fetch my Netbox instance to show our virtual machines.

I'm happy to find your lib, it work as well but I got issues to fetch a variable.

Maybe it's my low level in Ruby the cause, but I don't find any answer.

# I fetch VMs in my Controller
      vms = NetboxClientRuby.virtualization.virtual_machines.filter(cluster_id: cluster_id)

# I use the @vms var in my ERB html files

 <% @vms.each do |vm| %>
        <tr>
# This Work well
            <td><%= vm.name %></td>
            <td><%= vm.vcpus %></td>
            <td><%= vm.memory %>Mo</td>
            <td><%= vm.disk %>Go</td>
# This doesn't work
            <td> <%= vm.primary_ip.name %></td>   
        </tr>
<% end %>

I have tried vm.primary_ip['address'], vm.primary_ip('address') and few other way, but I'm unable to get my VM Primary IP Address.

I got error like this :

undefined methodname' for #`

Any idea ?

Thanks by advance

thde commented 3 years ago

vm.primary_ip.address?

thde commented 2 years ago

Closing this issue for now. Feel free to open it again if the issue persists.