'Create a new Rule in a Security Group
:param security_group: Security Group in which to add the rule
:type  security_group: :class:`OpenStackSecurityGroup`
:param ip_protocol: Protocol to which this rule applies
Examples: tcp, udp, ...
:type  ip_protocol: ``str``
:param from_port: First port of the port range
:type  from_port: ``int``
:param to_port: Last port of the port range
:type  to_port: ``int``
:param cidr: CIDR notation of the source IP range for this rule
:type  cidr: ``str``
:param source_security_group: Existing Security Group to use as the
source (instead of CIDR)
:type  source_security_group: L{OpenStackSecurityGroup
:rtype: :class:`OpenStackSecurityGroupRule`'

def ex_create_security_group_rule(self, security_group, ip_protocol, from_port, to_port, cidr=None, source_security_group=None):

    source_security_group_id = None
    if (type(source_security_group) == OpenStackSecurityGroup):
        source_security_group_id = source_security_group.id
    return self._to_security_group_rule(self.connection.request('/os-security-group-rules', method='POST', data={'security_group_rule': {'ip_protocol': ip_protocol, 'from_port': from_port, 'to_port': to_port, 'cidr': cidr, 'group_id': source_security_group_id, 'parent_group_id': security_group.id}}).object['security_group_rule'])
