+
+ @staticmethod
+ def add_route(node, ip_addr, prefix, gateway, namespace=None):
+ """Add route in namespace.
+
+ :param node: Node where to execute command.
+ :param ip_addr: Route destination IP address.
+ :param prefix: IP prefix.
+ :param namespace: Execute command in namespace. Optional.
+ :param gateway: Gateway address.
+ :type node: dict
+ :type ip_addr: str
+ :type prefix: int
+ :type gateway: str
+ :type namespace: str
+ """
+ if namespace is not None:
+ cmd = 'ip netns exec {} ip route add {}/{} via {}'.format(
+ namespace, ip_addr, prefix, gateway)
+ else:
+ cmd = 'ip route add {}/{} via {}'.format(ip_addr, prefix, gateway)
+ exec_cmd_no_error(node, cmd, sudo=True)