def my_connect(self, ipaddr, creds, pOptions): if pOptions: logger.debug("Using wsman options!") self.proto = WsManProtocol(ipaddr, creds, WsManOptions()) if self.proto is None: return False return True
def my_connect(self, ipaddr, creds, pOptions): if pOptions is None: pOptions = WsManOptions() self.proto = WsManProtocol(ipaddr, creds, pOptions) if self.proto is None: return False return True
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