
    Vh                     f    d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZ d Zd Zed	k(  r e        y
y
)    )absolute_importdivisionprint_functionaU  
module: cli_backup
author: Katherine Case (@Qalthos)
short_description: Back up device configuration from network devices over network_cli
description:
- This module provides platform agnostic way of backing up text based configuration from
  network devices over network_cli connection plugin.
version_added: 4.2.0
extends_documentation_fragment:
- ansible.netcommon.network_agnostic
options:
  defaults:
    description:
    - The I(defaults) argument will influence how the running-config is collected
      from the device.  When the value is set to true, the command used to collect
      the running-config is append with the all keyword.  When the value is set to
      false, the command is issued without the all keyword.
    default: no
    type: bool
  filename:
    description:
    - The filename to be used to store the backup configuration. If the filename
      is not given it will be generated based on the hostname, current time and
      date in format defined by <hostname>_config.<current-date>@<current-time>
    type: str
  dir_path:
    description:
    - This option provides the path ending with directory name in which the backup
      configuration file will be stored. If the directory does not exist it will
      be first created and the filename is either the value of C(filename) or
      default filename as described in C(filename) options description. If the
      path value is not given in that case a I(backup) directory will be created
      in the current working directory and backup configuration will be copied
      in C(filename) within I(backup) directory.
    type: path
zt
- name: configurable backup path
  ansible.netcommon.cli_backup:
    filename: backup.cfg
    dir_path: /home/user
z
backup_path:
  description: The full path to the backup file
  returned: always
  type: str
  sample: /playbooks/ansible/backup/hostname_config.2016-07-16@22:28:34
)AnsibleModule)
Connectionc                     dg}|D ]V  }| j                   |   s|j                  d|z        }|| j                  d|z         ?|rB| j                  d|z         X y)z1validate param if it is supported on the platformdefaultszsupports_%sNz}This platform does not specify whether %s is supported or not. Please report an issue against this platform's cliconf plugin.)msgz+Option %s is not supported on this platform)paramsget	fail_json)moduledevice_operationsfeature_listfeaturesupports_features        p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ansible/netcommon/plugins/modules/cli_backup.pyvalidate_argsr   F   s     	L   	^==!044]W5LM'  UW^_ !  &  %RU\%\ ]	^    c                  
   t        t        dd      t               t        d            } t        |       }ddi}t        |j                        }|j	                  |j                               }|r'|j                  d	t                     }t        ||       n
t               }|j                  d
   r'd|j                  d      v r|j                         }nd}ng }|j                  |      }||d<    |j                  di | y)zmain entry point for executionFbool)defaulttypepath)r   )r	   filenamedir_path)argument_specchangedr   r	   get_default_flagrpcall)flags
__backup__N )dictr   r   _socket_path	from_jsonget_capabilitiesr   r   r   r   
get_config	exit_json)r   r   result
connectioncapabilitiesr   r"   runnings           r   mainr/   X   s    e&16"M #F FF//0J##J$?$?$ABL(,,-@$&If/0 F}}Z !1!1%!88//1EE##%#0G"F<Fvr   __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   ansible.module_utils.connectionr   r   r/   __name__r$   r   r   <module>r9      sS    A @ #J
 5 6^$"J zF r   