'Check if the security group requested exists and belongs to
the project.
:param context: The nova request context.
:type context: nova.context.RequestContext
:param secgroups: list of requested security group names, or uuids in
the case of Neutron.
:type secgroups: list
:returns: list of requested security group names unmodified if using
nova-network. If using Neutron, the list returned is all uuids.
Note that \'default\' is a special case and will be unmodified if
it\'s requested.'

def _check_requested_secgroups(self, context, secgroups):

    security_groups = []
    for secgroup in secgroups:
        if (secgroup == 'default'):
            security_groups.append(secgroup)
            continue
        secgroup_dict = self.security_group_api.get(context, secgroup)
        if (not secgroup_dict):
            raise exception.SecurityGroupNotFoundForProject(project_id=context.project_id, security_group_id=secgroup)
        if isinstance(secgroup_dict['id'], int):
            security_groups.append(secgroup)
        else:
            security_groups.append(secgroup_dict['id'])
    return security_groups
