Yevgeny Zaspitsky has uploaded a new change for review. Change subject: restapi: update REST API to pass managementNetworkId on cluster creation ......................................................................
restapi: update REST API to pass managementNetworkId on cluster creation Enable passing managment network id on creating a cluster through the REST API. Change-Id: Iad3159ef098730940df15bc43019139e120aec8b Signed-off-by: Yevgeny Zaspitsky <yzasp...@redhat.com> --- 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/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendClustersResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendDataCenterClustersResource.java 4 files changed, 35 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/02/33502/13 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 0a2119a..33ef71c 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 @@ -1652,6 +1652,7 @@ <xs:element ref="serial_number" minOccurs="0" maxOccurs="1" /> <xs:element name="required_rng_sources" type="RngSources" minOccurs="0" maxOccurs="1" /> <xs:element ref="fencing_policy" minOccurs="0" maxOccurs="1"/> + <xs:element name="management_network_id" type="xs:string" minOccurs="0" maxOccurs="1"/> <!-- Also a rel="networks" link --> </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 76198c1..6ffdd23 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 @@ -1909,7 +1909,8 @@ cluster.scheduling_policy.thresholds.duration--DEPRECATED: 'xs:int', cluster.scheduling_policy.id: 'xs:string', cluster.scheduling_policy.properties.property--COLLECTION: {property.name: 'xs:string', property.value: 'xs:string'}, cluster.error_handling.on_error: 'xs:string', cluster.virt_service: 'xs:boolean', cluster.gluster_service: 'xs:boolean', cluster.threads_as_cores: 'xs:boolean', cluster.tunnel_migration: 'xs:boolean', cluster.trusted_service: 'xs:boolean', cluster.ha_reservation: 'xs:boolean', cluster.ballooning_enabled: 'xs:boolean', cluster.cpu.architecture: 'xs:string', cluster.display.proxy: 'xs:string', cluster.ksm.enabled: 'xs:boolean', - cluster.fencing_policy.enabled: 'xs:boolean', cluster.fencing_policy.skip_if_sd_active.enabled: 'xs:boolean', cluster.fencing_policy.skip_if_connectivity_broken.enabled: 'xs:boolean', cluster.fencing_policy.skip_if_connectivity_broken.threshold: 'xs:int'} + cluster.fencing_policy.enabled: 'xs:boolean', cluster.fencing_policy.skip_if_sd_active.enabled: 'xs:boolean', cluster.fencing_policy.skip_if_connectivity_broken.enabled: 'xs:boolean', cluster.fencing_policy.skip_if_connectivity_broken.threshold: 'xs:int', + cluster.management_network_id: 'xs:string'} description: add a new cluster to the system urlparams: {} headers: @@ -2333,7 +2334,8 @@ cluster.scheduling_policy.thresholds.duration--DEPRECATED: 'xs:int', cluster.scheduling_policy.id: 'xs:string', cluster.scheduling_policy.properties.property--COLLECTION: {property.name: 'xs:string', property.value: 'xs:string'}, cluster.error_handling.on_error: 'xs:string', cluster.virt_service: 'xs:boolean', cluster.gluster_service: 'xs:boolean', cluster.threads_as_cores: 'xs:boolean', - cluster.tunnel_migration: 'xs:boolean', cluster.ballooning_enabled: 'xs:boolean', cluster.cpu.architecture: 'xs:string', cluster.display.proxy: 'xs:string', cluster.ksm.enabled: 'xs:boolean',} + cluster.tunnel_migration: 'xs:boolean', cluster.ballooning_enabled: 'xs:boolean', cluster.cpu.architecture: 'xs:string', cluster.display.proxy: 'xs:string', cluster.ksm.enabled: 'xs:boolean', + cluster.management_network_id: 'xs:string'} description: add a new cluster to the data center urlparams: {} headers: diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendClustersResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendClustersResource.java index af100df..76917f0 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendClustersResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendClustersResource.java @@ -10,6 +10,7 @@ import org.ovirt.engine.api.model.Clusters; import org.ovirt.engine.api.resource.ClusterResource; import org.ovirt.engine.api.resource.ClustersResource; +import org.ovirt.engine.api.restapi.utils.GuidUtils; import org.ovirt.engine.core.common.action.AddClusterOperationParameters; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdsGroupParametersBase; @@ -72,15 +73,33 @@ @Override public Response add(Cluster cluster) { - validateParameters(cluster, "name", "dataCenter.name|id"); + validateParameters(cluster, getMandatoryParameters()); validateEnums(Cluster.class, cluster); - StoragePool pool = getStoragePool(cluster.getDataCenter(), this); - VDSGroup entity = map(cluster, map(pool)); + StoragePool dataCenter = getDataCenter(cluster); return performCreate(VdcActionType.AddVdsGroup, - new AddClusterOperationParameters(entity), + createCommandParams(cluster, dataCenter), new QueryIdResolver<Guid>(VdcQueryType.GetVdsGroupById, IdQueryParameters.class)); } + protected String[] getMandatoryParameters() { + return new String[] { "name", "dataCenter.name|id" }; + } + + protected StoragePool getDataCenter(Cluster cluster) { + return getStoragePool(cluster.getDataCenter(), this); + } + + protected AddClusterOperationParameters createCommandParams(Cluster cluster, StoragePool dataCenter) { + VDSGroup clusterEntity = map(cluster, map(dataCenter)); + + final AddClusterOperationParameters taskParams = + cluster.isSetManagementNetworkId() ? + new AddClusterOperationParameters(clusterEntity, + GuidUtils.asGuid(cluster.getManagementNetworkId())) : + new AddClusterOperationParameters(clusterEntity); + return taskParams; + } + @Override public Response performRemove(String id) { return performAction(VdcActionType.RemoveVdsGroup, new VdsGroupParametersBase(asGuid(id))); diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendDataCenterClustersResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendDataCenterClustersResource.java index 2ca8d9b..5d23d4f 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendDataCenterClustersResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendDataCenterClustersResource.java @@ -4,14 +4,10 @@ import java.util.List; -import javax.ws.rs.core.Response; - import org.ovirt.engine.api.model.Cluster; import org.ovirt.engine.api.model.Clusters; import org.ovirt.engine.api.model.DataCenter; import org.ovirt.engine.api.resource.ClusterResource; -import org.ovirt.engine.core.common.action.AddClusterOperationParameters; -import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.queries.IdQueryParameters; @@ -43,17 +39,17 @@ } @Override - public Response add(Cluster cluster) { - validateParameters(cluster, "name"); - validateEnums(Cluster.class, cluster); + protected String[] getMandatoryParameters() { + return new String[] { "name" }; + } + + @Override + protected StoragePool getDataCenter(Cluster cluster) { DataCenter dataCenter = new DataCenter(); dataCenter.setId(dataCenterId.toString()); cluster.setDataCenter(dataCenter); StoragePool pool = getStoragePool(cluster.getDataCenter(), this); - VDSGroup entity = map(cluster, map(pool)); - return performCreate(VdcActionType.AddVdsGroup, - new AddClusterOperationParameters(entity), - new QueryIdResolver<Guid>(VdcQueryType.GetVdsGroupById, IdQueryParameters.class)); + return pool; } } -- To view, visit http://gerrit.ovirt.org/33502 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iad3159ef098730940df15bc43019139e120aec8b Gerrit-PatchSet: 13 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yevgeny Zaspitsky <yzasp...@redhat.com> Gerrit-Reviewer: Alona Kaplan <alkap...@redhat.com> Gerrit-Reviewer: Juan Hernandez <juan.hernan...@redhat.com> Gerrit-Reviewer: Yevgeny Zaspitsky <yzasp...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-Reviewer: oVirt Jenkins CI Server _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches