Merge "Disable LB panel by default; allow UUID for Sec Group ID."
This commit is contained in:
commit
6a2c1763d4
@ -149,7 +149,7 @@ class SecurityGroup(APIResourceWrapper):
|
|||||||
def rules(self):
|
def rules(self):
|
||||||
"""Wraps transmitted rule info in the novaclient rule class."""
|
"""Wraps transmitted rule info in the novaclient rule class."""
|
||||||
if "_rules" not in self.__dict__:
|
if "_rules" not in self.__dict__:
|
||||||
manager = nova_rules.SecurityGroupRuleManager
|
manager = nova_rules.SecurityGroupRuleManager(None)
|
||||||
self._rules = [nova_rules.SecurityGroupRule(manager, rule)
|
self._rules = [nova_rules.SecurityGroupRule(manager, rule)
|
||||||
for rule in self._apiresource.rules]
|
for rule in self._apiresource.rules]
|
||||||
return self.__dict__['_rules']
|
return self.__dict__['_rules']
|
||||||
|
@ -30,6 +30,7 @@ from horizon.utils.validators import validate_port_range
|
|||||||
from horizon.utils import fields
|
from horizon.utils import fields
|
||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
|
from ..floating_ips.utils import get_int_or_uuid
|
||||||
|
|
||||||
|
|
||||||
class CreateGroup(forms.SelfHandlingForm):
|
class CreateGroup(forms.SelfHandlingForm):
|
||||||
@ -58,7 +59,7 @@ class CreateGroup(forms.SelfHandlingForm):
|
|||||||
|
|
||||||
|
|
||||||
class AddRule(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'),
|
ip_protocol = forms.ChoiceField(label=_('IP Protocol'),
|
||||||
choices=[('tcp', _('TCP')),
|
choices=[('tcp', _('TCP')),
|
||||||
('udp', _('UDP')),
|
('udp', _('UDP')),
|
||||||
@ -232,7 +233,7 @@ class AddRule(forms.SelfHandlingForm):
|
|||||||
try:
|
try:
|
||||||
rule = api.nova.security_group_rule_create(
|
rule = api.nova.security_group_rule_create(
|
||||||
request,
|
request,
|
||||||
data['id'],
|
get_int_or_uuid(data['id']),
|
||||||
data['ip_protocol'],
|
data['ip_protocol'],
|
||||||
data['from_port'],
|
data['from_port'],
|
||||||
data['to_port'],
|
data['to_port'],
|
||||||
|
@ -22,6 +22,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
from horizon import tables
|
from horizon import tables
|
||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
|
from ..floating_ips.utils import get_int_or_uuid
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -59,7 +60,7 @@ class SecurityGroupsTable(tables.DataTable):
|
|||||||
description = tables.Column("description", verbose_name=_("Description"))
|
description = tables.Column("description", verbose_name=_("Description"))
|
||||||
|
|
||||||
def sanitize_id(self, obj_id):
|
def sanitize_id(self, obj_id):
|
||||||
return int(obj_id)
|
return get_int_or_uuid(obj_id)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
name = "security_groups"
|
name = "security_groups"
|
||||||
@ -109,7 +110,7 @@ class RulesTable(tables.DataTable):
|
|||||||
source = tables.Column(get_source, verbose_name=_("Source"))
|
source = tables.Column(get_source, verbose_name=_("Source"))
|
||||||
|
|
||||||
def sanitize_id(self, obj_id):
|
def sanitize_id(self, obj_id):
|
||||||
return int(obj_id)
|
return get_int_or_uuid(obj_id)
|
||||||
|
|
||||||
def get_object_display(self, rule):
|
def get_object_display(self, rule):
|
||||||
return unicode(rule)
|
return unicode(rule)
|
||||||
|
@ -106,7 +106,6 @@ class SecurityGroupsViewTests(test.TestCase):
|
|||||||
api.nova.security_group_get(IsA(http.HttpRequest),
|
api.nova.security_group_get(IsA(http.HttpRequest),
|
||||||
sec_group.id).AndReturn(sec_group)
|
sec_group.id).AndReturn(sec_group)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
res = self.client.get(self.detail_url)
|
res = self.client.get(self.detail_url)
|
||||||
self.assertTemplateUsed(res,
|
self.assertTemplateUsed(res,
|
||||||
'project/access_and_security/security_groups/detail.html')
|
'project/access_and_security/security_groups/detail.html')
|
||||||
@ -371,3 +370,27 @@ class SecurityGroupsViewTests(test.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(strip_absolute_base(handled['location']),
|
self.assertEqual(strip_absolute_base(handled['location']),
|
||||||
INDEX_URL)
|
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 horizon import tables
|
||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
|
from ..floating_ips.utils import get_int_or_uuid
|
||||||
from .forms import CreateGroup, AddRule
|
from .forms import CreateGroup, AddRule
|
||||||
from .tables import RulesTable
|
from .tables import RulesTable
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ class DetailView(tables.DataTableView):
|
|||||||
template_name = 'project/access_and_security/security_groups/detail.html'
|
template_name = 'project/access_and_security/security_groups/detail.html'
|
||||||
|
|
||||||
def get_data(self):
|
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:
|
try:
|
||||||
self.object = api.nova.security_group_get(self.request,
|
self.object = api.nova.security_group_get(self.request,
|
||||||
security_group_id)
|
security_group_id)
|
||||||
@ -86,7 +87,7 @@ class AddRuleView(forms.ModalFormView):
|
|||||||
|
|
||||||
security_groups = []
|
security_groups = []
|
||||||
for group in 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,
|
security_groups.append((group.id,
|
||||||
_("%s (current)") % group.name))
|
_("%s (current)") % group.name))
|
||||||
else:
|
else:
|
||||||
|
@ -26,11 +26,16 @@ class BasePanels(horizon.PanelGroup):
|
|||||||
'instances',
|
'instances',
|
||||||
'volumes',
|
'volumes',
|
||||||
'images_and_snapshots',
|
'images_and_snapshots',
|
||||||
'access_and_security',
|
'access_and_security',)
|
||||||
'networks',
|
|
||||||
|
|
||||||
|
class NetworkPanels(horizon.PanelGroup):
|
||||||
|
slug = "network"
|
||||||
|
name = _("Manage Network")
|
||||||
|
panels = ('networks',
|
||||||
'routers',
|
'routers',
|
||||||
'network_topology',
|
'loadbalancers',
|
||||||
'loadbalancers')
|
'network_topology',)
|
||||||
|
|
||||||
|
|
||||||
class ObjectStorePanels(horizon.PanelGroup):
|
class ObjectStorePanels(horizon.PanelGroup):
|
||||||
@ -42,7 +47,7 @@ class ObjectStorePanels(horizon.PanelGroup):
|
|||||||
class Project(horizon.Dashboard):
|
class Project(horizon.Dashboard):
|
||||||
name = _("Project")
|
name = _("Project")
|
||||||
slug = "project"
|
slug = "project"
|
||||||
panels = (BasePanels, ObjectStorePanels)
|
panels = (BasePanels, NetworkPanels, ObjectStorePanels)
|
||||||
default_panel = 'overview'
|
default_panel = 'overview'
|
||||||
supports_tenants = True
|
supports_tenants = True
|
||||||
|
|
||||||
|
@ -11,6 +11,6 @@ class LoadBalancer(horizon.Panel):
|
|||||||
slug = "loadbalancers"
|
slug = "loadbalancers"
|
||||||
permissions = ('openstack.services.network',)
|
permissions = ('openstack.services.network',)
|
||||||
|
|
||||||
if hasattr(settings, 'OPENSTACK_QUANTUM_NETWORK'):
|
|
||||||
if getattr(settings, 'OPENSTACK_QUANTUM_NETWORK')['enable_lb']:
|
if getattr(settings, 'OPENSTACK_QUANTUM_NETWORK', {}).get('enable_lb', False):
|
||||||
dashboard.Project.register(LoadBalancer)
|
dashboard.Project.register(LoadBalancer)
|
||||||
|
@ -122,7 +122,7 @@ OPENSTACK_HYPERVISOR_FEATURES = {
|
|||||||
# services provided by quantum. Currently only the load balancer service
|
# services provided by quantum. Currently only the load balancer service
|
||||||
# is available.
|
# is available.
|
||||||
OPENSTACK_QUANTUM_NETWORK = {
|
OPENSTACK_QUANTUM_NETWORK = {
|
||||||
'enable_lb': True
|
'enable_lb': False
|
||||||
}
|
}
|
||||||
|
|
||||||
# OPENSTACK_ENDPOINT_TYPE specifies the endpoint type to use for the endpoints
|
# OPENSTACK_ENDPOINT_TYPE specifies the endpoint type to use for the endpoints
|
||||||
|
@ -141,7 +141,9 @@ def data(TEST):
|
|||||||
TEST.flavors = TestDataContainer()
|
TEST.flavors = TestDataContainer()
|
||||||
TEST.keypairs = TestDataContainer()
|
TEST.keypairs = TestDataContainer()
|
||||||
TEST.security_groups = TestDataContainer()
|
TEST.security_groups = TestDataContainer()
|
||||||
|
TEST.security_groups_uuid = TestDataContainer()
|
||||||
TEST.security_group_rules = TestDataContainer()
|
TEST.security_group_rules = TestDataContainer()
|
||||||
|
TEST.security_group_rules_uuid = TestDataContainer()
|
||||||
TEST.volumes = TestDataContainer()
|
TEST.volumes = TestDataContainer()
|
||||||
TEST.quotas = TestDataContainer()
|
TEST.quotas = TestDataContainer()
|
||||||
TEST.quota_usages = TestDataContainer()
|
TEST.quota_usages = TestDataContainer()
|
||||||
@ -229,64 +231,79 @@ def data(TEST):
|
|||||||
dict(name='keyName'))
|
dict(name='keyName'))
|
||||||
TEST.keypairs.add(keypair)
|
TEST.keypairs.add(keypair)
|
||||||
|
|
||||||
# Security Groups
|
# Security Groups and Rules
|
||||||
sg_manager = sec_groups.SecurityGroupManager(None)
|
def generate_security_groups(is_uuid=False):
|
||||||
sec_group_1 = sec_groups.SecurityGroup(sg_manager,
|
|
||||||
{"rules": [],
|
|
||||||
"tenant_id": TEST.tenant.id,
|
|
||||||
"id": 1,
|
|
||||||
"name": u"default",
|
|
||||||
"description": u"default"})
|
|
||||||
sec_group_2 = sec_groups.SecurityGroup(sg_manager,
|
|
||||||
{"rules": [],
|
|
||||||
"tenant_id": TEST.tenant.id,
|
|
||||||
"id": 2,
|
|
||||||
"name": u"other_group",
|
|
||||||
"description": u"Not default."})
|
|
||||||
sec_group_3 = sec_groups.SecurityGroup(sg_manager,
|
|
||||||
{"rules": [],
|
|
||||||
"tenant_id": TEST.tenant.id,
|
|
||||||
"id": 3,
|
|
||||||
"name": u"another_group",
|
|
||||||
"description": u"Not default."})
|
|
||||||
|
|
||||||
rule = {'id': 1,
|
def get_id(is_uuid):
|
||||||
'ip_protocol': u"tcp",
|
global current_int_id
|
||||||
'from_port': u"80",
|
if is_uuid:
|
||||||
'to_port': u"80",
|
return str(uuid.uuid4())
|
||||||
'parent_group_id': 1,
|
else:
|
||||||
'ip_range': {'cidr': u"0.0.0.0/32"}}
|
get_id.current_int_id += 1
|
||||||
|
return get_id.current_int_id
|
||||||
|
|
||||||
icmp_rule = {'id': 2,
|
get_id.current_int_id = 0
|
||||||
'ip_protocol': u"icmp",
|
|
||||||
'from_port': u"9",
|
|
||||||
'to_port': u"5",
|
|
||||||
'parent_group_id': 1,
|
|
||||||
'ip_range': {'cidr': u"0.0.0.0/32"}}
|
|
||||||
|
|
||||||
group_rule = {'id': 3,
|
sg_manager = sec_groups.SecurityGroupManager(None)
|
||||||
'ip_protocol': u"tcp",
|
rule_manager = rules.SecurityGroupRuleManager(None)
|
||||||
'from_port': u"80",
|
|
||||||
'to_port': u"80",
|
|
||||||
'parent_group_id': 1,
|
|
||||||
'source_group_id': 1}
|
|
||||||
|
|
||||||
rule_obj = rules.SecurityGroupRule(rules.SecurityGroupRuleManager(None),
|
sec_group_1 = sec_groups.SecurityGroup(sg_manager,
|
||||||
rule)
|
{"rules": [],
|
||||||
rule_obj2 = rules.SecurityGroupRule(rules.SecurityGroupRuleManager(None),
|
"tenant_id": TEST.tenant.id,
|
||||||
icmp_rule)
|
"id": get_id(is_uuid),
|
||||||
rule_obj3 = rules.SecurityGroupRule(rules.SecurityGroupRuleManager(None),
|
"name": u"default",
|
||||||
group_rule)
|
"description": u"default"})
|
||||||
|
sec_group_2 = sec_groups.SecurityGroup(sg_manager,
|
||||||
|
{"rules": [],
|
||||||
|
"tenant_id": TEST.tenant.id,
|
||||||
|
"id": get_id(is_uuid),
|
||||||
|
"name": u"other_group",
|
||||||
|
"description": u"NotDefault."})
|
||||||
|
sec_group_3 = sec_groups.SecurityGroup(sg_manager,
|
||||||
|
{"rules": [],
|
||||||
|
"tenant_id": TEST.tenant.id,
|
||||||
|
"id": get_id(is_uuid),
|
||||||
|
"name": u"another_group",
|
||||||
|
"description": u"NotDefault."})
|
||||||
|
|
||||||
TEST.security_group_rules.add(rule_obj)
|
rule = {'id': get_id(is_uuid),
|
||||||
TEST.security_group_rules.add(rule_obj2)
|
'ip_protocol': u"tcp",
|
||||||
TEST.security_group_rules.add(rule_obj3)
|
'from_port': u"80",
|
||||||
|
'to_port': u"80",
|
||||||
|
'parent_group_id': sec_group_1.id,
|
||||||
|
'ip_range': {'cidr': u"0.0.0.0/32"}}
|
||||||
|
|
||||||
sec_group_1.rules = [rule_obj]
|
icmp_rule = {'id': get_id(is_uuid),
|
||||||
sec_group_2.rules = [rule_obj]
|
'ip_protocol': u"icmp",
|
||||||
TEST.security_groups.add(sec_group_1, sec_group_2, sec_group_3)
|
'from_port': u"9",
|
||||||
|
'to_port': u"5",
|
||||||
|
'parent_group_id': sec_group_1.id,
|
||||||
|
'ip_range': {'cidr': u"0.0.0.0/32"}}
|
||||||
|
|
||||||
# Security Group Rules
|
group_rule = {'id': 3,
|
||||||
|
'ip_protocol': u"tcp",
|
||||||
|
'from_port': u"80",
|
||||||
|
'to_port': u"80",
|
||||||
|
'parent_group_id': sec_group_1.id,
|
||||||
|
'source_group_id': sec_group_1.id}
|
||||||
|
|
||||||
|
rule_obj = rules.SecurityGroupRule(rule_manager, rule)
|
||||||
|
rule_obj2 = rules.SecurityGroupRule(rule_manager, icmp_rule)
|
||||||
|
rule_obj3 = rules.SecurityGroupRule(rule_manager, group_rule)
|
||||||
|
|
||||||
|
sec_group_1.rules = [rule_obj]
|
||||||
|
sec_group_2.rules = [rule_obj]
|
||||||
|
|
||||||
|
return {"rules": [rule_obj, rule_obj2, rule_obj3],
|
||||||
|
"groups": [sec_group_1, sec_group_2, sec_group_3]}
|
||||||
|
|
||||||
|
sg_data = generate_security_groups()
|
||||||
|
TEST.security_group_rules.add(*sg_data["rules"])
|
||||||
|
TEST.security_groups.add(*sg_data["groups"])
|
||||||
|
|
||||||
|
sg_uuid_data = generate_security_groups(is_uuid=True)
|
||||||
|
TEST.security_group_rules_uuid.add(*sg_uuid_data["rules"])
|
||||||
|
TEST.security_groups_uuid.add(*sg_uuid_data["groups"])
|
||||||
|
|
||||||
# Quota Sets
|
# Quota Sets
|
||||||
quota_data = dict(metadata_items='1',
|
quota_data = dict(metadata_items='1',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user