Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error with "static" config file option #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions nx-os/poap/poap.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
# in your automation environment

# system and kickstart images, configuration: location on server (src) and target (dst)
n9k_image_version = "6.1.2" # this must match your code version
image_dir_src = "/tftpboot" # Sample - /Users/bob/poap
n9k_image_version = "7.0.3.I2.2a" # this must match your code version
image_dir_src = "/home/poap-sftp" # Sample - /Users/bob/poap
ftp_image_dir_src_root = image_dir_src
tftp_image_dir_src_root = image_dir_src
n9k_system_image_src = "n9000-dk9.%s.bin" % n9k_image_version
config_file_src = "/tftpboot/conf" # Sample - /Users/bob/poap/conf
image_dir_dst = "bootflash:poap" # directory where n9k image will be stored
n9k_system_image_src = "nxos.%s.bin" % n9k_image_version
config_file_src = "/home/poap-sftp/config" # Sample - /Users/bob/poap/co
nf
static_config_filename = "staticpoap.cfg"
image_dir_dst = "bootflash:poap" # directory where n9k image will be s
tored
system_image_dst = n9k_system_image_src
config_file_dst = "volatile:poap.cfg"
md5sum_ext_src = "md5"
Expand All @@ -50,10 +53,10 @@
protocol = "scp" # protocol to use to download images/config

# Host name and user credentials
username = "root" # server account
ftp_username = "anonymous" # server account
password = "root" # password
hostname = "1.1.1.1" # ip address of ftp/scp/http/sftp server
username = "poap-sftp" # server account
ftp_username = "poap-sftp" # server account
password = "C1sco123" # password
hostname = "10.0.0.15" # ip address of ftp/scp/http/sftp server

# vrf info
vrf = "management"
Expand Down Expand Up @@ -507,6 +510,12 @@ def set_config_file_src_serial_number ():
config_file_src = "%s.%s" % (config_file_src, serial_number)
poap_log("INFO: Selected config filename (serial_number) : %s" % config_file_src)

# set config name file to staticpoap.cfg
def set_config_file_src_static ():
global config_file_src
config_file_src = "%s.%s" % (config_file_src, static_config_filename)
poap_log("INFO: Selected config filename (static) : %s" % config_file_src)

# This check seems redundant but it's here as a defensive programming measure
# If the checks above change or go away, this code won't have to change
if config_file_type == "location" and cdp_interface is not None:
Expand All @@ -524,6 +533,8 @@ def set_config_file_src_serial_number ():
elif config_file_type == "serial_number":
#set source config file based on switch's serial number
set_config_file_src_serial_number()
elif config_file_type == "static":
set_config_file_src_static()
else:
poap_log("ERR: Either config_file_type is not valid or interface was not given and location can not be derived.")
exit(-1)
Expand Down