<s> """<STR_LIT>""" <EOL> from novaclient import base <EOL> from novaclient import exceptions <EOL> from novaclient . i18n import _ <EOL> class SecurityGroupRule ( base . Resource ) : <EOL> def __str__ ( self ) : <EOL> return str ( self . id ) <EOL> def delete ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . manager . delete ( self ) <EOL> class SecurityGroupRuleManager ( base . Manager ) : <EOL> resource_class = SecurityGroupRule <EOL> def create ( self , parent_group_id , ip_protocol = None , from_port = None , <EOL> to_port = None , cidr = None , group_id = None ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> from_port = int ( from_port ) <EOL> except ( TypeError , ValueError ) : <EOL> raise exceptions . CommandError ( _ ( "<STR_LIT>" ) ) <EOL> try : <EOL> to_port = int ( to_port ) <EOL> except ( TypeError , ValueError ) : <EOL> raise exceptions . CommandError ( _ ( "<STR_LIT>" ) ) <EOL> if ip_protocol . upper ( ) not in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> raise exceptions . CommandError ( _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> body = { "<STR_LIT>" : { <EOL> "<STR_LIT>" : ip_protocol , <EOL> "<STR_LIT>" : from_port , <EOL> "<STR_LIT>" : to_port , <EOL> "<STR_LIT>" : cidr , <EOL> "<STR_LIT>" : group_id , <EOL> "<STR_LIT>" : parent_group_id } } <EOL> return self . _create ( '<STR_LIT>' , body , <EOL> '<STR_LIT>' ) <EOL> def delete ( self , rule ) : <EOL> """<STR_LIT>""" <EOL> return self . _delete ( '<STR_LIT>' % base . getid ( rule ) ) </s>
