ensoft / entrance / EnTrance.Feature.Target.Config

Validating and commiting configuration changes via the CLI.

It takes a sequence of round-trip RPCs to actually get some configuration committed.

Load configuration into the target buffer

load : String -> EnTrance.Request.Request

Enter some CLI-expressed configuration into the router's target buffer.

Config.load "router bgp 10 \n neighbor 1.2.3.4 \n remote-as 20"
    |> Channel.sendRpc { model | loadResult = Loading }

decodeLoad : (EnTrance.Types.RpcData String -> msg) -> Json.Decode.Decoder msg

Decode the reply from a load request. Takes a message constructor.

Commit or validate the target buffer config

commit : CommitType -> EnTrance.Request.Request

Commit the configuration that was loaded via load.

Config.commit Commit
    |> Channel.sendRpc { model | commitResult = Loading }


type CommitType
    = OnlyCheck
    | Commit

Whether a commit should actually change the configuration, or merely validate.

decodeCommit : (EnTrance.Types.RpcData String -> msg) -> Json.Decode.Decoder msg

Decode the reply from a commit request. Takes a message constructor.

Get failures from a failed commit

getFailures : EnTrance.Request.Request

Retrieve any failures from a commit (whether actually committed or merely validated).

Config.getFailures
    |> Channel.sendRpc { model | getFailuresResult = Loading }

decodeGetFailures : (EnTrance.Types.RpcData String -> msg) -> Json.Decode.Decoder msg

Decode the reply from a getFailures request. Takes a message constructor.

Get the config that could not be validated

getUnvalidated : EnTrance.Request.Request

Retrieve any configuration items which could not be validated.

Config.getUnvalidated
    |> Channel.sendRpc { model | getUnvalidatedResult = Loading }

decodeGetUnvalidated : (EnTrance.Types.RpcData String -> msg) -> Json.Decode.Decoder msg

Decode the reply from a getUnvalidated request. Takes a message constructor.

Starting and stopping

start : EnTrance.Types.MaybeSubscribe -> EnTrance.Request.Request

Start a config feature instance. This represents the option to configure one router. This is an async request - use the connection state notifications to track progress.

stop : EnTrance.Request.Request

Stop a config feature instance. This is an async request.

decodeIsUp : (Basics.Bool -> msg) -> Json.Decode.Decoder msg

Decode an up/down notification requested by passing SubscribeToConState to start. Takes a message constructor.

Parsing failures

The result of a getFailures request is just a blob of text (as provided by the router). You can parse this into a more structured form using the following function.

parseFailures : EnTrance.Types.RpcData String -> List Failed

Parse the result of a getFailures request. If there is anything awkward about the inputs, just return the empty list.


type alias Failed =
{ config : String
, error : String 
}

A line of configuration that has failed, and the error string that prevented the configuration commit from succeeding.