Support Security Group Name Prefix Customization

As of now, if CONF.trove_security_groups_support == True, then a
Security Group is created for every new Instance, following the
naming scheme of: "SecGroup_<Instance's UUID>".

Nicira NVP for Quantum enforces a Security Group naming limitation of
40 chars maximum. Given the UUID's length, this only leaves 2
characters for the prefix, e.g. 'SG' vs. 'SecGroup'.

Even in lieu of restrictions, it's not inconceivable that a
vendor/user might want to customize the naming scheme of their
Security Groups to align with other cloud providers, etc.

Change-Id: I1043e15c71607cabe2fd6f72f64705e80cd2cde1
Closes-Bug: #1218589
This commit is contained in:
Auston McReynolds 2013-08-29 12:58:45 -07:00
parent 797fe9c2d3
commit 157e1807b4
2 changed files with 3 additions and 1 deletions

View File

@ -122,6 +122,7 @@ common_opts = [
help="Require user hostnames to be IPv4 addresses."),
cfg.BoolOpt('trove_security_groups_support', default=True),
cfg.BoolOpt('trove_security_groups_rules_support', default=True),
cfg.StrOpt('trove_security_group_name_prefix', default='SecGroup'),
cfg.StrOpt('trove_security_group_rule_protocol', default='tcp'),
cfg.IntOpt('trove_security_group_rule_port', default=3306),
cfg.StrOpt('trove_security_group_rule_cidr', default='0.0.0.0/0'),

View File

@ -76,7 +76,8 @@ class SecurityGroup(DatabaseModelBase):
@classmethod
def create_for_instance(cls, instance_id, context):
# Create a new security group
name = _("SecGroup_%s") % instance_id
name = _("%s_%s") %\
(CONF.trove_security_group_name_prefix, instance_id)
description = _("Security Group for %s") % instance_id
sec_group = cls.create_sec_group(name, description, context)