Page Menu
Home
VyOS Platform
Search
Configure Global Search
Log In
Files
F118305907
vyos-config-to-commands
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
717 B
Referenced Files
None
Subscribers
None
vyos-config-to-commands
View Options
#!/usr/bin/python3
import
sys
from
signal
import
signal
,
SIGPIPE
,
SIG_DFL
from
vyos.configtree
import
ConfigTree
signal
(
SIGPIPE
,
SIG_DFL
)
config_string
=
None
if
(
len
(
sys
.
argv
)
==
1
):
# If no argument given, act as a pipe
config_string
=
sys
.
stdin
.
read
()
else
:
file_name
=
sys
.
argv
[
1
]
try
:
with
open
(
file_name
,
'r'
)
as
f
:
config_string
=
f
.
read
()
except
OSError
as
e
:
print
(
"Could not read config file
{0}
:
{1}
"
.
format
(
file_name
,
e
),
file
=
sys
.
stderr
)
try
:
config
=
ConfigTree
(
config_string
)
commands
=
config
.
to_commands
()
except
ValueError
as
e
:
print
(
"Could not parse the config file:
{0}
"
.
format
(
e
),
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
print
(
commands
)
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Sat, Oct 17, 12:09 AM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4350230
Default Alt Text
vyos-config-to-commands (717 B)
Attached To
Mode
rVYOSONEX vyos-1x
Attached
Detach File
Event Timeline
Log In to Comment