def ipmi_enable(handle, priv=None, key=None, server_id=1): """ Enable IPMI over LAN. Args: handle (ImcHandle) priv (string): Optional privilege level: 'admin', 'user', 'read-only' key (string): Optional encryption key as hexadecimal string server_id (int): Server Id to be specified for C3260 platforms Returns: CommIpmiLan object Raises: ValueError if privilege or key are invalid Example: if ipmi_enable(handle): print("IPMI Enabled") """ from imcsdk.imcexception import ImcOperationError # Enable policy if only user mode is ipmi mos = handle.query_classid(class_id="AaaUserPolicy") userPolicy = mos[0] if userPolicy.user_mode != None and userPolicy.user_mode == 'non-ipmi': raise ImcOperationError("Enable IPMI over LAN", "IPMI user mode is disabled on the endpoint.") # Verify key is a hex number try: if key: hex(int(key, 16))[2:] except ValueError: raise ValueError('{0}: ERROR: Encryption key is not hex number: ' + '"{1}"'.format(handle.ip, key)) # Create enabled IPMI object mo = CommIpmiLan(parent_mo_or_dn=_get_comm_mo_dn(handle, server_id)) mo.admin_state = "enabled" mo.priv = priv mo.key = key # Configure IPMI object on CIMC handle.set_mo(mo) return mo
def is_ipmi_enabled(handle, server_id=1, **kwargs): """ Check if IPMI over LAN is enabled Args: handle (ImcHandle) server_id (int): Server Id to be specified for C3260 platforms Returns: True if enabled, else False """ mo = CommIpmiLan(parent_mo_or_dn=_get_comm_mo_dn(handle, server_id)) mo = handle.query_dn(mo.dn) kwargs['admin_state'] = "enabled" mo_exists = mo.check_prop_match(**kwargs) return (mo_exists, mo if mo_exists else None)
def ipmi_disable(handle, server_id=1): """ Disable IPMI over LAN. Args: handle (ImcHandle) server_id (int): Server Id to be specified for C3260 platforms Returns: CommIpmiLan object """ # Create disabled IPMI object mo = CommIpmiLan(parent_mo_or_dn=_get_comm_mo_dn(handle, server_id)) mo.admin_state = "disabled" # Configure IPMI object on CIMC handle.set_mo(mo) return mo
def ipmi_disable(handle, server_id=1): """ Disable IPMI over LAN. Args: handle (ImcHandle) server_id (int): Server Id to be specified for C3260 platforms Returns: CommIpmiLan object """ # Create disabled IPMI object ipmi_mo = CommIpmiLan(parent_mo_or_dn=_get_comm_mo_dn(handle, server_id)) ipmi_mo.admin_state = "disabled" # Configure IPMI object on CIMC handle.set_mo(ipmi_mo) return handle.query_dn(ipmi_mo.dn)
def ipmi_enable(handle, priv=CommIpmiLanConsts.PRIV_ADMIN, key='0' * 40, server_id=1): """ Enable IPMI over LAN. Args: handle (ImcHandle) priv (string): Optional privilege level: 'admin', 'user', 'read-only' key (string): Optional encryption key as hexadecimal string server_id (int): Server Id to be specified for C3260 platforms Returns: CommIpmiLan object Raises: ValueError if privilege or key are invalid Example: if ipmi_enable(handle): print("IPMI Enabled") """ # Verify key is a hex number try: hex(int(key, 16))[2:] except ValueError: raise ValueError('{0}: ERROR: Encryption key is not hex number: ' + '"{1}"'.format(handle.ip, key)) # Create enabled IPMI object ipmi_mo = CommIpmiLan(parent_mo_or_dn=_get_comm_mo_dn(handle, server_id)) ipmi_mo.admin_state = "enabled" ipmi_mo.priv = priv ipmi_mo.key = key # Configure IPMI object on CIMC handle.set_mo(ipmi_mo) return handle.query_dn(ipmi_mo.dn)
def ipmi_enable(handle, priv=None, key=None, server_id=1): """ Enable IPMI over LAN. Args: handle (ImcHandle) priv (string): Optional privilege level: 'admin', 'user', 'read-only' key (string): Optional encryption key as hexadecimal string server_id (int): Server Id to be specified for C3260 platforms Returns: CommIpmiLan object Raises: ValueError if privilege or key are invalid Example: if ipmi_enable(handle): print "IPMI Enabled" """ # Verify key is a hex number try: if key: hex(int(key, 16))[2:] except ValueError: raise ValueError('{0}: ERROR: Encryption key is not hex number: ' + '"{1}"'.format(handle.ip, key)) # Create enabled IPMI object mo = CommIpmiLan(parent_mo_or_dn=_get_comm_mo_dn(handle, server_id)) mo.admin_state = "enabled" mo.priv = priv mo.key = key # Configure IPMI object on CIMC handle.set_mo(mo) return mo
def is_ipmi_enabled(handle, server_id=1): """ Check if IPMI over LAN is enabled Args: handle (ImcHandle) server_id (int): Server Id to be specified for C3260 platforms Returns: True if enabled, else False """ ipmi_mo = CommIpmiLan(parent_mo_or_dn=_get_comm_mo_dn(handle, server_id)) ipmi_mo = handle.query_dn(ipmi_mo.dn) return (ipmi_mo.admin_state.lower() == "enabled")