#NEWLINE# def _parse_rules( sg , rules ) : #NEWLINE# #INDENT# _rules = [ ] #NEWLINE# for rule in rules : #NEWLINE# #INDENT# log . debug ( 'examining rule {0} for group {1}' . format ( rule , g_attr_map . id ) ) #NEWLINE# attrs = [ 'ip_protocol' , 'from_port' , 'to_port' , 'grants' ] #NEWLINE# _rule = odict . OrderedDict ( ) #NEWLINE# for attr in attrs : #NEWLINE# #INDENT# val = getattr ( rule , attr ) #NEWLINE# if ( not val ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( attr == 'grants' ) : #NEWLINE# #INDENT# _grants = [ ] #NEWLINE# for grant in val : #NEWLINE# #INDENT# log . debug ( 'examining grant {0} for' . format ( grant ) ) #NEWLINE# g_attrs = { #NEWLINE# #INDENT# 'name' : 'source_group_name' , #NEWLINE# 'owner_id' : 'source_group_owner_id' , #NEWLINE# 'group_id' : 'source_group_group_id' , #NEWLINE# 'cidr_ip' : 'cidr_ip' , #NEWLINE# #UNINDENT# } #NEWLINE# _grant = odict . OrderedDict ( ) #NEWLINE# for ( g_attr , g_attr_map ) in six . iteritems ( g_attrs ) : #NEWLINE# #INDENT# g_val = getattr ( grant , g_attr ) #NEWLINE# if ( not g_val ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# _grant [ g_attr_map ] = g_val #NEWLINE# #UNINDENT# _grants . append ( _grant ) #NEWLINE# #UNINDENT# _rule [ 'grants' ] = _grants #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( attr == 'from_port' ) : #NEWLINE# #INDENT# _rule [ attr ] = int ( val ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( attr == 'to_port' ) : #NEWLINE# #INDENT# _rule [ attr ] = int ( val ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# _rule [ attr ] = val #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# _rules . append ( _rule ) #NEWLINE# #UNINDENT# return _rules