Hi Nicholas,
I have created the following script with the purpose of what you want to achieve.
Basically your error is related to the command nat-settings.auto-rule "true" which fails.. I am not sure this is necessary. Leave it out if you don't need it.
Hope this can help you on your way.
You can test below code by
1) open ssh to SMS server
2) vi <name of the script file.sh>
3) press 'i' for insert
4) right click to paste code in to file
5) press ESC
6) press ':' and 'w' and 'q' for write and exist vi
7) chmod +x <name of script file.sh>
😎 ./<name of script file.sh>
Running the script will guide you what you need to do next.
As you can see it is now created.
---- start script Network.sh -------
#/bin/bash
#########################################################################
# script created by Kim Moberg, Eurowind Energy A/S - February 7th 2019
#
#########################################################################
# Clear screen
clear
########################################################################
# Login to the API server, and save session to file id.txt
# Remeber when running the script setting the username and password
# without saving the password in the script file.
#
#######################################################################
# ask for credentials from user
echo "Please enter your username and password"
read -p "Enter username and press [ENTER]: " USER
read -s -p "Enter password and press [ENTER]: " PASS
echo
mgmt_cli login user ${USER} password ${PASS} > id.txt
# in case of an error: print to screen the error message and abort
if [ $? -ne 0 ]; then
echo "Login command failed."
cat id.txt
exit 1
fi
######################################################################
# Ask for user to define variables.
#
# Enter the name of the Network
# Enter subnet eg. 192.0.2.0
# Enter subnet-mask eg. 255.255.255.0
#
#####################################################################
echo
echo "Please enter Network name and IP subnet address and subnet mask."
read -p "Enter Network Name eg. DMZ_Network [ENTER] : " NETWORKNAME
echo
echo "Please defind network"
read -p "Enter subnet eg. 192.0.2.0 [ENTER] : " SUBNET
read -p "Enter subnet-mask eg. 255.255.255.0 [ENTER] : " SUBNETMASK
echo
networkname="${NETWORKNAME}"
mgmt_cli -s id.txt add network name $networkname subnet "${SUBNET}" subnet-mask "${SUBNETMASK}" comments "Auto generated network object with MGMT API"
mgmt_cli -s id.txt publish
#####################################################################
# Finalize publish all the changes. We must logout.
#
# The correct flow when working with management API -
# Login -> work -> publish/discard -> logout
#
#####################################################################
mgmt_cli logout -s id.txt
----end of script file-----
Best regards
Kim
Best Regards
Kim