cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
459
Views
0
Helpful
0
Replies

How to deploy a service with guestshell on ISR1K?

DeanMoore
Level 1
Level 1

Morning folks,

 

I've been scratching my head/beard over this for a while and can't seem to resolve it, let me set the scene.

 

I have a ISR1K with guestshell, I've installed python3 and a few other tools and deployed my flask based app successfully, runs great if I log in to guestshell and run the command 

sudo -E python3 myapp.py

The problem arises when I wish to run the app as a service using systemd .service setup I run in to trouble with the environment variable.  the -E in the sudo command retains the environment from the current user, transferring all the setting over including the token file to be able to run Cisco CLI commands within python

I have hidden the token:

Environment=SHELL_SESSION_host="/cisco/nginx_shared/pnp_python.sock"
Environment=SHELL_SESSION_logfile="/cisco/cisco_cli/<<token>>/cisco_cli.log"
Environment=SHELL_SESSION_max_wait="3600"
Environment=SHELL_SESSION_pnp_listener_path="/pnp_python"
Environment=SHELL_SESSION_scheme="unixhttp"
Environment=SHELL_SESSION_session_id="<<token>>"
Environment=SHELL_SESSION_token_file="/cisco/cisco_cli/<<token>>/token"

I've tried to run the service as guestshell user and the command to run include the /usr/bin/sudo -E command, no dice.  I've tried creating an environment file for the systemd settings but as the token seems to be per session I'm not getting anywhere.  I've tried creating a startup bash script to run sudo -E but this also fails with errors saying missing 'host' variable in the environment which refers to the SHELL_SESSION_host variable above

 

Does anyone have any ideas on where I should go next?

 

Thanks

 

ps: I have remodeled the cli and pnp python modules to python3 as they are default python 2.7 on guestshell if anyone is interested in it

0 Replies 0