Create host from API fails me

I'm ussing a foreman 1.2.1.

When I try to create a host with this json works fine.

{"host":{"build":"1","puppet_ca_proxy_id":"4","puppet_proxy_id":"4","architecture_id":"1","hostgroup_id":"3","operatingsystem_id":"21","provision_method":"build","enabled":"1","medium_id":"20","ip":"10.240.8.1","organization_id":"2","compute_attributes":{"cpus":"1","start":"1","volumes_attributes":{"new_0":{"capacity":"10G","format_type":"raw","pool_name":"disks"}},"memory":"1073741824","nics_attributes":{"0":{"bridge":"virbr0"}}},"managed":"true","compute_resource_id":11,"name":"israelo4","mac":"","ptable_id":"11","location_id":"1"}}

But this other json fails (differences highlighted)

{"host":{"mac":"","compute_attributes":{"memory":"1073741824","cpus":"1","volumes_attributes":{"new_0":{"pool_name":"disks","capacity":"10G","format_type":"raw"}},"nics_attributes":{"0":{"network":"oamtraffic"}},"start":"1"},"compute_resource_id":11,"managed":"true","operatingsystem_id":"21","puppet_ca_proxy_id":"4","hostgroup_id":"3","build":"1","name":"israelo4","medium_id":"20","enabled":"1","ptable_id":"11","puppet_proxy_id":"4","organization_id":"2","architecture_id":"1","ip":"10.240.8.1","location_id":"1","provision_method":"build"}}

Ussing web interface works fine both.

With tcpdump I can see

1- xml when I use a bridge from API

  • <interface type='bridge'>*
  •  &lt;mac address=&#39;52:54:00:1b:ce:ed&#39;/&gt;*
    
  •  &lt;source bridge=&#39;virbr0&#39;/&gt;*
    
  •  &lt;model type=&#39;virtio&#39;/&gt;*
    
  •  &lt;address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x03&#39; 
    

function='0x0'/>*

  • </interface> *

2- xml when I use a network from API* (Here is the issue)*

  • <interface type='bridge'>*
  •  &lt;mac address=&#39;52:54:00:30:bc:ae&#39;/&gt;*
    
  •  &lt;source bridge=&#39;&#39;/&gt;*
    
  •  &lt;model type=&#39;virtio&#39;/&gt;*
    
  •  &lt;address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x03&#39; 
    

function='0x0'/>*

  • </interface>*

3- xml when I use a bridge from web interface

  • <interface type='bridge'>*
  •  &lt;mac address=&#39;52:54:00:60:e8:cd&#39;/&gt;*
    
  •  &lt;source bridge=&#39;virbr1&#39;/&gt;*
    
  •  &lt;target dev=&#39;vnet14&#39;/&gt;*
    
  •  &lt;model type=&#39;virtio&#39;/&gt;*
    
  •  &lt;alias name=&#39;net0&#39;/&gt;*
    
  •  &lt;address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x03&#39; 
    

function='0x0'/>*

  • </interface>*

4- xml when I use a network from webinterface

  • <interface type='network'>*
  •  &lt;mac address=&#39;52:54:00:17:e3:3a&#39;/&gt;*
    
  •  &lt;source network=&#39;oamtraffic&#39;/&gt;*
    
  •  &lt;model type=&#39;virtio&#39;/&gt;*
    
  •  &lt;address type=&#39;pci&#39; domain=&#39;0x0000&#39; bus=&#39;0x00&#39; slot=&#39;0x03&#39; 
    

function='0x0'/>*

  • </interface>*

Any Ideas?

Thanks.

More data.

Json in foreman log: creating from web interface.

