Project

General

Profile

Bug #1800

Not possible to create unmanaged host via API

Added by Tomas Karasek about 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Host creation
Target version:
Difficulty:
trivial
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

even though I send
'{"host": {"operatingsystem_id": 21, "managed": false, "name": "ip188000.domain.ch", "ip": "188.142.144.17", "hostgroup_id": 53, "mac": "00:17:3e:00:4e:4b", "architecture_id": 1, "build": "0", "ptable_id": 1}}'

host is created as managed

Would be cool if the logic reflected the managed:false item.

Associated revisions

Revision d076d573 (diff)
Added by Joseph Magen over 9 years ago

This commit adds most of the functionality required for API v1

The overall goal was to extract the existing JSON response
overall controllers, and to move them to a seperate name space.

  • documentation was added to all requests (available under /apidoc)
    this include same request and response generated using
    APIPIE_RECORD=examples rake test:api
  • Also Fixes #1800, fixes #1419, fixes #981 and fixes #1774

whats missing:

1. Permissions checks for all new controllers
2. Nested routes (e.g. /hosts/id/reports)
3. running tests with oauth/basic_auth (instead of as_admin {get /})

History

#1 Updated by Steve Traylen about 10 years ago

With the proposed patch from mailing list this is good and you can add hosts specifying the hostname and group only.

#2 Updated by Tomas Karasek about 10 years ago

the patch from the mailing list by Ohad

diff --git a/app/controllers/hosts_controller.rb b/app/controllers/hosts_controller.rb
index 2de8015..7fe9852 100644
--- a/app/controllers/hosts_controller.rb
+++ b/app/controllers/hosts_controller.rb
@@ -84,7 +84,7 @@ class HostsController < ApplicationController

   def create
     @host = Host.new(params[:host])
-    @host.managed = true
+    @host.managed = true if params[:host][:managed].nil?
     forward_request_url
     if @host.save

#3 Updated by Nacho Barrientos almost 10 years ago

Hi,

Do you plan to merge this patch?

#4 Updated by Ohad Levy almost 10 years ago

  • Target version set to 1.1

#5 Updated by Greg Sutcliffe almost 10 years ago

  • Target version changed from 1.1 to Bug scrub

#6 Updated by Joseph Magen over 9 years ago

  • Assignee set to Joseph Magen

#7 Updated by Joseph Magen over 9 years ago

  • Status changed from New to Assigned

#8 Updated by Joseph Magen over 9 years ago

  • Status changed from Assigned to Closed

#9 Updated by Joseph Magen over 9 years ago

  • Status changed from Closed to Ready For Testing

#10 Updated by Sam Kottler over 9 years ago

I'm going to mark this issue closed so we can get accurate numbers for how many issues got closed. Is this fix now included in the API v1 branch?

#11 Updated by Sam Kottler over 9 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF