def build_security_group_from_nova(sec_groups):
    """Translate nova security group

    Translate to the ooi a standard security group format.

    :param sec_groups: array of security groups
    """
    sec_list = []
    for sec in sec_groups:
        ooi_sec = {}
        rules_list = []
        ooi_sec['id'] = sec['id']
        ooi_sec['title'] = sec.get('name', None)
        ooi_sec['summary'] = sec.get('description', '')
        for rule in sec['rules']:
            ipversion = 'IPv4'
            rule_protocol = rule.get('ip_protocol', None)
            port_min = rule['from_port']
            port_max = rule['to_port']
            if port_min and port_min != port_max:
                rule_port = '%s-%s' % (port_min, port_max)
            else:
                rule_port = port_min
            rule_range = str(rule['ip_range'].get('cidr', ''))
            rules_list.append({'type': 'inbound', 'protocol': rule_protocol,
                'port': rule_port, 'range': rule_range, 'ipversion': ipversion}
                )
        ooi_sec['rules'] = rules_list
        sec_list.append(ooi_sec)
    return sec_list
