cancel
Showing results for 
Search instead for 
Did you mean: 

Python: Creating upm profile with script

Python: Creating upm profile with script

Nikolai_Andre_E
New Contributor
I'm trying to write a python script to configure new switches and right now I'm struggling with creating UPM profiles through the script as running create upm profile [profilename] opens an interactive session, are there ways to make the python interpreter direct its output into this session or alternatively other ways to creating / editing upm profiles without calling this interactive session?
5 REPLIES 5

Matthew_Helm1
Extreme Employee
You could use a subprocess shell to send commands that need CLI interaction:

This example creates a upm profile named 'test':

import subprocess

p = subprocess.Popen(['/exos/bin/exsh','-n0', '-b', '-e','remote_serial'],
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)

print >> p.stdin, 'create upm profile test'
print >> p.stdin, '.'

GTM-P2G8KFN