V2T: Fix bulk rules creation
Need to remove the default rules or else the entire call will fail Change-Id: I06cfa5d670789eeb7e9613c8f9db5741c7f786c4
This commit is contained in:
parent
4c0f3c9a00
commit
e4a7b66502
@ -384,23 +384,37 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
|
|||||||
n_errors = n_errors + 1
|
n_errors = n_errors + 1
|
||||||
|
|
||||||
# Use bulk rules creation for the rules of the SG
|
# Use bulk rules creation for the rules of the SG
|
||||||
if sg_rules:
|
if not sg_rules:
|
||||||
|
continue
|
||||||
rules = []
|
rules = []
|
||||||
for sg_rule in sg_rules:
|
for sg_rule in sg_rules:
|
||||||
|
# skip the default rules that were already created
|
||||||
|
skip = False
|
||||||
|
created_rules = new_sg['security_group'].get(
|
||||||
|
'security_group_rules', [])
|
||||||
|
for rule in created_rules:
|
||||||
|
if (rule['direction'] == sg_rule['direction'] and
|
||||||
|
rule['ethertype'] == sg_rule['ethertype'] and
|
||||||
|
rule['remote_group_id'] ==
|
||||||
|
sg_rule['remote_group_id'] and
|
||||||
|
not rule['protocol']):
|
||||||
|
skip = True
|
||||||
|
break
|
||||||
|
if not skip:
|
||||||
body = self.prepare_security_group_rule(sg_rule)
|
body = self.prepare_security_group_rule(sg_rule)
|
||||||
rules.append({'security_group_rule': body})
|
rules.append({'security_group_rule': body})
|
||||||
|
|
||||||
|
if not rules:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
rules = self.dest_neutron.create_security_group_rule(
|
rules = self.dest_neutron.create_security_group_rule(
|
||||||
{'security_group_rules': rules})
|
{'security_group_rules': rules})
|
||||||
LOG.debug("created %s security group rules for SG %s",
|
LOG.debug("created %s security group rules for SG %s",
|
||||||
len(rules), sg['id'])
|
len(rules), sg['id'])
|
||||||
except Exception:
|
except Exception as e:
|
||||||
# NOTE(arosen): when you create a default
|
LOG.error("Failed to create security group %s "
|
||||||
# security group it is automatically populated
|
"rules: %s", sg['id'], e)
|
||||||
# with some rules. When we go to create the rules
|
n_errors = n_errors + 1
|
||||||
# that already exist because of a match an error
|
|
||||||
# is raised here but that's okay.
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_dest_availablity_zones(self, resource):
|
def get_dest_availablity_zones(self, resource):
|
||||||
azs = self.dest_neutron.list_availability_zones()['availability_zones']
|
azs = self.dest_neutron.list_availability_zones()['availability_zones']
|
||||||
|
Loading…
Reference in New Issue
Block a user