'Create loginable security group rule
This function will create:
1. egress and ingress tcp port 22 allow rule in order to allow ssh
access for ipv4.
2. egress and ingress ipv6 icmp allow rule, in order to allow icmpv6.
3. egress and ingress ipv4 icmp allow rule, in order to allow icmpv4.'

def _create_loginable_secgroup_rule(self, security_group_rules_client=None, secgroup=None, security_groups_client=None):

    if (security_group_rules_client is None):
        security_group_rules_client = self.security_group_rules_client
    if (security_groups_client is None):
        security_groups_client = self.security_groups_client
    rules = []
    rulesets = [dict(protocol='tcp', port_range_min=22, port_range_max=22), dict(protocol='icmp'), dict(protocol='icmp', ethertype='IPv6')]
    sec_group_rules_client = security_group_rules_client
    for ruleset in rulesets:
        for r_direction in ['ingress', 'egress']:
            ruleset['direction'] = r_direction
            try:
                sg_rule = self._create_security_group_rule(sec_group_rules_client=sec_group_rules_client, secgroup=secgroup, security_groups_client=security_groups_client, **ruleset)
            except lib_exc.Conflict as ex:
                msg = 'Security    group    rule    already    exists'
                if (msg not in ex._error_string):
                    raise ex
            else:
                self.assertEqual(r_direction, sg_rule['direction'])
                rules.append(sg_rule)
    return rules
