Merge pull request #121 from spotify/base_new_methods
Merging tehhobbit-base_new_methods
This commit is contained in:
commit
cfc3b6cdca
2 files changed
+43
-16
No files matched your search
+40
-16
@@ -153,22 +153,45 @@ class FortiOSDriver(NetworkDriver):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def get_interfaces(self):
|
def get_interfaces(self):
|
||||||
interface_statistics = dict()
|
cmd_prefix = ''
|
||||||
self.device.load_config('system interface')
|
try:
|
||||||
for iface in self.get_facts()['interface_list']:
|
cmd_data = self.device.execute_command('diagnose hardware deviceinfo nic')
|
||||||
try:
|
except CommandExecutionException:
|
||||||
hw_output = execute_get(self.device, 'diagnose hardware deviceinfo nic {}'.format(iface), auto=True)
|
cmd_data = self.device.execute_command('conf global\n diagnose hardware deviceinfo nic ')
|
||||||
ifs = self._get_tab_separated_interfaces(hw_output)
|
cmd_prefix = 'conf global\n'
|
||||||
|
|
||||||
ifs['is_enabled'] = self.device.running_config['system interface'][iface].get_param('status') != 'down'
|
interface_list = [x.replace('\t', '') for x in cmd_data if x.startswith('\t')]
|
||||||
ifs['description'] = self.device.running_config['system interface'][iface].get_param('description')
|
interface_statistics = {}
|
||||||
ifs['last_flapped'] = None
|
for interface in interface_list:
|
||||||
# ifs['mode'] = 'routed'
|
if_data = self.device.execute_command(cmd_prefix + 'diagnose hardware deviceinfo nic {}'.format(interface))
|
||||||
ifs['last_flapped'] = None
|
parsed_data = {}
|
||||||
interface_statistics[iface] = ifs
|
if interface.startswith('mgmt'):
|
||||||
except CommandExecutionException:
|
for line in if_data:
|
||||||
interface_statistics[iface] = self._get_unsupported_interfaces()
|
if line.startswith('Speed'):
|
||||||
|
if line.split('\t')[-1].split(' ')[0].isdigit():
|
||||||
|
parsed_data['speed'] = int(line.split('\t')[-1].split(' ')[0])
|
||||||
|
else:
|
||||||
|
parsed_data['speed'] = -1
|
||||||
|
elif line.startswith('Link'):
|
||||||
|
parsed_data['is_up'] = line.split('\t')[-1] is 'up'
|
||||||
|
elif line.startswith('Current_HWaddr'):
|
||||||
|
parsed_data['mac_address'] = unicode(line.split('\t')[-1])
|
||||||
|
parsed_data['is_enabled'] = True
|
||||||
|
parsed_data['description'] = u''
|
||||||
|
parsed_data['last_flapped'] = -1.0
|
||||||
|
else:
|
||||||
|
for line in if_data:
|
||||||
|
if line.startswith('Admin'):
|
||||||
|
parsed_data['is_enabled'] = line.split(':')[-1] is 'up'
|
||||||
|
elif line.startswith('PHY Status'):
|
||||||
|
parsed_data['is_up'] = line.split(':')[-1] is 'up'
|
||||||
|
elif line.startswith('PHY Speed'):
|
||||||
|
parsed_data['speed'] = int(line.split(':')[-1])
|
||||||
|
elif line.startswith('Current_HWaddr'):
|
||||||
|
parsed_data['mac_address'] = unicode(line.split(' ')[-1])
|
||||||
|
parsed_data['description'] = u''
|
||||||
|
parsed_data['last_flapped'] = -1.0
|
||||||
|
interface_statistics[interface] = parsed_data
|
||||||
return interface_statistics
|
return interface_statistics
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -363,3 +386,4 @@ class FortiOSDriver(NetworkDriver):
|
|||||||
out['power'] = {t: {'status': True, 'capacity': -1.0, 'output': -1.0} for t in psus}
|
out['power'] = {t: {'status': True, 'capacity': -1.0, 'output': -1.0} for t in psus}
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
The following NICs are available:
|
||||||
|
mgmt2
|
||||||
|
port1
|
||||||
Reference in new issue
Block a user