DoubleCloudInc / vim-rest-api

15 stars 7 forks source link

Import OVA Issue #2

Open michaeldudli opened 6 years ago

michaeldudli commented 6 years ago

I'm trying to import an OVA, and i'm following this procedure:

ovfManager -> parseDescriptor to verify the ovf description ovfManager -> createImportSpec to create the import specification parameters ResourcePool -> importVApp to initiate the import/get the httpnfclease session so that i can put the file

Everything looks good, i can also map the network in createImportSpec, i get the importspec, i call importVApp, i get the HttpNfcLease, but when i call HttpNfcLease to get the state of the lease, i get an error:

curl -X GET "http://ipaddress:8080/api/HttpNfcLease/vcenter.local%3Asession%5B52ba657d-5433-0478-9c7f-2179c881559e%5D522bcd59-4aa3-3485-5ea6-a527e3bd5404" -H "accept: application/json" -H "authorization: Basic YXBpOnhlajR4MjJiQQ=="

{ "state": "error", "error": { "fault": { "argument": "spec", "stackTrace": [], "suppressedExceptions": [] }, "localizedMessage": "The request refers to an unexpected or unknown type." } }

The vmware vcenter log says:

2018-01-15T10:30:42.591+01:00 info vpxd[7FF596D9B700] [Originator@6876 sub=Default opID=7137a185] [VpxLRO] -- ERROR lro-2042429 -- propertyCollector -- vmodl.query.PropertyCollector.retrieveContents: vmodl.query.InvalidProperty: --> Result: --> (vmodl.query.InvalidProperty) { --> faultCause = (vmodl.MethodFault) null, --> faultMessage = , --> name = "initializeProgres" --> msg = "" --> } --> Args: --> --> Arg specSet: --> (vmodl.query.PropertyCollector.FilterSpec) [ --> (vmodl.query.PropertyCollector.FilterSpec) { --> propSet = (vmodl.query.PropertyCollector.PropertySpec) [ --> (vmodl.query.PropertyCollector.PropertySpec) { --> type = "vim.HttpNfcLease", --> all = false, --> pathSet = (vmodl.PropertyPath) [ --> "initializeProgres" --> ] --> } --> ], --> objectSet = (vmodl.query.PropertyCollector.ObjectSpec) [ --> (vmodl.query.PropertyCollector.ObjectSpec) { --> obj = 'vim.HttpNfcLease:session[52ba657d-5433-0478-9c7f-2179c881559e]522bcd59-4aa3-3485-5ea6-a527e3bd5404', --> skip = false, --> selectSet = --> } --> ], --> reportMissingObjectsInResults = --> } --> ]

I've tried two different ovfs (one from a firewall device, one from a windows server), it ends up with the same issue on both of them. I'm not sure if this issue is related to the ovf file, to the importspec, or to a wrong API call/parameter.

Any idea?

sjin2008 commented 6 years ago

I think it's a bug. To work around this, you can include specific property name as state as follows:

curl -X GET "http://ipaddress:8080/api/HttpNfcLease/vcenter.xelon.local%3Asession%5B52ba657d-5433-0478-9c7f-2179c881559e%5D522bcd59-4aa3-3485-5ea6-a527e3bd5404/state" -H "accept: application/json" -H "authorization: Basic YXBpOnhlajR4MjJiQQ=="

michaeldudli commented 6 years ago

I've already tried this, i get the following response body: curl -X GET "http://176.10.116.236:8080/api/HttpNfcLease/vcenter.local%3Asession%5B5281f861-6a0b-358e-54c5-c580eaf57052%5D52e18aa5-cc88-ef79-a972-2e9e60e66893/state" -H "accept: application/json" -H "authorization: Basic YXBpOnhlajR4MjJiQQ=="

{ "state": "error" }

This is a proper response from the vcenter, Nfc state is error. But as the createImportSpec worked fine, I'm not sure why the state is error. How can i troubleshoot this?

sjin2008 commented 6 years ago

Yes, the state property looks fine. Do you want to post the return of createImportSpec call and importVApp call?

michaeldudli commented 6 years ago

Sure!

CreateImportSpec return:

