Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1045350

Summary: REST error during VM creation via API
Product: [Retired] oVirt Reporter: Sven Kieske <s.kieske>
Component: ovirt-engine-apiAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED CURRENTRELEASE QA Contact: Ondra Machacek <omachace>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.3CC: acathrow, bazulay, iheim, juan.hernandez, omachace, tjelinek, yeylon
Target Milestone: ---   
Target Release: 3.4.0   
Hardware: x86_64   
OS: Linux   
Whiteboard: infra
Fixed In Version: ovirt-3.4.0-alpha1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-31 12:32:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1024889    
Attachments:
Description Flags
engine.log none

Description Sven Kieske 2013-12-20 08:46:12 UTC
Created attachment 839449 [details]
engine.log

Description of problem:
When you create a VM via REST-API

Version-Release number of selected component (if applicable):

ovirt-engine 3.3.2-1.el6

How reproducible:
POST request on https://virt-mgmt-01.internal/api/vms/:
{"name":"vr00001","cluster":{"id":"2ad11b5e-9e74-499a-b317-5a9a3027cfca","name":"localcluster1"},"template":{"id":"10080414-d017-490b-b212-e02cee6a7b6e","name":"ubuntu-server-12.04"},"console":{"enabled":true}}


Steps to Reproduce:
1.
2.
3.

Actual results:

<h1>HTTP Status 500 - org.codehaus.jackson.map.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.ovirt.engine.api.model.VM[&quot;console&quot;])</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>org.codehaus.jackson.map.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.ovirt.engine.api.model.VM[&quot;console&quot;])</u></p><p><b>description</b> <u>The server encountered an internal error (org.codehaus.jackson.map.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.ovirt.engine.api.model.VM[&quot;console&quot;])) that prevented it from fulfilling this request.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.0.13.Final</h3>

Expected results:

HTTP 201 OK with the vm data

Additional info:


the error code is wrong, the vm gets actually created (see attached engine.log)

Comment 1 Sven Kieske 2013-12-20 08:49:26 UTC
Sorry, the Description of the problem was incomplete:

Description of problem:
When you create a VM via REST-API, it get's successfully created, but you
get a Java Exception as answer and no expected HTTP 201 OK with the VM
Data you just submitted.

Comment 2 Sven Kieske 2014-01-02 13:04:14 UTC
This is an error in the API Implementation of 3.3. why is the target release
of the fix 3.4. ?

Comment 3 Juan Hernández 2014-01-02 13:29:01 UTC
Sven, this is a side effect of a known problem with RESTEasy JSON serialization. JSON serialization support is experimental at the moment (including 3.3.2) and will be fully supported starting with 3.4. The changes done for 3.4 will fix this particular problem. However they will also introduce changes to the names of many properties: all those that contain more than one word separated by underscores in the XML representation. For example if you are creating a VM using the "deleteProtected" property you will have to change your code to use
"delete_protected" instead.

Comment 4 Sandro Bonazzola 2014-01-13 13:56:50 UTC
oVirt 3.4.0 alpha has been released including the fix for this issue.

Comment 5 Ondra Machacek 2014-02-17 17:00:29 UTC
curl -k -X POST -H "Accept: application/json" -H "Content-Type: 
application/json" -d "@json_vm" -u $ADMIN $URL/vms

json_vm:
{"name":"test_vm2","cluster":{"id":"4200f114-f2d7-4711-994b-d29e525fc4fc", "name": "cl34"},"template":{"id":"00000000-0000-0000-0000-000000000000", "name": "Blank"},"console":{"enabled":true}}

output:
{
  "type" : "desktop",
  "status" : {
    "state" : "down"
  },
  "memory" : 1073741824,
  "cpu" : {
    "topology" : {
      "sockets" : "1",
      "cores" : "1"
    },
    "architecture" : "X86_64"
  },
  "cpu_shares" : "0",
  "os" : {
    "boot" : [ {
      "dev" : "hd"
    } ],
    "type" : "other"
  },
  "high_availability" : {
    "enabled" : false,
    "priority" : "0"
  },
  "display" : {
    "type" : "vnc",
    "monitors" : "1",
    "single_qxl_pci" : false,
    "allow_override" : false,
    "smartcard_enabled" : false
  },
  "cluster" : {
    "href" : "/ovirt-engine/api/clusters/4200f114-f2d7-4711-994b-d29e525fc4fc",
    "id" : "4200f114-f2d7-4711-994b-d29e525fc4fc"
  },
  "template" : {
    "href" : "/ovirt-engine/api/templates/00000000-0000-0000-0000-000000000000",
    "id" : "00000000-0000-0000-0000-000000000000"
  },
  "stop_time" : 1392656267945,
  "creation_time" : 1392656267943,
  "origin" : "ovirt",
  "stateless" : false,
  "delete_protected" : false,
  "sso" : {
    "methods" : {
      "method" : [ {
        "id" : "GUEST_AGENT"
      } ]
    }
  },
  "console" : {
    "enabled" : true
  },
  "initialization" : {
    "domain" : "",
    "regenerate_ssh_keys" : false,
    "nic_configurations" : { }
  },
  "placement_policy" : {
    "affinity" : "migratable"
  },
  "memory_policy" : {
    "guaranteed" : 1073741824,
    "ballooning" : true
  },
  "usb" : {
    "enabled" : false
  },
  "migration_downtime" : "-1",
  "virtio_scsi" : {
    "enabled" : true
  },
  "actions" : {
    "link" : [ {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/ticket",
      "rel" : "ticket"
    }, {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/migrate",
      "rel" : "migrate"
    }, {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/reboot",
      "rel" : "reboot"
    }, {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/cancelmigration",
      "rel" : "cancelmigration"
    }, {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/shutdown",
      "rel" : "shutdown"
    }, {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/start",
      "rel" : "start"
    }, {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/suspend",
      "rel" : "suspend"
    }, {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/stop",
      "rel" : "stop"
    }, {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/detach",
      "rel" : "detach"
    }, {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/export",
      "rel" : "export"
    }, {
      "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/move",
      "rel" : "move"
    } ]
  },
  "name" : "test_vm2",
  "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8",
  "id" : "f23baac6-e916-47d1-84ab-da0d373cd7a8",
  "link" : [ {
    "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/applications",
    "rel" : "applications"
  }, {
    "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/disks",
    "rel" : "disks"
  }, {
    "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/nics",
    "rel" : "nics"
  }, {
    "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/cdroms",
    "rel" : "cdroms"
  }, {
    "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/snapshots",
    "rel" : "snapshots"
  }, {
    "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/tags",
    "rel" : "tags"
  }, {
    "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/permissions",
    "rel" : "permissions"
  }, {
    "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/statistics",
    "rel" : "statistics"
  }, {
    "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/reporteddevices",
    "rel" : "reporteddevices"
  }, {
    "href" : "/ovirt-engine/api/vms/f23baac6-e916-47d1-84ab-da0d373cd7a8/watchdogs",
    "rel" : "watchdogs"
  } ]
}

Comment 6 Sandro Bonazzola 2014-03-31 12:32:38 UTC
this is an automated message: moving to Closed CURRENT RELEASE since oVirt 3.4.0 has been released