Submit a ticketCall us

Don’t fall victim to a ransomware attack
Backups are helpful, but sometimes that’s not enough to protect your business against ransomware. At our live webcast we will discuss how to protect against ransomware attacks with SolarWinds® Patch Manager and how to leverage log data to detect ransomware. Register now for our live webcast.

Home > Success Center > Kiwi CatTools > Kiwi CatTools 3.11 Administrator Guide > API > CatTools API Classes > CatTools Device class > Sample code for using the CatTools API Device object

Sample code for using the CatTools API Device object

Table of contents
No headers
Created by Caroline Juszczak, last modified by Caroline Juszczak on Jun 28, 2016

Views: 27 Votes: 0 Revisions: 1

Sample VB code showing you how to use the Device object of the CatTools API to add, edit or delete an entry in the database.

 

Add

Dim DB As CatToolsAPI.Database

Dim Device As CatToolsAPI.Device

 

Set DB = New CatToolsAPI.Database

If DB.OpenConnection Then

Set Device = DB.Devices.AddNew("Cisco.Router.General")

If Not Device Is Nothing Then

Device.Name = "My Device 01"

Device.HostAddress = "192.168.1.1"

Device.Group = "My Test Group"

Device.RequireVTYLogin = True

Device.VTYPass = "My Password"

Device.ConnectionMethod = "Telnet"

If DB.Devices.SaveDevice(Device) Then

Debug.Print Device.Name & " saved to the database OK."

Else

Debug.Print "Adding " & Device.Name & " failed: " & DB.ErrDescription

End If

Else

Debug.Print "Creation of a new device failed: " & DB.ErrDescription

End If

Else

Debug.Print "DB connection failed: " & DB.ErrDescription

End If

 

Set Device = Nothing

Set DB = Nothing

 

Edit

Dim DB As CatToolsAPI.Database

Dim Devices As CatToolsAPI.Devices

Dim Device As CatToolsAPI.Device

 

Set DB = New CatToolsAPI.Database

If DB.OpenConnection Then

Set Devices = DB.Devices

Set Device = Devices.GetByName("My Device 01")

If Not Device Is Nothing Then

Debug.Print Device.Name & " Loaded OK"

Device.AAAPassword = "My New Password "

If Devices.SaveDevice(Device) Then

Debug.Print ??Device.Name & " saved OK"

Else

Debug.Print Device.Name & " NOT saved: " & DB.ErrDescription

End If

Else

Debug.Print "Device not found"

End If

Else

Debug.Print "DB connection failed: " & DB.ErrDescription

End If

 

Set Device = Nothing

Set Devices = Nothing

Set DB = Nothing

 

Delete

Dim DB As CatToolsAPI.Database

 

Set DB = New CatToolsAPI.Database

If DB.OpenConnection Then

If DB.Devices.DeleteByName("My Device 01") Then

Debug.Print "Deleted OK"

Else

Debug.Print "Delete failed: " & DB.ErrDescription

End If

Else

Debug.Print "DB connection failed: " & DB.ErrDescription

End If

 

Set DB = Nothing

Last modified
07:23, 28 Jun 2016

Tags

Classifications

Public