Parameters: {"utf8"=>"✓",
"authenticity_token"=>"
*******************************************",
"host"=>{"name"=>"israelo4", "organization_id"=>"2", "location_id"=>"1",
"compute_resource_id"=>"11", "hostgroup_id"=>"3", "environment_id"=>"151",
"puppet_ca_proxy_id"=>"7", "puppet_proxy_id"=>"7", "puppetclass_ids"=>[""],
"managed"=>"true", "progress_report_id"=>"[FILTERED]",
"type"=>"Host::Managed", "compute_attributes"=>{"cpus"=>"1",
"memory"=>"805306368", "nics_attributes"=>{"new_nics"=>{"type"=>"bridge",
"_delete"=>"", "bridge"=>"bond0"}, "0"=>{"type"=>"network", "_delete"=>"",
"network"=>"oamtraffic", "bridge"=>"bond0"}},
"volumes_attributes"=>{"new_volumes"=>{"pool_name"=>"default",
"capacity"=>"10G", "format_type"=>"raw", "_delete"=>""},
"0"=>{"pool_name"=>"disks", "capacity"=>"10G", "format_type"=>"raw",
"_delete"=>""}}, "start"=>"1"}, "mac"=>"", "domain_id"=>"1",
"subnet_id"=>"4", "ip"=>"10.240.1.80",
"interfaces_attributes"=>{"new_interfaces"=>{"_destroy"=>"false",
"type"=>"Nic::Managed", "mac"=>"", "name"=>"", "domain_id"=>"",
"subnet_id"=>"", "ip"=>"", "provider"=>"IPMI"}}, "architecture_id"=>"1",
"operatingsystem_id"=>"21", "provision_method"=>"build", "build"=>"1",
"medium_id"=>"20", "ptable_id"=>"11", "disk"=>"",
"root_pass"=>"[FILTERED]", "is_owned_by"=>"", "enabled"=>"1",
"comment"=>"", "overwrite"=>"false"}, "capabilities"=>"build"}

Json in foreman log: creating from API.

  • Parameters: {"host"=>{"organization_id"=>"2", "architecture_id"=>"1",
    "compute_resource_id"=>11, "provision_method"=>"build",
    "compute_attributes"=>{"memory"=>"1073741824", "cpus"=>"1",
    "volumes_attributes"=>{"new_0"=>{"pool_name"=>"disks", "capacity"=>"10G",
    "format_type"=>"raw"}}, "start"=>"1",
    "nics_attributes"=>{"0"=>{"network"=>"oamtraffic"}}}, "location_id"=>"1",
    "puppet_ca_proxy_id"=>"4", "enabled"=>"1", "ip"=>"10.240.8.1",
    "name"=>"israelo4", "ptable_id"=>"11", "puppet_proxy_id"=>"4",
    "build"=>"1", "mac"=>"", "hostgroup_id"=>"3", "managed"=>"true",
    "operatingsystem_id"=>"21", "medium_id"=>"20"}}*
··· On Wednesday, January 8, 2014 10:33:25 AM UTC+1, Israel Calvete wrote: > > I'm ussing a foreman 1.2.1. > > When I try to create a host with this json works fine. > > > *{"host":{"build":"1","puppet_ca_proxy_id":"4","puppet_proxy_id":"4","architecture_id":"1","hostgroup_id":"3","operatingsystem_id":"21","provision_method":"build","enabled":"1","medium_id":"20","ip":"10.240.8.1","organization_id":"2","compute_attributes":{"cpus":"1","start":"1","volumes_attributes":{"new_0":{"capacity":"10G","format_type":"raw","pool_name":"disks"}},"memory":"1073741824","nics_attributes":{"0":{"bridge":"virbr0"}}},"managed":"true","compute_resource_id":11,"name":"israelo4","mac":"","ptable_id":"11","location_id":"1"}}* > > But this other json fails (differences highlighted) > > > *{"host":{"mac":"","compute_attributes":{"memory":"1073741824","cpus":"1","volumes_attributes":{"new_0":{"pool_name":"disks","capacity":"10G","format_type":"raw"}},"nics_attributes":{"0":{"network":"oamtraffic"}},"start":"1"},"compute_resource_id":11,"managed":"true","operatingsystem_id":"21","puppet_ca_proxy_id":"4","hostgroup_id":"3","build":"1","name":"israelo4","medium_id":"20","enabled":"1","ptable_id":"11","puppet_proxy_id":"4","organization_id":"2","architecture_id":"1","ip":"10.240.8.1","location_id":"1","provision_method":"build"}}* > > Ussing web interface works fine both. > > With tcpdump I can see > > 1- xml when I use a bridge from API > > * * > * * > * * > * * > * function='0x0'/>* > * * > > 2- xml when I use a network from API* (Here is the issue)* > > * * > * * > * * > * * > * function='0x0'/>* > * * > > 3- xml when I use a bridge from web interface > > * * > * * > * * > * * > * * > * * > * function='0x0'/>* > * * > > 4- xml when I use a network from webinterface > > * * > * * > * * > * * > * function='0x0'/>* > * * > > > Any Ideas? > > Thanks. >

Hello,
you can basically use the same json that is logged after your UI actions.

Try passing this piece:
"nics_attributes"=>{"0"=>{"type"=>"network", "network"=>"oamtraffic"}}

Regards,
Tomas

··· On 01/08/2014 11:13 AM, Israel Calvete wrote: > > More data. > > Json in foreman log: creating from web interface. > > /Parameters: {"utf8"=>"✓", > "authenticity_token"=>"*********************************************", > "host"=>{"name"=>"israelo4", "organization_id"=>"2", "location_id"=>"1", > "compute_resource_id"=>"11", "hostgroup_id"=>"3", > "environment_id"=>"151", "puppet_ca_proxy_id"=>"7", > "puppet_proxy_id"=>"7", "puppetclass_ids"=>[""], "managed"=>"true", > "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", > "compute_attributes"=>{"cpus"=>"1", "memory"=>"805306368", > *"nics_attributes"=>{"new_nics"=>{"type"=>"bridge", "_delete"=>"", > "bridge"=>"bond0"}, "0"=>{"type"=>"network", "_delete"=>"", > "network"=>"oamtraffic", "bridge"=>"bond0"*}}, > "volumes_attributes"=>{"new_volumes"=>{"pool_name"=>"default", > "capacity"=>"10G", "format_type"=>"raw", "_delete"=>""}, > "0"=>{"pool_name"=>"disks", "capacity"=>"10G", "format_type"=>"raw", > "_delete"=>""}}, "start"=>"1"}, "mac"=>"", "domain_id"=>"1", > "subnet_id"=>"4", "ip"=>"10.240.1.80", > "interfaces_attributes"=>{"new_interfaces"=>{"_destroy"=>"false", > "type"=>"Nic::Managed", "mac"=>"", "name"=>"", "domain_id"=>"", > "subnet_id"=>"", "ip"=>"", "provider"=>"IPMI"}}, "architecture_id"=>"1", > "operatingsystem_id"=>"21", "provision_method"=>"build", "build"=>"1", > "medium_id"=>"20", "ptable_id"=>"11", "disk"=>"", > "root_pass"=>"[FILTERED]", "is_owned_by"=>"", "enabled"=>"1", > "comment"=>"", "overwrite"=>"false"}, "capabilities"=>"build"}/ > > Json in foreman log: creating from API. > > / Parameters: {"host"=>{"organization_id"=>"2", "architecture_id"=>"1", > "compute_resource_id"=>11, "provision_method"=>"build", > "compute_attributes"=>{"memory"=>"1073741824", "cpus"=>"1", > "volumes_attributes"=>{"new_0"=>{"pool_name"=>"disks", > "capacity"=>"10G", "format_type"=>"raw"}}, "start"=>"1", > "nics_attributes"=>{"0"=>{"network"=>"oamtraffic"}}}, > "location_id"=>"1", "puppet_ca_proxy_id"=>"4", "enabled"=>"1", > "ip"=>"10.240.8.1", "name"=>"israelo4", "ptable_id"=>"11", > "puppet_proxy_id"=>"4", "build"=>"1", "mac"=>"", "hostgroup_id"=>"3", > "managed"=>"true", "operatingsystem_id"=>"21", "medium_id"=>"20"}}/ > > > On Wednesday, January 8, 2014 10:33:25 AM UTC+1, Israel Calvete wrote: > > I'm ussing a foreman 1.2.1. > > When I try to create a host with this json works fine. > > /{"host":{"build":"1","puppet_ca_proxy_id":"4","puppet_proxy_id":"4","architecture_id":"1","hostgroup_id":"3","operatingsystem_id":"21","provision_method":"build","enabled":"1","medium_id":"20","ip":"10.240.8.1","organization_id":"2","compute_attributes":{"cpus":"1","start":"1","volumes_attributes":{"new_0":{"capacity":"10G","format_type":"raw","pool_name":"disks"}},"memory":"1073741824","nics_attributes":{"0":{"bridge":"virbr0"}}},"managed":"true","compute_resource_id":11,"name":"israelo4","mac":"","ptable_id":"11","location_id":"1"}}/ > > But this other json fails (differences highlighted) > > /{"host":{"mac":"","compute_attributes":{"memory":"1073741824","cpus":"1","volumes_attributes":{"new_0":{"pool_name":"disks","capacity":"10G","format_type":"raw"}},"nics_attributes":{"0":*{"network":"oamtraffic"}*},"start":"1"},"compute_resource_id":11,"managed":"true","operatingsystem_id":"21","puppet_ca_proxy_id":"4","hostgroup_id":"3","build":"1","name":"israelo4","medium_id":"20","enabled":"1","ptable_id":"11","puppet_proxy_id":"4","organization_id":"2","architecture_id":"1","ip":"10.240.8.1","location_id":"1","provision_method":"build"}}/ > > Ussing web interface works fine both. > > With tcpdump I can see > > 1- xml when I use a bridge from API > > // > / / > / / > / / > / function='0x0'/>/ > / / > > 2- xml when I use a network from API*(Here is the issue)* > > /**/ > / / > /**/ > / / > / function='0x0'/>/ > / / > > 3- xml when I use a bridge from web interface > > / / > / / > / / > / / > / / > / / > / function='0x0'/>/ > / / > > 4- xml when I use a network from webinterface > > / / > / / > / / > / / > / function='0x0'/>/ > / / > > > Any Ideas? > > Thanks. >

