Michael Pasternak has posted comments on this change. Change subject: core: restapi: Introducing ImportVmFromConfigurationCommand ......................................................................
Patch Set 7: I would prefer that you didn't submit this (10 inline comments) .................................................... File backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/ConfigurationType.java Line 1: package org.ovirt.engine.api.model; Line 2: Line 3: public enum ConfigurationType { Line 4: OVF; Line 5: 1. please add: public String value() { return name().toLowerCase(); } 2. please describe this enum in the BackendCapabilitiesResource [1] [1] see BackendCapabilitiesResource.addStorageTypes() Line 6: public static ConfigurationType fromValue(String value) { Line 7: try { Line 8: return valueOf(value.toUpperCase()); Line 9: } catch (IllegalArgumentException e) { .................................................... File backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd Line 2091: </xs:annotation> Line 2092: </xs:element> Line 2093: </xs:sequence> Line 2094: </xs:complexType> Line 2095: please add element definition: e.g <xs:element name="configuration" type="Configuration"/> Line 2096: <xs:complexType name="Configuration"> Line 2097: <xs:choice> Line 2098: <xs:element name="type" type="xs:string" minOccurs="1"/> Line 2099: <xs:element name="data" type="xs:string" minOccurs="1"/> Line 2098: <xs:element name="type" type="xs:string" minOccurs="1"/> Line 2099: <xs:element name="data" type="xs:string" minOccurs="1"/> Line 2100: </xs:choice> Line 2101: </xs:complexType> Line 2102: same Line 2103: <xs:complexType name="Initialization"> Line 2104: <xs:choice> Line 2105: <xs:element name="configuration" type="Configuration" minOccurs="1"/> Line 2106: </xs:choice> Line 2152: <xs:element name="custom_properties" type="CustomProperties" minOccurs="0"/> Line 2153: <xs:element name="payloads" type="Payloads" minOccurs="0"/> Line 2154: <xs:element name="statistics" type="Statistics" minOccurs="0" maxOccurs="1"/> Line 2155: <xs:element name="disks" type="Disks" minOccurs="0" maxOccurs="1"/> Line 2156: <xs:element name="initialization" type="Initialization" minOccurs="0"/> please refer to the type using ref="initialization" Line 2157: <xs:element name="nics" type="Nics" minOccurs="0" maxOccurs="1"/> Line 2158: <xs:element name="tags" type="Tags" minOccurs="0" maxOccurs="1"/> Line 2159: <xs:element name="snapshots" type="Snapshots" minOccurs="0" maxOccurs="1"/> Line 2160: <xs:element name="placement_policy" type="VmPlacementPolicy" minOccurs="0" maxOccurs="1"/> .................................................... File backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml Line 134: vm.os.kernel: xs:string Line 135: vm.disks.clone: xs:boolean Line 136: vm.tunnel_migration: xs:boolean Line 137: vm.initialization.configuration.type: 'xs:string' Line 138: vm.initialization.configuration.data: 'xs:string' please create dedicated signature for this type of vm creation (without a template i guess) Line 139: vm.payloads.payload--COLLECTION: {payload.type: 'xs:string', payload.file.name: 'xs:string', payload.file.content: 'xs:string'} Line 140: vm.cpu.cpu_tune.vcpu_pin--COLLECTION: {vcpu_pin.vcpu: 'xs:int', vcpu_pin.cpu_set: 'xs:string'} Line 141: # the following signature is for clone VM from a Snapshot - requires the Snapshot ID Line 142: - mandatoryArguments: {vm.name: 'xs:string', vm.template.id|name: 'xs:string', vm.cluster.id|name: 'xs:string', .................................................... File backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java Line 82: public Response add(VM vm) { Line 83: validateParameters(vm, "cluster.id|name"); Line 84: validateEnums(VM.class, vm); Line 85: Response response = null; Line 86: if (vm.getInitialization() != null) { 1. vm.isSetInitialization() && #2 2. i guess you should also check that initalization.configuration isSet (i.e != NULL) && #3 3. configuration.type == OVF Line 87: response = importVmFromConfiguration(vm); Line 88: } else { Line 89: validateParameters(vm, "name"); Line 90: if (isCreateFromSnapshot(vm)) { Line 181: return payload; Line 182: } Line 183: Line 184: public Response importVmFromConfiguration(VM vm) { Line 185: Configuration config = vm.getInitialization().getConfiguration(); what if config == NULL? Line 186: ImportVmFromConfigurationParameters params = Line 187: new ImportVmFromConfigurationParameters(VmMapper.map(ConfigurationType.fromValue(config.getType()), null), config.getData().trim() , getClusterId(vm)); Line 188: return performCreate(VdcActionType.ImportVmFromConfiguration, Line 189: params, Line 183: Line 184: public Response importVmFromConfiguration(VM vm) { Line 185: Configuration config = vm.getInitialization().getConfiguration(); Line 186: ImportVmFromConfigurationParameters params = Line 187: new ImportVmFromConfigurationParameters(VmMapper.map(ConfigurationType.fromValue(config.getType()), null), config.getData().trim() , getClusterId(vm)); config.getType() ==> potential NPE, config can be NULL Line 188: return performCreate(VdcActionType.ImportVmFromConfiguration, Line 189: params, Line 190: new QueryIdResolver<Guid>(VdcQueryType.GetVmByVmId, IdQueryParameters.class)); Line 191: } .................................................... File backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java Line 607: switch (configurationType) { Line 608: case OVF: return org.ovirt.engine.core.common.businessentities.ConfigurationType.OVF; Line 609: default: return null; Line 610: } Line 611: } 1. no oposit direction ? 2. please add VmMapperTest round-trip assignment for this Line 612: Line 613: @Mapping(from = org.ovirt.engine.api.model.VmDeviceType.class, to = VmDeviceType.class) Line 614: public static VmDeviceType map(org.ovirt.engine.api.model.VmDeviceType deviceType, VmDeviceType template) { Line 615: switch (deviceType) { .................................................... Commit Message Line 4: Commit: Liron Aravot <lara...@redhat.com> Line 5: CommitDate: 2013-07-07 16:36:04 +0300 Line 6: Line 7: core: restapi: Introducing ImportVmFromConfigurationCommand Line 8: please add test/s for this use-case Line 9: ImportVmFromConfigurationCommand is used for adding a vm to the engine Line 10: with a configuration specified in an ovf file. Line 11: The command adds the vm and related devices as specified in the given Line 12: configuration and then attempts to attach to the vm the related disks. -- To view, visit http://gerrit.ovirt.org/15894 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I9390bcc11e5f3cb8c8c89ce791aabe63fe0ca341 Gerrit-PatchSet: 7 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liron Ar <lara...@redhat.com> Gerrit-Reviewer: A Burden <abur...@redhat.com> Gerrit-Reviewer: Alissa Bonas <abo...@redhat.com> Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com> Gerrit-Reviewer: Daniel Erez <de...@redhat.com> Gerrit-Reviewer: Itamar Heim <ih...@redhat.com> Gerrit-Reviewer: Maor Lipchuk <mlipc...@redhat.com> Gerrit-Reviewer: Michael Pasternak <mpast...@redhat.com> Gerrit-Reviewer: Sergey Gotliv <sgot...@redhat.com> Gerrit-Reviewer: oVirt Jenkins CI Server _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches