def CollectInventory(arglist): parser = ArgumentParser(description='Inventory Collector') parser.add_argument('-u', '--user', action="store", dest="user", type=str, nargs='?', default='root', help="Username to use for iDRAC") parser.add_argument('-p', '--password', action="store", dest="password", type=str, default='calvin', help="Password to use for iDRAC") parser.add_argument('-i', '--ipaddress', action="store", dest="idrac_ip", nargs='+', help="ipaddress of iDRAC") parser.add_argument('-f', '--folder', action="store", dest="folder", type=str, help="folder from where inventory is serialized") options = parser.parse_args(arglist) if options.password is None: print("password must be provided") return -1 if options.user is None: print("user must be provided") return -1 if options.folder is None: print("Folder must be provided") return -1 if options.idrac_ip is None or len(options.idrac_ip) <= 0: print("iDRAC ip addresses must be provided") return -1 updshare = LocalFile(local = options.folder, isFolder=True) if not updshare.IsValid: print("Folder is not writable!") return -2 print("Configuring Update Share...") UpdateManager.configure(updshare) sd = sdkinfra() sd.importPath() creds = UserCredentials(options.user, options.password) for ipaddr in options.idrac_ip: try: print("Connecting to " + ipaddr + " ... ") idrac = sd.get_driver(sd.driver_enum.iDRAC, ipaddr, creds) if idrac: print(" ... saving firmware!") UpdateHelper.save_firmware_inventory(idrac) idrac.disconnect() else: print(" failed to connect to iDRAC") except Exception as ex: print(str(ex))
def __init__(self, module_params): if not HAS_OMSDK: raise ImportError( "Dell EMC OMSDK library is required for this module") self.idrac_ip = module_params['idrac_ip'] self.idrac_user = module_params['idrac_user'] self.idrac_pwd = module_params['idrac_pwd'] self.idrac_port = module_params['idrac_port'] if not all((self.idrac_ip, self.idrac_user, self.idrac_pwd)): raise ValueError("hostname, username and password required") self.handle = None self.creds = UserCredentials(self.idrac_user, self.idrac_pwd) self.pOp = WsManOptions(port=self.idrac_port) self.sdk = sdkinfra() if self.sdk is None: msg = "Could not initialize iDRAC drivers." raise RuntimeError(msg)
def connect(self): results = {} ansible_module_params = self.module.params idrac = ansible_module_params.get('idrac') idrac_ip = ansible_module_params.get('idrac_ip') idrac_user = ansible_module_params.get('idrac_user') idrac_pwd = ansible_module_params.get('idrac_pwd') idrac_port = ansible_module_params.get('idrac_port') if idrac: return idrac try: sd = sdkinfra() sd.importPath() except Exception as e: results['msg'] = "Could not initialize drivers" results['exception'] = str(e) self.module.fail_json(**results) # Connect to iDRAC if idrac_ip == '' or idrac_user == '' or idrac_pwd == '': results['msg'] = "hostname, username and password required" self.module.fail_json(**results) else: creds = UserCredentials(idrac_user, idrac_pwd) pOp = WsManOptions(port=idrac_port) idrac = sd.get_driver(sd.driver_enum.iDRAC, idrac_ip, creds, pOptions=pOp) if idrac is None: results[ 'msg'] = "Could not find device driver for iDRAC with IP Address: " + idrac_ip self.module.fail_json(**results) self.handle = idrac return idrac
def connect(self): results = {} ansible_module_params = self.module.params idrac = ansible_module_params.get('idrac') idrac_ip = ansible_module_params.get('idrac_ip') idrac_user = ansible_module_params.get('idrac_user') idrac_pwd = ansible_module_params.get('idrac_pwd') idrac_port = ansible_module_params.get('idrac_port') if idrac: return idrac try: sd = sdkinfra() sd.importPath() except Exception as e: results['msg'] = "Could not initialize drivers" results['exception'] = str(e) self.module.fail_json(**results) # Connect to iDRAC if idrac_ip == '' or idrac_user == '' or idrac_pwd == '': results['msg'] = "hostname, username and password required" self.module.fail_json(**results) else: creds = UserCredentials(idrac_user, idrac_pwd) pOp = WsManOptions(port=idrac_port) idrac = sd.get_driver(sd.driver_enum.iDRAC, idrac_ip, creds, pOptions=pOp) if idrac is None: results['msg'] = "Could not find device driver for iDRAC with IP Address: " + idrac_ip self.module.fail_json(**results) self.handle = idrac return idrac
from omsdk.sdkfile import FileOnShare from omsdk.sdkprint import PrettyPrint import logging from omdrivers.lifecycle.iDRAC.RAIDHelper import * myshare = FileOnShare(remote="\\\\<share>\\Share", mount_point='Z:\\', isFolder=True, creds=UserCredentials("user@domain", "password")) ipaddr = '192.168.0.1' logging.basicConfig(level=logging.DEBUG) myshare.valid = True Simulator.start_simulating() sd = sdkinfra() sd.importPath() idrac = sd.get_driver('iDRAC', ipaddr, UserCredentials('user', 'pass')) idrac.config_mgr.set_liason_share(myshare) def emailtest(idrac, address, expected, action=1): print(expected) idrac.config_mgr._sysconfig.iDRAC.EmailAlert._index_helper.printx() try: if action == 1: idrac.config_mgr._sysconfig.iDRAC.EmailAlert.new( Address_EmailAlert=address, CustomMsg_EmailAlert=address) else: idrac.config_mgr._sysconfig.iDRAC.EmailAlert.remove( Address_EmailAlert=address)