Exactly

This Json works…

{"host":{"location_id":"1","mac":"","architecture_id":"1","managed":"true","medium_id":"20","build":"1","hostgroup_id":"3","ptable_id":"11","puppet_proxy_id":"4","ip":"10.240.8.1","organization_id":"2","puppet_ca_proxy_id":"4","name":"israelo4","compute_resource_id":11,"compute_attributes":{"nics_attributes":{"0":{"type":"network","network":"oamtraffic"}},"start":"1","memory":"1073741824","volumes_attributes":{"new_0":{"capacity":"10G","pool_name":"disks","format_type":"raw"}},"cpus":"1"},"enabled":"1","operatingsystem_id":"21","provision_method":"build"}}

Thanks!!!

··· On Wednesday, January 8, 2014 11:42:52 AM UTC+1, Tomas Strachota wrote: > > On 01/08/2014 11:13 AM, Israel Calvete wrote: > > > > More data. > > > > Json in foreman log: creating from web interface. > > > > /Parameters: {"utf8"=>"✓", > > "authenticity_token"=>"*********************************************", > > "host"=>{"name"=>"israelo4", "organization_id"=>"2", "location_id"=>"1", > > "compute_resource_id"=>"11", "hostgroup_id"=>"3", > > "environment_id"=>"151", "puppet_ca_proxy_id"=>"7", > > "puppet_proxy_id"=>"7", "puppetclass_ids"=>[""], "managed"=>"true", > > "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", > > "compute_attributes"=>{"cpus"=>"1", "memory"=>"805306368", > > *"nics_attributes"=>{"new_nics"=>{"type"=>"bridge", "_delete"=>"", > > "bridge"=>"bond0"}, "0"=>{"type"=>"network", "_delete"=>"", > > "network"=>"oamtraffic", "bridge"=>"bond0"*}}, > > "volumes_attributes"=>{"new_volumes"=>{"pool_name"=>"default", > > "capacity"=>"10G", "format_type"=>"raw", "_delete"=>""}, > > "0"=>{"pool_name"=>"disks", "capacity"=>"10G", "format_type"=>"raw", > > "_delete"=>""}}, "start"=>"1"}, "mac"=>"", "domain_id"=>"1", > > "subnet_id"=>"4", "ip"=>"10.240.1.80", > > "interfaces_attributes"=>{"new_interfaces"=>{"_destroy"=>"false", > > "type"=>"Nic::Managed", "mac"=>"", "name"=>"", "domain_id"=>"", > > "subnet_id"=>"", "ip"=>"", "provider"=>"IPMI"}}, "architecture_id"=>"1", > > "operatingsystem_id"=>"21", "provision_method"=>"build", "build"=>"1", > > "medium_id"=>"20", "ptable_id"=>"11", "disk"=>"", > > "root_pass"=>"[FILTERED]", "is_owned_by"=>"", "enabled"=>"1", > > "comment"=>"", "overwrite"=>"false"}, "capabilities"=>"build"}/ > > > > Json in foreman log: creating from API. > > > > / Parameters: {"host"=>{"organization_id"=>"2", "architecture_id"=>"1", > > "compute_resource_id"=>11, "provision_method"=>"build", > > "compute_attributes"=>{"memory"=>"1073741824", "cpus"=>"1", > > "volumes_attributes"=>{"new_0"=>{"pool_name"=>"disks", > > "capacity"=>"10G", "format_type"=>"raw"}}, "start"=>"1", > > "nics_attributes"=>{"0"=>{"network"=>"oamtraffic"}}}, > > "location_id"=>"1", "puppet_ca_proxy_id"=>"4", "enabled"=>"1", > > "ip"=>"10.240.8.1", "name"=>"israelo4", "ptable_id"=>"11", > > "puppet_proxy_id"=>"4", "build"=>"1", "mac"=>"", "hostgroup_id"=>"3", > > "managed"=>"true", "operatingsystem_id"=>"21", "medium_id"=>"20"}}/ > > > > > > On Wednesday, January 8, 2014 10:33:25 AM UTC+1, Israel Calvete wrote: > > > > I'm ussing a foreman 1.2.1. > > > > When I try to create a host with this json works fine. > > > > > /{"host":{"build":"1","puppet_ca_proxy_id":"4","puppet_proxy_id":"4","architecture_id":"1","hostgroup_id":"3","operatingsystem_id":"21","provision_method":"build","enabled":"1","medium_id":"20","ip":"10.240.8.1","organization_id":"2","compute_attributes":{"cpus":"1","start":"1","volumes_attributes":{"new_0":{"capacity":"10G","format_type":"raw","pool_name":"disks"}},"memory":"1073741824","nics_attributes":{"0":{"bridge":"virbr0"}}},"managed":"true","compute_resource_id":11,"name":"israelo4","mac":"","ptable_id":"11","location_id":"1"}}/ > > > > > But this other json fails (differences highlighted) > > > > > /{"host":{"mac":"","compute_attributes":{"memory":"1073741824","cpus":"1","volumes_attributes":{"new_0":{"pool_name":"disks","capacity":"10G","format_type":"raw"}},"nics_attributes":{"0":*{"network":"oamtraffic"}*},"start":"1"},"compute_resource_id":11,"managed":"true","operatingsystem_id":"21","puppet_ca_proxy_id":"4","hostgroup_id":"3","build":"1","name":"israelo4","medium_id":"20","enabled":"1","ptable_id":"11","puppet_proxy_id":"4","organization_id":"2","architecture_id":"1","ip":"10.240.8.1","location_id":"1","provision_method":"build"}}/ > > > > > Ussing web interface works fine both. > > > > With tcpdump I can see > > > > 1- xml when I use a bridge from API > > > > // > > / / > > / / > > / / > > / > function='0x0'/>/ > > / / > > > > 2- xml when I use a network from API*(Here is the issue)* > > > > /**/ > > / / > > /**/ > > / / > > / > function='0x0'/>/ > > / / > > > > 3- xml when I use a bridge from web interface > > > > / / > > / / > > / / > > / / > > / / > > / / > > / > function='0x0'/>/ > > / / > > > > 4- xml when I use a network from webinterface > > > > / / > > / / > > / / > > / / > > / > function='0x0'/>/ > > / / > > > > > > Any Ideas? > > > > Thanks. > > > > Hello, > you can basically use the same json that is logged after your UI actions. > > Try passing this piece: > "nics_attributes"=>{"0"=>{"type"=>"network", "network"=>"oamtraffic"}} > > Regards, > Tomas >