Update Cisco ASA object group with netmiko

This is a demo of configuring ASA with netmiko, there is a use case when a server is provisioned, the server’s hostname and ip addresses are assigned automatically by Vrealize, and run a python script to update the object-group of the server.

Here’s the code:

from netmiko import ConnectHandler
from getpass import getpass
import logging

usr = input("Username: ")
pwd = getpass()
asav = {  'device_type': 'cisco_asa',
    'ip': '192.168.1.15',
    'username': usr,
    'password': pwd,
    'secret': pwd,
    'port': '22', }

config_set = ['object network member1', 'host 1.1.1.1 ', 'exit', 'object network member2', 'host 2.2.2.2', 'exit', 'object-group network Group1',
           'network-object object member1', 'network-object object member2' ]

logging.basicConfig(level=logging.DEBUG)
with ConnectHandler(**asav) as m:
    m.enable()
    m.config_mode()
    m.send_config_set(config_set, True)
    m.send_command_expect('write memory')
Advertisement

One thought on “Update Cisco ASA object group with netmiko

  1. Have you found reliability issues when deploying ACL’s? I have found updating ACL’s impossible due to missing lines. The ACL’s I was trying to update were 65 lines and 107 lines.

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