05-10-2023 12:10 AM
Hi,
As part of the ZTP process the guestshell container initiated at bootup is destroyed automatically. How can we manage to keep it alived and persistent?
Platform tested : ISR4321 & ISR1111
Thanks and Regards,
Jerems
Solved! Go to Solution.
05-10-2023 12:43 AM
Hello @Jerems,
=> configure the guestshell to persist across reloads and power cycles.
--Creates a guestshell image with persistent storage on the device's flash memory:
ISR4321#guestshell create image persistflash:/guestshell.pie
--Activate the guestshell container using the newly created image:
ISR4321#guestshell run image persistflash:/guestshell.pie
--Configure the guestshell container to start automatically at bootup:
ISR4321#conf t
ISR4321(config)#guestshell enable
ISR4321(config)#exit
ISR4321#copy running-config startup-config
05-10-2023 12:43 AM
Hello @Jerems,
=> configure the guestshell to persist across reloads and power cycles.
--Creates a guestshell image with persistent storage on the device's flash memory:
ISR4321#guestshell create image persistflash:/guestshell.pie
--Activate the guestshell container using the newly created image:
ISR4321#guestshell run image persistflash:/guestshell.pie
--Configure the guestshell container to start automatically at bootup:
ISR4321#conf t
ISR4321(config)#guestshell enable
ISR4321(config)#exit
ISR4321#copy running-config startup-config
05-10-2023 12:52 AM
Hi M02@rt37,
Thank you so much for your great help !
Can you please point me to the url/documentation where all of these great informations are stored ?
Thanks in advance & have a great day !
Jerems
05-10-2023 02:13 AM
Hi, M02@rt37
Moreover,
I tried this in my ztp python script:
print("\n\n *** Execute Guestshell command - create persistent guestshell *** \n\n")
output1 = cli.execute("guestshell create image persistflash:/guestshell.pie")
print(output1)
But got this instead :
*** Execute Guestshell command - create persistent guestshell ***
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/cli/__init__.py", line 340, in cli
subprocess.check_output(cmdline, stderr=subprocess.STDOUT, shell=True)
File "/usr/lib64/python3.6/subprocess.py", line 356, in check_output
**kwargs).stdout
File "/usr/lib64/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'iosp_client -om 3 -o /tmp/.iosp_2023_05_10_08_29_15_195684_2026331682.output -i /tmp/.iosp_2023_05_10_08_29_15_195684_2026331682.cmd' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/bootflash/guest-share/downloaded_script.py", line 93, in <module>
output1 = cli.execute("guestshell create image persistflash:/guestshell.pie")
File "/usr/lib/python3.6/site-packages/cli/__init__.py", line 392, in execute
return (cli(command, timeout))
File "/usr/lib/python3.6/site-packages/cli/__init__.py", line 350, in cli
raise IOSPCLIError
cli.IOSPCLIError: CLI syntax error or execution Failure
Guestshell destroyed successfully
Thanks and Regards,
Jerems
05-10-2023 02:35 AM
Vous pouvez également essayer d'ajouter un délai entre le processus ZTP et la commande de création du guestshell pour vous assurer que le système est entièrement initialisé avant de créer le guestshell persistant.
------
You could also try adding a delay between the ZTP process and the guestshell creation command to make sure that the system is fully initialized before creating the persistent guestshell
-------
import time
# Delay for 30 seconds before creating the persistent guestshell
time.sleep(30)
# Create the persistent guestshell
output1 = cli.execute("guestshell create image persistflash:/guestshell.pie")
print(output1)
05-10-2023 03:09 AM
05-10-2023 04:15 AM - edited 05-10-2023 04:27 AM
On your routeur does the command, #guestshell create, is known ?
Also you don't enable iox service ?
05-10-2023 05:10 AM
Again, thank you for reverting to me so quickly,
Here is the full script downloaded and executed at bootup :
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
########################################################################################################################
# This file is a part of Jeyriku.net.
#
# Created: 05.05.2023 11:52:05
# Author: Jeremie Rouzet
#
# Last Modified: 10.05.2023 12:08:31
# Modified By: Jeremie Rouzet
#
# Copyright (c) 2023 foo.net
########################################################################################################################
import subprocess
import time
import cli
# Check if Pynetbox library is installed
split_ip = cli.execute("sh ip int brief | in 192.168.100.")
temp_ip = split_ip.split()[1]
print(temp_ip)
temp_ip.split(".")
last_digit_ip = temp_ip.split(".")[3]
print(last_digit_ip)
print("\n\n *** Configuring Hostname *** \n\n")
config_hostname = cli.configure(
[
"hostname jeyrouter" + "_" + last_digit_ip,
"end"
]
)
print(config_hostname)
print("\n\n *** Configuring Domain name + name server *** \n\n")
cli.configure(
[
"ip domain name foo.net",
"ip name-server 192.168.0.252 192.168.0.250",
"end"
]
)
print("\n\n *** Configuring Username *** \n\n")
cli.configure(
[
"username root privilege 15 secret 9 $14$De/u$t12PLWPZasn73E$Klf7X/ijzUPCkLCtM7FoF1m2yaEP79glNJDiggmxJBg",
"end"
]
)
print("\n\n *** Configuring Line VTY *** \n\n")
cli.configure(
[
"line vty 0 15",
"exec-timeout 0 0",
"login local",
"transport input telnet ssh",
"escape-character 17",
"end"
]
)
print("\n\n *** Configuring Iox *** \n\n")
cli.configure(
[
"iox",
"end"
]
)
time.sleep(30)
print("\n\n *** Configuring Interface for App-Hosting *** \n\n")
cli.configure(
[
"interface VirtualPortGroup0",
"ip address 192.168.1.1 255.255.255.0",
"ip nat inside",
# "no mop enabled",
# "no mop sysid",
"end"
]
)
print("\n\n *** Configuring Interface for App-Hosting *** \n\n")
cli.configure(
[
"interface GigabitEthernet0/0/0",
"ip address dhcp",
"ip nat outside",
"no shut",
"end"
]
)
print("\n\n *** Configuring ACL for App-Hosting *** \n\n")
cli.configure(
[
"ip access-list extended GUESTSHELL-NAT-ACL",
"10 permit ip 192.168.1.0 0.0.0.255 any",
"end"
]
)
print("\n\n *** Configuring NAT for App-Hosting *** \n\n")
cli.configure(
[
"ip nat inside source list GUESTSHELL-NAT-ACL interface GigabitEthernet0/0/0 overload",
"end"
]
)
print("\n\n *** Configuring App-Hosting *** \n\n")
cli.configure(
[
"app-hosting appid guestshell",
"app-vnic gateway0 virtualportgroup 0 guest-interface 0",
"guest-ipaddress 192.168.1.2 netmask 255.255.255.0",
"app-default-gateway 192.168.1.1 guest-interface 0",
"name-server0 192.168.0.252",
"name-server1 192.168.0.250",
"end"
]
)
time.sleep(30)
print("\n\n *** Launch Guestshell *** \n\n")
output = cli.execute(
"guestshell enable"
)
print(output)
time.sleep(60)
print("\n\n *** Execute Guestshell command - create persistent guestshell *** \n\n")
output1 = cli.execute(
"guestshell create image persistflash:/guestshell.pie"
)
print(output1)
print("\n\n *** Execute Guestshell command - execute persistent guestshell *** \n\n")
output2 = cli.execute(
"guestshell run image persistflash:/guestshell.pie"
)
print(output2)
print("\n\n *** Execute Guestshell command - install requests *** \n\n")
output3 = cli.execute(
"guestshell run sudo python3 -m pip install requests"
)
print(output3)
time.sleep(30)
print("\n\n *** Execute Guestshell command - install pynetbox *** \n\n")
output4 = cli.execute(
"guestshell run sudo python3 -m pip install pynetbox"
)
print(output4)
print("\n\n *** launch automatically Guestshell at bootup *** \n\n")
cli.configure(
[
"guestshell enable",
"end"
]
)
print("\n\n *** Execute Guestshell command - execute dohost command *** \n\n")
output5 = cli.execute(
[
"guestshell run bash dohost sh ip int brief"
]
)
print(output5)
Thanks & Regards
05-10-2023 05:42 AM
Ok @Jerems, thanks for the output.
On your routeur does the command, #guestshell create, is known ?
05-10-2023 06:52 AM
Hi M02@rt37,
Let me check on both platforms and revert to you.
05-10-2023 07:00 AM
On the ISR 1111, no such options :
Need to check on ISR4321
05-10-2023 07:41 AM
on your router
config-t > guestshell > sudo guestshell persist <image_filename>
Replace <image_filename> with the name you want to give the persistent guestshell image file.
Verify thaht the persistent guestshell image file has been created:
#show virtual-service detail name guestshell
(You should see the path and name of the persistent guestshell image file listed in the output)
05-10-2023 07:31 AM
Ok @Jerems,
I'm afraid the command is not available.
Let me check also on my side.
12-15-2023 08:36 AM
Still not possible on isr 4321 nor isr1111
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide