Inconsistent logic for Pause/Suspend action buttons
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Dashboard (Horizon) |
Fix Released
|
Low
|
Tihomir Trifonov |
Bug Description
It seems something was changed in the BatchAction logic.
Here is the code for TogglePause(the same is for ToggleSuspend):
class TogglePause(
name = "pause"
action_present = _("Pause")
action_past = _("Paused")
data_
data_
def allowed(self, request, instance=None):
if not instance:
return True
self.paused = instance.status == "PAUSED"
if self.paused:
return instance.status in ACTIVE_STATES
def action(self, request, obj_id):
if getattr(self, 'paused', False):
else:
1.
def allowed(..):
self.
As seems in code, action_present is only used in __init__() of base class, and changing it in allowed() method has no effect on the final result in UI.
In the base class has a method called def update(), which is supposed to handle cases like toggle buttons. But it is not used here.
Also, allowed() returns True if instance is None ? As long as there is a valid VM instance, this variable will be never None.
And return instance.status in ACTIVE_STATES - will return true only if the status is ACTIVE. And False if it is 'PAUSED'. So we rename the button label to 'Unpause', but it will be never displayed.
2. def action(..)
if getattr(self, 'paused', False):
According to me that means - if self.instance == "PAUSED" then server_pause() ? Should'n be it the opposite?
3. self.action_past - should be toggled after server_unpause() is called as it is dependant on the action.
Attached is a proposed fix for that. If you find it useful, I can commit and create a review with it.
Changed in horizon: | |
status: | New → Confirmed |
importance: | Undecided → Low |
milestone: | none → essex-4 |
Changed in horizon: | |
assignee: | nobody → Tihomir Trifonov (ttrifonov) |
Changed in horizon: | |
status: | Fix Committed → Fix Released |
Changed in horizon: | |
milestone: | essex-4 → 2012.1 |
Fix proposed to branch: master /review. openstack. org/3697
Review: https:/