Project

General

Profile

Actions

Bug #11124

closed

Interface compute attributes not merged from API request over compute profile

Added by Matt Chesler over 8 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Hammer command:

hammer host create --name network-test-host --architecture-id 1 --puppet-proxy-id 1 --puppet-ca-proxy-id 1 --compute-resource-id 1 --environment-id 1 --domain-id 1 --subnet-id 2 --interface compute_network=10-10-1-0-24-net,compute_type=VirtualVmxnet3,primary=true,provision=true --compute-attributes cluster=Cluster1,cpus=4,memory_mb=8192,guest_id=centos64Guest,scsi_controller_type=ParaVirtualSCSIController,resource_pool=RP1 --operatingsystem-id 2 --partition-table-id 17 --medium-id 8 --volume size_gb=50,datastore=DS4 --hostgroup-id 7

succeeds, but when checking VMware, the network set is not the network specified. Selecting the same network through the Web UI correctly sets the network in VMware.

production.log output when creating with hammer:

Started POST "/api/hosts" for 10.0.0.184 at 2015-07-15 11:39:57 -0400
2015-07-15 11:39:57 [I] Processing by Api::V2::HostsController#create as JSON
2015-07-15 11:39:57 [I]   Parameters: {"host"=>{"name"=>"network-test-host", "environment_id"=>"1", "architecture_id"=>"1", "domain_id"=>"1", "puppet_proxy_id"=>"1", "operatingsystem_id"=>"2", "medium_id"=>"8", "ptable_id"=>"17", "subnet_id"=>"2", "compute_resource_id"=>"1", "hostgroup_id"=>"7", "puppet_ca_proxy_id"=>"1", "build"=>true, "enabled"=>true, "managed"=>true, "compute_attributes"=>{"cluster"=>"Cluster1", "cpus"=>"4", "memory_mb"=>"8192", "guest_id"=>"centos64Guest", "scsi_controller_type"=>"ParaVirtualSCSIController", "resource_pool"=>"RP1", "volumes_attributes"=>{"0"=>{"size_gb"=>"50", "datastore"=>"DS4"}}}, "host_parameters_attributes"=>{}, "interfaces_attributes"=>{"0"=>{"primary"=>"true", "provision"=>"true", "compute_attributes"=>{"network"=>"10-10-1-0-24-net", "type"=>"VirtualVmxnet3"}}}}, "apiv"=>"v2"}
2015-07-15 11:39:57 [I] Skipping user group update for user matt.chesler as usergroup_sync is disabled
2015-07-15 11:39:57 [I] Authorized user matt.chesler(Matt Chesler)
2015-07-15 11:40:22 [I] Adding Compute instance for network-test-host.example.com
2015-07-15 11:40:22 [I] Successfully decrypted field for Foreman::Model::Vmware
2015-07-15 11:40:22 [I] Successfully decrypted field for Foreman::Model::Vmware
2015-07-15 11:40:26 [I] Create DHCP reservation for network-test-host.example.com-00:50:56:a1:28:78/10.10.1.69
2015-07-15 11:40:43 [I] Add the TFTP configuration for network-test-host.example.com
2015-07-15 11:40:44 [I] Fetching required TFTP boot files for network-test-host.example.com
2015-07-15 11:40:44 [I]   Rendered api/v2/hosts/create.json.rabl (80.4ms)
2015-07-15 11:40:44 [I] Completed 200 OK in 46729ms (Views: 78.8ms | ActiveRecord: 67.2ms)
2015-07-15 11:41:22 [I] 

production.log output when creating with Web UI:

Started POST "/hosts" for 10.0.0.184 at 2015-07-15 11:51:18 -0400
2015-07-15 11:51:18 [I] Processing by HostsController#create as */*
2015-07-15 11:51:18 [I]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"b6tTkXutY578Zn5NcPNi1th20FbjqsHE5DwotXRltBs=", "host"=>{"name"=>"network-test-host", "hostgroup_id"=>"7", "compute_resource_id"=>"1", "compute_profile_id"=>"1", "environment_id"=>"1", "puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "puppetclass_ids"=>[""], "managed"=>"true", "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", "interfaces_attributes"=>{"0"=>{"_destroy"=>"0", "type"=>"Nic::Managed", "mac"=>"", "identifier"=>"", "name"=>"network-test-host", "domain_id"=>"1", "subnet_id"=>"2", "ip"=>"10.10.1.75", "managed"=>"1", "primary"=>"1", "provision"=>"1", "virtual"=>"0", "tag"=>"", "attached_to"=>"", "compute_attributes"=>{"type"=>"VirtualVmxnet3", "network"=>"10-10-1-0-24-net"}}, "new_interfaces"=>{"_destroy"=>"1", "type"=>"Nic::Managed", "mac"=>"", "identifier"=>"", "name"=>"", "domain_id"=>"", "subnet_id"=>"", "ip"=>"", "managed"=>"1", "primary"=>"0", "provision"=>"0", "virtual"=>"0", "tag"=>"", "attached_to"=>"", "compute_attributes"=>{"type"=>"VirtualE1000", "network"=>"172-16-0-0-24-net"}}}, "compute_attributes"=>{"cpus"=>"4", "corespersocket"=>"1", "memory_mb"=>"8192", "cluster"=>"Cluster1", "path"=>"/Datacenters/Cluster1/vm", "guest_id"=>"centos64Guest", "scsi_controller_type"=>"ParaVirtualSCSIController", "hardware_version"=>"Default", "start"=>"1", "volumes_attributes"=>{"new_volumes"=>{"_delete"=>"", "datastore"=>"Backups", "name"=>"Hard disk", "size_gb"=>"10", "thin"=>"true", "eager_zero"=>"false"}, "0"=>{"_delete"=>"", "datastore"=>"DS4", "name"=>"Hard disk", "size_gb"=>"50", "thin"=>"true", "eager_zero"=>"false"}}}, "architecture_id"=>"1", "operatingsystem_id"=>"2", "provision_method"=>"build", "build"=>"1", "medium_id"=>"8", "ptable_id"=>"17", "disk"=>"", "root_pass"=>"[FILTERED]", "is_owned_by"=>"4-Users", "enabled"=>"1", "model_id"=>"", "comment"=>"", "overwrite"=>"false"}, "capabilities"=>"build image", "provider"=>"Vmware"}
2015-07-15 11:51:19 [I] Adding Compute instance for network-test-host.example.com
2015-07-15 11:51:19 [I] Successfully decrypted field for Foreman::Model::Vmware
2015-07-15 11:51:19 [I] Successfully decrypted field for Foreman::Model::Vmware
2015-07-15 11:51:20 [I] 


Related issues 3 (0 open3 closed)

Related to Foreman - Bug #9657: API for creating host can't merge NICs from compute profilesClosedTomáš Strachota03/05/2015Actions
Related to Foreman - Bug #13980: VMWARE: since 1.10, NIC type and Network different from profile configurationClosedDominic Cleal03/01/2016Actions
Related to Foreman - Bug #14179: Interface/NIC compute attributes in API host creation overwritten with compute profile attributesClosedDominic Cleal03/14/2016Actions
Actions #1

Updated by Dominic Cleal over 8 years ago

All looks correct to me unfortunately.

If you have the opportunity, you could try adding some logger.debug statements to add_interfaces_to_compute_attrs inside app/models/concerns/orchestration/compute.rb. This copies compute-related data from the interfaces_attributes part of the API request into the compute_attributes hash. It's possible that isn't working correctly and so the list of interface options isn't passed through.

The other bit to possibly check would be parse_networks in app/models/compute_resources/foreman/model/vmware.rb which takes the fully merged compute_attributes hash, finds the networks and creates interfaces.

Actions #2

Updated by Matt Chesler over 8 years ago

Adding debug logging to add_interfaces_to_compute_attrs turns up that compute_attributes[attrs_name] is {"0"=>{"type"=>"VirtualVmxnet3", "network"=>"VM Network", "from_profile"=>"1-Small"}}, confirming that the interfaces_attributes part of the API request isn't being added to the Host::Managed instance.

Actions #3

Updated by Dominic Cleal over 8 years ago

Ah, is it coming from a compute profile perhaps? Does the host group have one set? It might not merge the attributes you're passing in.

Actions #4

Updated by Matt Chesler over 8 years ago

Yes, it seems to be coming from the compute profile associated with the hostgroup. This is definitely unexpected behavior though.

a) via the Web UI, explicit selections override all attributes contained in the compute profile

b) via the API, explicit selections seem to override all but network related attributes contained in the compute profile. The compute_attributes that I specify around CPU, RAM, Disk size, and Datastore are all different than what's in that compute profile and are set properly.

Actions #5

Updated by Dominic Cleal over 8 years ago

  • Subject changed from Creating vmware host through API doesn't set network to Interface compute attributes not merged from API request over compute profile
Actions #6

Updated by Dominic Cleal over 8 years ago

  • Related to Bug #9657: API for creating host can't merge NICs from compute profiles added
Actions #7

Updated by Timo Goebel over 8 years ago

The Problem is the code in app/services/interface_merge.rb

def merge(nic, vm_nic, compute_attrs)
    nic.compute_attributes = vm_nic # this always overwrites the compute_attributes with the ones coming from the compute profile (vm_nic).
    nic.compute_attributes['from_profile'] = compute_attrs.compute_profile.name
    nic
  end

Working on a fix...

Actions #8

Updated by The Foreman Bot over 8 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2843 added
  • Pull request deleted ()
Actions #9

Updated by Dominic Cleal over 8 years ago

  • Assignee set to Timo Goebel
  • translation missing: en.field_release set to 104
Actions #10

Updated by Anonymous over 8 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #11

Updated by Dominic Cleal about 8 years ago

  • Related to Bug #13980: VMWARE: since 1.10, NIC type and Network different from profile configuration added
Actions #12

Updated by Dominic Cleal about 8 years ago

  • Related to Bug #14179: Interface/NIC compute attributes in API host creation overwritten with compute profile attributes added
Actions

Also available in: Atom PDF