@@ -440,7 +440,7 @@ SwitchPortNewMACDynAddress(lsp._uuid, mac_addr) :-
var mac_addr = match (static_dynamic_mac) {
None -> None,
Some{addr} -> {
- if (is_some(sw.subnet) or is_some(sw.ipv6_prefix) or
+ if (sw.subnet.is_some() or sw.ipv6_prefix.is_some() or
map_get(sw.ls.other_config, "mac_only") == Some{"true"}) {
Some{addr}
} else {
@@ -91,7 +91,7 @@ FirstHopLogicalRouter(lrouter, lswitch) :-
lsp in nb::Logical_Switch_Port(._uuid = lsp_uuid),
lsp.__type == "router",
lsp.options.get("router-port") == Some{lrp.name},
- is_none(lrp.peer).
+ lrp.peer == None.
/*
* Reachable routers.
@@ -118,7 +118,7 @@ ReachableLogicalRouter(a, a) :- ReachableLogicalRouter(a, _).
// ha_chassis_group and gateway_chassis may not both be present.
Warning[message] :-
lrp in nb::Logical_Router_Port(),
- is_some(lrp.ha_chassis_group),
+ lrp.ha_chassis_group.is_some(),
not lrp.gateway_chassis.is_empty(),
var message = "Both ha_chassis_group and gateway_chassis configured on "
"port ${lrp.name}; ignoring the latter".
@@ -126,7 +126,7 @@ Warning[message] :-
// A distributed gateway port cannot also be an L3 gateway router.
Warning[message] :-
lrp in nb::Logical_Router_Port(),
- is_some(lrp.ha_chassis_group) or not lrp.gateway_chassis.is_empty(),
+ lrp.ha_chassis_group.is_some() or not lrp.gateway_chassis.is_empty(),
lrp.options.contains_key("chassis"),
var message = "Bad configuration: distributed gateway port configured on "
"port ${lrp.name} on L3 gateway router".
@@ -143,7 +143,7 @@ DistributedGatewayPortCandidate(lr_uuid, lrp_uuid) :-
LogicalRouterPort(lrp_uuid, lr._uuid),
lrp in nb::Logical_Router_Port(._uuid = lrp_uuid),
not lrp.options.contains_key("chassis"),
- var has_hcg = is_some(lrp.ha_chassis_group),
+ var has_hcg = lrp.ha_chassis_group.is_some(),
var has_gc = not lrp.gateway_chassis.is_empty(),
has_hcg or has_gc.
Warning[message] :-
@@ -185,7 +185,7 @@ relation HAChassis(hacg_uuid: uuid,
HAChassis(ha_chassis_group_uuid(lrp._uuid), gw_chassis_uuid,
chassis_name, priority, external_ids) :-
DistributedGatewayPort(.lrp = lrp),
- is_none(lrp.ha_chassis_group),
+ lrp.ha_chassis_group == None,
var gw_chassis_uuid = FlatMap(lrp.gateway_chassis),
nb::Gateway_Chassis(._uuid = gw_chassis_uuid,
.chassis_name = chassis_name,
@@ -219,7 +219,7 @@ relation HAChassisGroup(uuid: uuid,
external_ids: Map<string,string>)
HAChassisGroup(ha_chassis_group_uuid(lrp._uuid), lrp.name, map_empty()) :-
DistributedGatewayPort(.lrp = lrp),
- is_none(lrp.ha_chassis_group),
+ lrp.ha_chassis_group == None,
not lrp.gateway_chassis.is_empty().
HAChassisGroup(ha_chassis_group_uuid(hac_group_uuid),
name, external_ids) :-
@@ -236,7 +236,7 @@ relation LogicalRouterHAChassisGroup(lr_uuid: uuid,
hacg_uuid: uuid)
LogicalRouterHAChassisGroup(lr_uuid, ha_chassis_group_uuid(lrp._uuid)) :-
DistributedGatewayPort(lrp, lr_uuid),
- is_none(lrp.ha_chassis_group),
+ lrp.ha_chassis_group == None,
lrp.gateway_chassis.size() > 0.
LogicalRouterHAChassisGroup(lr_uuid,
ha_chassis_group_uuid(hac_group_uuid)) :-
@@ -300,16 +300,16 @@ Warning["Bad MAC address ${s} in nat configuration for router ${lr_name}."] :-
relation LogicalRouterNAT(lr: uuid, nat: NAT)
LogicalRouterNAT(lr, NAT{nat, external_ip, external_mac, None}) :-
LogicalRouterNAT0(lr, nat, external_ip, external_mac),
- nat.allowed_ext_ips.is_none(),
- nat.exempted_ext_ips.is_none().
+ nat.allowed_ext_ips == None,
+ nat.exempted_ext_ips == None.
LogicalRouterNAT(lr, NAT{nat, external_ip, external_mac, Some{AllowedExtIps{__as}}}) :-
LogicalRouterNAT0(lr, nat, external_ip, external_mac),
- nat.exempted_ext_ips.is_none(),
+ nat.exempted_ext_ips == None,
Some{var __as_uuid} = nat.allowed_ext_ips,
__as in &AddressSetRef[nb::Address_Set{._uuid = __as_uuid}].
LogicalRouterNAT(lr, NAT{nat, external_ip, external_mac, Some{ExemptedExtIps{__as}}}) :-
LogicalRouterNAT0(lr, nat, external_ip, external_mac),
- nat.allowed_ext_ips.is_none(),
+ nat.allowed_ext_ips == None,
Some{var __as_uuid} = nat.exempted_ext_ips,
__as in &AddressSetRef[nb::Address_Set{._uuid = __as_uuid}].
Warning["NAT rule: ${nat._uuid} not applied, since"
@@ -444,7 +444,7 @@ relation &Router(
Some{rport} -> json_string_escape(chassis_redirect_name(rport.name)),
_ -> ""
},
- .is_gateway = is_some(lr.options.get("chassis")),
+ .is_gateway = lr.options.contains_key("chassis"),
.nats = nats,
.snat_ips = snat_ips,
.lbs = lbs,
@@ -623,7 +623,7 @@ relation &SwitchPort(
var dynamic_address_request = None;
for (addr in lsp.addresses) {
dynamic_address_request = parse_dynamic_address_request(addr);
- if (is_some(dynamic_address_request)) {
+ if (dynamic_address_request.is_some()) {
break
}
};
@@ -633,19 +633,18 @@ relation &SwitchPort(
None -> (None, None, None, false)
}
},
- var needs_dynamic_ipv4address = has_dyn_lsp_addr and is_none(peer) and is_some(subnet) and
- is_none(static_dynamic_ipv4),
- var needs_dynamic_macaddress = has_dyn_lsp_addr and is_none(peer) and is_none(static_dynamic_mac) and
- (is_some(subnet) or is_some(ipv6_prefix) or
+ var needs_dynamic_ipv4address = has_dyn_lsp_addr and peer == None and subnet.is_some() and
+ static_dynamic_ipv4 == None,
+ var needs_dynamic_macaddress = has_dyn_lsp_addr and peer == None and static_dynamic_mac == None and
+ (subnet.is_some() or ipv6_prefix.is_some() or
other_config.get("mac_only") == Some{"true"}),
- var needs_dynamic_ipv6address = has_dyn_lsp_addr and is_none(peer) and is_some(ipv6_prefix) and is_none(static_dynamic_ipv6),
+ var needs_dynamic_ipv6address = has_dyn_lsp_addr and peer == None and ipv6_prefix.is_some() and static_dynamic_ipv6 == None,
var parent_name = match (lsp.parent_name) {
None -> None,
Some{pname} -> if (pname == "") { None } else { Some{pname} }
},
/* Port needs dynamic tag if it has a parent and its `tag_request` is 0. */
- var needs_dynamic_tag = is_some(parent_name) and
- lsp.tag_request == Some{0},
+ var needs_dynamic_tag = parent_name.is_some() and lsp.tag_request == Some{0},
SwitchPortHAChassisGroup(.lsp_uuid = lsp._uuid,
.hac_group_uuid = hac_group_uuid).
@@ -197,7 +197,7 @@ OutProxy_Port_Binding(._uuid = lsp._uuid,
Some{nat_addresses} -> {
/* Only accept manual specification of ethernet address
* followed by IPv4 addresses on type "l3gateway" ports. */
- if (is_some(opt_chassis)) {
+ if (opt_chassis.is_some()) {
match (extract_lsp_addresses(nat_addresses)) {
None -> {
warn("Error extracting nat-addresses.");
@@ -229,9 +229,9 @@ OutProxy_Port_Binding(._uuid = lsp._uuid,
Some{rport} -> match (
(map_get_bool_def(rport.lrp.options, "reside-on-redirect-chassis",
false)
- and is_some(l3dgw_port)) or
+ and l3dgw_port.is_some()) or
Some{rport.lrp} == l3dgw_port or
- (is_some(rport.router.lr.options.get("chassis")) and
+ (rport.router.lr.options.contains_key("chassis") and
not sw.localnet_ports.is_empty())) {
false -> set_empty(),
true -> set_singleton(get_garp_nat_addresses(deref(rport)))
@@ -321,7 +321,7 @@ function get_nat_addresses(rport: RouterPort): Set<string> =
{
var addresses = set_empty();
var router = deref(rport.router);
- var has_redirect = is_some(router.l3dgw_port);
+ var has_redirect = router.l3dgw_port.is_some();
match (eth_addr_from_string(rport.lrp.mac)) {
None -> addresses,
Some{mac} -> {
@@ -333,7 +333,7 @@ function get_nat_addresses(rport: RouterPort): Set<string> =
/* Determine whether this NAT rule satisfies the conditions for
* distributed NAT processing. */
if (has_redirect and nat.nat.__type == "dnat_and_snat" and
- is_some(nat.nat.logical_port) and is_some(nat.external_mac)) {
+ nat.nat.logical_port.is_some() and nat.external_mac.is_some()) {
/* Distributed NAT rule. */
var logical_port = option_unwrap_or_default(nat.nat.logical_port);
var external_mac = option_unwrap_or_default(nat.external_mac);
@@ -3560,7 +3560,7 @@ for (lsp in &SwitchPort
* and if it doesn't belong to an HA chassis group ignore it. */
and (lsp.lsp.__type != "external"
or (not lsp.sw.localnet_ports.is_empty()
- and is_some(lsp.lsp.ha_chassis_group))))
+ and lsp.lsp.ha_chassis_group.is_some())))
{
for (lps in LogicalSwitchPort(.lport = lsp.lsp._uuid, .lswitch = lsuuid)) {
var json_key = json_string_escape(lsp.lsp.name) in
@@ -4733,7 +4733,7 @@ relation AddChassisResidentCheck_(lrp: uuid, add_check: bool)
AddChassisResidentCheck_(lrp._uuid, res) :-
&SwitchPort(.peer = Some{&RouterPort{.lrp = lrp, .router = &router, .is_redirect = is_redirect}},
.sw = sw),
- is_some(router.l3dgw_port),
+ router.l3dgw_port.is_some(),
not sw.localnet_ports.is_empty(),
var res = if (is_redirect) {
/* Traffic with eth.src = l3dgw_port->lrp_networks.ea
@@ -5396,7 +5396,7 @@ function lrouter_nat_add_ext_ip_match(
},
false -> {
/* S_ROUTER_OUT_SNAT uses priority (mask + 1 + 128 + 1) */
- var is_gw_router = router.l3dgw_port.is_none();
+ var is_gw_router = router.l3dgw_port == None;
var mask_1bits = ip46_count_cidr_bits(mask).unwrap_or(8'd0) as integer;
mask_1bits + 2 + { if (not is_gw_router) 128 else 0 }
}
@@ -5486,7 +5486,7 @@ for (r in &Router(.lr = lr,
.l3dgw_port = l3dgw_port,
.redirect_port_name = redirect_port_name,
.is_gateway = is_gateway)
- if is_some(l3dgw_port) or is_gateway)
+ if l3dgw_port.is_some() or is_gateway)
{
for (LogicalRouterNAT(.lr = lr._uuid, .nat = nat)) {
var ipX = ip46_ipX(nat.external_ip) in
@@ -5504,7 +5504,7 @@ for (r in &Router(.lr = lr,
} in
/* For distributed router NAT, determine whether this NAT rule
* satisfies the conditions for distributed NAT processing. */
- var mac = match ((is_some(l3dgw_port) and nat.nat.__type == "dnat_and_snat",
+ var mac = match ((l3dgw_port.is_some() and nat.nat.__type == "dnat_and_snat",
nat.nat.logical_port, nat.external_mac)) {
(true, Some{_}, Some{mac}) -> Some{mac},
_ -> None
@@ -5914,7 +5914,7 @@ for (RouterLBVIP(
.lb = lb,
.vip = vip,
.backends = backends)
- if is_some(l3dgw_port) or is_gateway)
+ if l3dgw_port.is_some() or is_gateway)
{
if (backends == "" and not map_get_bool_def(lb.options, "reject", false)) {
for (LoadBalancerEmptyEvents(lb)) {
@@ -6069,7 +6069,7 @@ Flow(.logical_datapath = r.lr._uuid,
.actions = actions,
.external_ids = stage_hint(lb._uuid)) :-
r in &Router(),
- is_some(r.l3dgw_port) or r.is_gateway,
+ r.l3dgw_port.is_some() or r.is_gateway,
LBVIPWithStatus[lbvip@&LBVIPWithStatus{.lb = lb}],
r.lr.load_balancer.contains(lb._uuid),
var __match
@@ -6960,7 +6960,7 @@ Flow(.logical_datapath = peer.router.lr._uuid,
Some{var virtual_parents} = lsp.options.get("virtual-parents"),
Some{var virtual_ip} = ip_parse(virtual_ip_s),
pb in sb::Port_Binding(.logical_port = sp.lsp.name),
- is_empty_set_or_string(pb.virtual_parent) or is_none(pb.chassis),
+ is_empty_set_or_string(pb.virtual_parent) or pb.chassis == None,
sp2 in &SwitchPort(.sw = sp.sw, .peer = Some{peer}),
Some{_} = find_lrp_member_ip(peer.networks, IPv4{virtual_ip}).
Flow(.logical_datapath = peer.router.lr._uuid,
@@ -6975,7 +6975,7 @@ Flow(.logical_datapath = peer.router.lr._uuid,
Some{var virtual_parents} = lsp.options.get("virtual-parents"),
Some{var virtual_ip} = ip_parse(virtual_ip_s),
pb in sb::Port_Binding(.logical_port = sp.lsp.name),
- not (is_empty_set_or_string(pb.virtual_parent) or is_none(pb.chassis)),
+ not (is_empty_set_or_string(pb.virtual_parent) or pb.chassis == None),
Some{var virtual_parent} = pb.virtual_parent,
vp in &SwitchPort(.lsp = nb::Logical_Switch_Port{.name = virtual_parent}),
var address = FlatMap(vp.static_addresses),
@@ -7647,7 +7647,7 @@ relation SwitchPortAllocatedTags(lsp_uuid: uuid, tag: Option<integer>)
SwitchPortAllocatedTags(lsp_uuid, tag) :-
&SwitchPort(.lsp = lsp, .needs_dynamic_tag = true, .parent_name = Some{parent_name}),
- is_none(lsp.tag),
+ lsp.tag == None,
var lsps_need_tag = lsp._uuid.group_by(parent_name).to_vec(),
SwitchPortReservedTags(parent_name, reserved),
var dyn_tags = allocate_opt(reserved,
@@ -7680,7 +7680,7 @@ SwitchPortNewDynamicTag(lsp._uuid, Some{tag}) :-
/* Case 3 */
SwitchPortNewDynamicTag(lsp._uuid, tag) :-
&SwitchPort(.lsp = lsp, .needs_dynamic_tag = true),
- is_none(lsp.tag),
+ lsp.tag == None,
SwitchPortAllocatedTags(lsp._uuid, tag).
/* IP_Multicast table (only applicable for Switches). */
DDlog supports a couple different forms of functions. You can write is_some(expr) or expr.is_some(), for example. The latter is usually easier to understand, especially in bigger expressions. It was introduced later so it's not consistently used in ovn-northd-ddlog. This commit switches to the object-like form throughout the code. Writing is_none(expr) or expr.is_none() is equivalent to writing expr == None. I think that the latter is easier to understand, so this commit also makes that change throughout. This code refactoring shouldn't change ovn-northd-ddlog behavior. Signed-off-by: Ben Pfaff <blp@ovn.org> --- northd/ipam.dl | 2 +- northd/lrouter.dl | 24 ++++++++++++------------ northd/lswitch.dl | 15 +++++++-------- northd/ovn_northd.dl | 32 ++++++++++++++++---------------- 4 files changed, 36 insertions(+), 37 deletions(-)