Skip to main content

A python library for accessing IGEL's IMI

Project description

A python library for accessing IGEL's IMI

``` {.sourceCode .python}
from igel import IMI, Devices, Directories, Profiles
from igel import IMIAuthError, IMIConnectionError, MoveError, CreateError
import sys

# First, create your IMI session
try:
imi = IMI(server='192.168.56.12', user='igel', password='igel#123')
except IMIAuthError as err:
print(err)
sys.exit(1)
except IMIConnectionError as err:
print(err)
sys.exit(1)

# retrieve a list of your devices
devices = Devices(imi)

# and also a list of your directories
directories = Directories(imi)

# and also a list of your Profiles
profiles = Profiles(imi)

# you can iterate through the retreived items
for device in devices:
print(device.name)

for directory in directories:
print(directory.name)

for profile in profiles:
print(profile.name)

# Or, to find a paricular device, you can search
# by name, IP address, or MAC
device1 = devices.find(name="ITC080027B8A48E")
device2 = devices.find(ip="192.168.56.104")
#device3 = devices.find(mac="080027B8A48E")

if device1:
print("device1 IP address is", device1.ip)

if device2:
print("device2 name is", device2.name)

# Check if your device is online like this
print("Is device1 online?", device1.online)
print("Is device2 online?", device2.online)

# You can find a directory by name
my_directory = directories.find(name="Portland")
if my_directory:
print("Found directory")
else:
print("directory was not found")

# Create a new directory for devices like this
try:
directories.create("Vancouver")
except CreateError as err:
print(err)


# Now that you have both a device and a directory,
# you can move the device into that directory
try:
device1.move(my_directory)
except MoveError as err:
print(err)

# And you can also move a device directory into another directory
my_directory2 = directories.find(name="Bend")
try:
my_directory2.move(my_directory)
except MoveError as err:
print(err)


# Here's how you assign a profile to a device or a directory
browser_profile = profiles.find(name='Browser')
device1.assign(browser_profile)
my_directory.assign(browser_profile)

# And then you can unassign a profile like this
device1.unassign(browser_profile)
my_directory.unassign(browser_profile)


# Get some additional information about your device
device1.get_info()
print("A smaller set of device info includes:", device1.info)

# Get more detailed information
device1.get_info(detailed=True)
# Now, device info shows more
print("A much larger set of device info includes:", device1.info)

# Run some commands on your device
device1.reboot()
device1.shutdown()
device1.wakeup()
device1.settings2tc()
#device1.factory()

# For now, when you factory a device
# you should retrieve all devices again to have a
# valid list
```

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for igel, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size igel-0.0.2-py3-none-any.whl (7.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size igel-0.0.2.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page