Project

General

Profile

Actions

Bug #32500

closed

private_ip expected as String, not Boolean when creating a host via the API

Added by Evgeni Golov about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Foreman integration
Target version:
Difficulty:
easy
Triaged:
Yes
Fixed in Releases:
Found in Releases:

Description

I am creating Azure VMs using the API (well, Ansible, but that doesn't matter).

I submit the following Interfaces config:

          interfaces_attributes:
            - type: "interface" 
              compute_attributes:
                network: default
                public_ip: Dynamic
                private_ip: false

Which yields the following error:

MsRestAzure::AzureOperationError: PrivateIPAddressMissing: Private IP address is required when privateIPAllocationMethod is Static in IP configuration /subscriptions/UUID/resourceGroups/foreman/providers/Microsoft.Network/networkInterfaces/whoa-nic0/ipConfigurations/whoa-nic0.

This is because the code at https://github.com/theforeman/foreman_azure_rm/blob/48c22cb6f4e3845d2faf61be26d3f0eea58b6b70/app/models/concerns/foreman_azure_rm/vm_extensions/managed_vm.rb#L126 reads:

private_ip = (attrs[:private_ip] == 'false') ? false : true

Which makes private_ip only False if the API parameter was a string with the value "false".

Actions

Also available in: Atom PDF