Merge "Remove redundant call to get/create default security group" into stable/train
This commit is contained in:
@@ -166,13 +166,8 @@ $MANAGE db online_data_migrations
|
|||||||
# creation of a new deleted marker instance.
|
# creation of a new deleted marker instance.
|
||||||
set +e
|
set +e
|
||||||
archive_deleted_rows
|
archive_deleted_rows
|
||||||
|
set -e
|
||||||
|
|
||||||
# Verify whether online data migrations run after archiving will succeed.
|
# Verify whether online data migrations run after archiving will succeed.
|
||||||
# See for more details: https://bugs.launchpad.net/nova/+bug/1824435
|
# See for more details: https://bugs.launchpad.net/nova/+bug/1824435
|
||||||
$MANAGE db online_data_migrations
|
$MANAGE db online_data_migrations
|
||||||
rc=$?
|
|
||||||
set -e
|
|
||||||
if [[ $rc -ne 2 ]]; then
|
|
||||||
echo "Expected return code 2 from online_data_migrations until bug 1824435 is fixed"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -1753,7 +1753,7 @@ def instance_create(context, values):
|
|||||||
values - dict containing column values.
|
values - dict containing column values.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
security_group_ensure_default(context)
|
default_group = security_group_ensure_default(context)
|
||||||
|
|
||||||
values = values.copy()
|
values = values.copy()
|
||||||
values['metadata'] = _metadata_refs(
|
values['metadata'] = _metadata_refs(
|
||||||
@@ -1782,21 +1782,19 @@ def instance_create(context, values):
|
|||||||
instance_ref['extra'].update(values.pop('extra', {}))
|
instance_ref['extra'].update(values.pop('extra', {}))
|
||||||
instance_ref.update(values)
|
instance_ref.update(values)
|
||||||
|
|
||||||
def _get_sec_group_models(security_groups):
|
# Gather the security groups for the instance
|
||||||
models = []
|
sg_models = []
|
||||||
default_group = _security_group_ensure_default(context)
|
|
||||||
if 'default' in security_groups:
|
if 'default' in security_groups:
|
||||||
models.append(default_group)
|
sg_models.append(default_group)
|
||||||
# Generate a new list, so we don't modify the original
|
# Generate a new list, so we don't modify the original
|
||||||
security_groups = [x for x in security_groups if x != 'default']
|
security_groups = [x for x in security_groups if x != 'default']
|
||||||
if security_groups:
|
if security_groups:
|
||||||
models.extend(_security_group_get_by_names(
|
sg_models.extend(_security_group_get_by_names(
|
||||||
context, security_groups))
|
context, security_groups))
|
||||||
return models
|
|
||||||
|
|
||||||
if 'hostname' in values:
|
if 'hostname' in values:
|
||||||
_validate_unique_server_name(context, values['hostname'])
|
_validate_unique_server_name(context, values['hostname'])
|
||||||
instance_ref.security_groups = _get_sec_group_models(security_groups)
|
instance_ref.security_groups = sg_models
|
||||||
context.session.add(instance_ref)
|
context.session.add(instance_ref)
|
||||||
|
|
||||||
# create the instance uuid to ec2_id mapping entry for instance
|
# create the instance uuid to ec2_id mapping entry for instance
|
||||||
|
|||||||
Reference in New Issue
Block a user