ssh sending of the config

This commit is contained in:
catvayor 2024-04-06 14:36:37 +02:00
parent be2534386a
commit 1c863a8495
2 changed files with 42 additions and 16 deletions

View file

@ -104,6 +104,10 @@ let module_inst = {
"me0"
];
in (import <nixpkgs/lib>).evalModules {
modules = [ module module_inst ];
specialArgs.pkgs = import <nixpkgs> {};
modules = [
module
module_inst
];
}

View file

@ -1,5 +1,5 @@
interfaces:
{ lib, config, ... }:
{ lib, pkgs, config, ... }:
let cfg = config;
in with lib; {
options = {
@ -41,6 +41,7 @@ in with lib; {
in types.listOf vlan_type;
default = [ ];
};
# TODO: use this option
dhcp_trusted = mkOption {
type = types.bool;
default = false;
@ -147,7 +148,7 @@ in with lib; {
</interface>
''
else "";
in [ ''
config = ''
<interfaces operation="replace">
${builtins.concatStringsSep "\n" interface_xmls}
${irb_intf}
@ -159,6 +160,27 @@ in with lib; {
</protocols>
<vlans operation="replace">
${builtins.concatStringsSep "\n" vlans}
</vlans>'' vlan_trust_table
];
</vlans>
'';
rpc_requests = pkgs.writeText "config_rpc.xml" ''
<rpc>
<edit-config>
<config>
<configuration>
${config}
</configuration>
</config>
<target>
<candidate/>
</target>
</edit-config>
</rpc>
<rpc>
<commit/>
</rpc>
'';
in pkgs.writeShellScript "deploy.sh" ''
${pkgs.openssh}/bin/ssh jourdan01.dgn -p 830 -s netconf < ${rpc_requests}
''
;
}