def _make_security_group_rule_dict(security_rule, fields=None): ethertype = protocols.human_readable_ethertype( security_rule.get("ethertype")) protocol = protocols.human_readable_protocol( security_rule.get("protocol"), ethertype) res = {"id": security_rule.get("id"), "ethertype": ethertype, "direction": security_rule.get("direction"), "tenant_id": security_rule.get("tenant_id"), "port_range_max": security_rule.get("port_range_max"), "port_range_min": security_rule.get("port_range_min"), "protocol": protocol, "remote_ip_prefix": security_rule.get("remote_ip_prefix"), "security_group_id": security_rule.get("group_id"), "remote_group_id": security_rule.get("remote_group_id")} return res
def _make_security_group_rule_dict(security_rule, fields=None): ethertype = protocols.human_readable_ethertype( security_rule.get("ethertype")) protocol = protocols.human_readable_protocol(security_rule.get("protocol"), ethertype) res = { "id": security_rule.get("id"), "ethertype": ethertype, "direction": security_rule.get("direction"), "tenant_id": security_rule.get("tenant_id"), "port_range_max": security_rule.get("port_range_max"), "port_range_min": security_rule.get("port_range_min"), "protocol": protocol, "remote_ip_prefix": security_rule.get("remote_ip_prefix"), "security_group_id": security_rule.get("group_id"), "remote_group_id": security_rule.get("remote_group_id") } return res
def test_human_readable_protocol_string_as_int(self): proto = protocols.human_readable_protocol("17", "IPv4") self.assertEqual(proto, "UDP")
def test_human_readable_protocol_icmpv6(self): proto = protocols.human_readable_protocol(58, "IPv6") self.assertEqual(proto, "ICMP")
def test_human_readable_protocol_int(self): proto = protocols.human_readable_protocol(17, "IPv4") self.assertEqual(proto, "UDP")