Skip to content

Commit e69d53a

Browse files
committed
confd: Add migrate script to migrate configuration to new YANG syntax
1 parent b064343 commit e69d53a

File tree

5 files changed

+59
-1
lines changed

5 files changed

+59
-1
lines changed

src/confd/configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ AC_CONFIG_FILES([
2020
share/migrate/1.4/Makefile
2121
share/migrate/1.5/Makefile
2222
share/migrate/1.6/Makefile
23+
share/migrate/1.7/Makefile
2324
yang/Makefile
2425
yang/confd/Makefile
2526
yang/test-mode/Makefile
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
# Migrate NETCONF server TCP parameters to new YANG schema (RFC 9643)
3+
# The 'local-address' leaf has been moved into a 'local-bind' list
4+
# Old: tcp-server-parameters/local-address
5+
# New: tcp-server-parameters/local-bind[]/local-address
6+
7+
file=$1
8+
temp=${file}.tmp
9+
10+
jq '
11+
if .["ietf-netconf-server:netconf-server"]?.listen?.endpoints?.endpoint then
12+
.["ietf-netconf-server:netconf-server"].listen.endpoints.endpoint |= map(
13+
if .ssh?."tcp-server-parameters"?."local-address" then
14+
# Extract and remove the old local-address value, then add new structure
15+
.ssh."tcp-server-parameters"."local-address" as $addr |
16+
.ssh."tcp-server-parameters" |= (del(."local-address") | . + {
17+
"local-bind": [{
18+
"local-address": $addr
19+
}]
20+
})
21+
else
22+
.
23+
end
24+
)
25+
else
26+
.
27+
end
28+
' "$file" > "$temp" && mv "$temp" "$file"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
# Migrate keystore symmetric key syntax to new YANG schema (RFC 9643)
3+
# The 'cleartext-key' leaf has been renamed to 'cleartext-symmetric-key'
4+
# Old: symmetric-key[]/key-type/cleartext-key
5+
# New: symmetric-key[]/key-type/cleartext-symmetric-key
6+
7+
file=$1
8+
temp=${file}.tmp
9+
10+
jq '
11+
if .["ietf-keystore:keystore"]?."symmetric-keys"?."symmetric-key" then
12+
.["ietf-keystore:keystore"]."symmetric-keys"."symmetric-key" |= map(
13+
if ."key-type"?."cleartext-key" then
14+
# Rename cleartext-key to cleartext-symmetric-key
15+
."key-type"."cleartext-key" as $key_value |
16+
."key-type" |= (del(."cleartext-key") | . + {
17+
"cleartext-symmetric-key": $key_value
18+
})
19+
else
20+
.
21+
end
22+
)
23+
else
24+
.
25+
end
26+
' "$file" > "$temp" && mv "$temp" "$file"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
migratedir = $(pkgdatadir)/migrate/1.7
2+
dist_migrate_DATA = 10-netconf-server-tcp-params.sh \
3+
20-keystore-cleartext-key-rename.sh
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
SUBDIRS = 1.0 1.1 1.2 1.3 1.4 1.5 1.6
1+
SUBDIRS = 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7
22
migratedir = $(pkgdatadir)/migrate

0 commit comments

Comments
 (0)