Lior Vernia has uploaded a new change for review. Change subject: restapi: Add CustomProperties member to HostNIC ......................................................................
restapi: Add CustomProperties member to HostNIC Added a new CustomProperties member to HostNIC, as well as updated its mapper (and corresponding test class) to reflect it. Also updated the Setup Networks entry in rsdl_metadata.yaml to include the new argument. Change-Id: Ie1cd53d4e3fd0d2f0d7bec7f1a480679a31c6c8f Signed-off-by: Lior Vernia <[email protected]> --- M backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd M backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostNicMapper.java M backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostNicMapperTest.java 4 files changed, 27 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/25/26725/1 diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd index e7345cf..dec8d51 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd @@ -3209,6 +3209,7 @@ <xs:element name="bridged" type="xs:boolean" minOccurs="0" maxOccurs="1"/> <xs:element name="custom_configuration" type="xs:boolean" minOccurs="0" maxOccurs="1"/> <xs:element name="override_configuration" type="xs:boolean" minOccurs="0" maxOccurs="1"/> + <xs:element name="custom_properties" type="CustomProperties" minOccurs="0"/> <!-- Also a rel="master" link for bonded nics --> </xs:sequence> </xs:extension> diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml index 705bbb2..cae872e 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml @@ -2703,7 +2703,9 @@ host_nic.boot_protocol: 'xs:string', host_nic.mac: 'xs:string', host_nic.ip.address: 'xs:string', host_nic.ip.netmask: 'xs:string', host_nic.bonding.options.option--COLLECTION: {option.name: 'xs:string', option.value: 'xs:string', option.type: 'xs:string'}, bonding.slaves.host_nic--COLLECTION: {host_nic.name|id: 'xs:string'}, - host_nic.override_configuration: 'xs:boolean', action.async: 'xs:boolean', action.grace_period.expiry: 'xs:long'} + host_nic.override_configuration: 'xs:boolean', + host_nic.custom_properties.custom_property--COLLECTION: {custom_property.name: 'xs:string', custom_property.value: 'xs:string'}, + action.async: 'xs:boolean', action.grace_period.expiry: 'xs:long'} action.checkConnectivity: xs:boolean action.connectivityTimeout: xs:int action.force: xs:boolean diff --git a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostNicMapper.java b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostNicMapper.java index 090fcdf..7bd13bd 100644 --- a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostNicMapper.java +++ b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostNicMapper.java @@ -1,9 +1,12 @@ package org.ovirt.engine.api.restapi.types; +import java.util.Map; + import org.apache.commons.lang.StringUtils; import org.ovirt.engine.api.common.util.StatusUtils; import org.ovirt.engine.api.model.Bonding; import org.ovirt.engine.api.model.BootProtocol; +import org.ovirt.engine.api.model.CustomProperties; import org.ovirt.engine.api.model.HostNIC; import org.ovirt.engine.api.model.IP; import org.ovirt.engine.api.model.MAC; @@ -11,6 +14,7 @@ import org.ovirt.engine.api.model.NicStatus; import org.ovirt.engine.api.model.Option; import org.ovirt.engine.api.model.Options; +import org.ovirt.engine.api.restapi.utils.CustomPropertiesParser; import org.ovirt.engine.api.restapi.utils.GuidUtils; import org.ovirt.engine.core.common.businessentities.network.Bond; import org.ovirt.engine.core.common.businessentities.network.InterfaceStatus; @@ -18,6 +22,7 @@ import org.ovirt.engine.core.common.businessentities.network.Nic; import org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface; import org.ovirt.engine.core.common.businessentities.network.Vlan; +import org.ovirt.engine.core.utils.customprop.SimpleCustomPropertiesUtil; public class HostNicMapper { private static final String OPTIONS_DELIMITER = "\\ "; @@ -79,6 +84,10 @@ if(networkBootProtocol != null){ entity.setBootProtocol(networkBootProtocol); } + } + if (model.isSetCustomProperties()) { + entity.setCustomProperties(SimpleCustomPropertiesUtil.getInstance() + .convertProperties(CustomPropertiesParser.parse(model.getCustomProperties().getCustomProperty()))); } return entity; } @@ -145,6 +154,15 @@ if (entity.getNetworkImplementationDetails() != null) { model.setCustomConfiguration(!entity.getNetworkImplementationDetails().isInSync()); } + + Map<String, String> entityProperties = entity.getCustomProperties(); + if (entityProperties != null && !entityProperties.isEmpty()) { + CustomProperties properties = new CustomProperties(); + properties.getCustomProperty().addAll(CustomPropertiesParser.parse(SimpleCustomPropertiesUtil.getInstance() + .convertProperties(entityProperties), false)); + model.setCustomProperties(properties); + } + return model; } diff --git a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostNicMapperTest.java b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostNicMapperTest.java index 0c297df..94215d8 100644 --- a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostNicMapperTest.java +++ b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostNicMapperTest.java @@ -2,6 +2,7 @@ import org.junit.Test; import org.ovirt.engine.api.model.HostNIC; +import org.ovirt.engine.api.restapi.utils.CustomPropertiesParser; import org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface; public class HostNicMapperTest extends AbstractInvertibleMappingTest<HostNIC, VdsNetworkInterface, VdsNetworkInterface> { @@ -41,6 +42,10 @@ .getValue()); } + assertNotNull(model.getCustomProperties()); + assertEquals(CustomPropertiesParser.parse(model.getCustomProperties().getCustomProperty()), + CustomPropertiesParser.parse(transform.getCustomProperties().getCustomProperty())); + } @Test -- To view, visit http://gerrit.ovirt.org/26725 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie1cd53d4e3fd0d2f0d7bec7f1a480679a31c6c8f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Lior Vernia <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
