def get_system_info(): ''' Get system information. :return: Returns a Dictionary containing information about the system to include name, description, version, etc... :rtype: dict ''' system_info = win32net.NetServerGetInfo(None, 101) return system_info
def set_computer_desc(desc=None): ''' Set the Windows computer description Args: desc (str): The computer description Returns: str: Description if successful, otherwise ``False`` CLI Example: .. code-block:: bash salt 'minion-id' system.set_computer_desc 'This computer belongs to Dave!' ''' if six.PY2: desc = _to_unicode(desc) # Make sure the system exists # Return an object containing current information array for the computer system_info = win32net.NetServerGetInfo(None, 101) # If desc is passed, decode it for unicode if desc is None: return False system_info['comment'] = desc # Apply new settings try: win32net.NetServerSetInfo(None, 101, system_info) except win32net.error as exc: (number, context, message) = exc log.error('Failed to update system') log.error('nbr: {0}'.format(number)) log.error('ctx: {0}'.format(context)) log.error('msg: {0}'.format(message)) return False return {'Computer Description': get_computer_desc()}
def set_computer_desc(desc=None): """ Set the Windows computer description Args: desc (str): The computer description Returns: str: Description if successful, otherwise ``False`` CLI Example: .. code-block:: bash salt 'minion-id' system.set_computer_desc 'This computer belongs to Dave!' """ # Make sure the system exists # Return an object containing current information array for the computer system_info = win32net.NetServerGetInfo(None, 101) # If desc is passed, decode it for unicode if desc is None: return False system_info["comment"] = desc # Apply new settings try: win32net.NetServerSetInfo(None, 101, system_info) except win32net.error as exc: (number, context, message) = exc.args log.error("Failed to update system") log.error("nbr: %s", number) log.error("ctx: %s", context) log.error("msg: %s", message) return False return {"Computer Description": get_computer_desc()}
def set_computer_desc(desc=None): ''' Set the Windows computer description :param str desc: The computer description :return: False if it fails. Description if successful. CLI Example: .. code-block:: bash salt 'minion-id' system.set_computer_desc 'This computer belongs to Dave!' ''' # Make sure the system exists # Return an object containing current information array for the computer system_info = win32net.NetServerGetInfo(None, 101) # If desc is passed, decode it for unicode if desc is None: return False if not isinstance(desc, str): desc = desc.decode('utf-8') system_info['comment'] = desc # Apply new settings try: win32net.NetServerSetInfo(None, 101, system_info) except win32net.error as exc: (number, context, message) = exc log.error('Failed to update system') log.error('nbr: {0}'.format(number)) log.error('ctx: {0}'.format(context)) log.error('msg: {0}'.format(message)) return False return {'Computer Description': get_computer_desc()}