update ce_static_route to fix bugs

pull/62498/head
zhangyan 5 years ago
parent 0e9f002073
commit 9a458d658f

@ -471,8 +471,10 @@ class StaticRoute(object):
if not self.changed:
return
if self.aftype == "v4":
aftype = "ip"
maskstr = self.convert_len_to_mask(self.mask)
else:
aftype = "ipv6"
maskstr = self.mask
if self.next_hop is None:
next_hop = ''
@ -493,38 +495,38 @@ class StaticRoute(object):
if self.state == "present":
if self.vrf != "_public_":
if self.destvrf != "_public_":
self.updates_cmd.append('ip route-static vpn-instance %s %s %s vpn-instance %s %s'
% (vrf, self.prefix, maskstr, destvrf, next_hop))
self.updates_cmd.append('%s route-static vpn-instance %s %s %s vpn-instance %s %s'
% (aftype, vrf, self.prefix, maskstr, destvrf, next_hop))
else:
self.updates_cmd.append('ip route-static vpn-instance %s %s %s %s %s'
% (vrf, self.prefix, maskstr, nhp_interface, next_hop))
self.updates_cmd.append('%s route-static vpn-instance %s %s %s %s %s'
% (aftype, vrf, self.prefix, maskstr, nhp_interface, next_hop))
elif self.destvrf != "_public_":
self.updates_cmd.append('ip route-static %s %s vpn-instance %s %s'
% (self.prefix, maskstr, self.destvrf, next_hop))
self.updates_cmd.append('%s route-static %s %s vpn-instance %s %s'
% (aftype, self.prefix, maskstr, self.destvrf, next_hop))
else:
self.updates_cmd.append('ip route-static %s %s %s %s'
% (self.prefix, maskstr, nhp_interface, next_hop))
self.updates_cmd.append('%s route-static %s %s %s %s'
% (aftype, self.prefix, maskstr, nhp_interface, next_hop))
if self.pref:
self.updates_cmd.append(' preference %s' % (self.pref))
self.updates_cmd[0] += ' preference %s' % (self.pref)
if self.tag:
self.updates_cmd.append(' tag %s' % (self.tag))
self.updates_cmd[0] += ' tag %s' % (self.tag)
if self.description:
self.updates_cmd.append(' description %s' % (self.description))
self.updates_cmd[0] += ' description %s' % (self.description)
if self.state == "absent":
if self.vrf != "_public_":
if self.destvrf != "_public_":
self.updates_cmd.append('undo ip route-static vpn-instance %s %s %s vpn-instance %s %s'
% (vrf, self.prefix, maskstr, destvrf, next_hop))
self.updates_cmd.append('undo %s route-static vpn-instance %s %s %s vpn-instance %s %s'
% (aftype, vrf, self.prefix, maskstr, destvrf, next_hop))
else:
self.updates_cmd.append('undo ip route-static vpn-instance %s %s %s %s %s'
% (vrf, self.prefix, maskstr, nhp_interface, next_hop))
self.updates_cmd.append('undo %s route-static vpn-instance %s %s %s %s %s'
% (aftype, vrf, self.prefix, maskstr, nhp_interface, next_hop))
elif self.destvrf != "_public_":
self.updates_cmd.append('undo ip route-static %s %s vpn-instance %s %s'
% (self.prefix, maskstr, self.destvrf, self.next_hop))
self.updates_cmd.append('undo %s route-static %s %s vpn-instance %s %s'
% (aftype, self.prefix, maskstr, self.destvrf, self.next_hop))
else:
self.updates_cmd.append('undo ip route-static %s %s %s %s'
% (self.prefix, maskstr, nhp_interface, next_hop))
self.updates_cmd.append('undo %s route-static %s %s %s %s'
% (aftype, self.prefix, maskstr, nhp_interface, next_hop))
def operate_static_route(self, version, prefix, mask, nhp_interface, next_hop, vrf, destvrf, state):
"""operate ipv4 static route"""

Loading…
Cancel
Save