ASAConsole::Test.script do |asa|
asa.connect
if asa.version? '< 8.3(1)'
log "Objects are not supported in version #{asa.version}"
else
id = 'TestObject-192.0.2.1'
asa.config_exec!('no object network ' + id, ignore_errors: true)
asa.config_exec!('object network ' + id)
asa.config_exec('description My network object', require_config_mode: 'config-network-object')
asa.config_exec('host 192.0.2.1', require_config_mode: 'config-network-object')
begin
asa.config_exec('description Something went wrong', require_config_mode: 'config-object')
rescue ASAConsole::Error::ConfigModeError => e
log "Rescued config mode error: #{e.message}"
end
rc = asa.running_config('object id ' + id).select('object')
desc = rc.select('description').config_data
host = rc.select('host').config_data
log "Network object #{id} has description #{desc.dump}"
log "Network object #{id} has host #{host}"
asa.config_exec!('no object network ' + id)
rc = asa.running_config('object id ' + id).select('object')
if rc.nil?
log "Object #{id} has been removed"
else
log "Object #{id} still exists"
end
end
asa.disconnect
end