Volumes page should not show inactive instances.
* fixes bug 917779 Change-Id: Ic804b0c9d978c36974a0f3bef7c017abe5847c90
This commit is contained in:
parent
4b4bbd4a5e
commit
a67402595b
@ -18,6 +18,7 @@ from horizon import forms
|
|||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from novaclient import exceptions as novaclient_exceptions
|
from novaclient import exceptions as novaclient_exceptions
|
||||||
|
|
||||||
|
from .tables import ACTIVE_STATES
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -59,8 +60,9 @@ class AttachForm(forms.SelfHandlingForm):
|
|||||||
instance_list = kwargs.get('initial', {}).get('instances', [])
|
instance_list = kwargs.get('initial', {}).get('instances', [])
|
||||||
instances = [('', "Select an instance")]
|
instances = [('', "Select an instance")]
|
||||||
for instance in instance_list:
|
for instance in instance_list:
|
||||||
instances.append((instance.id, '%s (%s)' % (instance.name,
|
if instance.status in ACTIVE_STATES:
|
||||||
instance.id)))
|
instances.append((instance.id, '%s (%s)' % (instance.name,
|
||||||
|
instance.id)))
|
||||||
self.fields['instance'].choices = instances
|
self.fields['instance'].choices = instances
|
||||||
|
|
||||||
def handle(self, request, data):
|
def handle(self, request, data):
|
||||||
|
@ -40,4 +40,8 @@ class VolumeViewTests(test.TestCase):
|
|||||||
url = reverse('horizon:nova:instances_and_volumes:volumes:attach',
|
url = reverse('horizon:nova:instances_and_volumes:volumes:attach',
|
||||||
args=[volume.id])
|
args=[volume.id])
|
||||||
res = self.client.get(url)
|
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)
|
self.assertEqual(res.status_code, 200)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user