Bug 1956774

Summary: private_ip expected as String, not Boolean when creating a host via the API
Product: Red Hat Satellite Reporter: Evgeni Golov <egolov>
Component: Compute Resources - AzureAssignee: Evgeni Golov <egolov>
Status: CLOSED ERRATA QA Contact: Jitendra Yejare <jyejare>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.8.0CC: tbrisker
Target Milestone: 6.10.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-foreman_azure_rm-2.2.3 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-16 14:10:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Evgeni Golov 2021-05-04 11:49:44 UTC
I am creating Azure VMs using the API (well, Ansible, but that doesn't matter).

I submit the following Interfaces config:

<pre>
          interfaces_attributes:
            - type: "interface"
              compute_attributes:
                network: default #not foreman-vnet-default
                public_ip: Dynamic
                private_ip: false

</pre>

Which yields the following error:

<pre>
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.
</pre>

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:

<pre>
private_ip = (attrs[:private_ip] == 'false') ? false : true
</pre>

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

Comment 1 Evgeni Golov 2021-05-04 11:49:50 UTC
Created from redmine issue https://projects.theforeman.org/issues/32500

Comment 2 Evgeni Golov 2021-05-04 11:49:52 UTC
Upstream bug assigned to egolov

Comment 3 Jitendra Yejare 2021-07-01 09:34:10 UTC
Verified!

Steps:
1. Create an Azure RM Compute Resource.
2. Provision the host on Azure CR but by setting private_ip to False(Boolean, not String) in interface attributes of host.

Behaviour:
The host provisioned is successful even though the private_ip is set to boolean value.

Comment 4 Jitendra Yejare 2021-07-01 09:39:13 UTC
Verified in Satellite 6.10 Snap 7.

Comment 7 errata-xmlrpc 2021-11-16 14:10:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.10 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:4702