mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Initial drac management
This commit is contained in:
parent
518590af40
commit
d1e9a7c080
81
salt/modules/drac.py
Normal file
81
salt/modules/drac.py
Normal file
@ -0,0 +1,81 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Manage Dell DRAC
|
||||
'''
|
||||
|
||||
import salt.utils
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
||||
'''
|
||||
if salt.utils.which('racadm'):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def __parse_drac(output):
|
||||
'''
|
||||
Parse Dell DRAC output
|
||||
'''
|
||||
drac = {}
|
||||
section = ''
|
||||
|
||||
for i in output.splitlines():
|
||||
if len(i.rstrip()) > 0 and '=' in i:
|
||||
if section in drac:
|
||||
drac[section].update(dict(
|
||||
[[prop.strip() for prop in i.split('=')]]
|
||||
))
|
||||
else:
|
||||
section = i.strip()[:-1]
|
||||
if section not in drac and section:
|
||||
drac[section] = {}
|
||||
|
||||
return drac
|
||||
|
||||
|
||||
def getsysinfo():
|
||||
'''
|
||||
Return System information
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt dell drac.getsysinfo
|
||||
'''
|
||||
drac = {}
|
||||
section = ''
|
||||
|
||||
cmd = __salt__['cmd.run_all']('racadm getsysinfo')
|
||||
|
||||
if cmd['retcode'] != 0:
|
||||
log.warn('racadm return an exit code \'{0}\'.'.format(cmd['retcode']))
|
||||
|
||||
return __parse_drac(cmd['stdout'])
|
||||
|
||||
|
||||
def getniccfg():
|
||||
'''
|
||||
Return Network Configuration
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt salt drac.getniccfg
|
||||
'''
|
||||
|
||||
cmd = __salt__['cmd.run_all']('racadm getniccfg')
|
||||
|
||||
if cmd['retcode'] != 0:
|
||||
log.warn('racadm return an exit code \'{0}\'.'.format(cmd['retcode']))
|
||||
|
||||
return __parse_drac(cmd['stdout'])
|
Loading…
Reference in New Issue
Block a user