Sahina Bose has posted comments on this change.
Change subject: restapi: Support for gluster hooks added
......................................................................
Patch Set 5: (20 inline comments)
Uploading patchset incorporating Michael's comments
....................................................
File
backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
Line 3153:
Line 3154: <xs:element name="hook_status" type="HookStatus"/>
Line 3155: <xs:complexType name="HookStatus">
Line 3156: <xs:sequence>
Line 3157: <xs:element name="hook_status" type="xs:string" minOccurs="0"
maxOccurs="unbounded">
Done. Removed hook_status element.
Line 3158: <xs:annotation>
Line 3159: <xs:appinfo>
Line 3160: <jaxb:property name="GlusterHookStatus"/>
Line 3161: </xs:appinfo>
Line 3203: <xs:complexContent>
Line 3204: <xs:extension base="BaseResource">
Line 3205: <xs:sequence>
Line 3206: <xs:element ref="host" minOccurs="0" maxOccurs="1"/>
Line 3207: <xs:element ref="content_types" minOccurs="0"
maxOccurs="1" />
Right. Changed to content_type and removed ref.
Line 3208: <xs:element ref="hook_status" minOccurs="0" maxOccurs="1"/>
Line 3209: <xs:element name="checksum" type="xs:string" minOccurs="0"
maxOccurs="1"/>
Line 3210: </xs:sequence>
Line 3211: </xs:extension>
Line 3204: <xs:extension base="BaseResource">
Line 3205: <xs:sequence>
Line 3206: <xs:element ref="host" minOccurs="0" maxOccurs="1"/>
Line 3207: <xs:element ref="content_types" minOccurs="0"
maxOccurs="1" />
Line 3208: <xs:element ref="hook_status" minOccurs="0" maxOccurs="1"/>
Removed reference to hook_status element.
Line 3209: <xs:element name="checksum" type="xs:string" minOccurs="0"
maxOccurs="1"/>
Line 3210: </xs:sequence>
Line 3211: </xs:extension>
Line 3212: </xs:complexContent>
Line 3223: <xs:extension base="BaseResource">
Line 3224: <xs:sequence>
Line 3225: <xs:element ref="cluster" minOccurs="0" maxOccurs="1"/>
Line 3226: <xs:element name="gluster_command" type="xs:string"
minOccurs="0" maxOccurs="1"/>
Line 3227: <xs:element name="gluster_stage" type="xs:string"
minOccurs="0" maxOccurs="1"/>
The name gluster_command indicates the gluster command (for instance "gluster
volume create") on which this hook would be invoked. "gluster" was prefixed to
indicate that it is a gluster command.
Removed from stage, as this is not gluster specific.
In cases like Gluster Hook - where the hook is different from VDSM hooks, I
feel the prefix brings clarity as to purpose of entity. That's just my opinion.
Line 3228: <xs:element name="content_type" type="xs:string"
minOccurs="0" maxOccurs="1"/>
Line 3229: <xs:element name="checksum" type="xs:string" minOccurs="0"
maxOccurs="1"/>
Line 3230: <xs:element name="content" type="xs:string" minOccurs="0"
maxOccurs="1"/>
Line 3231: <xs:element name="conflict_status" type="xs:unsignedShort"
minOccurs="0" maxOccurs="1"/>
Line 3229: <xs:element name="checksum" type="xs:string" minOccurs="0"
maxOccurs="1"/>
Line 3230: <xs:element name="content" type="xs:string" minOccurs="0"
maxOccurs="1"/>
Line 3231: <xs:element name="conflict_status" type="xs:unsignedShort"
minOccurs="0" maxOccurs="1"/>
Line 3232: <xs:element name="conflicts" type="xs:string"
minOccurs="0" maxOccurs="1"/>
Line 3233: <xs:element name="hook_status" type="xs:string"
minOccurs="0" maxOccurs="1"/>
Done
Line 3234: <xs:element ref="server_hooks" minOccurs="0"
maxOccurs="1"/>
Line 3235: </xs:sequence>
Line 3236: </xs:extension>
Line 3237: </xs:complexContent>
....................................................
File
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterHookResource.java
Line 43:
Line 44: @Override
Line 45: public GlusterHook get() {
Line 46: GlusterHook hook = performGet(VdcQueryType.GetGlusterHookById,
new GlusterHookQueryParameters(guid,true));
Line 47: VdcQueryReturnValue result =
runQuery(VdcQueryType.GetGlusterHookContent, new
GlusterHookContentQueryParameters(guid));
GetGlusterHookById query does not return the content as the content is not
needed in most cases in Web UI.
Line 48: if (result != null
Line 49: && result.getSucceeded()
Line 50: && result.getReturnValue() != null) {
Line 51: hook.setContent((String)result.getReturnValue());
Line 66: @Override
Line 67: public Response resolve(Action action) {
Line 68: validateParameters(action, "resolutionType");
Line 69:
Line 70: ResolutionType resolutionType =
validateEnum(ResolutionType.class, action.getResolutionType().toUpperCase());
Done. Thanks!
Line 71:
Line 72: switch (resolutionType) {
Line 73: case ADD:
Line 74: return addToMissingServers(action);
Line 84: }
Line 85:
Line 86: private Response copy(Action action) {
Line 87: GlusterHookManageParameters params = new
GlusterHookManageParameters(guid);
Line 88: if (action.getHost() != null) {
Done
Line 89: validateParameters(action.getHost(),"host.id|name");
Line 90: Guid hostId = getHostId(action);
Line 91: if (hostId == null) {
Line 92: return handleError(new
EntityNotFoundException(action.getHost().getId() != null ? id :
action.getHost().getName()), false);
Line 87: GlusterHookManageParameters params = new
GlusterHookManageParameters(guid);
Line 88: if (action.getHost() != null) {
Line 89: validateParameters(action.getHost(),"host.id|name");
Line 90: Guid hostId = getHostId(action);
Line 91: if (hostId == null) {
Done
Line 92: return handleError(new
EntityNotFoundException(action.getHost().getId() != null ? id :
action.getHost().getName()), false);
Line 93: }
Line 94: params.setSourceServerId(hostId);
Line 95: }
....................................................
File
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterHooksResource.java
Line 38:
Line 39: public BackendGlusterHooksResource(ClusterResource parent, String
clusterId) {
Line 40: this();
Line 41: setParent(parent);
Line 42: this.clusterId = clusterId;
Done
Line 43: }
Line 44:
Line 45: public ClusterResource getParent() {
Line 46: return parent;
....................................................
File
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterHookResourceTest.java
Line 72: verifyActionResponse(resource.resolve(action));
Line 73: }
Line 74:
Line 75: @Test
Line 76: public void testAdd() throws Exception {
Done. Also, renamed testUpdate to testResolveCopy - this tests the other
resolution method.
Line 77:
setUriInfo(setUpActionExpectations(VdcActionType.AddGlusterHook,
Line 78: GlusterHookManageParameters.class,
Line 79: new String[] { "HookId" },
Line 80: new Object[] { hookId}));
....................................................
File
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/GlusterHookMapper.java
Line 60: }
Line 61:
Line 62: if (entity.getStage() != null) {
Line 63: model.setGlusterStage(map(entity.getStage(),null));
Line 64: }
We're not creating a hook resource from API, so model to entity not required
Line 65:
Line 66: if (entity.getStatus() != null) {
Line 67: model.setHookStatus(map(entity.getStatus(),null));
Line 68: }
Line 68: }
Line 69:
Line 70: if (entity.getContentType() != null) {
Line 71: model.setContentType(map(entity.getContentType(), null));
Line 72: }
We're not creating a hook resource from API, so model to entity not required
Line 73:
Line 74: if (entity.getChecksum() != null) {
Line 75: model.setChecksum(entity.getChecksum());
Line 76: }
Line 118: return serverHookModel;
Line 119: }
Line 120:
Line 121: @Mapping(from =
org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType.class,
to = String.class)
Line 122: public static String
map(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType
hookContentType,
Done
Line 123: String template) {
Line 124: switch (hookContentType) {
Line 125: case BINARY:
Line 126: return
org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType.BINARY.toString();
Line 131: }
Line 132: }
Line 133:
Line 134: @Mapping(from =
org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStage.class,
to = String.class)
Line 135: public static String
map(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStage
hookStage,
Done
Line 136: String template) {
Line 137: switch (hookStage) {
Line 138: case POST:
Line 139: return
org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStage.POST.toString();
Line 144: }
Line 145: }
Line 146:
Line 147: @Mapping(from =
org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus.class,
to = String.class)
Line 148: public static String
map(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus
hookStatus,
Done
Line 149: String template) {
Line 150: switch (hookStatus) {
Line 151: case DISABLED:
Line 152: return
org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus.DISABLED.toString();
....................................................
Commit Message
Line 14:
Line 15: This patch adds API support for managing gluster hooks.
Line 16: - api/cluster/{id}/glusterhooks
Line 17: lists all gluster hooks in the cluster along with
Line 18: conflict status
Gluster hooks are only added at installation of gluster rpms. There's no
provision to add a hook that does not yet exist from engine.
Line 19: - api/cluster/{id}/glusterhooks/{glusterhook:id}|rel=delete
Line 20: resolve missing hook conflict by removing hook script from
Line 21: all servers and engine database
Line 22: - api/cluster/{id}/glusterhooks/{id}
Line 17: lists all gluster hooks in the cluster along with
Line 18: conflict status
Line 19: - api/cluster/{id}/glusterhooks/{glusterhook:id}|rel=delete
Line 20: resolve missing hook conflict by removing hook script from
Line 21: all servers and engine database
Since delete was also removing the resource from engine database (not just from
servers in the cluster), thought it would be candidate for DELETE verb.
Line 22: - api/cluster/{id}/glusterhooks/{id}
Line 23: show details of a gluster hook
Line 24:
Line 25: actions supported:
Line 27: enables hook in all servers in the cluster
Line 28: - disable
Line 29: disables hook in all servers in the cluster
Line 30: - resolve
Line 31: action.resolutionType = COPY
Done
Line 32: resolve content conflict by copying content from either
Line 33: engine or from one of the servers to all or servers where
Line 34: the hook is missing as applicable (based on parameters)
Line 35: action.resolutionType = ADD
Line 34: the hook is missing as applicable (based on parameters)
Line 35: action.resolutionType = ADD
Line 36: resolve missing hook conflict by copying hook stored in
Line 37: engine database to all servers where the hook is missing
Line 38:
Done
Line 39: Change-Id: Ibf9c0299977448e0b50feeed6e38a015c60b86fd
--
To view, visit http://gerrit.ovirt.org/16512
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ibf9c0299977448e0b50feeed6e38a015c60b86fd
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Sahina Bose <[email protected]>
Gerrit-Reviewer: Kanagaraj M <[email protected]>
Gerrit-Reviewer: Michael Pasternak <[email protected]>
Gerrit-Reviewer: Sahina Bose <[email protected]>
Gerrit-Reviewer: Shubhendu Tripathi <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches