Roy Golan has posted comments on this change. Change subject: WIP: engine: fetch exit reason from VDSM ......................................................................
Patch Set 5: (2 comments) http://gerrit.ovirt.org/#/c/23946/5/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmExitReason.java File backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmExitReason.java: Line 20: Line 21: private final static VmExitReason[] reasons = values(); // cache the array Line 22: Line 23: public int getValue() { Line 24: return this.ordinal(); look at VmStatus.java - that's a know pitfall with enums. i.e the getValue of Success == 1 because of the ordinal is is zero based order of the members. and if later we would remove AdminShutdown, then the UserShutdown getVAlue would == 6 you probably meant to return the reason variable. an enum is a great java utility. all members are final. and values() is final alreay so no need to cache it to get a forValue mapping you need to create a mapping between the reason value and the enum member. Line 25: } Line 26: Line 27: public static VmExitReason forValue(int value) { Line 28: return reasons[value+1]; // because we prepended Unknown(-1) http://gerrit.ovirt.org/#/c/23946/5/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java File backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java: Line 223: if (xmlRpcStruct.containsKey(VdsProperties.exit_message)) { Line 224: String exitMsg = (String) xmlRpcStruct.get(VdsProperties.exit_message); Line 225: vm.setExitMessage(exitMsg); Line 226: } Line 227: if (xmlRpcStruct.containsKey(VdsProperties.exit_reason)) { still wondering why can't we settle with exit_code. Line 228: String exitReasonStr = xmlRpcStruct.get(VdsProperties.exit_reason).toString(); Line 229: vm.setExitReason(VmExitReason.forValue(Integer.parseInt(exitReasonStr))); Line 230: } else { Line 231: vm.setExitReason(VmExitReason.Unknown); -- To view, visit http://gerrit.ovirt.org/23946 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib36f06f3ba63a743d624e417fe2c96b84dda60be Gerrit-PatchSet: 5 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Francesco Romani <from...@redhat.com> Gerrit-Reviewer: Francesco Romani <from...@redhat.com> Gerrit-Reviewer: Roy Golan <rgo...@redhat.com> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches