Disable LB panel by default; allow UUID for Sec Group ID.
A couple fixes for Quantum:
* The Load Balancers panel is now no longer enabled by
default since it is disabled by default in Quantum.
* Security Groups and Security Group Rules now support both
Nova's integer IDs and Quantum's UUID IDs.
* Regroups all the Quantum panels into a "Manage Network"
panel group to match "Manage Compute" above it.
* Adds tests for both int and UUID ids in the Security
Group test suite.
Fixes bug 1153477 and fixes bug 1155244.
Change-Id: I2327901634a83f95c5cff4ba91c8c7c32a0ad8af
This commit is contained in:
@@ -30,6 +30,7 @@ from horizon.utils.validators import validate_port_range
|
||||
from horizon.utils import fields
|
||||
|
||||
from openstack_dashboard import api
|
||||
from ..floating_ips.utils import get_int_or_uuid
|
||||
|
||||
|
||||
class CreateGroup(forms.SelfHandlingForm):
|
||||
@@ -58,7 +59,7 @@ class CreateGroup(forms.SelfHandlingForm):
|
||||
|
||||
|
||||
class AddRule(forms.SelfHandlingForm):
|
||||
id = forms.IntegerField(widget=forms.HiddenInput())
|
||||
id = forms.CharField(widget=forms.HiddenInput())
|
||||
ip_protocol = forms.ChoiceField(label=_('IP Protocol'),
|
||||
choices=[('tcp', _('TCP')),
|
||||
('udp', _('UDP')),
|
||||
@@ -232,7 +233,7 @@ class AddRule(forms.SelfHandlingForm):
|
||||
try:
|
||||
rule = api.nova.security_group_rule_create(
|
||||
request,
|
||||
data['id'],
|
||||
get_int_or_uuid(data['id']),
|
||||
data['ip_protocol'],
|
||||
data['from_port'],
|
||||
data['to_port'],
|
||||
|
||||
@@ -22,6 +22,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from horizon import tables
|
||||
|
||||
from openstack_dashboard import api
|
||||
from ..floating_ips.utils import get_int_or_uuid
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@@ -59,7 +60,7 @@ class SecurityGroupsTable(tables.DataTable):
|
||||
description = tables.Column("description", verbose_name=_("Description"))
|
||||
|
||||
def sanitize_id(self, obj_id):
|
||||
return int(obj_id)
|
||||
return get_int_or_uuid(obj_id)
|
||||
|
||||
class Meta:
|
||||
name = "security_groups"
|
||||
@@ -109,7 +110,7 @@ class RulesTable(tables.DataTable):
|
||||
source = tables.Column(get_source, verbose_name=_("Source"))
|
||||
|
||||
def sanitize_id(self, obj_id):
|
||||
return int(obj_id)
|
||||
return get_int_or_uuid(obj_id)
|
||||
|
||||
def get_object_display(self, rule):
|
||||
return unicode(rule)
|
||||
|
||||
@@ -106,7 +106,6 @@ class SecurityGroupsViewTests(test.TestCase):
|
||||
api.nova.security_group_get(IsA(http.HttpRequest),
|
||||
sec_group.id).AndReturn(sec_group)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(self.detail_url)
|
||||
self.assertTemplateUsed(res,
|
||||
'project/access_and_security/security_groups/detail.html')
|
||||
@@ -371,3 +370,27 @@ class SecurityGroupsViewTests(test.TestCase):
|
||||
|
||||
self.assertEqual(strip_absolute_base(handled['location']),
|
||||
INDEX_URL)
|
||||
|
||||
|
||||
class SecurityGroupsQuantumTests(SecurityGroupsViewTests):
|
||||
def setUp(self):
|
||||
super(SecurityGroupsQuantumTests, self).setUp()
|
||||
|
||||
self._sec_groups_orig = self.security_groups
|
||||
self.security_groups = self.security_groups_uuid
|
||||
|
||||
self._sec_group_rules_orig = self.security_group_rules
|
||||
self.security_group_rules = self.security_group_rules_uuid
|
||||
|
||||
sec_group = self.security_groups.first()
|
||||
self.detail_url = reverse('horizon:project:access_and_security:'
|
||||
'security_groups:detail',
|
||||
args=[sec_group.id])
|
||||
self.edit_url = reverse('horizon:project:access_and_security:'
|
||||
'security_groups:add_rule',
|
||||
args=[sec_group.id])
|
||||
|
||||
def tearDown(self):
|
||||
self.security_groups = self._sec_groups_orig
|
||||
self.security_group_rules = self._sec_group_rules_orig
|
||||
super(SecurityGroupsQuantumTests, self).tearDown()
|
||||
|
||||
@@ -31,6 +31,7 @@ from horizon import forms
|
||||
from horizon import tables
|
||||
|
||||
from openstack_dashboard import api
|
||||
from ..floating_ips.utils import get_int_or_uuid
|
||||
from .forms import CreateGroup, AddRule
|
||||
from .tables import RulesTable
|
||||
|
||||
@@ -43,7 +44,7 @@ class DetailView(tables.DataTableView):
|
||||
template_name = 'project/access_and_security/security_groups/detail.html'
|
||||
|
||||
def get_data(self):
|
||||
security_group_id = int(self.kwargs['security_group_id'])
|
||||
security_group_id = get_int_or_uuid(self.kwargs['security_group_id'])
|
||||
try:
|
||||
self.object = api.nova.security_group_get(self.request,
|
||||
security_group_id)
|
||||
@@ -86,7 +87,7 @@ class AddRuleView(forms.ModalFormView):
|
||||
|
||||
security_groups = []
|
||||
for group in groups:
|
||||
if group.id == int(self.kwargs['security_group_id']):
|
||||
if group.id == get_int_or_uuid(self.kwargs['security_group_id']):
|
||||
security_groups.append((group.id,
|
||||
_("%s (current)") % group.name))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user