#NEWLINE# def delete_security_group( self , context , id ) : #NEWLINE# #INDENT# filters = { #NEWLINE# #INDENT# 'security_group_id' : [ id ] , #NEWLINE# #UNINDENT# } #NEWLINE# ports = self . _get_port_security_group_bindings ( context , filters ) #NEWLINE# if ports : #NEWLINE# #INDENT# raise ext_sg . SecurityGroupInUse ( id = id ) #NEWLINE# #UNINDENT# sg = self . _get_security_group ( context , id ) #NEWLINE# if ( ( sg [ 'name' ] == 'default' ) and ( not self . is_admin ) ) : #NEWLINE# #INDENT# raise ext_sg . SecurityGroupCannotRemoveDefault ( ) #NEWLINE# #UNINDENT# kwargs = { #NEWLINE# #INDENT# 'context' : context , #NEWLINE# 'security_group_id' : id , #NEWLINE# 'security_group' : sg , #NEWLINE# #UNINDENT# } #NEWLINE# self . _registry_notify ( resources . SECURITY_GROUP , events . BEFORE_DELETE , exc_cls = ext_sg . SecurityGroupInUse , id = id , ** kwargs ) #NEWLINE# with context . session . begin ( subtransactions = True ) : #NEWLINE# #INDENT# self . _registry_notify ( resources . SECURITY_GROUP , events . PRECOMMIT_DELETE , exc_cls = ext_sg . SecurityGroupInUse , id = id , ** kwargs ) #NEWLINE# context . session . delete ( sg ) #NEWLINE# #UNINDENT# kwargs . pop ( 'security_group' ) #NEWLINE# registry . notify ( resources . SECURITY_GROUP , events . AFTER_DELETE , self , ** kwargs )