raise error when name is more than 32 when creating target group
This commit is contained in:
parent
a579280b7a
commit
d4c6111c40
3 changed files with 29 additions and 1 deletions
|
|
@ -166,3 +166,11 @@ class DuplicatePriorityError(ELBClientError):
|
|||
super(DuplicatePriorityError, self).__init__(
|
||||
"ValidationError",
|
||||
"Priority '%s' was provided multiple times" % invalid_value)
|
||||
|
||||
|
||||
class InvalidTargetGroupNameError(ELBClientError):
|
||||
|
||||
def __init__(self, invalid_name):
|
||||
super(InvalidTargetGroupNameError, self).__init__(
|
||||
"ValidationError",
|
||||
"Target group name '%s' cannot be longer than '32' characters" % invalid_name)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ from .exceptions import (
|
|||
ActionTargetGroupNotFoundError,
|
||||
InvalidDescribeRulesRequest,
|
||||
RuleNotFoundError,
|
||||
DuplicatePriorityError
|
||||
DuplicatePriorityError,
|
||||
InvalidTargetGroupNameError
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -264,6 +265,8 @@ class ELBv2Backend(BaseBackend):
|
|||
return [rule]
|
||||
|
||||
def create_target_group(self, name, **kwargs):
|
||||
if len(name) > 32:
|
||||
raise InvalidTargetGroupNameError(name)
|
||||
for target_group in self.target_groups.values():
|
||||
if target_group.name == name:
|
||||
raise DuplicateTargetGroupName()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue