예제 #1
0
    def _compute_commands(self,
                          interface,
                          key,
                          vif=None,
                          value=None,
                          remove=False):
        intf_context = "interfaces {0} {1}".format(
            get_interface_type(interface), interface)
        set_cmd = "set {0}".format(intf_context)
        del_cmd = "delete {0}".format(intf_context)

        if vif:
            set_cmd = set_cmd + (" vif {0}".format(vif))
            del_cmd = del_cmd + (" vif {0}".format(vif))

        if key == "enabled":
            if not value:
                command = "{0} disable".format(set_cmd)
            else:
                command = "{0} disable".format(del_cmd)
        else:
            if not remove:
                command = "{0} {1} '{2}'".format(set_cmd, key, value)
            else:
                command = "{0} {1}".format(del_cmd, key)

        return command
예제 #2
0
def _tmplt_ospf_int_auth_md5_delete(config_data):
    int_type = get_interface_type(config_data["name"])
    params = _get_parameters(config_data["address_family"])
    command = ("interfaces " + int_type + " {name} ".format(**config_data) +
               params[1] + " " + params[0] + " authentication")

    return command
예제 #3
0
def _tmplt_ospf_int_passive(config_data):
    int_type = get_interface_type(config_data["name"])
    params = _get_parameters(config_data["address_family"])
    command = ("interfaces " + int_type + " {name} ".format(**config_data) +
               params[1] + " " + params[0] + " passive")

    return command
예제 #4
0
def _tmplt_ospf_int_transmit_delay(config_data):
    int_type = get_interface_type(config_data["name"])
    params = _get_parameters(config_data["address_family"])
    command = ("interfaces " + int_type + " {name} ".format(**config_data) +
               params[1] + " " + params[0] +
               " transmit-delay {transmit_delay}".format(
                   **config_data["address_family"]))

    return command
예제 #5
0
def _tmplt_ospf_int_auth_md5(config_data):
    int_type = get_interface_type(config_data["name"])
    params = _get_parameters(config_data["address_family"])
    command = (
        "interfaces " + int_type + " {name} ".format(**config_data) +
        params[1] + " " + params[0] +
        " authentication md5 key-id {key_id} ".format(
            **config_data["address_family"]["authentication"]["md5_key"]) +
        "md5-key {key}".format(
            **config_data["address_family"]["authentication"]["md5_key"]))

    return command
예제 #6
0
    def _compute_commands(self,
                          interface,
                          key,
                          vif=None,
                          value=None,
                          remove=False):
        intf_context = 'interfaces {0} {1}'.format(
            get_interface_type(interface), interface)
        set_cmd = 'set {0}'.format(intf_context)
        del_cmd = 'delete {0}'.format(intf_context)

        if vif:
            set_cmd = set_cmd + (' vif {0}'.format(vif))
            del_cmd = del_cmd + (' vif {0}'.format(vif))

        if remove:
            command = "{0} {1} '{2}'".format(del_cmd, key, value)
        else:
            command = "{0} {1} '{2}'".format(set_cmd, key, value)

        return command