Api to create host... Doubts

In GUI to create an host with Foreman we must pass to network interface his
name. Which field it rappresente for Foreman Api?

It is correct this example??

"{"host": {" +
""name": "" + host.getName() + "","+ //'host_api'
""hostgroup_id": 1,"+
""environment_id": " + environmentid + ","+
""architecture_id": 1,"+
""mac": "","+
""compute_resource_id": " + host.getComputeResourceId() + ","+ //7
""build": 0,"+ // What is this field??
""enabled": " + host.getIsEnabled() + ","+ //0 //What is this field??
""managed": 0,"+ //What is this field??
""compute_attributes": {"+
""cpus": " + host.getCpu() + ","+ //1
""cluster": ""+ host.getCluster() + "","+ //'Provisioning'
""start": " + host.getIsStarted() + ","+ //0
""path": "" + host.getPathDataCenter() + "","+ //'' //What is this
field??
""interfaces_attributes": {"+
""new_interfaces": {"+
""_delete": "","+
""network": "nic1""+ //is this??
"},"+
""0": {"+
""_delete": "","+
""network": "" + host.getNetwork() + """+ //virtualmachine
"}"+
"},"+
""volumes_attributes": {"+
""new_volumes": {"+
""name": "Hard disk","+
""size_gb": " + host.getHardDiskVolume() + ","+ //8
""_delete": "","+
""datastore": "" + host.getDatastore() + """+ //'provisioning1' //are
the same??
"},"+
""0": {"+
""name": "Hard disk","+
""size_gb": " + host.getHardDiskSize() + ","+ //8
""_delete": "","+
""datastore": "" + host.getDatastore() + """+ //provisioning1 //are the
same??
"}"+
"},"+
""memory_mb": " + host.getRam() +""+ //256
"}"+
"}"+
"}";

I don't know what are the following fields: build, enabled, managed, path,
network (is it the name?), datastore.
The field "provisioningTemplate" where is??

Thanks in advance for your support.

Most of Foreman's default's are fairly sane - here's the Hash I send to
create a Libvirt host:

host_hash = {
  "host" => {
    "name"                => @hostname,
    "hostgroup_id"        => hostgroup_info['id'],
    "compute_resource_id" => compute_resource_id,
    "location_id"         => @location,
    "organization_id"     => @organisation,
    "architecture_id"     => architecture_id,
    "operatingsystem_id"  => operatingsystem_id,
    "build"               => 1,
    "compute_attributes"  => {
      "volumes_attributes" => {
        "0" => {
          "format_type" => "raw",
          "capacity"    => @disk_size,
          "pool_name"   => "default",
        },
      },
      "nics_attributes" => {
        "0" => { "bridge"  => @net_dev },
      },
      "start"=>"1",
      "memory"=>"536870912",
      "cpus"=>"1",
    },
  },
}

I'm not sure if you mean the DNS name for the secondary interfaces in the
Network tab (in which case I don't know the answer, as I'm only creating
one interface), or the name of the virtual network to connect a NIC to. If
it's the latter, you'll note that the network name is specified as part of
[host][compute_attributes][nics_attributes][0].

As to your other questions:

I don't know what are the following fields: build, enabled, managed, path,
> network (is it the name?), datastore.
>

Managed: Should Foreman manage the install on this host, or just recieve
Puppet reports?
Enabled: Should Foreman send Notifications for this host?
Build: Should Foreman install this Host now or just let it boot from disk?
Path/Network/Datastore: I think these are hypervisor-specific, I don't need
them for Libvirt, but you might for something else.

The field "provisioningTemplate" where is??
>

The choice of provisioning template is determined from the combination of
Operatingsystem, Environment, and Hostgroup - it's not requested explicitly
in the Host creation data.

Hope that heps,
Greg

Thanks for your help it is very apprecieted, but I have another problem.
With this json in Post I receive error 500 http status, maybe do you know
why?:

"{"host": {" +
""name": "prova2","+ //'host_ovirt'
""hostgroup_id": 1,"+
""operatingsystem_id": 1," +
""environment_id": 38," +
""architecture_id": 1," +
""domain_id": 1," +
""ip":""," +
""mac": ""," +
""compute_resource_id": "7"," +//7
""ptable_id"=>"11"," +
""build": 1,"+
""enabled": 1,"+ //0
""managed": 1,"+
""compute_attributes": {"+
""cpus": 1,"+ //1
""cluster": "Provisioning","+
""start": 0,"+ //0
""path": "/datacenters/xxx","+
""interfaces_attributes": {"+
""new_interfaces": {"+
""_delete": "","+
""network": "api/networks/xxx""+
"},"+
""0": {"+
""_delete": "","+
""network": "/networks/xxx""+
"}"+
"},"+
""volumes_attributes": {"+
""new_volumes": {"+
""name": "Harddisk","+
""size_gb": 8,"+ //8
""_delete": "","+
""datastore": "/storagedomains/xxx""+
"},"+
""0": {"+
""name": "Hard disk","+
""size_gb": "8","+ //8
""_delete": "","+
""datastore": "/storagedomains/xxx""+
"}"+
"},"+
""memory_mb": 512"+
"}"+
"}"+
"}";

··· Il giorno martedì 28 maggio 2013 11:53:19 UTC+2, Greg Sutcliffe ha scritto: > > Most of Foreman's default's are fairly sane - here's the Hash I send to > create a Libvirt host: > > host_hash = { > "host" => { > "name" => @hostname, > "hostgroup_id" => hostgroup_info['id'], > "compute_resource_id" => compute_resource_id, > "location_id" => @location, > "organization_id" => @organisation, > "architecture_id" => architecture_id, > "operatingsystem_id" => operatingsystem_id, > "build" => 1, > "compute_attributes" => { > "volumes_attributes" => { > "0" => { > "format_type" => "raw", > "capacity" => @disk_size, > "pool_name" => "default", > }, > }, > "nics_attributes" => { > "0" => { "bridge" => @net_dev }, > }, > "start"=>"1", > "memory"=>"536870912", > "cpus"=>"1", > }, > }, > } > > I'm not sure if you mean the DNS name for the secondary interfaces in the > Network tab (in which case I don't know the answer, as I'm only creating > one interface), or the name of the virtual network to connect a NIC to. If > it's the latter, you'll note that the network name is specified as part of > [host][compute_attributes][nics_attributes][0]. > > As to your other questions: > > I don't know what are the following fields: build, enabled, managed, path, >> network (is it the name?), datastore. >> > > Managed: Should Foreman manage the install on this host, or just recieve > Puppet reports? > Enabled: Should Foreman send Notifications for this host? > Build: Should Foreman install this Host now or just let it boot from disk? > Path/Network/Datastore: I think these are hypervisor-specific, I don't > need them for Libvirt, but you might for something else. > > The field "provisioningTemplate" where is?? >> > > The choice of provisioning template is determined from the combination of > Operatingsystem, Environment, and Hostgroup - it's not requested explicitly > in the Host creation data. > > Hope that heps, > Greg >

I solve this problem, it was a syntax error. Thanks for all.

··· Il giorno mercoledì 29 maggio 2013 11:40:50 UTC+2, Euclideo ha scritto: > > Thanks for your help it is very apprecieted, but I have another problem. > With this json in Post I receive error 500 http status, maybe do you know > why?: > > "{\"host\": {" + > "\"name\": \"prova2\","+ //'host_ovirt' > "\"hostgroup_id\": 1,"+ > "\"operatingsystem_id\": 1," + > "\"environment_id\": 38," + > "\"architecture_id\": 1," + > "\"domain_id\": 1," + > "\"ip\":\"\"," + > "\"mac\": \"\"," + > "\"compute_resource_id\": \"7\"," +//7 > "\"ptable_id\"=>\"11\"," + > "\"build\": 1,"+ > "\"enabled\": 1,"+ //0 > "\"managed\": 1,"+ > "\"compute_attributes\": {"+ > "\"cpus\": 1,"+ //1 > "\"cluster\": \"Provisioning\","+ > "\"start\": 0,"+ //0 > "\"path\": \"/datacenters/xxx\","+ > "\"interfaces_attributes\": {"+ > "\"new_interfaces\": {"+ > "\"_delete\": \"\","+ > "\"network\": \"api/networks/xxx\""+ > "},"+ > "\"0\": {"+ > "\"_delete\": \"\","+ > "\"network\": \"/networks/xxx\""+ > "}"+ > "},"+ > "\"volumes_attributes\": {"+ > "\"new_volumes\": {"+ > "\"name\": \"Harddisk\","+ > "\"size_gb\": 8,"+ //8 > "\"_delete\": \"\","+ > "\"datastore\": \"/storagedomains/xxx\""+ > "},"+ > "\"0\": {"+ > "\"name\": \"Hard disk\","+ > "\"size_gb\": \"8\","+ //8 > "\"_delete\": \"\","+ > "\"datastore\": \"/storagedomains/xxx\""+ > "}"+ > "},"+ > "\"memory_mb\": 512"+ > "}"+ > "}"+ > "}"; > > Il giorno martedì 28 maggio 2013 11:53:19 UTC+2, Greg Sutcliffe ha scritto: >> >> Most of Foreman's default's are fairly sane - here's the Hash I send to >> create a Libvirt host: >> >> host_hash = { >> "host" => { >> "name" => @hostname, >> "hostgroup_id" => hostgroup_info['id'], >> "compute_resource_id" => compute_resource_id, >> "location_id" => @location, >> "organization_id" => @organisation, >> "architecture_id" => architecture_id, >> "operatingsystem_id" => operatingsystem_id, >> "build" => 1, >> "compute_attributes" => { >> "volumes_attributes" => { >> "0" => { >> "format_type" => "raw", >> "capacity" => @disk_size, >> "pool_name" => "default", >> }, >> }, >> "nics_attributes" => { >> "0" => { "bridge" => @net_dev }, >> }, >> "start"=>"1", >> "memory"=>"536870912", >> "cpus"=>"1", >> }, >> }, >> } >> >> I'm not sure if you mean the DNS name for the secondary interfaces in the >> Network tab (in which case I don't know the answer, as I'm only creating >> one interface), or the name of the virtual network to connect a NIC to. If >> it's the latter, you'll note that the network name is specified as part of >> [host][compute_attributes][nics_attributes][0]. >> >> As to your other questions: >> >> I don't know what are the following fields: build, enabled, managed, >>> path, network (is it the name?), datastore. >>> >> >> Managed: Should Foreman manage the install on this host, or just recieve >> Puppet reports? >> Enabled: Should Foreman send Notifications for this host? >> Build: Should Foreman install this Host now or just let it boot from disk? >> Path/Network/Datastore: I think these are hypervisor-specific, I don't >> need them for Libvirt, but you might for something else. >> >> The field "provisioningTemplate" where is?? >>> >> >> The choice of provisioning template is determined from the combination of >> Operatingsystem, Environment, and Hostgroup - it's not requested explicitly >> in the Host creation data. >> >> Hope that heps, >> Greg >> >