def show_or_create_security_group(mgr_or_client, name,
                                  tenant_id=None, **kwargs):
    sc_list = Q.security_group_list(mgr_or_client, name)
    if len(sc_list) > 0:
        return Q.security_group_show(mgr_or_client, sc_list[0]['id'])
    return Q.security_group_create(mgr_or_client, name,
                                   tenant_id=tenant_id, **kwargs)
def create_security_group_loginable(mgr_or_client, name, **kwargs):
    try:
        sg = Q.security_group_list(mgr_or_client, name=name)[0]
    except Exception:
        sg = Q.security_group_create(mgr_or_client, name)
        create_security_group_ssh_rule(mgr_or_client, sg['id'])
        create_security_group_icmp_rule(mgr_or_client, sg['id'])
    return Q.security_group_show(mgr_or_client, sg['id'])