)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"45d52f27ca6a2743f1a3dffb21ec06b18d765a1a","unresolved":false,"context_lines":[{"line_number":4,"context_line":"Commit:     Balazs Gibizer \u003cbalazs.gibizer@ericsson.com\u003e"},{"line_number":5,"context_line":"CommitDate: 2016-09-02 07:30:44 +0000"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"Removed enum duplication from nova.compute"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"There are many state constants held within nova.compute. Because these"},{"line_number":10,"context_line":"now need to be used in versioned notifications, they were converted into"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":8,"id":"9a89bdaa_97ef3386","line":7,"updated":"2016-09-07 13:48:29.000000000","message":"Well, technically you\u0027re not removing the *enum* duplication from nova.compute. You are removing the duplicate reference of hard-coded constant strings and numbers. :) There is still duplication of the symbols.","commit_id":"7e435fa8f39537f1d915b1b3775c14866281ed6a"}],"nova/compute/power_state.py":[{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"9f4774b56111a09a1a791140052d987b1f9eac0b","unresolved":false,"context_lines":[{"line_number":29,"context_line":"# NOTE(maoy): These are *not* virDomainState values from libvirt."},{"line_number":30,"context_line":"# The hex value happens to match virDomainState for backward-compatibility"},{"line_number":31,"context_line":"# reasons."},{"line_number":32,"context_line":"NOSTATE \u003d 0x00"},{"line_number":33,"context_line":"RUNNING \u003d 0x01"},{"line_number":34,"context_line":"PAUSED \u003d 0x03"},{"line_number":35,"context_line":"SHUTDOWN \u003d 0x04  # the VM is powered off"}],"source_content_type":"text/x-python","patch_set":1,"id":"3aaa91ec_164f32bf","line":32,"updated":"2016-06-28 15:49:07.000000000","message":"These values are also duplicated in the fields.py and I think that can be easily removed as well in this patch.","commit_id":"a4cda54eb100c06f6576091e1389cee87696c122"},{"author":{"_account_id":11803,"name":"Ryan Rossiter","email":"rlrossit@us.ibm.com","username":"rlrossiter"},"change_message_id":"701a133392ea942717177eed109a1c2959fada9e","unresolved":false,"context_lines":[{"line_number":29,"context_line":"# NOTE(maoy): These are *not* virDomainState values from libvirt."},{"line_number":30,"context_line":"# The hex value happens to match virDomainState for backward-compatibility"},{"line_number":31,"context_line":"# reasons."},{"line_number":32,"context_line":"NOSTATE \u003d 0x00"},{"line_number":33,"context_line":"RUNNING \u003d 0x01"},{"line_number":34,"context_line":"PAUSED \u003d 0x03"},{"line_number":35,"context_line":"SHUTDOWN \u003d 0x04  # the VM is powered off"}],"source_content_type":"text/x-python","patch_set":1,"id":"3aaa91ec_e47f0515","line":32,"in_reply_to":"3aaa91ec_164f32bf","updated":"2016-06-29 20:45:18.000000000","message":"They were used as the keys in the dict in the enum, so I pulled them out into more constants within the enum. Hopefully that\u0027s what you had in mind to get these converted over too.","commit_id":"a4cda54eb100c06f6576091e1389cee87696c122"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"3bebddd6834d809ff2c78cfc60843582bd2c3087","unresolved":false,"context_lines":[{"line_number":39,"context_line":"# TODO(justinsb): Power state really needs to be a proper class,"},{"line_number":40,"context_line":"# so that we\u0027re not locked into the libvirt status codes and can put mapping"},{"line_number":41,"context_line":"# logic here rather than spread throughout the code"},{"line_number":42,"context_line":"STATE_MAP \u003d {"},{"line_number":43,"context_line":"    NOSTATE: fields.InstancePowerState.NOSTATE,"},{"line_number":44,"context_line":"    RUNNING: fields.InstancePowerState.RUNNING,"},{"line_number":45,"context_line":"    PAUSED: fields.InstancePowerState.PAUSED,"},{"line_number":46,"context_line":"    SHUTDOWN: fields.InstancePowerState.SHUTDOWN,"},{"line_number":47,"context_line":"    CRASHED: fields.InstancePowerState.CRASHED,"},{"line_number":48,"context_line":"    SUSPENDED: fields.InstancePowerState.SUSPENDED,"},{"line_number":49,"context_line":"}"}],"source_content_type":"text/x-python","patch_set":3,"id":"1aa78d24_89bb3172","line":49,"range":{"start_line":42,"start_character":0,"end_line":49,"end_character":1},"updated":"2016-07-04 09:29:48.000000000","message":"As far as I see this STATE_MAP is just the same dict than the VALUE_MAP in the enum. Could we just write the following?\n\n  STATE_MAP \u003d fields.InsatncePowerState.VALUE_MAP","commit_id":"2eee00c875e89e21445910797cad5f8a4e5b27ab"},{"author":{"_account_id":11803,"name":"Ryan Rossiter","email":"rlrossit@us.ibm.com","username":"rlrossiter"},"change_message_id":"bcf2f1b2b6598b0a059236d7c5c5b2a83ce5c4df","unresolved":false,"context_lines":[{"line_number":39,"context_line":"# TODO(justinsb): Power state really needs to be a proper class,"},{"line_number":40,"context_line":"# so that we\u0027re not locked into the libvirt status codes and can put mapping"},{"line_number":41,"context_line":"# logic here rather than spread throughout the code"},{"line_number":42,"context_line":"STATE_MAP \u003d {"},{"line_number":43,"context_line":"    NOSTATE: fields.InstancePowerState.NOSTATE,"},{"line_number":44,"context_line":"    RUNNING: fields.InstancePowerState.RUNNING,"},{"line_number":45,"context_line":"    PAUSED: fields.InstancePowerState.PAUSED,"},{"line_number":46,"context_line":"    SHUTDOWN: fields.InstancePowerState.SHUTDOWN,"},{"line_number":47,"context_line":"    CRASHED: fields.InstancePowerState.CRASHED,"},{"line_number":48,"context_line":"    SUSPENDED: fields.InstancePowerState.SUSPENDED,"},{"line_number":49,"context_line":"}"}],"source_content_type":"text/x-python","patch_set":3,"id":"1aa78d24_9f2155a2","line":49,"range":{"start_line":42,"start_character":0,"end_line":49,"end_character":1},"in_reply_to":"1aa78d24_89bb3172","updated":"2016-07-05 17:24:07.000000000","message":"Good call, I didn\u0027t think of that :)","commit_id":"2eee00c875e89e21445910797cad5f8a4e5b27ab"}],"nova/objects/fields.py":[{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"1afa0f73b0b40a5cad2aea723fe86203be41d39d","unresolved":false,"context_lines":[{"line_number":744,"context_line":"        PAUSED_KEY: PAUSED,"},{"line_number":745,"context_line":"        SHUTDOWN_KEY: SHUTDOWN,"},{"line_number":746,"context_line":"        CRASHED_KEY: CRASHED,"},{"line_number":747,"context_line":"        SUSPENDED_KEY: SUSPENDED"},{"line_number":748,"context_line":"    }"},{"line_number":749,"context_line":""},{"line_number":750,"context_line":"    ALL \u003d (NOSTATE, RUNNING, PAUSED, SHUTDOWN, CRASHED, SUSPENDED)"}],"source_content_type":"text/x-python","patch_set":4,"id":"1aa78d24_3c3914d8","line":747,"updated":"2016-07-06 15:40:07.000000000","message":"Hmmm... so the way Dan and I have been doing this in Nova has been to use the index() and from_index() methods to translate between integer and string keys:\n\nhttps://github.com/openstack/nova/blob/1f4711a76afe5baca09a89a744035b24dd908e71/nova/objects/fields.py#L330-L338\n\nI think that is cleaner than having a special _KEY suffix constant for each string key name. In this case, you\u0027re missing 0x02, so you would want to inject some sentinal for that unused value:\n\n class InstancePowerState(Enum):\n\n     _UNUSED \u003d object()\n     NOSTATE \u003d \u0027pending\u0027\n     RUNNING \u003d \u0027running\u0027\n     PAUSED \u003d \u0027paused\u0027\n     SHUTDOWN \u003d \u0027shutdown\u0027\n     CRASHED \u003d \u0027crashed\u0027\n     SUSPENDED \u003d \u0027suspended\u0027\n\n     # The order is important here. If you make changes, only *append*\n     # values to the end of the list.\n     ALL \u003d (\n         NOSTATE,\n         RUNNING,\n         _UNUSED,\n         PAUSED,\n         SHUTDOWN,\n         CRASHED,\n         SUSPENDED,\n     )\n\n     def __init__(self):\n         super(InstancePowerState, self).__init__(\n               valid_values\u003dInstancePowerState.ALL)\n\n     @classmethod\n     def index(cls, value):\n         \"\"\"Return an index into the Enum given a value.\"\"\"\n         return cls.ALL.index(value)\n\n     @classmethod\n     def from_index(cls, index):\n         \"\"\"Return the Enum value at a given index.\"\"\"\n     return cls.ALL[index]","commit_id":"3797318589481e7ff86b7cdbde5c5de0be7c811a"},{"author":{"_account_id":9708,"name":"Balazs Gibizer","display_name":"gibi","email":"gibizer@gmail.com","username":"gibi"},"change_message_id":"704001408c5df57a461f1b056167732492e982cd","unresolved":false,"context_lines":[{"line_number":744,"context_line":"        PAUSED_KEY: PAUSED,"},{"line_number":745,"context_line":"        SHUTDOWN_KEY: SHUTDOWN,"},{"line_number":746,"context_line":"        CRASHED_KEY: CRASHED,"},{"line_number":747,"context_line":"        SUSPENDED_KEY: SUSPENDED"},{"line_number":748,"context_line":"    }"},{"line_number":749,"context_line":""},{"line_number":750,"context_line":"    ALL \u003d (NOSTATE, RUNNING, PAUSED, SHUTDOWN, CRASHED, SUSPENDED)"}],"source_content_type":"text/x-python","patch_set":4,"id":"1ac06dbe_11082728","line":747,"in_reply_to":"1aa78d24_3c3914d8","updated":"2016-08-24 15:17:34.000000000","message":"Can be done. See patch set 6 for the result. The extra _UNUSED enum value causes some object version change I ignored for now as _UNUSED is not used for real. \n\nI had to use a string value for the _UNUSED sentinel to keep the test happy that assert every value in ALL is a valid value of the enum.\n\nI also decided to keep the constants in power_states.py unaffected so that other parts of the nova code does not need to be changed.","commit_id":"3797318589481e7ff86b7cdbde5c5de0be7c811a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"e8007fe4c6b49fa9ab290e4898731d7ead2cab28","unresolved":false,"context_lines":[{"line_number":611,"context_line":"    CRASHED \u003d \u0027crashed\u0027"},{"line_number":612,"context_line":"    SUSPENDED \u003d \u0027suspended\u0027"},{"line_number":613,"context_line":""},{"line_number":614,"context_line":"    VALUE_MAP \u003d {"},{"line_number":615,"context_line":"        0x00: NOSTATE,"},{"line_number":616,"context_line":"        0x01: RUNNING,"},{"line_number":617,"context_line":"        0x03: PAUSED,"},{"line_number":618,"context_line":"        0x04: SHUTDOWN,"},{"line_number":619,"context_line":"        0x06: CRASHED,"},{"line_number":620,"context_line":"        0x07: SUSPENDED"},{"line_number":621,"context_line":"    }"},{"line_number":622,"context_line":""},{"line_number":623,"context_line":"    ALL \u003d (NOSTATE, RUNNING, PAUSED, SHUTDOWN, CRASHED, SUSPENDED)"},{"line_number":624,"context_line":""}],"source_content_type":"text/x-python","patch_set":8,"id":"9a89bdaa_3bf52eec","side":"PARENT","line":621,"range":{"start_line":614,"start_character":4,"end_line":621,"end_character":5},"updated":"2016-09-08 14:47:45.000000000","message":"Nit: I kinda prefer this one to the extra _UNUSED, but there are ups and downs to both approaches.","commit_id":"8f35bb321d26bd7d296c57f4188ec12fcde897c3"},{"author":{"_account_id":10618,"name":"Pavel Kholkin","email":"p.v.holkin@mail.ru","username":"pkholkin"},"change_message_id":"10b0e51b712484b8d5691eb4ef4858e9c18021ec","unresolved":false,"context_lines":[{"line_number":619,"context_line":"        _UNUSED,"},{"line_number":620,"context_line":"        PAUSED,"},{"line_number":621,"context_line":"        SHUTDOWN,"},{"line_number":622,"context_line":"        _UNUSED,"},{"line_number":623,"context_line":"        CRASHED,"},{"line_number":624,"context_line":"        SUSPENDED,"},{"line_number":625,"context_line":"    )"}],"source_content_type":"text/x-python","patch_set":8,"id":"9a89bdaa_25c36358","line":622,"updated":"2016-09-08 09:39:46.000000000","message":"I saw some comments about second _UNUSED, maybe we should add some notes?","commit_id":"7e435fa8f39537f1d915b1b3775c14866281ed6a"}]}