{ "returnval": { "importSpec": { "configSpec": { "name": "testovf", "version": "vmx-07", "guestId": "otherLinuxGuest", "annotation": "The SonicWall Secure Mobile Access (SMA) 500v Virtual Appliance provides mobile and remote workers using smartphones, tablets or laptops with fast, easy, policy-enforced access to mission-critical applications, data and resources, without compromising security.", "files": { "vmPathName": "[vsanDatastore]" }, "tools": { "afterPowerOn": true, "afterResume": true, "beforeGuestStandby": true, "beforeGuestShutdown": true, "beforeGuestReboot": true }, "numCPUs": 1, "numCoresPerSocket": 1, "memoryMB": 2204, "memoryHotAddEnabled": false, "cpuHotAddEnabled": false, "cpuHotRemoveEnabled": false, "virtualICH7MPresent": false, "virtualSMCPresent": false, "deviceChange": [ { "operation": "add", "device": { "key": -100, "backing": { "deviceName": "Floppy 0" }, "connectable": { "startConnected": false, "allowGuestControl": true, "connected": false }, "controllerKey": 400, "unitNumber": 0 } }, { "operation": "add", "device": { "busNumber": 0, "device": [ -100 ], "key": 400 } }, { "operation": "add", "device": { "key": -101, "backing": { "deviceName": "CD/DVD drive 0" }, "connectable": { "startConnected": false, "allowGuestControl": true, "connected": false }, "controllerKey": 201, "unitNumber": 0 } }, { "operation": "add", "device": { "busNumber": 1, "device": [ -101 ], "key": 201, "connectable": { "startConnected": true, "allowGuestControl": false, "connected": true } } }, { "operation": "add", "device": { "addressType": "generated", "wakeOnLanEnabled": true, "key": -102, "backing": { "port": { "switchUuid": "50 2e c9 c5 e4 14 65 a7-90 44 7e 34 91 d9 22 cc", "portgroupKey": "dvportgroup-787" } }, "connectable": { "startConnected": true, "allowGuestControl": true, "connected": true }, "slotInfo": { "pciSlotNumber": 32 } } }, { "operation": "add", "device": { "addressType": "generated", "wakeOnLanEnabled": true, "key": -103, "backing": { "port": { "switchUuid": "50 2e c9 c5 e4 14 65 a7-90 44 7e 34 91 d9 22 cc", "portgroupKey": "dvportgroup-787" } }, "connectable": { "startConnected": true, "allowGuestControl": true, "connected": true }, "slotInfo": { "pciSlotNumber": 33 } } }, { "operation": "add", "device": { "addressType": "generated", "wakeOnLanEnabled": true, "key": -104, "backing": { "port": { "switchUuid": "50 2e c9 c5 e4 14 65 a7-90 44 7e 34 91 d9 22 cc", "portgroupKey": "dvportgroup-787" } }, "connectable": { "startConnected": true, "allowGuestControl": true, "connected": true }, "slotInfo": { "pciSlotNumber": 34 } } }, { "operation": "add", "fileOperation": "create", "device": { "capacityInKB": 20971520, "key": -106, "backing": { "diskMode": "persistent", "split": false, "eagerlyScrub": false, "fileName": "" }, "connectable": { "startConnected": true, "allowGuestControl": false, "connected": false }, "controllerKey": -105, "unitNumber": 0 } }, { "operation": "add", "device": { "sharedBus": "noSharing", "busNumber": 0, "device": [ -106 ], "key": -105, "connectable": { "startConnected": true, "allowGuestControl": false, "connected": false }, "slotInfo": { "pciSlotNumber": 16 } } } ], "vAppConfig": { "product": [ { "info": { "key": 0, "classId": "", "instanceId": "", "name": "SonicWall SMA 500v Virtual Appliance", "vendor": "SonicWall Inc.", "version": "8.6.0.0", "fullVersion": "ROM(5.0.0.5)", "vendorUrl": "http://www.sonicwall.com", "productUrl": "http://www.sonicwall.com/products/sra-virtual-appliance", "appUrl": "" }, "operation": "add" } ], "eula": [ "SonicWall End User Product Agreement." ], "ovfSection": [ { "info": { "key": 12, "namespace": "http://www.vmware.com/schema/ovf", "type": "StorageGroupSection", "atEnvelopeLevel": true, "contents": "<vmw:StorageGroupSection ovf:required=\"false\" vmw:id=\"group1\" vmw:name=\"vSAN Default Storage Policy\" xmlns=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:ovf=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:rasd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData\" xmlns:vmw=\"http://www.vmware.com/schema/ovf\" xmlns:vssd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData\"> Storage policy for group of disks The vSAN Default Storage Policy storage policy group</vmw:Description> </vmw:StorageGroupSection>" }, "operation": "add" }, { "info": { "key": 13, "namespace": "http://www.vmware.com/schema/ovf", "type": "StorageSection", "atEnvelopeLevel": false, "contents": "<vmw:StorageSection ovf:required=\"false\" vmw:group=\"group1\" xmlns=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:ovf=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:rasd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData\" xmlns:vmw=\"http://www.vmware.com/schema/ovf\" xmlns:vssd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData\"> Storage policy group reference </vmw:StorageSection>" }, "operation": "add" } ], "installBootRequired": false, "installBootStopDelay": 0 }, "nestedHVEnabled": false }, "entityConfig": { "tag": "testovf" }, "instantiationOst": { "id": "", "type": "envelope", "child": [ { "id": "testovf", "type": "virtualSystem" } ] } }, "fileItem": [ { "deviceId": "/testovf/VirtualBusLogicController0:0", "path": "sw_smavm_eng_8_6.0.1_8.6.0_p_9sv_982896.signed-1.vmdk", "compressionMethod": "", "size": -1, "cimType": 17, "create": false } ] } }

and the importVapp return:

{ "returnval": { "type": "HttpNfcLease", "val": "session[527829bd-8d13-8299-5e14-cf1eec9ab050]521551e1-2a6f-d328-2449-1a658efa9d99" } }

HttpNfcLease return:

{ "state": "error", "error": { "fault": { "argument": "spec", "stackTrace": [], "suppressedExceptions": [] }, "localizedMessage": "The request refers to an unexpected or unknown type." } }

and again the vcenter log:

2018-01-18T19:47:47.885+01:00 info vpxd[7FF596000700] [Originator@6876 sub=Default opID=3f6b7270] [VpxLRO] -- ERROR lro-6201602 -- propertyCollector -- vmodl.query.PropertyCollector.retrieveContents: vmodl.query.InvalidProperty: --> Result: --> (vmodl.query.InvalidProperty) { --> faultCause = (vmodl.MethodFault) null, --> faultMessage = , --> name = "initializeProgres" --> msg = "" --> } --> Args: --> --> Arg specSet: --> (vmodl.query.PropertyCollector.FilterSpec) [ --> (vmodl.query.PropertyCollector.FilterSpec) { --> propSet = (vmodl.query.PropertyCollector.PropertySpec) [ --> (vmodl.query.PropertyCollector.PropertySpec) { --> type = "vim.HttpNfcLease", --> all = false, --> pathSet = (vmodl.PropertyPath) [ --> "initializeProgres" --> ] --> } --> ], --> objectSet = (vmodl.query.PropertyCollector.ObjectSpec) [ --> (vmodl.query.PropertyCollector.ObjectSpec) { --> obj = 'vim.HttpNfcLease:session[527829bd-8d13-8299-5e14-cf1eec9ab050]521551e1-2a6f-d328-2449-1a658efa9d99', --> skip = false, --> selectSet = --> } --> ], --> reportMissingObjectsInResults = --> } --> ]

sjin2008 commented 6 years ago

The vCenter log is a noise caused by retrieval of a property with wrong time. Let's ignore that for the moment. For the importVApp endpoint, what values for the parameters you passed in: spec, folder, host in request body?

michaeldudli commented 6 years ago

This is the request body:

{ "spec": {

"configSpec": { "name": "testovf", "version": "vmx-07", "guestId": "otherLinuxGuest", "annotation": "The SonicWall Secure Mobile Access (SMA) 500v Virtual Appliance provides mobile and remote workers using smartphones, tablets or laptops with fast, easy, policy-enforced access to mission-critical applications, data and resources, without compromising security.", "files": { "vmPathName": "[vsanDatastore]" }, "tools": { "afterPowerOn": true, "afterResume": true, "beforeGuestStandby": true, "beforeGuestShutdown": true, "beforeGuestReboot": true }, "numCPUs": 1, "numCoresPerSocket": 1, "memoryMB": 2204, "memoryHotAddEnabled": false, "cpuHotAddEnabled": false, "cpuHotRemoveEnabled": false, "virtualICH7MPresent": false, "virtualSMCPresent": false, "deviceChange": [ { "operation": "add", "device": { "key": -100, "backing": { "deviceName": "Floppy 0" }, "connectable": { "startConnected": false, "allowGuestControl": true, "connected": false }, "controllerKey": 400, "unitNumber": 0 } }, { "operation": "add", "device": { "busNumber": 0, "device": [ -100 ], "key": 400 } }, { "operation": "add", "device": { "key": -101, "backing": { "deviceName": "CD/DVD drive 0" }, "connectable": { "startConnected": false, "allowGuestControl": true, "connected": false }, "controllerKey": 201, "unitNumber": 0 } }, { "operation": "add", "device": { "busNumber": 1, "device": [ -101 ], "key": 201, "connectable": { "startConnected": true, "allowGuestControl": false, "connected": true } } }, { "operation": "add", "device": { "addressType": "generated", "wakeOnLanEnabled": true, "key": -102, "backing": { "port": { "switchUuid": "50 2e c9 c5 e4 14 65 a7-90 44 7e 34 91 d9 22 cc", "portgroupKey": "dvportgroup-787" } }, "connectable": { "startConnected": true, "allowGuestControl": true, "connected": true }, "slotInfo": { "pciSlotNumber": 32 } } }, { "operation": "add", "device": { "addressType": "generated", "wakeOnLanEnabled": true, "key": -103, "backing": { "port": { "switchUuid": "50 2e c9 c5 e4 14 65 a7-90 44 7e 34 91 d9 22 cc", "portgroupKey": "dvportgroup-787" } }, "connectable": { "startConnected": true, "allowGuestControl": true, "connected": true }, "slotInfo": { "pciSlotNumber": 33 } } }, { "operation": "add", "device": { "addressType": "generated", "wakeOnLanEnabled": true, "key": -104, "backing": { "port": { "switchUuid": "50 2e c9 c5 e4 14 65 a7-90 44 7e 34 91 d9 22 cc", "portgroupKey": "dvportgroup-787" } }, "connectable": { "startConnected": true, "allowGuestControl": true, "connected": true }, "slotInfo": { "pciSlotNumber": 34 } } }, { "operation": "add", "fileOperation": "create", "device": { "capacityInKB": 20971520, "key": -106, "backing": { "diskMode": "persistent", "split": false, "eagerlyScrub": false, "fileName": "" }, "connectable": { "startConnected": true, "allowGuestControl": false, "connected": false }, "controllerKey": -105, "unitNumber": 0 } }, { "operation": "add", "device": { "sharedBus": "noSharing", "busNumber": 0, "device": [ -106 ], "key": -105, "connectable": { "startConnected": true, "allowGuestControl": false, "connected": false }, "slotInfo": { "pciSlotNumber": 16 } } } ], "vAppConfig": { "product": [ { "info": { "key": 0, "classId": "", "instanceId": "", "name": "SonicWall SMA 500v Virtual Appliance", "vendor": "SonicWall Inc.", "version": "8.6.0.0", "fullVersion": "ROM(5.0.0.5)", "vendorUrl": "http://www.sonicwall.com", "productUrl": "http://www.sonicwall.com/products/sra-virtual-appliance", "appUrl": "" }, "operation": "add" } ], "eula": [ "SonicWall End User Product Agreement." ], "ovfSection": [ { "info": { "key": 12, "namespace": "http://www.vmware.com/schema/ovf", "type": "StorageGroupSection", "atEnvelopeLevel": true, "contents": "<vmw:StorageGroupSection ovf:required=\"false\" vmw:id=\"group1\" vmw:name=\"vSAN Default Storage Policy\" xmlns=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:ovf=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:rasd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData\" xmlns:vmw=\"http://www.vmware.com/schema/ovf\" xmlns:vssd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData\"> Storage policy for group of disks The vSAN Default Storage Policy storage policy group</vmw:Description> </vmw:StorageGroupSection>" }, "operation": "add" }, { "info": { "key": 13, "namespace": "http://www.vmware.com/schema/ovf", "type": "StorageSection", "atEnvelopeLevel": false, "contents": "<vmw:StorageSection ovf:required=\"false\" vmw:group=\"group1\" xmlns=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:ovf=\"http://schemas.dmtf.org/ovf/envelope/1\" xmlns:rasd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData\" xmlns:vmw=\"http://www.vmware.com/schema/ovf\" xmlns:vssd=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData\"> Storage policy group reference </vmw:StorageSection>" }, "operation": "add" } ], "installBootRequired": false, "installBootStopDelay": 0 }, "nestedHVEnabled": false }, "entityConfig": { "tag": "testovf" }, "instantiationOst": { "id": "", "type": "envelope", "child": [ { "id": "testovf", "type": "virtualSystem" } ] } }, "folder": { "val": "group-v736", "type": "Folder" } }

host is not defined, but even if i define a host "host": {"val": "host-10","type": "HostSystem"} , i get the same error.

sjin2008 commented 6 years ago

The data looks fine. I assume you got the spec value from the previous createImportSpec endpoint? It should be copied as it is.

What endpoint URL you post the data to?

michaeldudli commented 6 years ago

yes, value is copied from the previous return!

What do you mean by "endpoint URL"?

sjin2008 commented 6 years ago

I think the spec object needs some type hints for the back end in the deviceChange value. For example, the Hard Disk, we need to add: @type: 'VirtualDisk' For its backing, we need: @type: 'VirtualDiskFlatVer2BackingInfo' For the slotInfo, we need: @type: VirtualDeviceBusSlotInfo It may not be the final fix, but should be a step closer to the final solution.