#NEWLINE# def _check_for_duplicate_rules_in_db( self , context , security_group_rule ) : #NEWLINE# #INDENT# filters = self . _make_security_group_rule_filter_dict ( security_group_rule ) #NEWLINE# keys = security_group_rule [ 'security_group_rule' ] . keys ( ) #NEWLINE# fields = ( list ( keys ) + [ 'id' ] ) #NEWLINE# db_rules = self . get_security_group_rules ( db_rules , filters , fields = fields ) #NEWLINE# rule_dict = security_group_rule [ 'security_group_rule' ] . copy ( ) #NEWLINE# rule_dict . pop ( 'id' , None ) #NEWLINE# sg_protocol = rule_dict . pop ( 'protocol' , None ) #NEWLINE# for db_rule in db_rules : #NEWLINE# #INDENT# rule_id = db_rule . pop ( 'id' , None ) #NEWLINE# db_protocol = db_rule . pop ( 'protocol' , None ) #NEWLINE# is_protocol_matching = ( self . _get_ip_proto_name_and_num ( db_protocol ) == self . _get_ip_proto_name_and_num ( sg_protocol ) ) #NEWLINE# if ( is_protocol_matching and ( rule_dict == db_rule ) ) : #NEWLINE# #INDENT# raise ext_sg . SecurityGroupRuleExists ( rule_id = rule_id )