HP VSR Update 7.10 E0102 now supports Python

HP has released an update of the VSR (Virtual Service Router) firmware.

The update can be downloaded here:

https://h10145.www1.hp.com/downloads/SoftwareReleases.aspx?ProductNumber=JG811AAE&lang=&cc=&prodSeriesId=

Although release notes state it is just a maintenance release (after 0101), so no new features have been released, I realized I was still working on version E0001 (never even noticed E0101), so a nice new feature of Comware 7 is included:

Python scripting support !

So the network admin can now take advantage of Python language and scripts locally on the device.

This is a very basic example, first the device version:

<HP>dis version
HP Comware Software, Version 7.1.049, ESS 0102
Copyright (c) 2010-2013 Hewlett-Packard Development Company, L.P.
HP VSR1000 uptime is 0 weeks, 0 days, 1 hour, 18 minutes
Last reboot reason : Power on
Boot image: flash:/VSR1000-CMW710-BOOT-E0102-X64.bin
Boot image version: 7.1.049P03, ESS 0102
  Compiled Dec 19 2013 16:49:30
System image: flash:/VSR1000-CMW710-SYSTEM-E0102-X64.bin
System image version: 7.1.049, ESS 0102
  Compiled Dec 19 2013 16:49:30

CPU ID: 0x01000101, vCPUs: Total 1, Available 1
0.54G bytes RAM Memory
Basic    BootWare Version:  1.02
Extended BootWare Version:  1.02
[SLOT  1]VNIC-E1000         (Driver)1.0

<HP>

Now enter the Python script view:

<HP>
<HP>python
Python 2.7.3 (default, May 24 2013, 14:39:11)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

This would be a sample script to create 5 subinterfaces with a Vlan ID and an IP address:

import comware
for x in range(1, 5):
strcli = “sys ;int g1/0.%d ;vlan-type dot1q vid %d ;ip address 10.0.%d.1 24” % (x, x, x)
comware.CLI(strcli)
 
 

And this is the output on the device:

<HP>
<HP>python
Python 2.7.3 (default, May 24 2013, 14:39:11)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import comware
>>> for x in range(1, 5):
...     strcli = "sys ;int g1/0.%d ;vlan-type dot1q vid %d ;ip address 10.0.%d.1 24" % (x, x, x)
...     comware.CLI(strcli)
...
<HP>sys
System View: return to User View with Ctrl+Z.
[HP]int g1/0.1
[HP-GigabitEthernet1/0.1]vlan-type dot1q vid 1
[HP-GigabitEthernet1/0.1]ip address 10.0.1.1 24
<comware.CLI object at 0x7fcd42fc40f0>

<HP>sys
System View: return to User View with Ctrl+Z.
[HP]int g1/0.2
[HP-GigabitEthernet1/0.2]vlan-type dot1q vid 2
[HP-GigabitEthernet1/0.2]ip address 10.0.2.1 24
<comware.CLI object at 0x7fcd42fc4108>
<HP>sys
System View: return to User View with Ctrl+Z.
[HP]int g1/0.3
[HP-GigabitEthernet1/0.3]vlan-type dot1q vid 3
[HP-GigabitEthernet1/0.3]ip address 10.0.3.1 24
<comware.CLI object at 0x7fcd42fc40f0>
<HP>sys
System View: return to User View with Ctrl+Z.
[HP]int g1/0.4
[HP-GigabitEthernet1/0.4]vlan-type dot1q vid 4
[HP-GigabitEthernet1/0.4]ip address 10.0.4.1 24
<comware.CLI object at 0x7fcd42fc4108>
>>>

And on the normal CLI interface:

<HP>dis int brief
Brief information on interface(s) under route mode:
Link: ADM - administratively down; Stby - standby
Protocol: (s) - spoofing
Interface            Link Protocol Main IP         Description
GE1/0                UP   UP       192.168.5.254
GE1/0.1              UP   UP       10.0.1.1
GE1/0.2              UP   UP       10.0.2.1
GE1/0.3              UP   UP       10.0.3.1
GE1/0.4              UP   UP       10.0.4.1
InLoop0              UP   UP(s)    --
NULL0                UP   UP(s)    --
REG0                 DOWN --       --

<HP>

Next to ad-hoc scripts, it is also possible to save .py files on the device and launch these from the same prompt:

<HP>python ?
  STRING  [drive][path][file name]
  <cr>

<HP>python interface.py

So this can be useful for automation of templates or parsing display output.

This entry was posted in Comware7 and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s