#NEWLINE# def create_security_group( context , group_name , group_description , vpc_id = None ) : #NEWLINE# #INDENT# if ( group_name == DEFAULT_GROUP_NAME ) : #NEWLINE# #INDENT# if vpc_id : #NEWLINE# #INDENT# raise exception . InvalidParameterValue ( ( _ ( 'Cannot use reserved security group name: %s' ) % DEFAULT_GROUP_NAME ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise exception . InvalidGroupReserved ( group_name = group_name ) #NEWLINE# #UNINDENT# #UNINDENT# filter = [ { #NEWLINE# #INDENT# 'name' : 'group-name' , #NEWLINE# 'value' : [ group_name ] , #NEWLINE# #UNINDENT# } ] #NEWLINE# if ( vpc_id and ( group_name != vpc_id ) ) : #NEWLINE# #INDENT# filter . append ( { #NEWLINE# #INDENT# 'name' : 'vpc-id' , #NEWLINE# 'value' : [ vpc_id ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# security_groups = describe_security_groups ( context , filter = filter ) [ 'securityGroupInfo' ] #NEWLINE# if ( not vpc_id ) : #NEWLINE# #INDENT# security_groups = [ sg for sg in security_groups if ( sg . get ( 'vpcId' ) is None ) ] #NEWLINE# #UNINDENT# if security_groups : #NEWLINE# #INDENT# raise exception . InvalidGroupDuplicate ( name = group_name ) #NEWLINE# #UNINDENT# return _create_security_group ( context , group_name , group_description , vpc_id )