9.6. networking

class nettoolkit.nettoolkit_common.networking.IP[source]

Bases: object

Collection of static methods for Networking on (IP). see more…

static bin2dec(binmask)[source]

convert binary mask to decimal mask

Parameters:

binmask (str) – binary mask value

Returns:

Decimal mask

Return type:

int

static inv2dec(invmask)[source]

convert inverse mask to decimal mask

Parameters:

invmask (str) – inverse mask value

Returns:

Decimal mask

Return type:

int

static ping_average(ip)[source]

return average ping responce for provided ip

Parameters:

ip (str) – ip address string

Returns:

responce time or None

Return type:

int, None

nettoolkit.nettoolkit_common.networking.expand_if(ifname)[source]

get the full length interface string for variable length interface

Parameters:

ifname (str) – variable length interface name

Returns:

updated interface string

Return type:

str

nettoolkit.nettoolkit_common.networking.expand_if_dict(d)[source]

returns updated the dictionary with standard expanded interface format in keys.

Parameters:

d (dict) – dictionary where keys are interface names

Returns:

updated dictionary keys with standard expanded interface format

Return type:

dict

nettoolkit.nettoolkit_common.networking.get_int_ip(ip)[source]

get ip address from ip/mask info

Parameters:

ip (str) – ip with mask

Returns:

ip address

Return type:

str

nettoolkit.nettoolkit_common.networking.get_int_mask(ip)[source]

get mask from ip/mask info

Parameters:

ip (str) – ip with mask

Returns:

mask

Return type:

str

nettoolkit.nettoolkit_common.networking.get_interface_cisco(line)[source]

get the standard interface string from interface config line

Parameters:

ifname (str) – line starting with interface [interface name]

Returns:

standard interface string

Return type:

str

nettoolkit.nettoolkit_common.networking.get_juniper_pw_string(spl, key_index)[source]

get plain-text-password from encrypted password.

Parameters:
  • spl (list) – splitted set command list for password entry.

  • key_index (int) – index of password

Returns:

decrypted password

Return type:

str

nettoolkit.nettoolkit_common.networking.get_vlans_cisco(line)[source]

set of vlan numbers allowed for the interface.

Parameters:

line (str) – interface config line containing vlan info

Returns:

vlan information dictionary

Return type:

dict

nettoolkit.nettoolkit_common.networking.get_vlans_juniper(spl, how='s')[source]

get the list of vlans on the interface

Parameters:

spl (list) – splitted line

Returns:

list of vlans

Return type:

list

nettoolkit.nettoolkit_common.networking.get_vrf_cisco(line)[source]

get the standard vrf string from vrf config line

Parameters:

ifname (str) – line starting with vrf definition [vrf name]

Returns:

standard interface string

Return type:

str

nettoolkit.nettoolkit_common.networking.nslookup(ip)[source]

return discovered hostname for provided ip

Parameters:

ip (str) – ip address

Returns:

domain name string

Return type:

str

nettoolkit.nettoolkit_common.networking.trunk_vlans_cisco(line)[source]

supportive to get_vlans_cisco(). derives trunk vlans

Parameters:

line (str) – interface config line containing vlan info

Returns:

list or set of trunk vlans

Return type:

list, set