Skip to content

Commit

Permalink
Volumes page should not show inactive instances.
Browse files Browse the repository at this point in the history
  * fixes bug 917779

Change-Id: Ic804b0c9d978c36974a0f3bef7c017abe5847c90
  • Loading branch information
emmasteimann authored and jakedahn committed Feb 29, 2012
1 parent 4b4bbd4 commit a674025
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -18,6 +18,7 @@
from horizon import exceptions
from novaclient import exceptions as novaclient_exceptions

from .tables import ACTIVE_STATES

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -59,8 +60,9 @@ def __init__(self, *args, **kwargs):
instance_list = kwargs.get('initial', {}).get('instances', [])
instances = [('', "Select an instance")]
for instance in instance_list:
instances.append((instance.id, '%s (%s)' % (instance.name,
instance.id)))
if instance.status in ACTIVE_STATES:
instances.append((instance.id, '%s (%s)' % (instance.name,
instance.id)))
self.fields['instance'].choices = instances

def handle(self, request, data):
Expand Down
Expand Up @@ -40,4 +40,8 @@ def test_edit_attachments(self):
url = reverse('horizon:nova:instances_and_volumes:volumes:attach',
args=[volume.id])
res = self.client.get(url)
# Asserting length of 2 accounts for the one instance option,
# and the one 'Choose Instance' option.
self.assertEqual(len(res.context['form'].fields['instance']._choices),
2)
self.assertEqual(res.status_code, 200)

0 comments on commit a674025

Please sign in to comment.